Skip to content

Commit 720d8a0

Browse files
Pietro AbatePietro Abate
Pietro Abate
authored and
Pietro Abate
committed
- add COPYING file
- fix randcudf status problem - make dist now does not include test cases
1 parent 663f28f commit 720d8a0

File tree

4 files changed

+247
-24
lines changed

4 files changed

+247
-24
lines changed

COPYING

+195
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
This library is free software: you can redistribute it and/or modify
2+
it under the terms of the GNU Lesser General Public License as
3+
published by the Free Software Foundation, either version 3 of the
4+
License, or (at your option) any later version.
5+
6+
As a special exception to the GNU Lesser General Public License, you
7+
may link, statically or dynamically, a "work that uses the Library"
8+
with a publicly distributed version of the Library to produce an
9+
executable file containing portions of the Library, and distribute
10+
that executable file under terms of your choice, without any of the
11+
additional requirements listed in clause 6 of the GNU Lesser General
12+
Public License. By "a publicly distributed version of the Library",
13+
we mean either the unmodified Library as distributed, or a modified
14+
version of the Library that is distributed under the conditions
15+
defined in clause 3 of the GNU Lesser General Public License. This
16+
exception does not however invalidate any other reasons why the
17+
executable file might be covered by the GNU Lesser General Public
18+
License.
19+
20+
This program is distributed in the hope that it will be useful, but
21+
WITHOUT ANY WARRANTY; without even the implied warranty of
22+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23+
Lesser General Public License for more details.
24+
25+
You should have received a copy of the GNU Lesser General Public
26+
License along with this program. If not, see
27+
<http://www.gnu.org/licenses/>.
28+
29+
----------------------------------------------------------------------------
30+
31+
GNU LESSER GENERAL PUBLIC LICENSE
32+
Version 3, 29 June 2007
33+
34+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
35+
Everyone is permitted to copy and distribute verbatim copies
36+
of this license document, but changing it is not allowed.
37+
38+
39+
This version of the GNU Lesser General Public License incorporates
40+
the terms and conditions of version 3 of the GNU General Public
41+
License, supplemented by the additional permissions listed below.
42+
43+
0. Additional Definitions.
44+
45+
As used herein, "this License" refers to version 3 of the GNU Lesser
46+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
47+
General Public License.
48+
49+
"The Library" refers to a covered work governed by this License,
50+
other than an Application or a Combined Work as defined below.
51+
52+
An "Application" is any work that makes use of an interface provided
53+
by the Library, but which is not otherwise based on the Library.
54+
Defining a subclass of a class defined by the Library is deemed a mode
55+
of using an interface provided by the Library.
56+
57+
A "Combined Work" is a work produced by combining or linking an
58+
Application with the Library. The particular version of the Library
59+
with which the Combined Work was made is also called the "Linked
60+
Version".
61+
62+
The "Minimal Corresponding Source" for a Combined Work means the
63+
Corresponding Source for the Combined Work, excluding any source code
64+
for portions of the Combined Work that, considered in isolation, are
65+
based on the Application, and not on the Linked Version.
66+
67+
The "Corresponding Application Code" for a Combined Work means the
68+
object code and/or source code for the Application, including any data
69+
and utility programs needed for reproducing the Combined Work from the
70+
Application, but excluding the System Libraries of the Combined Work.
71+
72+
1. Exception to Section 3 of the GNU GPL.
73+
74+
You may convey a covered work under sections 3 and 4 of this License
75+
without being bound by section 3 of the GNU GPL.
76+
77+
2. Conveying Modified Versions.
78+
79+
If you modify a copy of the Library, and, in your modifications, a
80+
facility refers to a function or data to be supplied by an Application
81+
that uses the facility (other than as an argument passed when the
82+
facility is invoked), then you may convey a copy of the modified
83+
version:
84+
85+
a) under this License, provided that you make a good faith effort to
86+
ensure that, in the event an Application does not supply the
87+
function or data, the facility still operates, and performs
88+
whatever part of its purpose remains meaningful, or
89+
90+
b) under the GNU GPL, with none of the additional permissions of
91+
this License applicable to that copy.
92+
93+
3. Object Code Incorporating Material from Library Header Files.
94+
95+
The object code form of an Application may incorporate material from
96+
a header file that is part of the Library. You may convey such object
97+
code under terms of your choice, provided that, if the incorporated
98+
material is not limited to numerical parameters, data structure
99+
layouts and accessors, or small macros, inline functions and templates
100+
(ten or fewer lines in length), you do both of the following:
101+
102+
a) Give prominent notice with each copy of the object code that the
103+
Library is used in it and that the Library and its use are
104+
covered by this License.
105+
106+
b) Accompany the object code with a copy of the GNU GPL and this license
107+
document.
108+
109+
4. Combined Works.
110+
111+
You may convey a Combined Work under terms of your choice that,
112+
taken together, effectively do not restrict modification of the
113+
portions of the Library contained in the Combined Work and reverse
114+
engineering for debugging such modifications, if you also do each of
115+
the following:
116+
117+
a) Give prominent notice with each copy of the Combined Work that
118+
the Library is used in it and that the Library and its use are
119+
covered by this License.
120+
121+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
122+
document.
123+
124+
c) For a Combined Work that displays copyright notices during
125+
execution, include the copyright notice for the Library among
126+
these notices, as well as a reference directing the user to the
127+
copies of the GNU GPL and this license document.
128+
129+
d) Do one of the following:
130+
131+
0) Convey the Minimal Corresponding Source under the terms of this
132+
License, and the Corresponding Application Code in a form
133+
suitable for, and under terms that permit, the user to
134+
recombine or relink the Application with a modified version of
135+
the Linked Version to produce a modified Combined Work, in the
136+
manner specified by section 6 of the GNU GPL for conveying
137+
Corresponding Source.
138+
139+
1) Use a suitable shared library mechanism for linking with the
140+
Library. A suitable mechanism is one that (a) uses at run time
141+
a copy of the Library already present on the user's computer
142+
system, and (b) will operate properly with a modified version
143+
of the Library that is interface-compatible with the Linked
144+
Version.
145+
146+
e) Provide Installation Information, but only if you would otherwise
147+
be required to provide such information under section 6 of the
148+
GNU GPL, and only to the extent that such information is
149+
necessary to install and execute a modified version of the
150+
Combined Work produced by recombining or relinking the
151+
Application with a modified version of the Linked Version. (If
152+
you use option 4d0, the Installation Information must accompany
153+
the Minimal Corresponding Source and Corresponding Application
154+
Code. If you use option 4d1, you must provide the Installation
155+
Information in the manner specified by section 6 of the GNU GPL
156+
for conveying Corresponding Source.)
157+
158+
5. Combined Libraries.
159+
160+
You may place library facilities that are a work based on the
161+
Library side by side in a single library together with other library
162+
facilities that are not Applications and are not covered by this
163+
License, and convey such a combined library under terms of your
164+
choice, if you do both of the following:
165+
166+
a) Accompany the combined library with a copy of the same work based
167+
on the Library, uncombined with any other library facilities,
168+
conveyed under the terms of this License.
169+
170+
b) Give prominent notice with the combined library that part of it
171+
is a work based on the Library, and explaining where to find the
172+
accompanying uncombined form of the same work.
173+
174+
6. Revised Versions of the GNU Lesser General Public License.
175+
176+
The Free Software Foundation may publish revised and/or new versions
177+
of the GNU Lesser General Public License from time to time. Such new
178+
versions will be similar in spirit to the present version, but may
179+
differ in detail to address new problems or concerns.
180+
181+
Each version is given a distinguishing version number. If the
182+
Library as you received it specifies that a certain numbered version
183+
of the GNU Lesser General Public License "or any later version"
184+
applies to it, you have the option of following the terms and
185+
conditions either of that published version or of any later version
186+
published by the Free Software Foundation. If the Library as you
187+
received it does not specify a version number of the GNU Lesser
188+
General Public License, you may choose any version of the GNU Lesser
189+
General Public License ever published by the Free Software Foundation.
190+
191+
If the Library as you received it specifies that a proxy can decide
192+
whether future versions of the GNU Lesser General Public License shall
193+
apply, that proxy's public statement of acceptance of any version is
194+
permanent authorization for you to choose that version for the
195+
Library.

Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ dist: ./$(DIST_TARBALL)
7474
svn export . ./$(DIST_DIR)
7575
rm -rf ./$(DIST_DIR)/debian
7676
rm -rf ./$(DIST_DIR)/libcudf
77+
rm -rf ./$(DIST_DIR)/deb/tests
78+
rm -rf ./$(DIST_DIR)/rpm/tests
79+
rm -rf ./$(DIST_DIR)/common/tests
80+
rm -rf ./$(DIST_DIR)/algo/tests
7781
tar cvzf ./$(DIST_TARBALL) ./$(DIST_DIR)
7882
rm -rf ./$(DIST_DIR)
7983
@echo "Distribution tarball: ./$(DIST_TARBALL)"

