pax_global_header 0000666 0000000 0000000 00000000064 14267014770 0014522 g ustar 00root root 0000000 0000000 52 comment=f55ef1feab551c524cf670bb1b9d5fb90d157b1a
cudf-v0.10/ 0000775 0000000 0000000 00000000000 14267014770 0012551 5 ustar 00root root 0000000 0000000 cudf-v0.10/.gitignore 0000664 0000000 0000000 00000000055 14267014770 0014541 0 ustar 00root root 0000000 0000000 /c-lib/_build
/_opam/
/_build/
/cudf.install
cudf-v0.10/.headache.conf 0000664 0000000 0000000 00000000160 14267014770 0015215 0 ustar 00root root 0000000 0000000 ".*\\.ml[il]?" -> frame open:"(*" line:"*" close:"*)"
| ".*\\.mly" -> frame open:"/*" line:"*" close:"*/"
cudf-v0.10/.ocamlinit-cudf 0000664 0000000 0000000 00000000753 14267014770 0015455 0 ustar 00root root 0000000 0000000 #use "topfind";;
#require "extlib";;
#require "oUnit";;
#use_output "dune top";;
open ExtLib;;
open Cudf;;
open Cudf_checker;;
open Cudf_parser;;
open Cudf_printer;;
open Cudf_types_pp;;
let p = Cudf_parser.from_in_channel (open_in "tests/data/legacy.cudf")
let (pre, pkgs, req) as cudf_doc =
match Cudf_parser.parse_from_file "tests/data/legacy.cudf" with
| Some pre, pkgs, Some req -> pre, pkgs, req
| _ -> assert false ;;
let (univ, _) as cudf = Cudf.load_universe pkgs, req
cudf-v0.10/BUGS 0000664 0000000 0000000 00000000101 14267014770 0013224 0 ustar 00root root 0000000 0000000 See issue tracker at:
https://gitlab.com/irill/cudf/-/issues
cudf-v0.10/COPYING 0000664 0000000 0000000 00000021716 14267014770 0013613 0 ustar 00root root 0000000 0000000 This library is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
As a special exception to the GNU Lesser General Public License, you
may link, statically or dynamically, a "work that uses the Library"
with a publicly distributed version of the Library to produce an
executable file containing portions of the Library, and distribute
that executable file under terms of your choice, without any of the
additional requirements listed in clause 6 of the GNU Lesser General
Public License. By "a publicly distributed version of the Library",
we mean either the unmodified Library as distributed, or a modified
version of the Library that is distributed under the conditions
defined in clause 3 of the GNU Lesser General Public License. This
exception does not however invalidate any other reasons why the
executable file might be covered by the GNU Lesser General Public
License.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this program. If not, see
.
----------------------------------------------------------------------------
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
cudf-v0.10/ChangeLog 0000664 0000000 0000000 00000012544 14267014770 0014331 0 ustar 00root root 0000000 0000000 2022-07-23 Kate Deplaix
* ALL release 0.10
* Build: Add support for OCaml 5.0
* Build: Drop support for OCaml < 4.07
* Build: Switch from ocamlbuild & ocamlfind to dune to build the OCaml library
* testsuite: Switch from ounit to ounit2
2017-03-21 Stefano Zacchiroli
* ALL release 0.9
* Build: remove spurious dependencies on no longer used camlp4
* Makefile: fix build issues on Windows
2015-03-31 Stefano Zacchiroli
* ALL release 0.8
* Cudf: performance improvement by allocating larger hashtbl
* Cudf: expose empty_universe
(Thanks to Pietro Abate for the above 2 patches)
* Makefile: inhibit parallel build (thanks to Roberto Di Cosmo)
* Cudf_parser: prevent in_channel leaks when using from_file
2014-04-29 Stefano Zacchiroli
* ALL release 0.7
* Cudf_checker: do not report as multi-upgrade error a package
providing itself
* Cudf refactoring: change name2pkgs and univ.features internal
structures to list ref from multi-binding hash table.
* Cudf: add iterators on packages grouped by name
* Cudf: allow add/remove imperative changes to universes
(Thanks Pietro Abate for the above 3 patches)
* test runner: port "make test" to ocamlbuild >= 4.x
* cudf-check: make exit code dependent on check result
* cudf-check: include a man page, available under doc/
2012-08-03 Stefano Zacchiroli
* ALL release 0.6.3
* Cudf: bugfix: ensure that Cudf.status sizes are non-bogus
* Cudf: new functions to lookup properties as typed values
lookup_typed_{package,request,preamble}_property
* Cudf: new functions to lookup type declarations
for both core and extra package properties
* Cudf_conf: offer direct access to per-stanza property schemata
* testsuite: add printers to better inspect test failures
* Cudf: refactoring, build raw property access on top of typed one
* Cudf_conf: refactoring, deduplicate "keep" property enums
2011-11-27 Stefano Zacchiroli
* ALL release 0.6.2
* ALL Cudf: add a new mapping between packages and unique integer
identifiers, useful to avoid external uid maps (patch by Pietro
Abate)
* ALL Cudf: who_provides is now more general and can query both
installed and available packages (patch by Pietro Abate)
* ALL Cudf_printer: expose generic higher order printers
2011-09-15 Stefano Zacchiroli
* ALL release 0.6.1
* ALL Cudf_parser: allow parsing of empty universes as well as
parsing of documents containing only a (possibly empty) request
2011-06-01 Stefano Zacchiroli
* ALL release 0.6
* ALL cudf-check: faster (~ 2x) -dump
* ALL Cudf_printer/Cudf_types_pp: speed improvement (~ 3.5x)
get rid of Format, output only on strings (_types_pp) or on
out_channel (_printer). [ API change ]
* ALL Cudf_printer: add IO.output based API
* ALL Cudf_types_pp: fix pretty printing of "enum[...]" type
* ALL Cudf_printer.pp_cudf: avoid extra blank line before request
* doc: clarify is_solution meaning wrt inconsistent universes
* c-lib: link caml_hash_variant with -ldl
2010-11-04 Stefano Zacchiroli
* ALL parser: add support for ExtLib IO channels
Thanks Pietro Abate for the patch. (Closes: #299)
* ALL add Cudf.mem_package (Closes: #307)
* ALL Development release 0.5.99
2010-06-25 Stefano Zacchiroli
* ALL bug fix: do not enforce Keep on uninstalled packages
Thanks Ralf Treinen for the patch! (Closes: #266)
* ALL bug fix: nicer error message for unknown packages found in
solution (Closes: #267)
* ALL bug fix: avoid pretty printing some malformed vpkgformulae
(Closes: #272)
* ALL bug fix: check for duplicate property in 822 stanzas
(Closes: #269)
* ALL bug fix: comments no longer split stanzas in two
(Closes: #250)
* ALL bug fix: perform string escape when pretty printing type
declarations (Closes: #271)
* ALL add several test cases to the test suite
* ALL Development release 0.5.98
2010-06-03 Stefano Zacchiroli
* ALL bug fix: optional/mandatory extra property management
* c-lib bug fix: add handling of vpkgformula extra properties
* ALL bug fix: allow empty vpkglist as default values
* ALL bug fix: do not accept trivial formulae as v(eq)pkglist
* ALL Development release 0.5.97
2010-06-01 Stefano Zacchiroli
* c-lib add structured accessors to request fields
(patch by Gustavo Gutierrez, thanks!)
* doc better explain the role of load_solution
* ALL simpler API for solutions: cudf_load_solution_from_file
* ALL bug fix: avoid losing ?typedecl in convenience functions
* c-lib add bindings for cudf_load_solution_from_file
* backward-compatibility enabling compilation with OCaml 3.10.2
* ALL bug fix: support heading '+' when parsing posint
* ALL Development release 0.5.96
2009-12-18 Stefano Zacchiroli
* c-lib Remove the need of OCaml devel stuff to use the C API
* c-lib Provide bindings to OCaml native code, if available
* c-lib Hide OCaml "value", it is way more safe (API change)
* c-lib O(n^2) -> O(n) speed-up in package list conversion
* ALL Development release 0.5.94
2009-11-25 Stefano Zacchiroli
* ALL Porting to CUDF 2.0
* ALL Development release 0.5.92
2009-02-24 Stefano Zacchiroli
* ALL First public release, version 0.4
cudf-v0.10/INSTALL 0000664 0000000 0000000 00000002440 14267014770 0013602 0 ustar 00root root 0000000 0000000
To build
========
Build dependencies:
- ocaml >= 3.10.2 (Debian package: "ocaml-nox", RPM: "ocaml")
- findlib (Debian package: "ocaml-findlib", RPM: "ocaml-findlib")
- extlib (Debian package: "libextlib-ocaml-dev",
RPM: "ocaml-extlib-devel")
- oUnit (only needed to run the test suite
Debian package: "libounit-ocaml-dev",
RPM: "ocaml-ounit-devel")
- glib (only needed to build the C bindings
Debian package: "libglib2.0-dev",
RPM: "libglib2.0-devel")
- perl (for pod2man, to build cudf-check.1 man page)
To build run:
$ make all # build bytecode libs and executables
$ make opt # build native code libs and executables (if you have ocamlopt)
$ make test # run the test suite (need oUnit)
C bindings
----------
To build the C bindings to the OCaml library run:
$ make -C c-lib # build C bindings (to OCaml bytecode)
$ make -C c-lib-opt # build C bindings (to OCaml native code)
$ make -C c-lib test # run the test suite for C bindings
To install
==========
To install run, after compilation:
# make install # install libs and executables
To install under a non-standard location, say "/my/dest/dir":
$ make install DESTDIR=/my/dest/dir
To uninstall
============
# make uninstall
or:
$ make uninstall DESTDIR=/my/dest/dir
cudf-v0.10/Makefile 0000664 0000000 0000000 00000003432 14267014770 0014213 0 ustar 00root root 0000000 0000000 include Makefile.config
NAME = cudf
DOC = doc/cudf-check.1
SOURCES = $(wildcard */*.ml */*.mli */*.mll */*.mly)
C_LIB_DIR = c-lib
C_LIB_SOURCES = $(wildcard $(C_LIB_DIR)/*.c $(C_LIB_DIR)/*.h)
ifeq ($(DESTDIR),)
INSTALL = dune install
UNINSTALL = dune uninstall
else
DESTDIR:=$(DESTDIR)/
INSTALL = dune install --destdir=$(DESTDIR)
UNINSTALL = dune uninstall --destdir=$(DESTDIR)
endif
DIST_DIR = $(NAME)-$(VERSION)
DIST_TARBALL = $(DIST_DIR).tar.gz
all: doc/cudf-check.1
dune build
doc/cudf-check.1: doc/cudf-check.pod
$(MAKE) -C doc/
.PHONY: c-lib c-lib-opt doc
c-lib:
make -C $(C_LIB_DIR) all
c-lib-opt:
make -C $(C_LIB_DIR) opt
clean:
make -C $(C_LIB_DIR) clean
make -C doc/ clean
dune clean
rm -rf $(NAME)-*.gz $(NAME)_*.gz $(NAME)-*/
top-level:
ledit ocaml -init ./.ocamlinit-cudf
headers: header.txt .headache.conf
headache -h header.txt -c .headache.conf $(SOURCES) $(C_LIB_SOURCES)
test:
dune runtest
c-lib-test:
make -C $(C_LIB_DIR) test
tags: TAGS
TAGS: $(SOURCES)
otags $^
install:
$(INSTALL)
if [ -f $(C_LIB_DIR)/cudf.o ] ; then \
$(MAKE) -C c-lib/ -e install ; \
fi
uninstall:
$(UNINSTALL)
-rmdir -p $(DESTDIR)$(OCAMLLIBDIR) $(DESTDIR)$(BINDIR)
dist: ./$(DIST_TARBALL)
./$(DIST_TARBALL):
git archive --format=tar --prefix=$(DIST_DIR)/ HEAD | gzip > $@
@echo "Distribution tarball: ./$(DIST_TARBALL)"
rpm: ./$(DIST_TARBALL)
rpmbuild --nodeps -ta $<
distcheck: ./$(DIST_TARBALL)
tar xzf $<
$(MAKE) -C ./$(DIST_DIR) all
$(MAKE) -C ./$(DIST_DIR) test
$(MAKE) -C ./$(DIST_DIR)/$(C_LIB_DIR)/ all
$(MAKE) -C ./$(DIST_DIR) install DESTDIR=$(CURDIR)/$(DIST_DIR)/tmp
rm -rf ./$(DIST_DIR)
doc:
dune build @doc
world: all c-lib c-lib-opt doc
.PHONY: all world clean top-level headers test tags install uninstall
.PHONY: dep rpm c-lib c-lib-opt dist doc
.NOTPARALLEL:
cudf-v0.10/Makefile.config 0000664 0000000 0000000 00000000420 14267014770 0015451 0 ustar 00root root 0000000 0000000 VERSION = 0.10
export DESTDIR =
# all the following variables will be prepended by $(DESTDIR) upon install
export OCAMLLIBDIR := $(shell ocamlc -where)
export BINDIR = /usr/bin
export LIBDIR = /usr/lib
export INCDIR = /usr/include
export PCDIR = $(LIBDIR)/pkgconfig
cudf-v0.10/README 0000664 0000000 0000000 00000004023 14267014770 0013430 0 ustar 00root root 0000000 0000000 libCUDF - CUDF (Common Upgradeability Description Format) library
=================================================================
libCUDF is a reference implementation of CUDF (Common Upgradeability
Description Format), a document format to describe package upgrade scenarios,
in a package manager agnostic way. distributions.
A CUDF document consists of an optional leading "preamble", a "package
universe", and a trailing "user request":
- The package universe describes all packages known to the package
manager, a subset of which (the "package status") denotes the
package being currently installed on a given machine.
- The user request denotes a change to the package status requested by
the user, e.g.: "install package foo", "remove package bar", ...
- The preamble contains meta-information such as a typing information
for custom package properties, checksums, document unique
identifiers, ...
A CUDF document is naturally complemented by a "solution" describing
the resulting package status (if any) that satisfies the user request,
as found by a package manager.
libCUDF enables manipulation of CUDF and related documents.
Development
-----------
Development happens on GitLab, in the [CUDF project][1]. There you can find:
* [releases][4]
* [Git repository][5]
* [bug reports][6]
[1]: https://gitlab.com/irill/cudf
[4]: https://gitlab.com/irill/cudf/-/tags
[5]: https://gitlab.com/irill/cudf/-/tree/master
[6]: https://gitlab.com/irill/cudf/-/issues
Please report bugs using the [bug tracker][6].
Patches are welcome!, just submit a merge request on GitLab.
If you're in a hurry and just want to get the latest version of the code, here
is the command you're looking for:
$ git clone https://gitlab.com/irill/cudf/
Reference
---------
libCUDF implements the Common Upgradeability Description Format (CUDF)
2.0 [specifications][2], edited by the [Mancoosi project][3].
[2]: http://www.mancoosi.org/reports/tr3.pdf
[3]: http://www.mancoosi.org
-- Stefano Zacchiroli Sun, 14 Oct 2012 16:28:32 +0100
cudf-v0.10/bin/ 0000775 0000000 0000000 00000000000 14267014770 0013321 5 ustar 00root root 0000000 0000000 cudf-v0.10/bin/dune 0000664 0000000 0000000 00000000345 14267014770 0014201 0 ustar 00root root 0000000 0000000 (executable
(public_name cudf-check)
(name main_cudf_check)
(modules main_cudf_check)
(libraries cudf))
(executable
(public_name cudf-parse-822)
(name main_cudf_parse_822)
(modules main_cudf_parse_822)
(libraries cudf))
cudf-v0.10/bin/main_cudf_check.ml 0000664 0000000 0000000 00000012115 14267014770 0016735 0 ustar 00root root 0000000 0000000 (*****************************************************************************)
(* libCUDF - CUDF (Common Upgrade Description Format) manipulation library *)
(* Copyright (C) 2009-2012 Stefano Zacchiroli *)
(* *)
(* This library is free software: you can redistribute it and/or modify *)
(* it under the terms of the GNU Lesser General Public License as *)
(* published by the Free Software Foundation, either version 3 of the *)
(* License, or (at your option) any later version. A special linking *)
(* exception to the GNU Lesser General Public License applies to this *)
(* library, see the COPYING file for more information. *)
(*****************************************************************************)
open ExtLib
open Printf
open Cudf_checker
let cudf_arg = ref ""
let univ_arg = ref ""
let sol_arg = ref ""
let dump_arg = ref false
let cudf = ref None
let univ = ref None
let sol = ref None
let arg_spec = [
"-cudf", Arg.Set_string cudf_arg,
"parse the given CUDF (universe + request)" ;
"-univ", Arg.Set_string univ_arg, "parse the given package universe" ;
"-sol", Arg.Set_string sol_arg, "parse the given problem solution" ;
"-dump", Arg.Set dump_arg, "dump parse results to standard output" ;
]
let usage_msg =
"Usage: cudf-check [OPTION...]
In particular:
cudf-check -cudf FILE validate CUDF
cudf-check -cudf FILE -sol FILE validate CUDF and its solution
cudf-check -univ FILE validate package universe (no request)
Options:"
let die_usage () = Arg.usage arg_spec usage_msg ; exit 2
let print_inst_info inst =
match is_consistent inst with
| true, _ -> printf "original installation status consistent\n%!"; true
| false, Some r ->
printf "original installation status inconsistent (reason: %s)\n%!"
(explain_reason (r :> bad_solution_reason));
false
| _ -> assert false
let print_cudf (pre, univ, req) =
if !dump_arg then begin
let pre' = Option.default Cudf.default_preamble pre in
Cudf_printer.pp_cudf stdout (pre', univ, req)
end
let print_univ univ =
if !dump_arg then
Cudf_printer.pp_universe stdout univ
let print_sol_info inst sol =
match is_solution inst sol with
| true, _ -> printf "is_solution: true\n%!"; true
| false, rs ->
printf "is_solution: false (reason: %s)\n%!"
(String.concat "; " (List.map explain_reason rs));
false
let pp_loc (start_pos, end_pos) =
let line { Lexing.pos_lnum = l; _ } = l in
if line start_pos = line end_pos
then sprintf "line: %d" (line start_pos)
else sprintf "lines: %d-%d" (line start_pos) (line end_pos)
let main () =
let load_univ p =
let _pre,univ,_req = Cudf_parser.load p in
univ
in
let fail_parse source msg loc =
eprintf "Error while parsing %s: %s\n" source msg ;
eprintf "Location: %s\n%!" (pp_loc loc) ;
exit 1
in
let exit_ rc = if rc then exit 0 else exit 1 in
if !cudf_arg <> "" then begin
try
let p = Cudf_parser.from_in_channel (open_in !cudf_arg) in
eprintf "loading CUDF ...\n%!";
(match Cudf_parser.load p with
| _pre, _univ, None ->
eprintf "Error: missing request description item.\n%!";
exit (-1)
| pre, univ, Some req -> cudf := Some (pre, univ, req))
with
| Cudf_parser.Parse_error (msg, loc) -> fail_parse "CUDF" msg loc
| Cudf.Constraint_violation _ as exn ->
eprintf "Error while loading CUDF from %s: %s\n%!"
!cudf_arg (Printexc.to_string exn);
exit (-1)
end;
if !univ_arg <> "" then begin
try
let p = Cudf_parser.from_in_channel (open_in !univ_arg) in
eprintf "loading package universe ...\n%!";
univ := Some (load_univ p)
with
| Cudf_parser.Parse_error (msg, loc) -> fail_parse "universe" msg loc
| Cudf.Constraint_violation _ as exn ->
eprintf "Error while loading universe from %s: %s\n%!"
!univ_arg (Printexc.to_string exn);
exit (-1)
end;
if !sol_arg <> "" then
(* postpone solution parsing, we need the input CUDF for that *)
sol := Some (Cudf_parser.from_in_channel (open_in !sol_arg));
match !cudf, !univ, !sol with
| Some (pre,univ,req), None, None ->
let rc = print_inst_info univ in
print_cudf (pre,univ,req);
exit_ rc
| Some (pre,univ,req), None, Some sol_parser ->
(try
eprintf "loading solution ...\n%!";
let _pre', sol = Cudf_parser.load_solution sol_parser univ in
let rc1 = print_inst_info univ in
let rc2 = print_sol_info (univ,req) sol in
print_cudf (pre,univ,req);
exit_ (rc1 && rc2)
with
| Cudf_parser.Parse_error (msg, loc) -> fail_parse "solution" msg loc
| Cudf.Constraint_violation _ as exn ->
eprintf "Error while loading solution from %s: %s\n%!"
!sol_arg (Printexc.to_string exn);
exit (-1))
| None, Some univ, None ->
let rc = print_inst_info univ in
print_univ univ;
exit_ rc
| _ -> die_usage ()
let _ =
Arg.parse arg_spec ignore usage_msg;
main()
cudf-v0.10/bin/main_cudf_parse_822.ml 0000664 0000000 0000000 00000003420 14267014770 0017364 0 ustar 00root root 0000000 0000000 (*****************************************************************************)
(* libCUDF - CUDF (Common Upgrade Description Format) manipulation library *)
(* Copyright (C) 2009-2012 Stefano Zacchiroli *)
(* *)
(* This library is free software: you can redistribute it and/or modify *)
(* it under the terms of the GNU Lesser General Public License as *)
(* published by the Free Software Foundation, either version 3 of the *)
(* License, or (at your option) any later version. A special linking *)
(* exception to the GNU Lesser General Public License applies to this *)
(* library, see the COPYING file for more information. *)
(*****************************************************************************)
open Printf
open Cudf_types
let file_arg = ref ""
let arg_spec = [
]
let usage_msg = "Usage: cudf-parse-822 FILE"
let die_usage () = Arg.usage arg_spec usage_msg ; exit (-2)
let pp_822 =
let pp_stanza stanza =
List.iter (fun (k, (_loc, v)) -> printf "%s: %s\n%!" k v) stanza;
print_newline ()
in
List.iter pp_stanza
let pp_lpos { Lexing.pos_fname = _fname;
pos_lnum = lnum; pos_bol = bol; pos_cnum = cnum } =
sprintf "%d:%d" lnum (cnum - bol)
let main () =
Arg.parse arg_spec ((:=) file_arg) usage_msg;
if !file_arg = "" then
die_usage ();
let ic = open_in !file_arg in
let lexbuf = Lexing.from_channel ic in
try
let stanzas = Cudf_822_parser.doc_822 Cudf_822_lexer.token_822 lexbuf in
pp_822 stanzas
with Parse_error_822 (_msg, (startpos, endpos)) ->
failwith (sprintf "Parse error on file %s:%s--%s" !file_arg
(pp_lpos startpos) (pp_lpos endpos))
let _ = main ()
cudf-v0.10/c-lib/ 0000775 0000000 0000000 00000000000 14267014770 0013537 5 ustar 00root root 0000000 0000000 cudf-v0.10/c-lib/.gitignore 0000664 0000000 0000000 00000000074 14267014770 0015530 0 ustar 00root root 0000000 0000000 *.a
*.o
c-test
c-test-opt
caml_hash_variant
cudf-variants.h
cudf-v0.10/c-lib/Makefile 0000664 0000000 0000000 00000005203 14267014770 0015177 0 ustar 00root root 0000000 0000000 include ../Makefile.config
all: libcudf.a c-test
opt: libcudf-opt.a c-test-opt
include Makefile.variants
ifneq ($(DESTDIR),)
DESTDIR:=$(DESTDIR)/
endif
NULL =
CFLAGS = -Wall -DG_LOG_DOMAIN=\"libCUDF\"
PROG_CFLAGS = -Wall
OCAML_LIBDIR := $(shell ocamlc -where)
INCLUDES = -I . -I $(OCAML_LIBDIR) $(shell pkg-config --cflags glib-2.0)
CUDF_LDFLAGS = -L$(OCAML_LIBDIR) -L$(CURDIR)
CUDF_CLIBS = -lcudf -lm -ldl -lunix -lncurses -lglib-2.0
OCAMLC = ocamlfind ocamlc -package unix,extlib
OCAMLOPT = ocamlfind ocamlopt -package unix,extlib
INSTALL_STUFF = libcudf.a cudf.h cudf.pc
libcudf.a: cudf-caml.o cudf.o
cp $(OCAML_LIBDIR)/libcamlrun.a $@
ar r $@ $^
libcudf-opt.a: cudf-caml-opt.o cudf.o
cp $(OCAML_LIBDIR)/libasmrun.a $@
ar r $@ $^
cudf_c.cmo: cudf_c.ml
$(OCAMLC) -linkpkg -I ../_build/install/default/lib/cudf/ ../_build/install/default/lib/cudf/cudf.cma $^
cudf_c.cmx: cudf_c.ml
$(OCAMLOPT) -linkpkg -I ../_build/install/default/lib/cudf/ ../_build/install/default/lib/cudf/cudf.cmxa $^
cudf-caml.o: cudf_c.cmo
$(OCAMLC) -linkpkg -output-obj -o $@ ../_build/install/default/lib/cudf/cudf.cma $^
cudf-caml-opt.o: cudf_c.cmx
$(OCAMLOPT) -linkpkg -output-obj -o $@ ../_build/install/default/lib/cudf/cudf.cmxa $^
cudf.o: cudf.c cudf.h cudf-variants.h
c-test.o: c-test.c cudf.o
$(CC) $(PROG_CFLAGS) $(INCLUDES) -c $<
c-test: c-test.o libcudf.a
$(CC) $(PROG_CFLAGS) -o $@ $(INCLUDES) $(CUDF_LDFLAGS) $< $(CUDF_CLIBS)
c-test-opt: c-test.o libcudf-opt.a
$(CC) $(PROG_CFLAGS) -o $@ $(INCLUDES) $(CUDF_LDFLAGS) $< \
$(subst -lcudf,-lcudf-opt,$(CUDF_CLIBS))
test: ../tests/data/legacy.cudf ../tests/data/legacy-sol.cudf c-test
./c-test ../tests/data/legacy.cudf ../tests/data/legacy-sol.cudf > /dev/null
cudf.pc: cudf.pc.in
cat $< | sed -e "s,@OCAMLLIBDIR@,$(OCAMLLIBDIR),g" \
-e "s,@VERSION@,$(VERSION),g" \
-e "s,@LIBDIR@,$(LIBDIR),g" \
-e "s,@INCDIR@,$(INCDIR),g" \
> $@
%.o: %.c
$(CC) $(CFLAGS) $(INCLUDES) -c $<
clean:
rm -f *.a *.o *.cmo *.cmi
rm -f c-test c-test-opt
rm -f cudf.pc
install: cudf.pc
test -d $(DESTDIR)$(LIBDIR) || mkdir -p $(DESTDIR)$(LIBDIR)
test -d $(DESTDIR)$(INCDIR) || mkdir -p $(DESTDIR)$(INCDIR)
test -d $(DESTDIR)$(PCDIR) || mkdir -p $(DESTDIR)$(PCDIR)
if [ -f libcudf-opt.a ] ; then \
cp libcudf-opt.a $(DESTDIR)$(LIBDIR)/libcudf.a ; \
else \
cp libcudf.a $(DESTDIR)$(LIBDIR)/libcudf.a ; \
fi
cp libcudf.a $(DESTDIR)$(LIBDIR)
cp cudf.h $(DESTDIR)$(INCDIR)
cp cudf.pc $(DESTDIR)$(PCDIR)
uninstall:
rm $(DESTDIR)$(LIBDIR)/libcudf.a
rm $(DESTDIR)$(INCDIR)/cudf.h
rm $(DESTDIR)$(PCDIR)/cudf.pc
-rmdir -p $(DESTDIR)$(LIBDIR) $(DESTDIR)$(INCDIR) $(DESTDIR)$(PCDIR)
.PHONY: all opt clean test install uninstall
cudf-v0.10/c-lib/Makefile.variants 0000664 0000000 0000000 00000002556 14267014770 0017035 0 ustar 00root root 0000000 0000000 # OCaml (polymorphic) variants used by the bindings
# Will be used to generate cudf-variants.h
ML_VARIANTS = \
$(ML_RELOP_VARIANTS) \
$(ML_TYPE_VARIANTS) \
$(ML_KEEP_VARIANTS) \
$(ML_ITEM_VARIANTS) \
$(NULL)
ML_RELOP_VARIANTS = \
Eq \
Neq \
Geq \
Gt \
Leq \
Lt \
$(NULL)
ML_TYPE_VARIANTS = \
Int \
Posint \
Nat \
Bool \
String \
Enum \
Pkgname \
Ident \
Vpkg \
Vpkgformula \
Vpkglist \
Veqpkg \
Veqpkglist \
Typedecl \
$(NULL)
ML_KEEP_VARIANTS = \
Keep_version \
Keep_package \
Keep_feature \
Keep_none \
$(NULL)
ML_ITEM_VARIANTS = \
Preamble \
Package \
Request \
$(NULL)
cudf.o: cudf-variants.h
cudf-variants.h: caml_hash_variant Makefile.variants
@echo "/* THIS FILE IS GENERATED, DO NOT EDIT */" > $@
@echo "/* See Makefile.variants for generation logics */" >> $@
@echo >> $@
@echo "#ifndef _CUDF_VARIANTS_H" >> $@
@echo "#define _CUDF_VARIANTS_H" >> $@
@echo >> $@
@(for variant in $(ML_VARIANTS) ; do \
./$< $$variant ; \
done) >> $@
@echo >> $@
@echo "#endif\t/* end of cudf-variants.h */" >> $@
@echo >> $@
caml_hash_variant: caml_hash_variant.o
> dummy.ml
ocamlc -o dummy.o -output-obj dummy.ml
$(CC) $(CFLAGS) -o $@ $< dummy.o -L$(OCAML_LIBDIR) -lcamlrun -lm -lcurses -ldl
@rm -f dummy.*
clean: clean-variants
clean-variants:
rm -f caml_hash_variant cudf-variants.h
rm -f dummy.*
.PHONY: clean-variants
cudf-v0.10/c-lib/c-test.c 0000664 0000000 0000000 00000016673 14267014770 0015117 0 ustar 00root root 0000000 0000000 /*****************************************************************************/
/* libCUDF - CUDF (Common Upgrade Description Format) manipulation library */
/* Copyright (C) 2009-2012 Stefano Zacchiroli */
/* */
/* This library is free software: you can redistribute it and/or modify */
/* it under the terms of the GNU Lesser General Public License as */
/* published by the Free Software Foundation, either version 3 of the */
/* License, or (at your option) any later version. A special linking */
/* exception to the GNU Lesser General Public License applies to this */
/* library, see the COPYING file for more information. */
/*****************************************************************************/
/* Compile with:
cc -o c-test c-test.c `pkg-config --cflags cudf` `pkg-config --libs cudf`
*/
#include
#include
#include
#include
/* Print to stdout a relational operator (on versions) */
void print_relop(int relop) {
switch (relop) {
case RELOP_EQ : printf("=") ; break ;
case RELOP_NEQ : printf("!=") ; break ;
case RELOP_GEQ : printf(">=") ; break ;
case RELOP_GT : printf(">") ; break ;
case RELOP_LEQ : printf("<=") ; break ;
case RELOP_LT : printf("<") ; break ;
case RELOP_NOP :
default :
g_error("Unexpected integer, which is not a RELOP_*: %d",
relop);
}
}
/* Print to stdout a package version predicate */
void print_vpkg(cudf_vpkg_t *vpkg) {
if (vpkg == NULL)
return;
printf("%s", vpkg->name);
if (vpkg->relop) {
printf(" ");
print_relop(vpkg->relop);
printf(" %d", vpkg->version);
}
}
/* Print to stdout a list of package predicates, separated by a given
separator */
void print_vpkglist(cudf_vpkglist_t l, const char *sep) {
cudf_vpkg_t *vpkg;
GList *last;
last = g_list_last(l);
while (l != NULL) {
vpkg = g_list_nth_data(l, 0);
print_vpkg(vpkg);
if (l != last)
printf(sep);
l = g_list_next(l);
}
}
/* Print to stdout a package formula */
void print_vpkgformula(cudf_vpkgformula_t fmla) {
GList *last;
last = g_list_last(fmla);
while (fmla != NULL) {
print_vpkglist(g_list_nth_data(fmla, 0), " | ");
if (fmla != last)
printf(", ");
fmla = g_list_next(fmla);
}
}
/* Print to stdout a CUDF preamble */
void print_preamble(cudf_doc_t *doc) {
char *s;
char *props[] = { "preamble", "property", "univ-checksum",
"status-checksum", "req-checksum" };
int i;
if (! doc->has_preamble)
return;
for (i=0 ; i<5 ; i++) {
s = cudf_pre_property(doc->preamble, props[i]);
printf(" %s: %s\n", props[i], s);
free(s);
}
}
/* Print to stdout a CUDF request */
void print_request(cudf_doc_t *doc) {
char *s;
if (! doc->has_request)
return;
s = cudf_req_property(doc->request, "request");
printf(" request: %s\n", s);
free(s);
printf(" install: ");
print_vpkglist(cudf_req_install(doc->request), ", ");
printf("\n");
printf(" upgrade: ");
print_vpkglist(cudf_req_upgrade(doc->request), ", ");
printf("\n");
printf(" remove: ");
print_vpkglist(cudf_req_remove(doc->request), ", ");
printf("\n");
}
/* Print to stdout a possible value of the "keep" package property */
void print_keep(int keep) {
switch (keep) {
case KEEP_NONE : printf(" keep: version\n"); break;
case KEEP_VERSION : printf(" keep: version\n"); break;
case KEEP_PACKAGE : printf(" keep: package\n"); break;
case KEEP_FEATURE : printf(" keep: feature\n"); break;
default : g_error("Unexpected \"keep\" value: %d", keep);
}
}
void print_value(cudf_value_t *v) {
int typ;
if (v == NULL)
return;
typ = v->typ;
switch (typ) {
case TYPE_INT :
case TYPE_POSINT :
case TYPE_NAT :
printf("%d", v->val.i);
break;
case TYPE_BOOL :
printf("%s", v->val.i ? "true" : "false");
break;
case TYPE_STRING :
case TYPE_PKGNAME :
case TYPE_IDENT :
case TYPE_ENUM :
printf("%s", v->val.s);
break;
case TYPE_VPKG :
case TYPE_VEQPKG :
print_vpkg(v->val.vpkg);
break;
case TYPE_VPKGLIST :
case TYPE_VEQPKGLIST :
print_vpkglist(v->val.vpkgs, ", ");
break;
case TYPE_VPKGFORMULA :
print_vpkgformula(v->val.f);
break;
case TYPE_TYPEDECL :
break;
default :
g_error("Internal error: unexpected variant for type: %d", typ);
}
}
/* Print to stdout a generic property, i.e. a pair */
void print_property(gpointer k, gpointer v, gpointer user_data) {
printf(" %s: ", (char *) k);
print_value(v);
printf("\n");
}
/* Print to stdout a set of extra properties */
#define print_extra(e) (g_hash_table_foreach(e, print_property, NULL))
/* Print to stdout a CUDF package */
void print_pkg(cudf_package_t pkg) {
cudf_vpkgformula_t fmla;
cudf_vpkglist_t vpkglist;
cudf_extra_t extra;
printf(" package: %s\n", cudf_pkg_name(pkg));
printf(" version: %d\n", cudf_pkg_version(pkg));
printf(" installed: %s\n",
cudf_pkg_installed(pkg) ? "true" : "false");
printf(" was-installed: %s\n",
cudf_pkg_was_installed(pkg) ? "true" : "false");
fmla = cudf_pkg_depends(pkg);
printf(" depends: ");
print_vpkgformula(fmla);
printf("\n");
cudf_free_vpkgformula(fmla);
vpkglist = cudf_pkg_conflicts(pkg); /* conflicts */
printf(" conflicts: ");
print_vpkglist(vpkglist, ", ");
printf("\n");
cudf_free_vpkglist(vpkglist);
vpkglist = cudf_pkg_provides(pkg); /* provides */
printf(" provides: ");
print_vpkglist(vpkglist, ", ");
printf("\n");
cudf_free_vpkglist(vpkglist);
print_keep(cudf_pkg_keep(pkg)); /* keep */
extra = cudf_pkg_extra(pkg); /* extra properties */
print_extra(extra);
printf("\n");
cudf_free_extra(extra);
}
int main(int argc, char **argv) {
cudf_doc_t *doc = NULL;
cudf_t *cudf = NULL, *sol = NULL;
cudf_package_t pkg;
cudf_universe_t univ = NULL;
GList *l = NULL;
cudf_init();
if (argc < 2) {
printf("Usage: %s CUDF_FILE [ SOLUTION_FILE ]\n", argv[0]);
exit(2);
}
g_message("Parsing CUDF document %s ...", argv[1]);
doc = cudf_parse_from_file(argv[1]);
printf("Has preamble: %s\n", doc->has_preamble ? "yes" : "no");
if (doc->has_preamble) {
printf("Preamble: \n");
print_preamble(doc);
printf("\n");
}
printf("Has request: %s\n", doc->has_request ? "yes" : "no");
if (doc->has_request) {
printf("Request: \n");
print_request(doc);
printf("\n");
}
printf("Universe:\n");
l = doc->packages;
while (l != NULL) {
pkg = (cudf_package_t) g_list_nth_data(l, 0);
print_pkg(pkg);
l = g_list_next(l);
}
g_message("Try packages -> universe conversion ...");
univ = cudf_load_universe(doc->packages);
printf("Universe size: %d/%d (installed/total)\n",
cudf_installed_size(univ), cudf_universe_size(univ));
printf("Universe consistent: %s\n", cudf_is_consistent(univ) ?
"yes" : "no");
g_message("Freeing memory ...");
cudf_free_universe(univ);
cudf_free_doc(doc);
g_message("Try direct CUDF loading ...");
cudf = cudf_load_from_file(argv[1]);
printf("Universe size: %d/%d (installed/total)\n",
cudf_installed_size(cudf->universe),
cudf_universe_size(cudf->universe));
printf("Universe consistent: %s\n",
cudf_is_consistent(cudf->universe) ? "yes" : "no");
if (argc >= 3) {
g_message("Loading solution %s ...", argv[2]);
sol = cudf_load_solution_from_file(argv[2], cudf->universe);
printf("Is solution: %s\n",
cudf_is_solution(cudf, sol->universe) ? "yes" : "no");
}
g_message("Freeing memory (direct loading)...");
cudf_free_cudf(sol);
cudf_free_cudf(cudf);
g_message("All done.");
exit(0);
}
cudf-v0.10/c-lib/caml_hash_variant.c 0000664 0000000 0000000 00000002536 14267014770 0017354 0 ustar 00root root 0000000 0000000 /*****************************************************************************/
/* libCUDF - CUDF (Common Upgrade Description Format) manipulation library */
/* Copyright (C) 2009-2012 Stefano Zacchiroli */
/* */
/* This library is free software: you can redistribute it and/or modify */
/* it under the terms of the GNU Lesser General Public License as */
/* published by the Free Software Foundation, either version 3 of the */
/* License, or (at your option) any later version. A special linking */
/* exception to the GNU Lesser General Public License applies to this */
/* library, see the COPYING file for more information. */
/*****************************************************************************/
#define CAML_NAME_SPACE
#include
#include
int main(int argc, char **argv)
{
char *shortname, *variant;
if (argc == 2) {
variant = argv[1];
shortname = argv[1];
} else if (argc == 3) {
variant = argv[1];
shortname = argv[2];
} else {
printf("Usage: hash_variant VARIANT [SHORT_NAME]\n");
exit(2);
}
printf("#define\tMLPVAR_%s\t(%d)\t/* caml hash for \"`%s\" */\n",
shortname, Int_val(caml_hash_variant(variant)), variant);
return 0;
}
cudf-v0.10/c-lib/cudf-private.h 0000664 0000000 0000000 00000002535 14267014770 0016306 0 ustar 00root root 0000000 0000000 /*****************************************************************************/
/* libCUDF - CUDF (Common Upgrade Description Format) manipulation library */
/* Copyright (C) 2009-2012 Stefano Zacchiroli */
/* */
/* This library is free software: you can redistribute it and/or modify */
/* it under the terms of the GNU Lesser General Public License as */
/* published by the Free Software Foundation, either version 3 of the */
/* License, or (at your option) any later version. A special linking */
/* exception to the GNU Lesser General Public License applies to this */
/* library, see the COPYING file for more information. */
/*****************************************************************************/
#ifndef _CUDF_PRIVATE_H
#define _CUDF_PRIVATE_H
/* Instantiation of OCaml-related abstract data types. To be used only libcudf
implementation itself. Rationale: all use of OCaml's values from C is very
subtle and should be avoided in final C applications; additionally, hiding
"value" type removes the need of having OCaml C headers installed. */
typedef value *cudf_preamble_t;
typedef value *cudf_request_t;
typedef value *cudf_universe_t;
typedef value *cudf_package_t;
#endif
cudf-v0.10/c-lib/cudf.c 0000664 0000000 0000000 00000040617 14267014770 0014634 0 ustar 00root root 0000000 0000000 /*****************************************************************************/
/* libCUDF - CUDF (Common Upgrade Description Format) manipulation library */
/* Copyright (C) 2009-2012 Stefano Zacchiroli */
/* */
/* This library is free software: you can redistribute it and/or modify */
/* it under the terms of the GNU Lesser General Public License as */
/* published by the Free Software Foundation, either version 3 of the */
/* License, or (at your option) any later version. A special linking */
/* exception to the GNU Lesser General Public License applies to this */
/* library, see the COPYING file for more information. */
/*****************************************************************************/
// TODO should check / handle exceptions for all invoked caml_callback-s
// TODO better management of g_error() (not all should be fatal)
// TODO property-by-property access for preamble (as per packages)
#include
#include
#define CAML_NAME_SPACE
#include
#include
#include
#include
#include "cudf-private.h" // instantiate OCaml-related ADTs
#include "cudf-variants.h"
#include "cudf.h"
#define Val_none Val_int(0)
#define Some_val(v) Field(v,0)
/* field indexes in the return type of {!Cudf_parser.parse_from_file},
* {!Cudf_parser.load_from_file}, and {!Cudf_parser.load_solution_from_file} */
#define FIELD_PRE 0
#define FIELD_UNIV 1 // universe for load_*, package list for parse_*
#define FIELD_REQ 2 // unused for load_solution_from_file
/* field indexes in {!Cudf.package} */
#define FIELD_PKG 0
#define FIELD_VERSION 1
#define FIELD_DEPS 2
#define FIELD_CONFL 3
#define FIELD_PROV 4
#define FIELD_INST 5
#define FIELD_WASINST 6
#define FIELD_KEEP 7
#define FIELD_PKGEXTRA 8
/* field indexes in {!Cudf.request} */
#define FIELD_REQID 0
#define FIELD_REQINST 1
#define FIELD_REQREM 2
#define FIELD_REQUP 3
#define FIELD_REQEXTRA 4
/* field indexes in {!Cudf.preamble} */
#define FIELD_PREID 0
#define FIELD_TYPEDECL 1
#define FIELD_UCHECK 2
#define FIELD_SCHECK 3
#define FIELD_RCHECK 4
/* field indexes in the return type of {!Cudf_checker.is_solution} and
* {!Cudf_checker.is_consistent} */
#define FIELD_ISSOL 0
/* Initialize a pointer to an OCaml value */
#define NEW_MLVAL(p) \
do { p = malloc(sizeof(value)); \
caml_register_global_root(p); } \
while (0)
/* Free a pointer to an OCaml value */
#define FREE_MLVAL(p) \
do { free(p); \
caml_remove_global_root(p); } \
while (0)
/** generic OCaml binding helpers */
#if 0
static int caml_list_length(value l) {
int length = 0;
while (l != Val_emptylist) {
length++;
l = Field(l, 1);
}
return length;
}
#endif
/** CUDF-specific binding helpers */
static int relop_val(value v) {
CAMLparam1(v);
int op;
switch (Int_val(v)) {
case MLPVAR_Eq : op = RELOP_EQ ; break ;
case MLPVAR_Neq : op = RELOP_NEQ ; break ;
case MLPVAR_Geq : op = RELOP_GEQ ; break ;
case MLPVAR_Gt : op = RELOP_GT ; break ;
case MLPVAR_Leq : op = RELOP_LEQ ; break ;
case MLPVAR_Lt : op = RELOP_LT ; break ;
default :
g_error("Internal error: unexpected variant for \"relop\": %d",
Int_val(v));
}
CAMLreturnT(int, op);
}
cudf_vpkg_t *cudf_vpkg_val(value ml_vpkg) {
CAMLparam1(ml_vpkg);
CAMLlocal1(ml_constr);
cudf_vpkg_t *vpkg;
vpkg = malloc(sizeof(cudf_vpkg_t));
vpkg->name = strdup(String_val(Field(ml_vpkg, 0)));
if (Field(ml_vpkg, 1) != Val_none) { /* version constraint */
ml_constr = Some_val(Field(ml_vpkg, 1));
vpkg->relop = relop_val(Field(ml_constr, 0));
vpkg->version = Int_val(Field(ml_constr, 1));
} else { /* no version constraint */
vpkg->relop = 0;
vpkg->version = -1;
}
CAMLreturnT(cudf_vpkg_t *, vpkg);
}
cudf_vpkglist_t cudf_vpkglist_val(value ml_vpkgs) {
CAMLparam1(ml_vpkgs);
CAMLlocal1(ml_vpkg);
GList *l = NULL;
cudf_vpkg_t *vpkg;
while (ml_vpkgs != Val_emptylist) {
ml_vpkg = Field(ml_vpkgs, 0);
vpkg = cudf_vpkg_val(ml_vpkg);
l = g_list_append(l, vpkg);
ml_vpkgs = Field(ml_vpkgs, 1);
}
CAMLreturnT(cudf_vpkglist_t, l);
}
cudf_vpkgformula_t cudf_vpkgformula_val(value ml_fmla) {
CAMLparam1(ml_fmla);
CAMLlocal2(ml_and, ml_or);
GList *and_l = NULL; /* top-level formula (CNF) */
GList *or_l; /* OR-ed deps */
/* ml_and: iterates over OR-ed deps (which are AND-ed together) */
/* ml_or: iterates over vpkg-s (which are OR-ed together) */
cudf_vpkg_t *vpkg;
ml_and = ml_fmla;
while (ml_and != Val_emptylist) {
ml_or = Field(ml_and, 0);
or_l = NULL;
while (ml_or != Val_emptylist) {
vpkg = cudf_vpkg_val(Field(ml_or, 0));
or_l = g_list_append(or_l, vpkg);
ml_or = Field(ml_or, 1);
}
and_l = g_list_append(and_l, or_l);
ml_and = Field(ml_and, 1);
}
CAMLreturnT(cudf_vpkgformula_t, and_l);
}
cudf_value_t *cudf_value_val(value ml_v) {
CAMLparam1(ml_v);
CAMLlocal1(ml_payload);
cudf_value_t *v;
int typ;
v = malloc(sizeof(cudf_value_t));
typ = Int_val(Field(ml_v, 0));
ml_payload = Field(ml_v, 1);
v->typ = typ;
switch (typ) {
case MLPVAR_Int :
v->typ = TYPE_INT;
v->val.i = Int_val(ml_payload);
break;
case MLPVAR_Posint :
v->typ = TYPE_POSINT;
v->val.i = Int_val(ml_payload);
break;
case MLPVAR_Nat :
v->typ = TYPE_NAT;
v->val.i = Int_val(ml_payload);
break;
case MLPVAR_Bool :
v->typ = TYPE_BOOL;
v->val.i = Bool_val(ml_payload);
break;
case MLPVAR_String :
v->typ = TYPE_STRING;
v->val.s = strdup(String_val(ml_payload));
case MLPVAR_Pkgname :
v->typ = TYPE_PKGNAME;
v->val.s = strdup(String_val(ml_payload));
case MLPVAR_Ident :
v->typ = TYPE_IDENT;
v->val.s = strdup(String_val(ml_payload));
break;
case MLPVAR_Enum :
v->typ = TYPE_ENUM;
/* Skip enum list and jump to the actual enum. Enum list is
* currently not accessible using C bindings. */
v->val.s = strdup(String_val(Field(ml_payload, 1)));
break;
case MLPVAR_Vpkg :
v->typ = TYPE_VPKG;
v->val.vpkg = cudf_vpkg_val(ml_payload);
break;
case MLPVAR_Veqpkg :
v->typ = TYPE_VEQPKG;
v->val.vpkg = cudf_vpkg_val(ml_payload);
break;
case MLPVAR_Vpkglist :
v->typ = TYPE_VPKGLIST;
v->val.vpkgs = cudf_vpkglist_val(ml_payload);
break;
case MLPVAR_Veqpkglist :
v->typ = TYPE_VEQPKGLIST;
v->val.vpkgs = cudf_vpkglist_val(ml_payload);
break;
case MLPVAR_Vpkgformula :
v->typ = TYPE_VPKGFORMULA;
v->val.f = cudf_vpkgformula_val(ml_payload);
break;
case MLPVAR_Typedecl :
v->typ = TYPE_TYPEDECL;
break;
default :
g_error("Internal error: unexpected variant for type: %d", typ);
}
CAMLreturnT(cudf_value_t *, v);
}
/** libCUDF binding public interface */
void cudf_init() {
char *fake_argv[] = {"", NULL};
static int cudf_initialized = 0;
if (cudf_initialized)
return;
caml_startup(fake_argv);
cudf_initialized = 1;
}
cudf_doc_t *cudf_parse_from_file(char *fname) {
CAMLparam0();
CAMLlocal2(ml_doc, ml_pkgs);
static value *closure_f = NULL;
cudf_doc_t *doc;
GList *l = NULL;
cudf_package_t pkg;
doc = malloc(sizeof(cudf_doc_t));
if (closure_f == NULL)
closure_f = caml_named_value("parse_from_file");
ml_doc = caml_callback(*closure_f, caml_copy_string(fname));
NEW_MLVAL(doc->preamble); /* preamble */
if (Field(ml_doc, FIELD_PRE) != Val_none) {
doc->has_preamble = 1;
*(doc->preamble) = Some_val(Field(ml_doc, FIELD_PRE));
} else {
doc->has_preamble = 0;
*(doc->preamble) = Val_none;
}
NEW_MLVAL(doc->request); /* request */
if (Field(ml_doc, FIELD_REQ) != Val_none) {
doc->has_request = 1;
*(doc->request) = Some_val(Field(ml_doc, FIELD_REQ));
} else {
doc->has_request = 0;
*(doc->request) = Val_none;
}
ml_pkgs = Field(ml_doc, FIELD_UNIV); /* packages */
while (ml_pkgs != Val_emptylist) {
NEW_MLVAL(pkg);
*pkg = Field(ml_pkgs, 0);
l = g_list_prepend(l, pkg);
ml_pkgs = Field(ml_pkgs, 1);
}
doc->packages = g_list_reverse(l);
CAMLreturnT(cudf_doc_t *, doc);
}
cudf_t *cudf_load_from_file(char *fname) {
CAMLparam0();
CAMLlocal1(ml_cudf);
static value *closure_f = NULL;
cudf_t *cudf;
cudf = malloc(sizeof(cudf_t));
if (closure_f == NULL)
closure_f = caml_named_value("load_from_file");
ml_cudf = caml_callback(*closure_f, caml_copy_string(fname));
NEW_MLVAL(cudf->preamble); /* preamble */
if (Field(ml_cudf, FIELD_PRE) != Val_none) {
cudf->has_preamble = 1;
*(cudf->preamble) = Some_val(Field(ml_cudf, FIELD_PRE));
} else {
cudf->has_preamble = 0;
*(cudf->preamble) = Val_none;
}
NEW_MLVAL(cudf->request); /* request */
if (Field(ml_cudf, FIELD_REQ) != Val_none) {
cudf->has_request = 1;
*(cudf->request) = Some_val(Field(ml_cudf, FIELD_REQ));
} else {
cudf->has_request = 0;
*(cudf->request) = Val_none;
}
NEW_MLVAL(cudf->universe); /* universe */
*(cudf->universe) = Field(ml_cudf, FIELD_UNIV);
CAMLreturnT(cudf_t *, cudf);
}
cudf_t *cudf_load_solution_from_file(char *fname, cudf_universe_t ref_univ) {
CAMLparam0();
CAMLlocal1(ml_cudf);
static value *closure_f = NULL;
cudf_t *cudf;
cudf = malloc(sizeof(cudf_t));
if (closure_f == NULL)
closure_f = caml_named_value("load_solution_from_file");
ml_cudf = caml_callback2(*closure_f, caml_copy_string(fname),
*ref_univ);
NEW_MLVAL(cudf->preamble); /* preamble */
if (Field(ml_cudf, FIELD_PRE) != Val_none) {
cudf->has_preamble = 1;
*(cudf->preamble) = Some_val(Field(ml_cudf, FIELD_PRE));
} else {
cudf->has_preamble = 0;
*(cudf->preamble) = Val_none;
}
NEW_MLVAL(cudf->request); /* request */
cudf->has_request = 0; /* solutions have no request */
*(cudf->request) = Val_none;
NEW_MLVAL(cudf->universe); /* universe */
*(cudf->universe) = Field(ml_cudf, FIELD_UNIV);
CAMLreturnT(cudf_t *, cudf);
}
char *cudf_pkg_name(cudf_package_t pkg) {
return String_val(Field(*pkg, FIELD_PKG));
}
int cudf_pkg_version(cudf_package_t pkg) {
return Int_val(Field(*pkg, FIELD_VERSION));
}
int cudf_pkg_installed(cudf_package_t pkg) {
return Int_val(Field(*pkg, FIELD_INST));
}
int cudf_pkg_was_installed(cudf_package_t pkg) {
return Int_val(Field(*pkg, FIELD_WASINST));
}
int cudf_pkg_keep(cudf_package_t pkg) {
CAMLparam0();
CAMLlocal1(keep);
int k;
keep = Field(*pkg, FIELD_KEEP);
switch (Int_val(keep)) {
case MLPVAR_Keep_none : k = KEEP_NONE ; break ;
case MLPVAR_Keep_version : k = KEEP_VERSION ; break ;
case MLPVAR_Keep_package : k = KEEP_PACKAGE ; break ;
case MLPVAR_Keep_feature : k = KEEP_FEATURE ; break ;
default :
g_error("Internal error: unexpected variant for \"keep\": %d",
Int_val(keep));
}
CAMLreturnT(int, k);
}
cudf_vpkgformula_t cudf_pkg_depends(cudf_package_t pkg) {
return cudf_vpkgformula_val(Field(*pkg, FIELD_DEPS));
}
cudf_vpkglist_t cudf_pkg_conflicts(cudf_package_t pkg) {
return cudf_vpkglist_val(Field(*pkg, FIELD_CONFL));
}
cudf_vpkglist_t cudf_pkg_provides(cudf_package_t pkg) {
return cudf_vpkglist_val(Field(*pkg, FIELD_PROV));
}
char *cudf_pkg_property(cudf_package_t pkg, const char *prop) {
CAMLparam0();
CAMLlocal1(prop_val);
static value *closure_f = NULL;
if (closure_f == NULL)
closure_f = caml_named_value("lookup_package_property");
prop_val = caml_callback2_exn(*closure_f, *pkg, caml_copy_string(prop));
CAMLreturnT(char *,
Is_exception_result(prop_val) ? NULL :
strdup(String_val(prop_val)));
}
char *cudf_req_property(cudf_request_t req, const char *prop) {
CAMLparam0();
CAMLlocal1(prop_val);
static value *closure_f = NULL;
if (closure_f == NULL)
closure_f = caml_named_value("lookup_request_property");
prop_val = caml_callback2_exn(*closure_f, *req, caml_copy_string(prop));
CAMLreturnT(char *,
Is_exception_result(prop_val) ? NULL :
strdup(String_val(prop_val)));
}
cudf_vpkglist_t cudf_req_install(cudf_request_t req) {
return cudf_vpkglist_val(Field(*req, FIELD_REQINST));
}
cudf_vpkglist_t cudf_req_remove(cudf_request_t req) {
return cudf_vpkglist_val(Field(*req, FIELD_REQREM));
}
cudf_vpkglist_t cudf_req_upgrade(cudf_request_t req) {
return cudf_vpkglist_val(Field(*req, FIELD_REQUP));
}
char *cudf_pre_property(cudf_preamble_t pre, const char *prop) {
CAMLparam0();
CAMLlocal1(prop_val);
static value *closure_f = NULL;
if (closure_f == NULL)
closure_f = caml_named_value("lookup_preamble_property");
prop_val = caml_callback2_exn(*closure_f, *pre, caml_copy_string(prop));
CAMLreturnT(char *,
Is_exception_result(prop_val) ? NULL :
strdup(String_val(prop_val)));
}
cudf_extra_t cudf_pkg_extra(cudf_package_t pkg) {
CAMLparam0();
CAMLlocal2(ml_extras, ml_prop);
GHashTable *h = NULL;
h = g_hash_table_new_full(g_str_hash, g_str_equal,
g_free, (GDestroyNotify) cudf_free_value);
ml_extras = Field(*pkg, FIELD_PKGEXTRA);
while (ml_extras != Val_emptylist) {
ml_prop = Field(ml_extras, 0);
g_hash_table_insert(h, strdup(String_val(Field(ml_prop, 0))),
cudf_value_val(Field(ml_prop, 1)));
ml_extras = Field(ml_extras, 1);
}
CAMLreturnT(cudf_extra_t, h);
}
/** Universe management */
cudf_universe_t cudf_load_universe(GList *packages) {
CAMLparam0();
CAMLlocal2(ml_pkgs, cons);
static value *closure_f = NULL;
GList *l = packages;
cudf_universe_t univ = NULL;
ml_pkgs = Val_emptylist;
while (l != NULL) {
cons = caml_alloc(2, 0);
Store_field(cons, 0, * (cudf_package_t) g_list_nth_data(l, 0));
Store_field(cons, 1, ml_pkgs);
ml_pkgs = cons;
l = g_list_next(l);
}
if (closure_f == NULL)
closure_f = caml_named_value("load_universe");
NEW_MLVAL(univ);
*univ = caml_callback(*closure_f, ml_pkgs);
CAMLreturnT(cudf_universe_t, univ);
}
int cudf_universe_size(cudf_universe_t univ) {
static value *closure_f = NULL;
if (closure_f == NULL)
closure_f = caml_named_value("universe_size");
return Int_val(caml_callback(*closure_f, *univ));
}
int cudf_installed_size(cudf_universe_t univ) {
static value *closure_f = NULL;
if (closure_f == NULL)
closure_f = caml_named_value("installed_size");
return Int_val(caml_callback(*closure_f, *univ));
}
int cudf_is_consistent(cudf_universe_t univ) {
static value *closure_f = NULL;
if (closure_f == NULL)
closure_f = caml_named_value("is_consistent");
return Bool_val(Field(caml_callback(*closure_f, *univ), FIELD_ISSOL));
}
int cudf_is_solution(cudf_t *cudf, cudf_universe_t sol) {
CAMLparam0();
CAMLlocal1(ml_cudf);
static value *closure_f = NULL;
if (closure_f == NULL)
closure_f = caml_named_value("is_solution");
if (! cudf->has_request)
g_error("Given CUDF has no request: cannot compare it with a solution.");
ml_cudf = caml_alloc(2, 0);
Store_field(ml_cudf, 0, *(cudf->universe));
Store_field(ml_cudf, 1, *(cudf->request));
CAMLreturnT(int,
Bool_val(Field(caml_callback2(*closure_f, ml_cudf, *sol),
FIELD_ISSOL)));
}
/** Memory management.
free-like functions to free binding-specific data structures */
void cudf_free_doc(cudf_doc_t *doc) {
GList *l;
if (doc == NULL)
return;
FREE_MLVAL(doc->preamble);
FREE_MLVAL(doc->request);
l = doc->packages;
while (l != NULL) {
FREE_MLVAL(g_list_nth_data(l, 0));
l = g_list_next(l);
}
g_list_free(l);
free(doc);
}
void cudf_free_cudf(cudf_t *cudf) {
if (cudf == NULL)
return;
FREE_MLVAL(cudf->preamble);
FREE_MLVAL(cudf->request);
FREE_MLVAL(cudf->universe);
free(cudf);
}
void cudf_free_universe(cudf_universe_t univ) {
if (univ == NULL)
return;
FREE_MLVAL(univ);
}
void cudf_free_vpkg(cudf_vpkg_t *vpkg) {
if (vpkg == NULL)
return;
if (vpkg->name != NULL)
free(vpkg->name);
free(vpkg);
}
void cudf_free_vpkglist(cudf_vpkglist_t vpkgs) {
GList *l = vpkgs;
while (l != NULL) {
cudf_free_vpkg(g_list_nth_data(l, 0));
l = g_list_next(l);
}
g_list_free(vpkgs);
}
void cudf_free_vpkgformula(cudf_vpkgformula_t fmla) {
GList *l = fmla;
while (l != NULL) {
cudf_free_vpkglist(g_list_nth_data(l, 0));
l = g_list_next(l);
}
g_list_free(fmla);
}
void cudf_free_value(cudf_value_t *v) {
int typ;
if (v == NULL)
return;
typ = v->typ;
switch (typ) {
case TYPE_INT :
case TYPE_POSINT :
case TYPE_NAT :
case TYPE_BOOL :
break; /* integers don't require any freeing */
case TYPE_STRING :
case TYPE_PKGNAME :
case TYPE_IDENT :
case TYPE_ENUM :
free(v->val.s);
break;
case TYPE_VPKG :
case TYPE_VEQPKG :
cudf_free_vpkg(v->val.vpkg);
break;
case TYPE_VPKGLIST :
case TYPE_VEQPKGLIST :
cudf_free_vpkglist(v->val.vpkgs);
break;
case TYPE_VPKGFORMULA :
cudf_free_vpkgformula(v->val.f);
break;
case TYPE_TYPEDECL :
break;
default :
g_error("Internal error: unexpected variant for type: %d", typ);
}
free(v);
}
void cudf_free_extra(cudf_extra_t extra) {
g_hash_table_destroy(extra);
}
cudf-v0.10/c-lib/cudf.h 0000664 0000000 0000000 00000022452 14267014770 0014636 0 ustar 00root root 0000000 0000000 /*****************************************************************************/
/* libCUDF - CUDF (Common Upgrade Description Format) manipulation library */
/* Copyright (C) 2009-2012 Stefano Zacchiroli */
/* */
/* This library is free software: you can redistribute it and/or modify */
/* it under the terms of the GNU Lesser General Public License as */
/* published by the Free Software Foundation, either version 3 of the */
/* License, or (at your option) any later version. A special linking */
/* exception to the GNU Lesser General Public License applies to this */
/* library, see the COPYING file for more information. */
/*****************************************************************************/
#ifndef _CUDF_H
#define _CUDF_H
#include
#ifndef _CUDF_PRIVATE_H
/* Abstract data types. You should access them only with the functions given
below. Really (or you will face the anger of OCaml GC).*/
typedef void *cudf_preamble_t; /* preamble of a CUDF document */
typedef void *cudf_request_t; /* request of a CUDF document */
typedef void *cudf_universe_t; /* package universe (i.e. all known packages) */
typedef void *cudf_package_t; /* single package from the universe */
#endif
typedef GList *cudf_packages_t; /* List of CUDF packages */
typedef struct __cudf_doc {
int has_preamble; /* Whether user request was provided or not */
int has_request; /* Whether request was provided or not */
cudf_preamble_t preamble; /* Preamble (iff has_preamble != 0) */
cudf_request_t request; /* User request (iff has_request != 0) */
cudf_packages_t packages; /* List of packages */
} cudf_doc_t;
typedef struct __cudf {
int has_preamble; /* Whether user request was provided or not */
int has_request; /* Whether request was provided or not */
cudf_preamble_t preamble; /* Preamble (iff has_preamble != 0) */
cudf_request_t request; /* User request (iff has_request != 0) */
cudf_universe_t universe; /* Abstract package universe */
} cudf_t;
/* Initialization */
/* Call cudf_init() before doing anything else with libCUDF. (Or you will get a
* segfault, you've been warned.) */
void cudf_init();
/* Parsing */
/* Parse a CUDF document from file, without doing any further processing. */
cudf_doc_t *cudf_parse_from_file(char *fname);
/* Load a CUDF document from file, i.e. parse it and then store the contained
* packages as an universe structure.
*
* Note: to load solutions you should prefer cudf_load_solution_from_file,
* which can be invoked after CUDF document loading. */
cudf_t *cudf_load_from_file(char *fname);
/* Load from file a CUDF universe representing a solution to an upgrade
* scenario. Solution format is as per Appendix B of CUDF 2.0 spec
* (i.e. package/version pairs, together with installation status).
*
* @param ref_univ is the reference universe to be used to expand package
* information, usually it is the universe of the original CUDF
*/
cudf_t *cudf_load_solution_from_file(char *fname, cudf_universe_t ref_univ);
/* Package predicate
Examples:
- bar ---> { name="bar" ; relop=0 ; version=UNSPECIFIED }
- foo >= 2 ---> { name="foo" ; relop=RELOP_GEQ ; version=2 }
*/
typedef struct __cudf_vpkg {
char *name; /* Package name */
int relop; /* Version constraint operator, see RELOP_* constants.
0 (i.e. RELOP_NOP) means no constraint */
int version; /* Version constraint value (iff constr != 0) */
} cudf_vpkg_t;
typedef GList *cudf_vpkglist_t; /* List of cudf_vpkg */
/* Hash table mapping property names (char *) to typed values (cudf_value_t). */
typedef GHashTable *cudf_extra_t;
/* List of (cudf_vpkg_t *) lists.
CNF encoding: the inner lists are OR-ed, while the outer are AND-ed */
typedef GList *cudf_vpkgformula_t;
/* Version comparison operators */
#define RELOP_EQ 1 /* "=" */
#define RELOP_NEQ 2 /* "!=" */
#define RELOP_GEQ 3 /* ">=" */
#define RELOP_GT 4 /* ">" */
#define RELOP_LEQ 5 /* "<=" */
#define RELOP_LT 6 /* "<" */
#define RELOP_NOP 0 /* dummy operator */
/* CUDF types */
#define TYPE_INT 1 /* type "int" */
#define TYPE_POSINT 2 /* type "posint" */
#define TYPE_NAT 3 /* type "nat" */
#define TYPE_BOOL 4 /* type "bool" */
#define TYPE_STRING 5 /* type "string" */
#define TYPE_ENUM 6 /* type "enum" (whichever enum list) */
#define TYPE_PKGNAME 7 /* type "pkgname" */
#define TYPE_IDENT 8 /* type "ident" */
#define TYPE_VPKG 9 /* type "vpkg" */
#define TYPE_VPKGFORMULA 10 /* type "vpkgformula" */
#define TYPE_VPKGLIST 11 /* type "vpkglist" */
#define TYPE_VEQPKG 12 /* type "veqpkg" */
#define TYPE_VEQPKGLIST 13 /* type "veqpkglist" */
#define TYPE_TYPEDECL 14 /* type "typedecl" */
#define TYPE_NOTYPE 0 /* dummy type */
/* Typed CUDF value */
typedef struct __cudf_value {
int typ; /* CUDF type, one of the TYPE_* constants */
union {
int i;
char *s;
cudf_vpkg_t *vpkg;
cudf_vpkgformula_t f;
cudf_vpkglist_t vpkgs;
/* cudf_typedecl types; */ /* currently not supported */
} val; /* CUDF value
depending on typ above, one of the above union field is set:
typ | val field
-----------------+-------------------
TYPE_INT | int i
TYPE_POSINT | int i
TYPE_NAT | int i
TYPE_BOOL | int i
TYPE_STRING | char *s
TYPE_ENUM | char *s
TYPE_PKGNAME | char *s
TYPE_IDENT | char *s
TYPE_VPKG | cudf_vpkg_t *pkg
TYPE_VEQPKG | cudf_vpkg_t *pkg
TYPE_VPKGLIST | cudf_vpkglist_t pkgs
TYPE_VEQPKGLIST | cudf_vpkglist_t pkgs
TYPE_VPKGFORMULA | cudf_vpkgformula_t f
TYPE_TYPEDECL | cudf_typedecl_t types
*/
} cudf_value_t;
/* Macros for accessing cudf_package values */
/* Get package name of a cudf_pkg */
char *cudf_pkg_name(cudf_package_t pkg);
/* Get package version of a cudf_pkg */
int cudf_pkg_version(cudf_package_t pkg);
/* Get (current) installation status of a cudf_pkg */
int cudf_pkg_installed(cudf_package_t pkg);
/* Get (past) installation status of a cudf_pkg */
int cudf_pkg_was_installed(cudf_package_t pkg);
/* Possible values returned by cudf_pkg_keep() */
#define KEEP_NONE 0 /* keep: none */
#define KEEP_VERSION 1 /* keep: version */
#define KEEP_PACKAGE 2 /* keep: package */
#define KEEP_FEATURE 3 /* keep: feature */
/* Get "keep" property from a cudf_pkg. See KEEP_* macros */
int cudf_pkg_keep(cudf_package_t pkg);
/* Get dependencies of a package */
cudf_vpkgformula_t cudf_pkg_depends(cudf_package_t pkg);
/* Get conflicts of a package */
cudf_vpkglist_t cudf_pkg_conflicts(cudf_package_t pkg);
/* Get provided features of a package */
cudf_vpkglist_t cudf_pkg_provides(cudf_package_t pkg);
/* Get extra properties of a package. */
cudf_extra_t cudf_pkg_extra(cudf_package_t pkg);
/* Lookup package property by name. Returned string should be manually freed.
Return NULL if the property is missing (and has no default value). */
char *cudf_pkg_property(cudf_package_t pkg, const char *prop);
/* Lookup request property by name. Returned string should be manually freed.
Return NULL if the property is missing (and has no default value). */
char *cudf_req_property(cudf_request_t req, const char *prop);
/* Get install section of the request. */
cudf_vpkglist_t cudf_req_install(cudf_request_t req) ;
/* Get upgrade section of the request. */
cudf_vpkglist_t cudf_req_upgrade(cudf_request_t req) ;
/* Get remove section of the request. */
cudf_vpkglist_t cudf_req_remove(cudf_request_t req) ;
/* Lookup preamble property by name. Returned string should be manually freed.
Return NULL if the property is missing (and has no default value). */
char *cudf_pre_property(cudf_preamble_t pre, const char *prop);
/* Universe management */
/* @param packages list of (pointers to) cudf_package-s; the packages member of
a cudf_doc structure is a suitable value
@return a freshly allocated universe, which should be freed when no longer
needed using cudf_free_universe */
cudf_universe_t cudf_load_universe(GList *packages);
/* Return the number of packages in the given universe. */
int cudf_universe_size(cudf_universe_t univ);
/* Return the number of installed packages in the given universe. */
int cudf_installed_size(cudf_universe_t univ);
/* Check whether the package status of the given universe is consistent
* (i.e. dependencies and conflicts or all installed packages are
* respected). */
int cudf_is_consistent(cudf_universe_t univ);
/* Check whether the given universe contains a proper solution for the given
* CUDF (i.e. its package status is consistent and satisfies user request).
*
* Solution should normally be obtained via cudf_load_solution_from_file(), and
* passing cudf->universe to it, e.g.:
*
* cudf = cudf_load_from_file(...);
* sol = cudf_load_solution_from_file(..., cudf->universe);
* ok = is_solution(cudf, sol);
*/
int cudf_is_solution(cudf_t *cudf, cudf_universe_t solution);
/* Memory management */
void cudf_free_doc(cudf_doc_t *doc);
void cudf_free_cudf(cudf_t *cudf);
void cudf_free_universe(cudf_universe_t univ);
void cudf_free_vpkg(cudf_vpkg_t *vpkg);
void cudf_free_vpkglist(cudf_vpkglist_t l);
void cudf_free_vpkgformula(cudf_vpkgformula_t fmla);
void cudf_free_value(cudf_value_t *val);
void cudf_free_extra(cudf_extra_t extra);
#endif /* end of cudf.h */
cudf-v0.10/c-lib/cudf.pc.in 0000664 0000000 0000000 00000000441 14267014770 0015410 0 ustar 00root root 0000000 0000000 libdir=@LIBDIR@
includedir=@INCDIR@
datarootdir=/usr/share
datadir=${datarootdir}
ocaml_libdir=@OCAMLLIBDIR@
Name: CUDF
Description: access descriptions of package upgrade problems
Version: @VERSION@
Requires: glib-2.0
Libs: -L${libdir} -L${ocaml_libdir} -lcudf -lm -ldl -lunix -lncurses
cudf-v0.10/c-lib/cudf_c.ml 0000664 0000000 0000000 00000003214 14267014770 0015314 0 ustar 00root root 0000000 0000000 (*****************************************************************************)
(* libCUDF - CUDF (Common Upgrade Description Format) manipulation library *)
(* Copyright (C) 2009-2012 Stefano Zacchiroli *)
(* *)
(* This library is free software: you can redistribute it and/or modify *)
(* it under the terms of the GNU Lesser General Public License as *)
(* published by the Free Software Foundation, either version 3 of the *)
(* License, or (at your option) any later version. A special linking *)
(* exception to the GNU Lesser General Public License applies to this *)
(* library, see the COPYING file for more information. *)
(*****************************************************************************)
let () =
Callback.register "parse_from_file"
(Cudf_parser.parse_from_file ?typedecl:None);
Callback.register "load_from_file"
(Cudf_parser.load_from_file ?typedecl:None);
Callback.register "load_solution_from_file"
Cudf_parser.load_solution_from_file;
Callback.register "lookup_package_property" Cudf.lookup_package_property;
Callback.register "lookup_request_property" Cudf.lookup_request_property;
Callback.register "lookup_preamble_property" Cudf.lookup_preamble_property;
Callback.register "universe_size" Cudf.universe_size;
Callback.register "installed_size" Cudf.installed_size;
Callback.register "is_consistent" Cudf_checker.is_consistent;
Callback.register "is_solution" Cudf_checker.is_solution;
Callback.register "load_universe" Cudf.load_universe;
cudf-v0.10/cudf.opam 0000664 0000000 0000000 00000001512 14267014770 0014347 0 ustar 00root root 0000000 0000000 opam-version: "2.0"
version: "0.10"
license: "LGPL-3.0-or-later WITH OCaml-LGPL-linking-exception"
maintainer: "roberto@dicosmo.org"
authors: [
"Roberto di Cosmo "
"Stefano Zacchiroli"
"Pietro Abate"
]
homepage: "http://www.mancoosi.org/cudf/"
bug-reports: "https://gitlab.com/irill/cudf/-/issues"
dev-repo: "git+https://gitlab.com/irill/cudf.git"
build: ["dune" "build" "-p" name "-j" jobs]
run-test: ["dune" "runtest" "-p" name "-j" jobs]
depends: [
"ocaml" {>= "4.07"}
"dune" {>= "2.0"}
("extlib" | "extlib-compat")
"ounit2" {with-test & >= "2.0.0"}
"odoc" {with-doc}
]
synopsis: "CUDF library (part of the Mancoosi tools)"
description: """
CUDF (for Common Upgradeability Description Format) is a format for
describing upgrade scenarios in package-based Free and Open Source
Software distribution."""
cudf-v0.10/cudf.spec 0000664 0000000 0000000 00000006454 14267014770 0014357 0 ustar 00root root 0000000 0000000 Summary: CUDF (Common Upgradeability Description Format) tools and libraries
Name: cudf
Version: 0.6
Release: 1
Source: https://gforge.inria.fr/frs/?group_id=4385
URL: http://www.mancoosi.org/cudf/
License: LGPL
Group: Development/Libraries
BuildRequires: ocaml ocaml-findlib ocaml-extlib-devel
BuildRoot: %{_tmppath}/%{name}-root
%description
CUDF (for Common Upgradeability Description Format) is a format for describing
upgrade scenarios in package-based Free and Open Source Software distribution.
libCUDF is a library to manipulate so called CUDF documents. A CUDF document
describe an upgrade problem, as faced by package managers in popular
package-based GNU/Linux distributions.
%package tools
Summary: CUDF (Common Upgradeability Description Format) command-line tools
%description tools
CUDF (for Common Upgradeability Description Format) is a format for describing
upgrade scenarios in package-based Free and Open Source Software distribution.
libCUDF is a library to manipulate so called CUDF documents. A CUDF document
describe an upgrade problem, as faced by package managers in popular
package-based GNU/Linux distributions.
This package contains command line tools to manipulate CUDF and related
documents. In particular it contains cudf-check, which enables checking of
document properties such as installation consistency and matching of problems
with their solutions.
%package devel
Summary: CUDF (Common Upgradeability Description Format) C development stuff
%description devel
CUDF (for Common Upgradeability Description Format) is a format for describing
upgrade scenarios in package-based Free and Open Source Software distribution.
libCUDF is a library to manipulate so called CUDF documents. A CUDF document
describe an upgrade problem, as faced by package managers in popular
package-based GNU/Linux distributions.
This package contains the development stuff needed to use libCUDF in your C
programs.
%package ocaml-devel
Summary: CUDF (Common Upgradeability Description Format) OCaml development stuff
%description ocaml-devel
CUDF (for Common Upgradeability Description Format) is a format for describing
upgrade scenarios in package-based Free and Open Source Software distribution.
libCUDF is a library to manipulate so called CUDF documents. A CUDF document
describe an upgrade problem, as faced by package managers in popular
package-based GNU/Linux distributions.
This package contains the development stuff needed to use libCUDF in your OCaml
programs.
%prep
%setup -q
%build
make all c-lib
which /usr/bin/ocamlopt > /dev/null && make opt c-lib-opt
%install
rm -rf "$RPM_BUILD_ROOT"
make install \
DESTDIR="$RPM_BUILD_ROOT" \
LIBDIR="%{_libdir}" \
OCAMLLIBDIR="%{_libdir}/ocaml"
%check
make test
%clean
rm -rf "$RPM_BUILD_ROOT"
%files tools
%defattr(-,root,root)
%{_bindir}/cudf-check
%{_bindir}/cudf-parse-822
%files devel
%defattr(-,root,root)
%{_includedir}/cudf.h
%{_libdir}/*.a
%{_libdir}/pkgconfig/cudf.pc
%files ocaml-devel
%defattr(-,root,root)
%{_libdir}/ocaml/cudf
%changelog
* Tue Dec 22 2009 Stefano Zacchiroli
- use default rpm installation paths (in particular, /usr/lib64 on x86_64)
* Sat Dec 19 2009 Stefano Zacchiroli
- various adjustments (deps, description, native code, ...)
* Fri Dec 18 2009 Jeff Johnson
- create.
cudf-v0.10/doc/ 0000775 0000000 0000000 00000000000 14267014770 0013316 5 ustar 00root root 0000000 0000000 cudf-v0.10/doc/.gitignore 0000664 0000000 0000000 00000000015 14267014770 0015302 0 ustar 00root root 0000000 0000000 cudf-check.1
cudf-v0.10/doc/Makefile 0000664 0000000 0000000 00000000365 14267014770 0014762 0 ustar 00root root 0000000 0000000 include ../Makefile.config
MANPAGES = cudf-check
GEN_STUFF = $(patsubst %,%.1,$(MANPAGES))
all: $(GEN_STUFF)
%.1: %.pod
pod2man --release $(VERSION) $< > $@
clean:
rm -f $(GEN_STUFF)
show: cudf-check.1
man -l $<
.PHONY: all clean show
cudf-v0.10/doc/cudf-check.pod 0000664 0000000 0000000 00000002474 14267014770 0016025 0 ustar 00root root 0000000 0000000 =head1 NAME
cudf-check - manipulate CUDF documents
=head1 SYNOPSIS
=over
=item B [I