diff options
author | Richard Hughes <rhughes@redhat.com> | 2008-06-16 14:43:03 -0400 |
---|---|---|
committer | Kristian Høgsberg <krh@redhat.com> | 2008-06-16 15:40:30 -0400 |
commit | e967bfd71a068d6c3f5831cfa93de92d78136065 (patch) | |
tree | 80484292b4f3e4877853bf14acb7d15e5cbf108f | |
parent | 614b267207d0caf51c33d5c3e7036195aa0624c4 (diff) |
Autoconfify razor.
-rw-r--r-- | .gitignore | 38 | ||||
-rw-r--r-- | AUTHORS | 2 | ||||
-rw-r--r-- | Makefile | 27 | ||||
-rw-r--r-- | Makefile.am | 38 | ||||
-rw-r--r-- | NEWS | 0 | ||||
-rwxr-xr-x | autogen.sh | 95 | ||||
-rw-r--r-- | configure.ac | 201 | ||||
-rw-r--r-- | contrib/razor.spec | 0 | ||||
-rw-r--r-- | data/.gitignore | 2 | ||||
-rw-r--r-- | data/Makefile.am | 11 | ||||
-rw-r--r-- | data/bash-completion.sh (renamed from bash-completion.sh) | 0 | ||||
-rw-r--r-- | data/razor.pc.in | 12 | ||||
-rw-r--r-- | docs/DEPSOLVE.txt (renamed from DEPSOLVE.txt) | 0 | ||||
-rw-r--r-- | docs/Makefile.am | 5 | ||||
-rw-r--r-- | docs/REPO.txt (renamed from REPO.txt) | 0 | ||||
-rw-r--r-- | librazor/.gitignore | 5 | ||||
-rw-r--r-- | librazor/Makefile.am | 34 | ||||
-rw-r--r-- | librazor/razor-internal.h (renamed from razor-internal.h) | 0 | ||||
-rw-r--r-- | librazor/razor-root.c (renamed from razor-root.c) | 2 | ||||
-rw-r--r-- | librazor/razor.c (renamed from razor.c) | 48 | ||||
-rw-r--r-- | librazor/razor.h (renamed from razor.h) | 0 | ||||
-rw-r--r-- | librazor/rpm.c (renamed from rpm.c) | 301 | ||||
-rw-r--r-- | librazor/types.c (renamed from types.c) | 0 | ||||
-rw-r--r-- | librazor/types.h (renamed from types.h) | 0 | ||||
-rw-r--r-- | librazor/util.c (renamed from util.c) | 0 | ||||
-rw-r--r-- | po/.gitignore | 4 | ||||
-rw-r--r-- | po/LINGUAS | 0 | ||||
-rw-r--r-- | po/POTFILES.in | 0 | ||||
-rw-r--r-- | src/.gitignore | 5 | ||||
-rw-r--r-- | src/Makefile.am | 26 | ||||
-rw-r--r-- | src/import-rpmdb.c | 157 | ||||
-rw-r--r-- | src/import-yum.c (renamed from yum.c) | 2 | ||||
-rw-r--r-- | src/main.c (renamed from main.c) | 4 | ||||
-rw-r--r-- | src/rpm.c (renamed from rpm-razor.c) | 2 | ||||
-rw-r--r-- | src/test-driver.c (renamed from test-driver.c) | 8 | ||||
-rw-r--r-- | src/test.xml (renamed from test.xml) | 0 |
36 files changed, 843 insertions, 186 deletions
@@ -1,10 +1,32 @@ -.gitignore +aclocal.m4 +autom4te.cache +compile +config.guess +config.h +config.h.in +config.log +config.status +config.sub +configure +depcomp +INSTALL +install-sh +intltool-extract +intltool-extract.in +intltool-merge +intltool-merge.in +intltool-update +intltool-update.in +libtool +ltmain.sh +Makefile +Makefile.in +missing +mkinstalldirs +py-compile +stamp-h1 *.o +ChangeLog +*.tar.gz *~ -*.repo -razor -test-driver -pkgs -set -primary.xml.gz -filelists.xml.gz + @@ -0,0 +1,2 @@ +Kristian Høgsberg <krh@redhat.com> + diff --git a/Makefile b/Makefile deleted file mode 100644 index 5e26373..0000000 --- a/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -CFLAGS = -Wall -Wstrict-prototypes -Wmissing-prototypes -g -LDLIBS = librazor.a -lexpat -lz -g -lrpm -lcurl - -all : razor test-driver rpm-razor - -librazor_objs = razor.o yum.o rpm.o types.o util.o razor-root.o -librazor.a : $(librazor_objs) - ar cr $@ $(librazor_objs) - -razor : main.o librazor.a - -*.o : razor.h razor-internal.h -razor.o : types.h - -test-driver : librazor.a test-driver.o - -rpm-razor : librazor.a rpm-razor.o - -test : test-driver - ./test-driver test.xml - -reset : ./razor - sudo rm -rf install - ./razor init - -clean : - rm -f *.o razor librazor.a diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..d54ddd4 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,38 @@ +## Process this file with automake to produce Makefile.in + +SUBDIRS = data docs librazor src po + +# Creating ChangeLog from git log (taken from cairo/Makefile.am): +ChangeLog: $(srcdir)/ChangeLog + +$(srcdir)/ChangeLog: + @if test -d "$(srcdir)/.git"; then \ + (cd "$(srcdir)" && \ + ./missing --run git-log --stat) | fmt --split-only > $@.tmp \ + && mv -f $@.tmp $@ \ + || ($(RM) $@.tmp; \ + echo Failed to generate ChangeLog, your ChangeLog may be outdated >&2; \ + (test -f $@ || echo git-log is required to generate this file >> $@)); \ + else \ + test -f $@ || \ + (echo A git checkout and git-log is required to generate ChangeLog >&2 && \ + echo A git checkout and git-log is required to generate this file >> $@); \ + fi + +.PHONY: ChangeLog $(srcdir)/ChangeLog + +EXTRA_DIST = \ + TODO \ + ChangeLog \ + intltool-extract.in \ + intltool-merge.in \ + intltool-update.in + +DISTCLEANFILES = \ + intltool-extract \ + intltool-merge \ + intltool-update + +clean-local : + rm -f *~ + diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..347c3e1 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,95 @@ +#!/bin/sh +# Run this to generate all the initial makefiles, etc. + +srcdir=`dirname $0` +test -z "$srcdir" && srcdir=. + +DIE=0 + +(test -f $srcdir/configure.ac) || { + echo -n "**Error**: Directory $srcdir does not look like the" + echo " top-level package directory" + exit 1 +} + +(autoconf --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "**Error**: You must have autoconf installed." + echo "Download the appropriate package for your distribution," + echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/" + DIE=1 +} + +(grep "^AM_PROG_LIBTOOL" $srcdir/configure.ac >/dev/null) && { + (libtool --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "**Error**: You must have libtool installed." + echo "You can get it from: ftp://ftp.gnu.org/pub/gnu/" + DIE=1 + } +} + +(automake --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "**Error**: You must have automake installed." + echo "You can get it from: ftp://ftp.gnu.org/pub/gnu/" + DIE=1 + NO_AUTOMAKE=yes +} + + +# if no automake, don't bother testing for aclocal +test -n "$NO_AUTOMAKE" || (aclocal --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "**Error**: Missing aclocal. The version of automake" + echo "installed doesn't appear recent enough." + echo "You can get automake from ftp://ftp.gnu.org/pub/gnu/" + DIE=1 +} + +if test "$DIE" -eq 1; then + exit 1 +fi + +if test -z "$*"; then + echo "**Warning**: I am going to run configure with no arguments." + echo "If you wish to pass any to it, please specify them on the" + echo $0 " command line." + echo +fi + +case $CC in +xlc ) + am_opt=--include-deps;; +esac + + aclocalinclude="$ACLOCAL_FLAGS" + + if grep "^AM_PROG_LIBTOOL" configure.ac >/dev/null; then + if test -z "$NO_LIBTOOLIZE" ; then + echo "Running libtoolize..." + libtoolize --force --copy + fi + fi + echo "Running aclocal $aclocalinclude ..." + aclocal $aclocalinclude + if grep "^AM_CONFIG_HEADER" configure.ac >/dev/null; then + echo "Running autoheader..." + autoheader + fi + echo "Running automake --gnu -Wno-portability $am_opt ..." + automake --add-missing --gnu -Wno-portability $am_opt + echo "Running autoconf ..." + autoconf + +intltoolize --copy --force --automake || exit 1 + +conf_flags="--enable-maintainer-mode" + +if test x$NOCONFIGURE = x; then + echo "Running $srcdir/configure $conf_flags $@ ..." + $srcdir/configure $conf_flags "$@" \ + && echo "Now type make to compile." || exit 1 +else + echo "Skipping configure process." +fi diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..a6559d4 --- /dev/null +++ b/configure.ac @@ -0,0 +1,201 @@ +dnl Process this file with autoconf to produce a configure script. + +AC_PREREQ(2.59c) +AC_INIT(razor, 0.8, krh@redhat.com) +AM_INIT_AUTOMAKE(razor, 0.1) +AM_CONFIG_HEADER(config.h) +AM_MAINTAINER_MODE + +# libtool versioning - this applies to all libraries in this package +# +# See http://sources.redhat.com/autobook/autobook/autobook_91.html#SEC91 for details +# +LT_CURRENT=1 +LT_REVISION=0 +LT_AGE=0 +AC_SUBST(LT_CURRENT) +AC_SUBST(LT_REVISION) +AC_SUBST(LT_AGE) + +AC_ISC_POSIX +AC_PROG_CC +AM_PROG_CC_STDC +AC_HEADER_STDC +AM_PROG_LIBTOOL +AC_PROG_MAKE_SET +AC_PROG_LN_S +AC_SYS_LARGEFILE +AM_PROG_CC_C_O + +# Taken from dbus +AC_ARG_ENABLE(ansi, [ --enable-ansi enable -ansi -pedantic gcc flags],enable_ansi=$enableval,enable_ansi=no) +AC_ARG_ENABLE(verbose-mode, [ --enable-verbose-mode support verbose debug mode],enable_verbose_mode=$enableval,enable_verbose_mode=$USE_MAINTAINER_MODE) + +if test "${enable_verbose_mode}" != no; then + # To get -rdynamic you pass -export-dynamic to libtool. + AC_DEFINE(BUILT_R_DYNAMIC,1,[whether -export-dynamic was passed to libtool]) + R_DYNAMIC_LDFLAG=-export-dynamic +else + R_DYNAMIC_LDFLAG= +fi +AC_SUBST(R_DYNAMIC_LDFLAG) + +#### gcc warning flags + +if test "x$GCC" = "xyes"; then + changequote(,)dnl + case " $CFLAGS " in + *[\ \ ]-Wall[\ \ ]*) ;; + *) CFLAGS="$CFLAGS -Wall" ;; + esac + + case " $CFLAGS " in + *[\ \ ]-Wchar-subscripts[\ \ ]*) ;; + *) CFLAGS="$CFLAGS -Wchar-subscripts" ;; + esac + + case " $CFLAGS " in + *[\ \ ]-Wmissing-declarations[\ \ ]*) ;; + *) CFLAGS="$CFLAGS -Wmissing-declarations" ;; + esac + + case " $CFLAGS " in + *[\ \ ]-Wnested-externs[\ \ ]*) ;; + *) CFLAGS="$CFLAGS -Wnested-externs" ;; + esac + + case " $CFLAGS " in + *[\ \ ]-Wcast-align[\ \ ]*) ;; + *) CFLAGS="$CFLAGS -Wcast-align" ;; + esac + + case " $CFLAGS " in + *[\ \ ]-Wformat[\ \ ]*) ;; + *) CFLAGS="$CFLAGS -Wformat" ;; + esac + + case " $CFLAGS " in + *[\ \ ]-Wformat-security[\ \ ]*) ;; + *) CFLAGS="$CFLAGS -Wformat-security" ;; + esac + + if test "x$enable_ansi" = "xyes"; then + case " $CFLAGS " in + *[\ \ ]-ansi[\ \ ]*) ;; + *) CFLAGS="$CFLAGS -ansi" ;; + esac + + case " $CFLAGS " in + *[\ \ ]-D_POSIX_C_SOURCE*) ;; + *) CFLAGS="$CFLAGS -D_POSIX_C_SOURCE=199309L" ;; + esac + + case " $CFLAGS " in + *[\ \ ]-D_BSD_SOURCE[\ \ ]*) ;; + *) CFLAGS="$CFLAGS -D_BSD_SOURCE" ;; + esac + + case " $CFLAGS " in + *[\ \ ]-pedantic[\ \ ]*) ;; + *) CFLAGS="$CFLAGS -pedantic" ;; + esac + fi + changequote([,])dnl +fi + +PKG_CHECK_MODULES(CURL, [libcurl]) +AC_SUBST(CURL_CFLAGS) +AC_SUBST(CURL_LIBS) + +ZLIB_LIBS="" +AC_ARG_WITH(zlib, [ --with-zlib=<dir> Use zlib from here], + [ + zlib=$withval + CPPFLAGS="$CPPFLAGS -I$withval/include" + LDFLAGS="$LDFLAGS -L$withval/lib" + ] + ) +AC_CHECK_HEADERS(zlib.h, [AC_DEFINE(HAVE_ZLIB_H)], + [AC_MSG_ERROR([Can't find zlib.h. Please install zlib.])]) +AC_CHECK_LIB(z, inflate, [ZLIB_LIBS="-lz"], + [AC_MSG_ERROR([Can't find zlib library. Please install zlib.])]) +AC_SUBST(ZLIB_LIBS) + +EXPAT_LIB="" +AC_ARG_WITH(expat, [ --with-expat=<dir> Use expat from here], + [ + expat=$withval + CPPFLAGS="$CPPFLAGS -I$withval/include" + LDFLAGS="$LDFLAGS -L$withval/lib" + ] + ) +AC_CHECK_HEADERS(expat.h, [AC_DEFINE(HAVE_EXPAT_H)], + [AC_MSG_ERROR([Can't find expat.h. Please install expat.])]) +AC_CHECK_LIB(expat, XML_ParserCreate, [EXPAT_LIBS="-lexpat"], + [AC_MSG_ERROR([Can't find expat library. Please install expat.])]) +AC_SUBST(EXPAT_LIBS) + +RPM_LIB="" +AC_ARG_WITH(rpm, [ --with-rpm=<dir> Use rpm from here], + [ + rpm=$withval + CPPFLAGS="$CPPFLAGS -I$withval/include" + LDFLAGS="$LDFLAGS -L$withval/lib" + ] + ) +AC_CHECK_HEADERS(rpm/rpmlib.h, [], + [AC_MSG_ERROR([Can't find rpm/rpmlib.h. Please install rpm-devel.])]) +AC_CHECK_LIB(rpm,rpmdbOpen,[RPM_LIBS="-lrpm"], + [AC_MSG_ERROR([Can't find rpm library. Please install rpm-devel.])]) +AC_SUBST(RPM_LIBS) + +if test "x$GCC" = "xyes"; then + LDFLAGS="-Wl,--as-needed $LDFLAGS" +fi + +# ***************************** +# Make available to Makefile.am +# ***************************** +AC_SUBST(SYSCONFDIR, $sysconfdir) + +# ******************** +# Internationalisation +# ******************** + +IT_PROG_INTLTOOL([0.36.0]) +GETTEXT_PACKAGE=razor +AC_SUBST([GETTEXT_PACKAGE]) +AM_GLIB_GNU_GETTEXT +AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE],["$GETTEXT_PACKAGE"],[gettext domain]) + +AC_OUTPUT([ +Makefile +data/razor.pc +data/Makefile +librazor/Makefile +src/Makefile +docs/Makefile +po/Makefile.in +]) + +dnl ========================================================================== +echo " + razor $VERSION + ================= + + prefix: ${prefix} + libdir: ${libdir} + libexecdir: ${libexecdir} + bindir: ${bindir} + sbindir: ${sbindir} + datadir: ${datadir} + sysconfdir: ${sysconfdir} + localstatedir: ${localstatedir} + docdir: ${docdir} + + compiler: ${CC} + cflags: ${CFLAGS} + Maintainer mode: ${USE_MAINTAINER_MODE} + Building verbose mode: ${enable_verbose_mode} +" + diff --git a/contrib/razor.spec b/contrib/razor.spec new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/contrib/razor.spec diff --git a/data/.gitignore b/data/.gitignore new file mode 100644 index 0000000..16bc098 --- /dev/null +++ b/data/.gitignore @@ -0,0 +1,2 @@ +razor.pc + diff --git a/data/Makefile.am b/data/Makefile.am new file mode 100644 index 0000000..9405c68 --- /dev/null +++ b/data/Makefile.am @@ -0,0 +1,11 @@ +## Process this file with automake to produce Makefile.in + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = razor.pc + +bashcompletiondir = ${SYSCONFDIR}/bash_completion.d +dist_bashcompletion_DATA = bash-completion.sh + +clean-local : + rm -f *~ + diff --git a/bash-completion.sh b/data/bash-completion.sh index a4e9f4e..a4e9f4e 100644 --- a/bash-completion.sh +++ b/data/bash-completion.sh diff --git a/data/razor.pc.in b/data/razor.pc.in new file mode 100644 index 0000000..ddf0ba0 --- /dev/null +++ b/data/razor.pc.in @@ -0,0 +1,12 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: razor +Description: library for depsolving, installing and removing packages +Version: @VERSION@ +Requires: expat curl +Libs: -L${libdir} -lexpat -lz -lcurl +Cflags: -I${includedir}/razor + diff --git a/DEPSOLVE.txt b/docs/DEPSOLVE.txt index fce8698..fce8698 100644 --- a/DEPSOLVE.txt +++ b/docs/DEPSOLVE.txt diff --git a/docs/Makefile.am b/docs/Makefile.am new file mode 100644 index 0000000..cfefb5c --- /dev/null +++ b/docs/Makefile.am @@ -0,0 +1,5 @@ + +EXTRA_DIST = \ + DEPSOLVE.txt \ + REPO.txt + diff --git a/librazor/.gitignore b/librazor/.gitignore new file mode 100644 index 0000000..7fe452b --- /dev/null +++ b/librazor/.gitignore @@ -0,0 +1,5 @@ +.deps +.libs +*.lo +*.la + diff --git a/librazor/Makefile.am b/librazor/Makefile.am new file mode 100644 index 0000000..0231424 --- /dev/null +++ b/librazor/Makefile.am @@ -0,0 +1,34 @@ +## Process this file with automake to produce Makefile.in + +INCLUDES = \ + -I$(top_builddir)/src -I$(top_srcdir)/src \ + -DPACKAGE_LIBEXEC_DIR=\""$(libexecdir)"\" \ + -DPACKAGE_SYSCONF_DIR=\""$(sysconfdir)"\" \ + -DPACKAGE_DATA_DIR=\""$(datadir)"\" \ + -DPACKAGE_BIN_DIR=\""$(bindir)"\" \ + -DPACKAGE_LOCALSTATE_DIR=\""$(localstatedir)"\" \ + -DPACKAGE_LOCALE_DIR=\""$(localedir)"\" \ + -DPACKAGE_LIB_DIR=\""$(libdir)"\" + +lib_LTLIBRARIES = librazor.la + +librazorincludedir = $(includedir)/razor + +librazorinclude_HEADERS = \ + razor.h + +librazor_la_SOURCES = \ + razor-internal.h \ + razor.h \ + razor.c \ + razor-root.c \ + types.h \ + types.c \ + util.c \ + rpm.c + +librazor_la_LIBADD = $(ZLIB_LIBS) + +clean-local : + rm -f *~ + diff --git a/razor-internal.h b/librazor/razor-internal.h index f2a922f..f2a922f 100644 --- a/razor-internal.h +++ b/librazor/razor-internal.h diff --git a/razor-root.c b/librazor/razor-root.c index fafbcc2..12de470 100644 --- a/razor-root.c +++ b/librazor/razor-root.c @@ -22,7 +22,7 @@ struct razor_root { int razor_root_create(const char *root) -{ +{ struct stat buf; struct razor_set *set; char path[PATH_MAX]; diff --git a/razor.c b/librazor/razor.c index b74f3dd..c5b986b 100644 --- a/razor.c +++ b/librazor/razor.c @@ -444,7 +444,7 @@ compare_properties(const void *p1, const void *p2, void *data) struct razor_set *set = data; char *pool = set->string_pool.data; - if (prop1->name != prop2->name) + if (prop1->name != prop2->name) return strcmp(&pool[prop1->name], &pool[prop2->name]); else if (prop1->type != prop2->type) return prop1->type - prop2->type; @@ -547,7 +547,7 @@ count_entries(struct import_directory *d) count_entries(p); d->count += p->count + 1; p++; - } + } } static void @@ -571,7 +571,7 @@ serialize_files(struct razor_set *set, list_set_array(&e->packages, &set->package_pool, &p->packages, 0); array_release(&p->packages); p++; - } + } if (e != NULL) e->flags |= RAZOR_ENTRY_LAST; @@ -639,7 +639,7 @@ build_file_tree(struct razor_importer *importer) array_init(&d->last->files); array_init(&d->last->packages); } - d = d->last; + d = d->last; f = end + 1; if (*end == '\0') break; @@ -1074,7 +1074,7 @@ razor_package_iterator_create_for_file(struct razor_set *set, entry = find_entry(set, set->files.data, filename); if (entry == NULL) return NULL; - + index = list_first(&entry->packages, &set->package_pool); return razor_package_iterator_create_with_index(set, index); } @@ -1088,7 +1088,7 @@ list_package_files(struct razor_set *set, struct list *r, uint32_t next, file; char *pool; int len; - + entries = (struct razor_entry *) set->files.data; pool = set->string_pool.data; @@ -1112,7 +1112,7 @@ list_package_files(struct razor_set *set, struct list *r, if (e->flags & RAZOR_ENTRY_LAST) next = end; else { - f = e + 1; + f = e + 1; while (f->start == 0 && !(f->flags & RAZOR_ENTRY_LAST)) f++; if (f->start == 0) @@ -1961,10 +1961,10 @@ remove_matching_providers(struct razor_transaction *trans, set = trans->system.set; else set = trans->upstream.set; - + pkgs = (struct razor_package *) set->packages.data; - for (p = ppi->p; - p < ppi->end && + for (p = ppi->p; + p < ppi->end && p->name == ppi->p->name && p->type == ppi->p->type; p++) { @@ -1973,7 +1973,7 @@ remove_matching_providers(struct razor_transaction *trans, if (!provider_satisfies_requirement(p, ppi->pool, relation, version)) continue; - + razor_package_iterator_init_for_property(&pkg_iter, set, p); while (razor_package_iterator_next(&pkg_iter, &pkg, &n, &v, &a)) { @@ -2004,10 +2004,10 @@ flag_matching_providers(struct razor_transaction *trans, set = trans->upstream.set; flags = trans->upstream.packages; } - + pkgs = (struct razor_package *) set->packages.data; - for (p = ppi->p; - p < ppi->end && + for (p = ppi->p; + p < ppi->end && p->name == ppi->p->name && p->type == ppi->p->type; p++) { @@ -2017,7 +2017,7 @@ flag_matching_providers(struct razor_transaction *trans, r->relation, &rpi->pool[r->version])) continue; - + razor_package_iterator_init_for_property(&pkg_iter, set, p); while (razor_package_iterator_next(&pkg_iter, &pkg, &name, &version, &arch)) { @@ -2077,7 +2077,7 @@ remove_obsoleted_packages(struct razor_transaction *trans) spkgs = trans->system.set->packages.data; prop_iter_init(&spi, &trans->system); prop_iter_init(&upi, &trans->upstream); - + while (prop_iter_next(&upi, RAZOR_PROPERTY_OBSOLETES, &up)) { if (!prop_iter_seek_to(&spi, RAZOR_PROPERTY_PROVIDES, &upi.pool[up->name])) @@ -2171,11 +2171,11 @@ update_unsatisfied_packages(struct razor_transaction *trans) spkgs = trans->system.set->packages.data; prop_iter_init(&spi, &trans->system); - + while (prop_iter_next(&spi, RAZOR_PROPERTY_REQUIRES, &sp)) { if (spi.present[sp - spi.start] & TRANS_PROPERTY_SATISFIED) continue; - + razor_package_iterator_init_for_property(&pkg_iter, trans->system.set, sp); @@ -2277,9 +2277,9 @@ pull_in_requirements(struct razor_transaction *trans, fprintf(stderr, "pulling in %s which provides %s %s %s " "to satisfy %s %s %s\n", ppi->pool + pkg->name, - ppi->pool + pp->name, + ppi->pool + pp->name, relation_string[pp->relation], - ppi->pool + pp->version, + ppi->pool + pp->version, &rpi->pool[rp->name], relation_string[rp->relation], &rpi->pool[rp->version]); @@ -2296,7 +2296,7 @@ pull_in_all_requirements(struct razor_transaction *trans) prop_iter_init(&rpi, &trans->system); prop_iter_init(&ppi, &trans->upstream); pull_in_requirements(trans, &rpi, &ppi); - + prop_iter_init(&rpi, &trans->upstream); prop_iter_init(&ppi, &trans->upstream); pull_in_requirements(trans, &rpi, &ppi); @@ -2325,7 +2325,7 @@ flush_scheduled_system_updates(struct razor_transaction *trans) RAZOR_VERSION_GREATER, version); if (pkg == NULL) continue; - + fprintf(stderr, "updating %s-%s to %s-%s\n", name, version, &ppi.pool[pkg->name], &ppi.pool[pkg->version]); @@ -2457,7 +2457,7 @@ razor_transaction_unsatisfied_property(struct razor_transaction *trans, p->relation == rel && strcmp(&pi.pool[p->name], name) == 0 && strcmp(&pi.pool[p->version], version) == 0) - + return 1; } @@ -2467,7 +2467,7 @@ razor_transaction_unsatisfied_property(struct razor_transaction *trans, p->relation == rel && strcmp(&pi.pool[p->name], name) == 0 && strcmp(&pi.pool[p->version], version) == 0) - + return 1; } diff --git a/razor.h b/librazor/razor.h index 4f2cc05..4f2cc05 100644 --- a/razor.h +++ b/librazor/razor.h @@ -19,6 +19,7 @@ #include <stdio.h> #include <stddef.h> +#include <stdlib.h> #include <string.h> #include <errno.h> #include <sys/stat.h> @@ -26,10 +27,9 @@ #include <sys/types.h> #include <sys/wait.h> #include <fcntl.h> +#include <dirent.h> #include <unistd.h> #include <arpa/inet.h> -#include <rpm/rpmlib.h> -#include <rpm/rpmdb.h> #include <zlib.h> #include "razor.h" @@ -37,6 +37,181 @@ #define RPM_LEAD_SIZE 96 +enum { + PIPE = 1, /*!< pipe/fifo */ + CDEV = 2, /*!< character device */ + XDIR = 4, /*!< directory */ + BDEV = 6, /*!< block device */ + REG = 8, /*!< regular file */ + LINK = 10, /*!< hard link */ + SOCK = 12 /*!< socket */ +}; + +enum { + RPMSENSE_LESS = (1 << 1), + RPMSENSE_GREATER = (1 << 2), + RPMSENSE_EQUAL = (1 << 3), +}; + +enum { + RPMTAG_NAME = 1000, /* s */ + RPMTAG_VERSION = 1001, /* s */ + RPMTAG_RELEASE = 1002, /* s */ + RPMTAG_EPOCH = 1003, /* i */ + RPMTAG_SUMMARY = 1004, /* s{} */ + RPMTAG_DESCRIPTION = 1005, /* s{} */ + RPMTAG_BUILDTIME = 1006, /* i */ + RPMTAG_BUILDHOST = 1007, /* s */ + RPMTAG_INSTALLTIME = 1008, /* i */ + RPMTAG_SIZE = 1009, /* i */ + RPMTAG_DISTRIBUTION = 1010, /* s */ + RPMTAG_VENDOR = 1011, /* s */ + RPMTAG_GIF = 1012, /* x */ + RPMTAG_XPM = 1013, /* x */ + RPMTAG_LICENSE = 1014, /* s */ + RPMTAG_PACKAGER = 1015, /* s */ + RPMTAG_GROUP = 1016, /* s{} */ + RPMTAG_CHANGELOG = 1017, /*!< s[] internal */ + RPMTAG_SOURCE = 1018, /* s[] */ + RPMTAG_PATCH = 1019, /* s[] */ + RPMTAG_URL = 1020, /* s */ + RPMTAG_OS = 1021, /* s legacy used int */ + RPMTAG_ARCH = 1022, /* s legacy used int */ + RPMTAG_PREIN = 1023, /* s */ + RPMTAG_POSTIN = 1024, /* s */ + RPMTAG_PREUN = 1025, /* s */ + RPMTAG_POSTUN = 1026, /* s */ + RPMTAG_OLDFILENAMES = 1027, /* s[] obsolete */ + RPMTAG_FILESIZES = 1028, /* i */ + RPMTAG_FILESTATES = 1029, /* c */ + RPMTAG_FILEMODES = 1030, /* h */ + RPMTAG_FILEUIDS = 1031, /*!< internal */ + RPMTAG_FILEGIDS = 1032, /*!< internal */ + RPMTAG_FILERDEVS = 1033, /* h */ + RPMTAG_FILEMTIMES = 1034, /* i */ + RPMTAG_FILEMD5S = 1035, /* s[] */ + RPMTAG_FILELINKTOS = 1036, /* s[] */ + RPMTAG_FILEFLAGS = 1037, /* i */ + RPMTAG_ROOT = 1038, /*!< internal - obsolete */ + RPMTAG_FILEUSERNAME = 1039, /* s[] */ + RPMTAG_FILEGROUPNAME = 1040, /* s[] */ + RPMTAG_EXCLUDE = 1041, /*!< internal - obsolete */ + RPMTAG_EXCLUSIVE = 1042, /*!< internal - obsolete */ + RPMTAG_ICON = 1043, + RPMTAG_SOURCERPM = 1044, /* s */ + RPMTAG_FILEVERIFYFLAGS = 1045, /* i */ + RPMTAG_ARCHIVESIZE = 1046, /* i */ + RPMTAG_PROVIDENAME = 1047, /* s[] */ + RPMTAG_REQUIREFLAGS = 1048, /* i */ + RPMTAG_REQUIRENAME = 1049, /* s[] */ + RPMTAG_REQUIREVERSION = 1050, /* s[] */ + RPMTAG_NOSOURCE = 1051, /*!< internal */ + RPMTAG_NOPATCH = 1052, /*!< internal */ + RPMTAG_CONFLICTFLAGS = 1053, /* i */ + RPMTAG_CONFLICTNAME = 1054, /* s[] */ + RPMTAG_CONFLICTVERSION = 1055, /* s[] */ + RPMTAG_DEFAULTPREFIX = 1056, /*!< internal - deprecated */ + RPMTAG_BUILDROOT = 1057, /*!< internal */ + RPMTAG_INSTALLPREFIX = 1058, /*!< internal - deprecated */ + RPMTAG_EXCLUDEARCH = 1059, + RPMTAG_EXCLUDEOS = 1060, + RPMTAG_EXCLUSIVEARCH = 1061, + RPMTAG_EXCLUSIVEOS = 1062, + RPMTAG_AUTOREQPROV = 1063, /*!< internal */ + RPMTAG_RPMVERSION = 1064, /* s */ + RPMTAG_TRIGGERSCRIPTS = 1065, /* s[] */ + RPMTAG_TRIGGERNAME = 1066, /* s[] */ + RPMTAG_TRIGGERVERSION = 1067, /* s[] */ + RPMTAG_TRIGGERFLAGS = 1068, /* i */ + RPMTAG_TRIGGERINDEX = 1069, /* i */ + RPMTAG_VERIFYSCRIPT = 1079, /* s */ + RPMTAG_CHANGELOGTIME = 1080, /* i */ + RPMTAG_CHANGELOGNAME = 1081, /* s[] */ + RPMTAG_CHANGELOGTEXT = 1082, /* s[] */ + RPMTAG_BROKENMD5 = 1083, /*!< internal - obsolete */ + RPMTAG_PREREQ = 1084, /*!< internal */ + RPMTAG_PREINPROG = 1085, /* s */ + RPMTAG_POSTINPROG = 1086, /* s */ + RPMTAG_PREUNPROG = 1087, /* s */ + RPMTAG_POSTUNPROG = 1088, /* s */ + RPMTAG_BUILDARCHS = 1089, + RPMTAG_OBSOLETENAME = 1090, /* s[] */ + RPMTAG_VERIFYSCRIPTPROG = 1091, /* s */ + RPMTAG_TRIGGERSCRIPTPROG = 1092, /* s */ + RPMTAG_DOCDIR = 1093, /*!< internal */ + RPMTAG_COOKIE = 1094, /* s */ + RPMTAG_FILEDEVICES = 1095, /* i */ + RPMTAG_FILEINODES = 1096, /* i */ + RPMTAG_FILELANGS = 1097, /* s[] */ + RPMTAG_PREFIXES = 1098, /* s[] */ + RPMTAG_INSTPREFIXES = 1099, /* s[] */ + RPMTAG_TRIGGERIN = 1100, /*!< internal */ + RPMTAG_TRIGGERUN = 1101, /*!< internal */ + RPMTAG_TRIGGERPOSTUN = 1102, /*!< internal */ + RPMTAG_AUTOREQ = 1103, /*!< internal */ + RPMTAG_AUTOPROV = 1104, /*!< internal */ + RPMTAG_CAPABILITY = 1105, /*!< internal - obsolete */ + RPMTAG_SOURCEPACKAGE = 1106, /*!< i src.rpm header marker */ + RPMTAG_OLDORIGFILENAMES = 1107, /*!< internal - obsolete */ + RPMTAG_BUILDPREREQ = 1108, /*!< internal */ + RPMTAG_BUILDREQUIRES = 1109, /*!< internal */ + RPMTAG_BUILDCONFLICTS = 1110, /*!< internal */ + RPMTAG_BUILDMACROS = 1111, /*!< internal - unused */ + RPMTAG_PROVIDEFLAGS = 1112, /* i */ + RPMTAG_PROVIDEVERSION = 1113, /* s[] */ + RPMTAG_OBSOLETEFLAGS = 1114, /* i */ + RPMTAG_OBSOLETEVERSION = 1115, /* s[] */ + RPMTAG_DIRINDEXES = 1116, /* i */ + RPMTAG_BASENAMES = 1117, /* s[] */ + RPMTAG_DIRNAMES = 1118, /* s[] */ + RPMTAG_ORIGDIRINDEXES = 1119, /*!< internal */ + RPMTAG_ORIGBASENAMES = 1120, /*!< internal */ + RPMTAG_ORIGDIRNAMES = 1121, /*!< internal */ + RPMTAG_OPTFLAGS = 1122, /* s */ + RPMTAG_DISTURL = 1123, /* s */ + RPMTAG_PAYLOADFORMAT = 1124, /* s */ + RPMTAG_PAYLOADCOMPRESSOR = 1125, /* s */ + RPMTAG_PAYLOADFLAGS = 1126, /* s */ + RPMTAG_INSTALLCOLOR = 1127, /*!< i transaction color when installed */ + RPMTAG_INSTALLTID = 1128, /* i */ + RPMTAG_REMOVETID = 1129, /* i */ + RPMTAG_SHA1RHN = 1130, /*!< internal - obsolete */ + RPMTAG_RHNPLATFORM = 1131, /* s */ + RPMTAG_PLATFORM = 1132, /* s */ + RPMTAG_PATCHESNAME = 1133, /*!< placeholder (SuSE) */ + RPMTAG_PATCHESFLAGS = 1134, /*!< placeholder (SuSE) */ + RPMTAG_PATCHESVERSION = 1135, /*!< placeholder (SuSE) */ + RPMTAG_CACHECTIME = 1136, /* i */ + RPMTAG_CACHEPKGPATH = 1137, /* s */ + RPMTAG_CACHEPKGSIZE = 1138, /* i */ + RPMTAG_CACHEPKGMTIME = 1139, /* i */ + RPMTAG_FILECOLORS = 1140, /* i */ + RPMTAG_FILECLASS = 1141, /* i */ + RPMTAG_CLASSDICT = 1142, /* s[] */ + RPMTAG_FILEDEPENDSX = 1143, /* i */ + RPMTAG_FILEDEPENDSN = 1144, /* i */ + RPMTAG_DEPENDSDICT = 1145, /* i */ + RPMTAG_SOURCEPKGID = 1146, /* x */ + RPMTAG_FILECONTEXTS = 1147, /* s[] */ + RPMTAG_FSCONTEXTS = 1148, /*!< s[] extension */ + RPMTAG_RECONTEXTS = 1149, /*!< s[] extension */ + RPMTAG_POLICIES = 1150, /*!< s[] selinux *.te policy file. */ + RPMTAG_PRETRANS = 1151, /* s */ + RPMTAG_POSTTRANS = 1152, /* s */ + RPMTAG_PRETRANSPROG = 1153, /* s */ + RPMTAG_POSTTRANSPROG = 1154, /* s */ + RPMTAG_DISTTAG = 1155, /* s */ + RPMTAG_SUGGESTSNAME = 1156, /* s[] extension placeholder */ + RPMTAG_SUGGESTSVERSION = 1157, /* s[] extension placeholder */ + RPMTAG_SUGGESTSFLAGS = 1158, /* i extension placeholder */ + RPMTAG_ENHANCESNAME = 1159, /* s[] extension placeholder */ + RPMTAG_ENHANCESVERSION = 1160, /* s[] extension placeholder */ + RPMTAG_ENHANCESFLAGS = 1161, /* i extension placeholder */ + RPMTAG_PRIORITY = 1162, /* i extension placeholder */ + RPMTAG_CVSID = 1163, /* s */ + RPMTAG_TRIGGERPREIN = 1171, /*!< internal */ +}; + struct rpm_header { unsigned char magic[4]; unsigned char reserved[4]; @@ -95,7 +270,7 @@ razor_rpm_get_indirect(struct razor_rpm *rpm, } static enum razor_version_relation -rpm_to_razor_flags (uint_32 flags) +rpm_to_razor_flags(uint32_t flags) { switch (flags & (RPMSENSE_LESS | RPMSENSE_EQUAL | RPMSENSE_GREATER)) { case RPMSENSE_LESS: @@ -120,8 +295,8 @@ import_properties(struct razor_importer *importer, unsigned long type, int name_tag, int version_tag, int flags_tag) { const char *name, *version; - const uint_32 *flags; - uint_32 f; + const uint32_t *flags; + uint32_t f; unsigned int i, count; name = razor_rpm_get_indirect(rpm, name_tag, &count); @@ -493,7 +668,7 @@ installer_finish(struct installer *installer) if (err != Z_OK) { fprintf(stderr, "inflateEnd error: %d\n", err); return -1; - } + } return 0; } @@ -544,7 +719,7 @@ razor_rpm_install(struct razor_rpm *rpm, const char *root) installer.rest = sizeof *header; if (installer_inflate(&installer)) return -1; - + header = (struct cpio_file_header *) installer.buffer; mode = fixed_hex_to_ulong(header->mode, sizeof header->mode); filesize = fixed_hex_to_ulong(header->filesize, @@ -593,7 +768,7 @@ int razor_importer_add_rpm(struct razor_importer *importer, struct razor_rpm *rpm) { const char *name, *version, *release, *arch; - const uint_32 *epoch; + const uint32_t *epoch; char evr[128], buf[16]; name = razor_rpm_get_indirect(rpm, RPMTAG_NAME, NULL); @@ -636,113 +811,3 @@ razor_importer_add_rpm(struct razor_importer *importer, struct razor_rpm *rpm) return 0; } - -union rpm_entry { - void *p; - char *string; - char **list; - uint_32 *flags; - uint_32 integer; -}; - -static void -add_properties(struct razor_importer *importer, - enum razor_property_type property_type, - Header h, int_32 name_tag, int_32 version_tag, int_32 flags_tag) -{ - union rpm_entry names, versions, flags; - int_32 i, type, count; - - headerGetEntry(h, name_tag, &type, &names.p, &count); - headerGetEntry(h, version_tag, &type, &versions.p, &count); - headerGetEntry(h, flags_tag, &type, &flags.p, &count); - - for (i = 0; i < count; i++) - razor_importer_add_property(importer, - names.list[i], - rpm_to_razor_flags (flags.flags[i]), - versions.list[i], - property_type); -} - -struct razor_set * -razor_set_create_from_rpmdb(void) -{ - struct razor_importer *importer; - rpmdbMatchIterator iter; - Header h; - int_32 type, count, i; - union rpm_entry name, epoch, version, release, arch; - union rpm_entry basenames, dirnames, dirindexes; - char filename[PATH_MAX], evr[128], buf[16]; - rpmdb db; - - rpmReadConfigFiles(NULL, NULL); - - if (rpmdbOpen("", &db, O_RDONLY, 0644) != 0) { - fprintf(stderr, "cannot open rpm database\n"); - exit(1); - } - - importer = razor_importer_new(); - - iter = rpmdbInitIterator(db, 0, NULL, 0); - while (h = rpmdbNextIterator(iter), h != NULL) { - headerGetEntry(h, RPMTAG_NAME, &type, &name.p, &count); - headerGetEntry(h, RPMTAG_EPOCH, &type, &epoch.p, &count); - headerGetEntry(h, RPMTAG_VERSION, &type, &version.p, &count); - headerGetEntry(h, RPMTAG_RELEASE, &type, &release.p, &count); - headerGetEntry(h, RPMTAG_ARCH, &type, &arch.p, &count); - - if (epoch.flags != NULL) { - snprintf(buf, sizeof buf, "%u", *epoch.flags); - razor_build_evr(evr, sizeof evr, - buf, version.string, release.string); - } else { - razor_build_evr(evr, sizeof evr, - NULL, version.string, release.string); - } - - razor_importer_begin_package(importer, - name.string, evr, arch.string); - - add_properties(importer, RAZOR_PROPERTY_REQUIRES, h, - RPMTAG_REQUIRENAME, - RPMTAG_REQUIREVERSION, - RPMTAG_REQUIREFLAGS); - - add_properties(importer, RAZOR_PROPERTY_PROVIDES, h, - RPMTAG_PROVIDENAME, - RPMTAG_PROVIDEVERSION, - RPMTAG_PROVIDEFLAGS); - - add_properties(importer, RAZOR_PROPERTY_OBSOLETES, h, - RPMTAG_OBSOLETENAME, - RPMTAG_OBSOLETEVERSION, - RPMTAG_OBSOLETEFLAGS); - - add_properties(importer, RAZOR_PROPERTY_CONFLICTS, h, - RPMTAG_CONFLICTNAME, - RPMTAG_CONFLICTVERSION, - RPMTAG_CONFLICTFLAGS); - - headerGetEntry(h, RPMTAG_BASENAMES, &type, - &basenames.p, &count); - headerGetEntry(h, RPMTAG_DIRNAMES, &type, - &dirnames.p, &count); - headerGetEntry(h, RPMTAG_DIRINDEXES, &type, - &dirindexes.p, &count); - for (i = 0; i < count; i++) { - snprintf(filename, sizeof filename, "%s%s", - dirnames.list[dirindexes.flags[i]], - basenames.list[i]); - razor_importer_add_file(importer, filename); - } - - razor_importer_finish_package(importer); - } - - rpmdbClose(db); - - return razor_importer_finish(importer); -} diff --git a/types.c b/librazor/types.c index adb5b89..adb5b89 100644 --- a/types.c +++ b/librazor/types.c diff --git a/types.h b/librazor/types.h index 6e36754..6e36754 100644 --- a/types.h +++ b/librazor/types.h diff --git a/po/.gitignore b/po/.gitignore new file mode 100644 index 0000000..7398a05 --- /dev/null +++ b/po/.gitignore @@ -0,0 +1,4 @@ +POTFILES +Makefile.in.in +stamp-it + diff --git a/po/LINGUAS b/po/LINGUAS new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/po/LINGUAS diff --git a/po/POTFILES.in b/po/POTFILES.in new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/po/POTFILES.in diff --git a/src/.gitignore b/src/.gitignore new file mode 100644 index 0000000..25f606c --- /dev/null +++ b/src/.gitignore @@ -0,0 +1,5 @@ +.deps +.libs +razor +rpm-razor + diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..58f7788 --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,26 @@ +## Process this file with automake to produce Makefile.in + +INCLUDES = \ + $(CURL_CFLAGS) \ + $(EXPAT_CFLAGS) \ + $(RPM_CFLAGS) \ + -I$(top_builddir)/src -I$(top_srcdir)/src \ + -I$(top_srcdir)/librazor \ + -DPACKAGE_LIBEXEC_DIR=\""$(libexecdir)"\" \ + -DPACKAGE_SYSCONF_DIR=\""$(sysconfdir)"\" \ + -DPACKAGE_DATA_DIR=\""$(datadir)"\" \ + -DPACKAGE_BIN_DIR=\""$(bindir)"\" \ + -DPACKAGE_LOCALSTATEDIR=\""$(localstatedir)"\" \ + -DPACKAGE_LOCALE_DIR=\""$(localedir)"\" + +bin_PROGRAMS = razor rpm + +razor_SOURCES = main.c import-rpmdb.c import-yum.c +razor_LDADD = $(RPM_LIBS) $(EXPAT_LIBS) $(CURL_LIBS) $(top_builddir)/librazor/librazor.la + +rpm_SOURCES = rpm.c +rpm_LDADD = $(top_builddir)/librazor/librazor.la + +clean-local : + rm -f *~ + diff --git a/src/import-rpmdb.c b/src/import-rpmdb.c new file mode 100644 index 0000000..ddfed9e --- /dev/null +++ b/src/import-rpmdb.c @@ -0,0 +1,157 @@ +/* + * Copyright (C) 2008 Kristian Høgsberg <krh@redhat.com> + * Copyright (C) 2008 Red Hat, Inc + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include <stdio.h> +#include <stddef.h> +#include <string.h> +#include <fcntl.h> +#include <rpm/rpmlib.h> +#include <rpm/rpmdb.h> + +#include "razor.h" + +union rpm_entry { + void *p; + char *string; + char **list; + uint_32 *flags; + uint_32 integer; +}; + +static enum razor_version_relation +rpm_to_razor_flags (uint_32 flags) +{ + switch (flags & (RPMSENSE_LESS | RPMSENSE_EQUAL | RPMSENSE_GREATER)) { + case RPMSENSE_LESS: + return RAZOR_VERSION_LESS; + case RPMSENSE_LESS|RPMSENSE_EQUAL: + return RAZOR_VERSION_LESS_OR_EQUAL; + case RPMSENSE_EQUAL: + return RAZOR_VERSION_EQUAL; + case RPMSENSE_GREATER|RPMSENSE_EQUAL: + return RAZOR_VERSION_GREATER_OR_EQUAL; + case RPMSENSE_GREATER: + return RAZOR_VERSION_GREATER; + } + + /* FIXME? */ + return RAZOR_VERSION_EQUAL; +} + +static void +add_properties(struct razor_importer *importer, + enum razor_property_type property_type, + Header h, int_32 name_tag, int_32 version_tag, int_32 flags_tag) +{ + union rpm_entry names, versions, flags; + int_32 i, type, count; + + headerGetEntry(h, name_tag, &type, &names.p, &count); + headerGetEntry(h, version_tag, &type, &versions.p, &count); + headerGetEntry(h, flags_tag, &type, &flags.p, &count); + + for (i = 0; i < count; i++) + razor_importer_add_property(importer, + names.list[i], + rpm_to_razor_flags (flags.flags[i]), + versions.list[i], + property_type); +} + +struct razor_set * +razor_set_create_from_rpmdb(void) +{ + struct razor_importer *importer; + rpmdbMatchIterator iter; + Header h; + int_32 type, count, i; + union rpm_entry name, epoch, version, release, arch; + union rpm_entry basenames, dirnames, dirindexes; + char filename[PATH_MAX], evr[128], buf[16]; + rpmdb db; + + rpmReadConfigFiles(NULL, NULL); + + if (rpmdbOpen("", &db, O_RDONLY, 0644) != 0) { + fprintf(stderr, "cannot open rpm database\n"); + exit(1); + } + + importer = razor_importer_new(); + + iter = rpmdbInitIterator(db, 0, NULL, 0); + while (h = rpmdbNextIterator(iter), h != NULL) { + headerGetEntry(h, RPMTAG_NAME, &type, &name.p, &count); + headerGetEntry(h, RPMTAG_EPOCH, &type, &epoch.p, &count); + headerGetEntry(h, RPMTAG_VERSION, &type, &version.p, &count); + headerGetEntry(h, RPMTAG_RELEASE, &type, &release.p, &count); + headerGetEntry(h, RPMTAG_ARCH, &type, &arch.p, &count); + + if (epoch.flags != NULL) { + snprintf(buf, sizeof buf, "%u", *epoch.flags); + razor_build_evr(evr, sizeof evr, + buf, version.string, release.string); + } else { + razor_build_evr(evr, sizeof evr, + NULL, version.string, release.string); + } + + razor_importer_begin_package(importer, + name.string, evr, arch.string); + + add_properties(importer, RAZOR_PROPERTY_REQUIRES, h, + RPMTAG_REQUIRENAME, + RPMTAG_REQUIREVERSION, + RPMTAG_REQUIREFLAGS); + + add_properties(importer, RAZOR_PROPERTY_PROVIDES, h, + RPMTAG_PROVIDENAME, + RPMTAG_PROVIDEVERSION, + RPMTAG_PROVIDEFLAGS); + + add_properties(importer, RAZOR_PROPERTY_OBSOLETES, h, + RPMTAG_OBSOLETENAME, + RPMTAG_OBSOLETEVERSION, + RPMTAG_OBSOLETEFLAGS); + + add_properties(importer, RAZOR_PROPERTY_CONFLICTS, h, + RPMTAG_CONFLICTNAME, + RPMTAG_CONFLICTVERSION, + RPMTAG_CONFLICTFLAGS); + + headerGetEntry(h, RPMTAG_BASENAMES, &type, + &basenames.p, &count); + headerGetEntry(h, RPMTAG_DIRNAMES, &type, + &dirnames.p, &count); + headerGetEntry(h, RPMTAG_DIRINDEXES, &type, + &dirindexes.p, &count); + for (i = 0; i < count; i++) { + snprintf(filename, sizeof filename, "%s%s", + dirnames.list[dirindexes.flags[i]], + basenames.list[i]); + razor_importer_add_file(importer, filename); + } + + razor_importer_finish_package(importer); + } + + rpmdbClose(db); + + return razor_importer_finish(importer); +} @@ -270,7 +270,7 @@ razor_set_create_from_yum(void) gzFile primary, filelists; XML_ParsingStatus status; - ctx.importer = razor_importer_new(); + ctx.importer = razor_importer_new(); ctx.state = YUM_STATE_BEGIN; ctx.primary_parser = XML_ParserCreate(NULL); @@ -429,7 +429,7 @@ command_update(int argc, const char *argv[]) return 1; } } - + errors = razor_transaction_resolve(trans); if (errors) return 1; @@ -497,7 +497,7 @@ command_diff(int argc, const char *argv[]) if (set == NULL || updated == NULL) return 1; - razor_set_diff(set, updated, print_diff, NULL); + razor_set_diff(set, updated, print_diff, NULL); razor_set_destroy(set); razor_set_destroy(updated); @@ -253,7 +253,7 @@ command_initdb(int argc, const char *argv[]) } static struct razor_property * -add_property_packages(struct razor_set *set, +add_property_packages(struct razor_set *set, struct razor_package_query *query, const char *ref_name, const char *ref_version, diff --git a/test-driver.c b/src/test-driver.c index 98b216d..876d248 100644 --- a/test-driver.c +++ b/src/test-driver.c @@ -237,7 +237,7 @@ start_property(struct test_context *ctx, enum razor_property_type type, const ch } } else rel = RAZOR_VERSION_EQUAL; - + if (ctx->unsat) check_unsatisfiable_property(ctx, type, name, rel, version); else @@ -262,12 +262,12 @@ end_transaction(struct test_context *ctx) pkg = razor_set_get_package(ctx->repo_set, ctx->install_pkgs[i]); razor_transaction_install_package(ctx->trans, pkg); - } + } for (i = 0; i < ctx->n_remove_pkgs; i++) { pkg = razor_set_get_package(ctx->repo_set, ctx->remove_pkgs[i]); razor_transaction_remove_package(ctx->trans, pkg); - } + } errors = razor_transaction_resolve(ctx->trans); printf("\n"); @@ -435,7 +435,7 @@ int main(int argc, char *argv[]) if (argc > 3) { fprintf(stderr, "usage: %s [-d] [TESTS-FILE]\n", argv[0]); - exit(-1); + exit(-1); } if (argc >= 2 && !strcmp (argv[1], "-d")) { |