applications/randcudf.ml

+46-23
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ module Options = struct
2525
let keep = StdOpt.int_option ~default:0 ()
2626
let rstatus = StdOpt.int_option ~default:0 ()
2727
let relop = StdOpt.float_option ~default:0.3 ()
28-
let nostatus = StdOpt.store_true ()
2928
let upgradeAll = StdOpt.store_true ()
3029

3130
let outdir = StdOpt.str_option ()
@@ -43,7 +42,6 @@ module Options = struct
4342
add options ~short_name:'k' ~long_name:"keep" ~help:"add keep version to n random packages" keep;
4443
add options ~long_name:"upgradeAll" ~help:"generate one upgrade all cudf document" upgradeAll;
4544
add options ~long_name:"rstatus" ~help:"add installed to n random packages" rstatus;
46-
add options ~long_name:"nostatus" ~help:"do no consider the first argument as a status file" nostatus;
4745
add options ~long_name:"relop" ~help:"relop probability" relop;
4846
add options ~long_name:"outdir" ~help:"specify the output directory" outdir;
4947
add options ~long_name:"seed" ~help:"specify the random generator seed" seed;
@@ -83,11 +81,6 @@ let extras_properties =
8381
;;
8482
let extras = List.map fst extras_properties ;;
8583

86-
let preamble =
87-
let l = List.map snd extras_properties in
88-
CudfAdd.add_properties Debian.Debcudf.preamble l
89-
;;
90-
9184
let create_pkglist pkglist status =
9285
let (>>) f g = g f in
9386
let build_hash n =
@@ -99,20 +92,31 @@ let create_pkglist pkglist status =
9992
let keep_hash = build_hash (OptParse.Opt.get Options.keep) in
10093
let rstatus_hash = build_hash (OptParse.Opt.get Options.rstatus) in
10194
let status_hash =
95+
let h = Hashtbl.create (List.length status) in
10296
List.iter (fun pkg ->
103-
Hashtbl.add rstatus_hash (pkg.package,Some(`Eq,pkg.version)) ()
104-
) status
105-
;
106-
rstatus_hash
97+
try
98+
if (List.assoc "status" pkg.Debian.Packages.extras) = "install ok installed" then
99+
Hashtbl.add h (pkg.Debian.Packages.name,pkg.Debian.Packages.version) ()
100+
with Not_found -> ()
101+
) status;
102+
h
107103
in
108104
let app h f pkg =
109105
if Hashtbl.mem h (pkg.package,Some(`Eq, pkg.version)) then f pkg else pkg
110106
in
111107
let l =
112108
List.map (fun pkg ->
113109
pkg >>
114-
app status_hash (fun p -> { p with installed = true }) >>
115-
app keep_hash (fun p -> {p with keep = `Keep_version})
110+
app rstatus_hash (fun p -> { p with installed = true }) >>
111+
app keep_hash (fun p -> {p with keep = `Keep_version}) >>
112+
(fun pkg ->
113+
try
114+
let number = Cudf.lookup_package_property pkg "number" in
115+
if Hashtbl.mem status_hash (pkg.package,number) then
116+
{ pkg with installed = true }
117+
else pkg
118+
with Not_found -> pkg
119+
)
116120
) pkglist
117121
in
118122
(l, Cudf.load_universe l)
@@ -130,7 +134,7 @@ let to_remove_random p l =
130134
get_random ~ver:p l (OptParse.Opt.get Options.remove)
131135
;;
132136

133-
let create_cudf universe (to_install,to_upgrade,to_remove) =
137+
let create_cudf preamble universe (to_install,to_upgrade,to_remove) =
134138
let oc =
135139
if (OptParse.Opt.is_set Options.outdir) then begin
136140
let tmpfile = Filename.temp_file "rand" ".cudf" in
@@ -164,19 +168,38 @@ let main () =
164168
let (statusfile, uris) =
165169
match posargs with
166170
|[] -> (Printf.eprintf "Missing input" ; exit 1 )
167-
|[h] when (OptParse.Opt.get Options.nostatus) -> ("",[h])
168-
|[h] -> (Printf.eprintf "Missing arguments" ; exit 1)
169-
|h::t when (OptParse.Opt.get Options.nostatus) -> ("",h::t)
171+
|[h] ->
172+
begin match Input.parse_uri h with
173+
|("cudf",(_,_,_,_,f),_) -> ("",[f])
174+
|_ -> (Printf.eprintf "Missing arguments" ; exit 1) end
170175
|h::t -> (h,h::t)
171176
in
172177

173-
let (status,_,_) =
178+
(* we assume the status file is alwasy in dpkg format ! *)
179+
let status =
180+
if statusfile = "" then []
181+
else
182+
match Input.parse_uri statusfile with
183+
|("deb",(_,_,_,_,f),_) -> Debian.Packages.input_raw [f]
184+
|_ -> assert false
185+
in
186+
(* raw -> cudf *)
187+
let (preamble,pkglist) =
188+
let default_preamble =
189+
let l = List.map snd extras_properties in
190+
CudfAdd.add_properties Debian.Debcudf.preamble l
191+
in
174192
if statusfile = "" then
175-
([],(fun p -> assert false),(fun (p,v) -> assert false))
176-
else Boilerplate.load_list [statusfile]
193+
let preamble, pkglist, _ = CudfAdd.parse_cudf (List.hd uris) in
194+
match preamble with
195+
|None -> (default_preamble,pkglist)
196+
|Some preamble -> (preamble,pkglist)
197+
else
198+
let (pkglist,_,_) = Boilerplate.load_list ~extras:extras_properties uris in
199+
(default_preamble,pkglist)
177200
in
178-
let (pkglist,_,_) = Boilerplate.load_list ~extras:extras_properties uris in
179201

202+
Printf.printf "Package %d\n%!" (List.length pkglist);
180203
Printf.printf "Generating %d random documents with\n%!" (OptParse.Opt.get Options.documents);
181204
Printf.printf "install : %d\n%!" (OptParse.Opt.get Options.install);
182205
Printf.printf "remove : %d\n%!" (OptParse.Opt.get Options.remove);
@@ -195,7 +218,7 @@ let main () =
195218
let u = to_upgrade_random installed in
196219
let r = to_remove_random p installed in
197220
Printf.printf "%d %!" j;
198-
create_cudf universe (i,u,r)
221+
create_cudf preamble universe (i,u,r)
199222
done
200223
;
201224
if (OptParse.Opt.get Options.upgradeAll) then begin
@@ -205,7 +228,7 @@ let main () =
205228
if pkg.installed then pkg::l else l
206229
) [] universe
207230
in
208-
create_cudf universe ([],List.map (fun pkg -> (pkg.package,None)) installed,[])
231+
create_cudf preamble universe ([],List.map (fun pkg -> (pkg.package,None)) installed,[])
209232
end
210233
;;
211234

deb/packages.ml

+2-1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ let parse_packages_fields extras par =
6767
if l = s then Some(f) else None
6868
with Not_found -> Some(f) (* this package doesn't have a status field *)
6969
in
70+
let extras = "status"::extras in
7071
let parse_s f field = f (single_line field (List.assoc field par)) in
7172
let parse_m f field = f (String.concat " " (List.assoc field par)) in
7273
let parse_e extras =
@@ -94,7 +95,7 @@ let parse_packages_fields extras par =
9495
extras = parse_e extras;
9596
}
9697
in
97-
try guard_field "status" "install ok installed" (exec ())
98+
try (* guard_field "status" "install ok installed" *) Some(exec ())
9899
with Not_found -> None (* this package doesn't either have version or name *)
99100

100101
(** parse a debian Packages file from the channel [ch] *)

0 commit comments

Comments
 (0)