first pass at new transaction api; basic installing/removing works

fine but I wouldn't push it much harder then that

CVS patchset: 2603
CVS date: 1998/12/16 21:58:53
This commit is contained in:
ewt 1998-12-16 21:58:53 +00:00
parent 033797c0ef
commit 10d3b6d5b6
26 changed files with 802 additions and 1132 deletions

View File

@ -1,4 +1,4 @@
# Makefile.in generated automatically by automake 1.3b from Makefile.am # Makefile.in generated automatically by automake 1.3 from Makefile.am
# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. # Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation # This Makefile.in is free software; the Free Software Foundation
@ -34,7 +34,7 @@ mandir = @mandir@
includedir = @includedir@ includedir = @includedir@
oldincludedir = /usr/include oldincludedir = /usr/include
DESTDIR = DISTDIR =
pkgdatadir = $(datadir)/@PACKAGE@ pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@
@ -180,8 +180,8 @@ rpm_LDFLAGS =
SCRIPTS = $(bin_SCRIPTS) $(config_SCRIPTS) SCRIPTS = $(bin_SCRIPTS) $(config_SCRIPTS)
CFLAGS = @CFLAGS@ CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
LINK = $(CC) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ LINK = $(CC) $(CFLAGS) $(LDFLAGS) -o $@
man8dir = $(mandir)/man8 man8dir = $(mandir)/man8
MANS = $(man_MANS) MANS = $(man_MANS)
@ -198,7 +198,7 @@ missing mkinstalldirs stamp-h.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = gtar TAR = tar
GZIP = --best GZIP = --best
DEP_FILES = .deps/build.P .deps/checksig.P .deps/convertdb.P \ DEP_FILES = .deps/build.P .deps/checksig.P .deps/convertdb.P \
.deps/ftp.P .deps/install.P .deps/oldrpmdb.P .deps/rpm.P \ .deps/ftp.P .deps/install.P .deps/oldrpmdb.P .deps/rpm.P \
@ -220,7 +220,7 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
$(ACLOCAL_M4): configure.in $(ACLOCAL_M4): configure.in
cd $(srcdir) && $(ACLOCAL) cd $(srcdir) && $(ACLOCAL)
config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) config.status: $(srcdir)/configure
$(SHELL) ./config.status --recheck $(SHELL) ./config.status --recheck
$(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES) $(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
cd $(srcdir) && $(AUTOCONF) cd $(srcdir) && $(AUTOCONF)
@ -246,11 +246,11 @@ distclean-hdr:
maintainer-clean-hdr: maintainer-clean-hdr:
Makefile.inc: $(top_builddir)/config.status Makefile.inc.in Makefile.inc: $(top_builddir)/config.status Makefile.inc.in
cd $(top_builddir) && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status cd $(top_builddir) && CONFIG_FILES=$@ CONFIG_HEADERS= ./config.status
lib-rpmrc: $(top_builddir)/config.status lib-rpmrc.in lib-rpmrc: $(top_builddir)/config.status lib-rpmrc.in
cd $(top_builddir) && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status cd $(top_builddir) && CONFIG_FILES=$@ CONFIG_HEADERS= ./config.status
macros: $(top_builddir)/config.status macros.in macros: $(top_builddir)/config.status macros.in
cd $(top_builddir) && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status cd $(top_builddir) && CONFIG_FILES=$@ CONFIG_HEADERS= ./config.status
mostlyclean-binPROGRAMS: mostlyclean-binPROGRAMS:
@ -266,15 +266,15 @@ install-binPROGRAMS: $(bin_PROGRAMS)
$(mkinstalldirs) $(DESTDIR)$(bindir) $(mkinstalldirs) $(DESTDIR)$(bindir)
@list='$(bin_PROGRAMS)'; for p in $$list; do \ @list='$(bin_PROGRAMS)'; for p in $$list; do \
if test -f $$p; then \ if test -f $$p; then \
echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \ echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`"; \
$(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \
else :; fi; \ else :; fi; \
done done
uninstall-binPROGRAMS: uninstall-binPROGRAMS:
@$(NORMAL_UNINSTALL) @$(NORMAL_UNINSTALL)
list='$(bin_PROGRAMS)'; for p in $$list; do \ list='$(bin_PROGRAMS)'; for p in $$list; do \
rm -f $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ rm -f $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \
done done
mostlyclean-noinstPROGRAMS: mostlyclean-noinstPROGRAMS:
@ -300,15 +300,15 @@ install-rpmbinPROGRAMS: $(rpmbin_PROGRAMS)
$(mkinstalldirs) $(DESTDIR)$(rpmbindir) $(mkinstalldirs) $(DESTDIR)$(rpmbindir)
@list='$(rpmbin_PROGRAMS)'; for p in $$list; do \ @list='$(rpmbin_PROGRAMS)'; for p in $$list; do \
if test -f $$p; then \ if test -f $$p; then \
echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(rpmbindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \ echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(rpmbindir)/`echo $$p|sed '$(transform)'`"; \
$(INSTALL_PROGRAM) $$p $(DESTDIR)$(rpmbindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ $(INSTALL_PROGRAM) $$p $(DESTDIR)$(rpmbindir)/`echo $$p|sed '$(transform)'`; \
else :; fi; \ else :; fi; \
done done
uninstall-rpmbinPROGRAMS: uninstall-rpmbinPROGRAMS:
@$(NORMAL_UNINSTALL) @$(NORMAL_UNINSTALL)
list='$(rpmbin_PROGRAMS)'; for p in $$list; do \ list='$(rpmbin_PROGRAMS)'; for p in $$list; do \
rm -f $(DESTDIR)$(rpmbindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ rm -f $(DESTDIR)$(rpmbindir)/`echo $$p|sed '$(transform)'`; \
done done
.s.o: .s.o:
@ -411,10 +411,10 @@ uninstall-man8:
done done
install-man: $(MANS) install-man: $(MANS)
@$(NORMAL_INSTALL) @$(NORMAL_INSTALL)
$(MAKE) $(AM_MAKEFLAGS) install-man8 $(MAKE) install-man8
uninstall-man: uninstall-man:
@$(NORMAL_UNINSTALL) @$(NORMAL_UNINSTALL)
$(MAKE) $(AM_MAKEFLAGS) uninstall-man8 $(MAKE) uninstall-man8
install-configDATA: $(config_DATA) install-configDATA: $(config_DATA)
@$(NORMAL_INSTALL) @$(NORMAL_INSTALL)
@ -451,7 +451,7 @@ check-recursive installcheck-recursive info-recursive dvi-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \ list='$(SUBDIRS)'; for subdir in $$list; do \
target=`echo $@ | sed s/-recursive//`; \ target=`echo $@ | sed s/-recursive//`; \
echo "Making $$target in $$subdir"; \ echo "Making $$target in $$subdir"; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$target) \ (cd $$subdir && $(MAKE) $$target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done && test -z "$$fail" done && test -z "$$fail"
@ -464,12 +464,12 @@ maintainer-clean-recursive:
for subdir in $$rev; do \ for subdir in $$rev; do \
target=`echo $@ | sed s/-recursive//`; \ target=`echo $@ | sed s/-recursive//`; \
echo "Making $$target in $$subdir"; \ echo "Making $$target in $$subdir"; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$target) \ (cd $$subdir && $(MAKE) $$target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done && test -z "$$fail" done && test -z "$$fail"
tags-recursive: tags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \ list='$(SUBDIRS)'; for subdir in $$list; do \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ (cd $$subdir && $(MAKE) tags); \
done done
tags: TAGS tags: TAGS
@ -514,12 +514,12 @@ distcheck: dist
dc_install_base=`cd $(distdir)/=inst && pwd`; \ dc_install_base=`cd $(distdir)/=inst && pwd`; \
cd $(distdir)/=build \ cd $(distdir)/=build \
&& ../configure --with-included-gettext --srcdir=.. --prefix=$$dc_install_base \ && ../configure --with-included-gettext --srcdir=.. --prefix=$$dc_install_base \
&& $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) dvi \
&& $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) check \
&& $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) install \
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) installcheck \
&& $(MAKE) $(AM_MAKEFLAGS) dist && $(MAKE) dist
-rm -rf $(distdir) -rm -rf $(distdir)
@echo "========================"; \ @echo "========================"; \
echo "$(distdir).tar.gz is ready for distribution"; \ echo "$(distdir).tar.gz is ready for distribution"; \
@ -552,7 +552,7 @@ distdir: $(DISTFILES)
|| mkdir $(distdir)/$$subdir \ || mkdir $(distdir)/$$subdir \
|| exit 1; \ || exit 1; \
chmod 777 $(distdir)/$$subdir; \ chmod 777 $(distdir)/$$subdir; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$(distdir) distdir=../$(distdir)/$$subdir distdir) \ (cd $$subdir && $(MAKE) top_distdir=../$(distdir) distdir=../$(distdir)/$$subdir distdir) \
|| exit 1; \ || exit 1; \
done done
@ -582,10 +582,10 @@ maintainer-clean-depend:
info: info-recursive info: info-recursive
dvi: dvi-recursive dvi: dvi-recursive
check: all-am check: all-am
$(MAKE) $(AM_MAKEFLAGS) check-recursive $(MAKE) check-recursive
installcheck: installcheck-recursive installcheck: installcheck-recursive
all-recursive-am: config.h all-recursive-am: config.h
$(MAKE) $(AM_MAKEFLAGS) all-recursive $(MAKE) all-recursive
all-am: Makefile $(PROGRAMS) $(SCRIPTS) $(MANS) $(DATA) $(HEADERS) config.h all-am: Makefile $(PROGRAMS) $(SCRIPTS) $(MANS) $(DATA) $(HEADERS) config.h
@ -607,22 +607,27 @@ install: install-recursive install-exec-am install-data-am
uninstall: uninstall-recursive uninstall-am uninstall: uninstall-recursive uninstall-am
install-strip: install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install
installdirs: installdirs-recursive installdirs: installdirs-recursive
$(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(rpmbindir) \ $(mkinstalldirs) $(DATADIR)$(bindir) $(DATADIR)$(rpmbindir) \
$(DESTDIR)$(bindir) $(DESTDIR)$(configdir) \ $(DATADIR)$(bindir) $(DATADIR)$(configdir) \
$(DESTDIR)$(mandir)/man8 $(DESTDIR)$(configdir) $(DESTDIR)$(mandir)/man8 $(DATADIR)$(configdir)
mostlyclean-generic: mostlyclean-generic:
-test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
clean-generic: clean-generic:
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic: distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES) -rm -f Makefile $(DISTCLEANFILES)
-rm -f config.cache config.log stamp-h stamp-h[0-9]* -rm -f config.cache config.log stamp-h stamp-h[0-9]*
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic: maintainer-clean-generic:
-test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
-test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
mostlyclean-am: mostlyclean-hdr mostlyclean-binPROGRAMS \ mostlyclean-am: mostlyclean-hdr mostlyclean-binPROGRAMS \
mostlyclean-noinstPROGRAMS mostlyclean-rpmbinPROGRAMS \ mostlyclean-noinstPROGRAMS mostlyclean-rpmbinPROGRAMS \
mostlyclean-compile mostlyclean-tags mostlyclean-depend \ mostlyclean-compile mostlyclean-tags mostlyclean-depend \

View File

@ -1,4 +1,4 @@
# Makefile.in generated automatically by automake 1.3b from Makefile.am # Makefile.in generated automatically by automake 1.3 from Makefile.am
# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. # Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation # This Makefile.in is free software; the Free Software Foundation
@ -34,7 +34,7 @@ mandir = @mandir@
includedir = @includedir@ includedir = @includedir@
oldincludedir = /usr/include oldincludedir = /usr/include
DESTDIR = DISTDIR =
pkgdatadir = $(datadir)/@PACKAGE@ pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@
@ -151,8 +151,8 @@ names.o pack.o parseBuildInstallClean.o parseChangelog.o \
parseDescription.o parseFiles.o parsePreamble.o parsePrep.o parseReqs.o \ parseDescription.o parseFiles.o parsePreamble.o parsePrep.o parseReqs.o \
parseScript.o parseSpec.o reqprov.o spec.o parseScript.o parseSpec.o reqprov.o spec.o
CFLAGS = @CFLAGS@ CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
LINK = $(CC) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ LINK = $(CC) $(CFLAGS) $(LDFLAGS) -o $@
HEADERS = $(noinst_HEADERS) $(rpminc_HEADERS) HEADERS = $(noinst_HEADERS) $(rpminc_HEADERS)
DIST_COMMON = Makefile.am Makefile.in TODO DIST_COMMON = Makefile.am Makefile.in TODO
@ -160,7 +160,7 @@ DIST_COMMON = Makefile.am Makefile.in TODO
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = gtar TAR = tar
GZIP = --best GZIP = --best
DEP_FILES = .deps/build.P .deps/expression.P .deps/files.P .deps/misc.P \ DEP_FILES = .deps/build.P .deps/expression.P .deps/files.P .deps/misc.P \
.deps/myftw.P .deps/names.P .deps/pack.P .deps/parseBuildInstallClean.P \ .deps/myftw.P .deps/names.P .deps/pack.P .deps/parseBuildInstallClean.P \
@ -194,7 +194,7 @@ maintainer-clean-libLIBRARIES:
install-libLIBRARIES: $(lib_LIBRARIES) install-libLIBRARIES: $(lib_LIBRARIES)
@$(NORMAL_INSTALL) @$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(libdir) $(mkinstalldirs) $(DESTDIR)$(libdir)
@list='$(lib_LIBRARIES)'; for p in $$list; do \ list='$(lib_LIBRARIES)'; for p in $$list; do \
if test -f $$p; then \ if test -f $$p; then \
echo " $(INSTALL_DATA) $$p $(DESTDIR)$(libdir)/$$p"; \ echo " $(INSTALL_DATA) $$p $(DESTDIR)$(libdir)/$$p"; \
$(INSTALL_DATA) $$p $(DESTDIR)$(libdir)/$$p; \ $(INSTALL_DATA) $$p $(DESTDIR)$(libdir)/$$p; \
@ -318,6 +318,7 @@ maintainer-clean-depend:
info: info:
dvi: dvi:
check: all check: all
$(MAKE)
installcheck: installcheck:
install-exec: install-libLIBRARIES install-exec: install-libLIBRARIES
@$(NORMAL_INSTALL) @$(NORMAL_INSTALL)
@ -331,20 +332,25 @@ install: install-exec install-data all
uninstall: uninstall-libLIBRARIES uninstall-rpmincHEADERS uninstall: uninstall-libLIBRARIES uninstall-rpmincHEADERS
install-strip: install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install
installdirs: installdirs:
$(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(rpmincdir) $(mkinstalldirs) $(DATADIR)$(libdir) $(DATADIR)$(rpmincdir)
mostlyclean-generic: mostlyclean-generic:
-test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
clean-generic: clean-generic:
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic: distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES) -rm -f Makefile $(DISTCLEANFILES)
-rm -f config.cache config.log stamp-h stamp-h[0-9]* -rm -f config.cache config.log stamp-h stamp-h[0-9]*
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic: maintainer-clean-generic:
-test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
-test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
mostlyclean: mostlyclean-libLIBRARIES mostlyclean-compile \ mostlyclean: mostlyclean-libLIBRARIES mostlyclean-compile \
mostlyclean-tags mostlyclean-depend mostlyclean-generic mostlyclean-tags mostlyclean-depend mostlyclean-generic

313
install.c
View File

@ -6,12 +6,15 @@
#include "url.h" #include "url.h"
#include "ftp.h" #include "ftp.h"
static int hashesPrinted = 0;
static void printHash(const unsigned long amount, const unsigned long total); static void printHash(const unsigned long amount, const unsigned long total);
static void printPercent(const unsigned long amount, const unsigned long total);
static void printDepProblems(FILE * f, struct rpmDependencyConflict * conflicts, static void printDepProblems(FILE * f, struct rpmDependencyConflict * conflicts,
int numConflicts); int numConflicts);
static void showProgress(const Header h, const rpmNotifyType what,
const unsigned long amount,
const unsigned long total,
void * data);
static int hashesPrinted = 0;
static void printHash(const unsigned long amount, const unsigned long total) { static void printHash(const unsigned long amount, const unsigned long total) {
int hashesNeeded; int hashesNeeded;
@ -30,118 +33,70 @@ static void printHash(const unsigned long amount, const unsigned long total) {
} }
} }
static void printPercent(const unsigned long amount, const unsigned long total) static void showProgress(const Header h, const rpmNotifyType what,
{ const unsigned long amount,
fprintf(stdout, "%%%% %f\n", (total const unsigned long total,
? ((float) ((((float) amount) / total) * 100)) void * data) {
: 100.0)); char * s;
fflush(stdout); int flags = (int) data;
}
static int installPackages(char * rootdir, char ** packages,
int numPackages, int installFlags,
int interfaceFlags, rpmdb db,
struct rpmRelocation * relocations) {
FD_t fd;
int i;
int numFailed = 0;
char ** filename;
char * printFormat = NULL;
char * chptr;
int rc;
rpmNotifyFunction fn;
if (interfaceFlags & INSTALL_PERCENT)
fn = printPercent;
else if (interfaceFlags & INSTALL_HASH)
fn = printHash;
else
fn = NULL;
for (i = 0, filename = packages; i < numPackages; i++, filename++) {
if (!*filename) continue;
switch (what) {
case RPMNOTIFY_INST_START:
hashesPrinted = 0; hashesPrinted = 0;
if (flags & INSTALL_LABEL) {
fd = fdOpen(*filename, O_RDONLY, 0); s = headerSprintf(h, "%s-%s-%s", rpmTagTable, rpmHeaderFormats,
if (fdFileno(fd) < 0) { NULL);
rpmMessage(RPMMESS_ERROR, _("cannot open file %s\n"), *filename); printf("%-28s", s);
numFailed++; free(s);
*filename = NULL;
continue;
}
if (interfaceFlags & INSTALL_PERCENT)
printFormat = "%%f %s:%s:%s\n";
else if (rpmIsVerbose() && (interfaceFlags & INSTALL_HASH)) {
chptr = strrchr(*filename, '/');
if (!chptr)
chptr = *filename;
else
chptr++;
printFormat = "%-28s";
} else if (rpmIsVerbose())
fprintf(stdout, _("Installing %s\n"), *filename);
if (db != NULL) {
rc = rpmInstallPackage(rootdir, db, fd, relocations, installFlags,
fn, printFormat);
} else {
if (installFlags &= RPMINSTALL_TEST) {
rpmMessage(RPMMESS_DEBUG, _("stopping source install as we're "
"just testing\n"));
rc = 0;
} else {
rc = rpmInstallSourcePackage(rootdir, fd, NULL, fn,
printFormat, NULL);
}
}
if (rc == 1) {
rpmMessage(RPMMESS_ERROR,
_("%s does not appear to be a RPM package\n"),
*filename);
}
if (rc) {
rpmMessage(RPMMESS_ERROR, _("%s cannot be installed\n"), *filename);
numFailed++;
} }
break;
fdClose(fd); case RPMNOTIFY_INST_PROGRESS:
if (flags & INSTALL_PERCENT) {
fprintf(stdout, "%%%% %f\n", (total
? ((float) ((((float) amount) / total) * 100))
: 100.0));
} else if (flags & INSTALL_PERCENT) {
printHash(amount, total);
}
break;
} }
}
return numFailed;
}
int doInstall(char * rootdir, char ** argv, int installFlags, int doInstall(char * rootdir, char ** argv, int installFlags,
int interfaceFlags, struct rpmRelocation * relocations) { int interfaceFlags, int probFilter,
rpmdb db; rpmRelocation * relocations) {
rpmdb db = NULL;
FD_t fd; FD_t fd;
int i; int i;
int mode, rc; int mode, rc, major;
char ** packages, ** tmpPackages; char ** packages, ** tmpPackages;
char ** filename; char ** filename;
int numPackages; int numPackages;
int numTmpPackages = 0, numBinaryPackages = 0, numSourcePackages = 0; int numTmpPackages = 0, numBinaryPackages = 0, numSourcePackages = 0;
int numFailed = 0; int numFailed = 0;
Header * binaryHeaders; Header h;
int isSource; int isSource;
int tmpnum = 0; int tmpnum = 0;
rpmDependencies rpmdep; rpmTransactionSet rpmdep;
struct rpmDependencyConflict * conflicts; struct rpmDependencyConflict * conflicts;
int numConflicts; int numConflicts;
int stopInstall = 0; int stopInstall = 0;
size_t nb; size_t nb;
const char *tmppath = rpmGetVar(RPMVAR_TMPPATH); const char *tmppath = rpmGetVar(RPMVAR_TMPPATH);
const char *myroot; const char *myroot;
int notifyFlags = interfaceFlags | (rpmIsVerbose ? INSTALL_HASH : 0 );
int transFlags = 0;
rpmProblemSet probs, finalProbs;
if (installFlags & RPMINSTALL_TEST) if (installFlags & RPMINSTALL_TEST)
mode = O_RDONLY; mode = O_RDONLY;
else else
mode = O_RDWR | O_CREAT; mode = O_RDWR | O_CREAT;
if (installFlags & RPMINSTALL_TEST)
transFlags |= RPMTRANS_FLAG_TEST;
rpmMessage(RPMMESS_DEBUG, _("counting packages to install\n")); rpmMessage(RPMMESS_DEBUG, _("counting packages to install\n"));
for (filename = argv, numPackages = 0; *filename; filename++, numPackages++) for (filename = argv, numPackages = 0; *filename; filename++, numPackages++)
; ;
@ -154,8 +109,6 @@ int doInstall(char * rootdir, char ** argv, int installFlags,
tmpPackages = alloca(nb); tmpPackages = alloca(nb);
memset(tmpPackages, 0, nb); memset(tmpPackages, 0, nb);
nb = (numPackages + 1) * sizeof(Header); nb = (numPackages + 1) * sizeof(Header);
binaryHeaders = alloca(nb);
memset(binaryHeaders, 0, nb);
myroot = rootdir; myroot = rootdir;
if (myroot[0] == '/' && myroot[1] == '\0' && tmppath[0] == '/') if (myroot[0] == '/' && myroot[1] == '\0' && tmppath[0] == '/')
@ -201,8 +154,19 @@ int doInstall(char * rootdir, char ** argv, int installFlags,
rpmMessage(RPMMESS_DEBUG, _("retrieved %d packages\n"), numTmpPackages); rpmMessage(RPMMESS_DEBUG, _("retrieved %d packages\n"), numTmpPackages);
rpmMessage(RPMMESS_DEBUG, _("finding source and binary packages\n")); /* Build up the transaction set. As a special case, v1 source packages
for (filename = packages, i = 0; *filename; filename++, i++) { are installed right here, only because they don't have headers and
would create all sorts of confusion later. */
rpmMessage(RPMMESS_DEBUG, _("opening database mode: 0%o\n"), mode);
if (rpmdbOpen(rootdir, &db, mode, 0644)) {
fprintf(stderr, _("error: cannot open %s%s/packages.rpm\n"),
rootdir, rpmGetVar(RPMVAR_DBPATH));
exit(EXIT_FAILURE);
}
rpmdep = rpmtransCreateSet(db, rootdir);
for (filename = packages; *filename; filename++) {
fd = fdOpen(*filename, O_RDONLY, 0); fd = fdOpen(*filename, O_RDONLY, 0);
if (fdFileno(fd) < 0) { if (fdFileno(fd) < 0) {
rpmMessage(RPMMESS_ERROR, _("cannot open file %s\n"), *filename); rpmMessage(RPMMESS_ERROR, _("cannot open file %s\n"), *filename);
@ -211,93 +175,87 @@ int doInstall(char * rootdir, char ** argv, int installFlags,
continue; continue;
} }
rc = rpmReadPackageHeader(fd, &binaryHeaders[numBinaryPackages], rc = rpmReadPackageHeader(fd, &h, &isSource, &major, NULL);
&isSource, NULL, NULL);
fdClose(fd);
if (rc == 1) { if (rc == 1) {
rpmMessage(RPMMESS_ERROR, fdClose(fd);
_("%s does not appear to be a RPM package\n"), fprintf(stderr,
*filename); _("error: %s does not appear to be a RPM package\n"),
} *filename);
} else if (rc) {
if (rc) { fprintf(stderr, _("error: %s cannot be installed\n"), *filename);
rpmMessage(RPMMESS_ERROR, _("%s cannot be installed\n"), *filename);
numFailed++; numFailed++;
packages[i] = NULL; packages[i] = NULL;
} else if (isSource) { } else if (isSource && major == 1) {
/* the header will be NULL if this is a v1 source package */ printf("XXX FIXME I can't install v1 source packages!!!\n");
if (binaryHeaders[numBinaryPackages] != NULL)
headerFree(binaryHeaders[numBinaryPackages]);
numSourcePackages++;
} else { } else {
numBinaryPackages++; rpmtransAddPackage(rpmdep, h, fd,
packages[i],
(interfaceFlags & INSTALL_UPGRADE) != 0,
relocations);
} }
} }
rpmMessage(RPMMESS_DEBUG, _("found %d source and %d binary packages\n"), rpmMessage(RPMMESS_DEBUG, _("found %d source and %d binary packages\n"),
numSourcePackages, numBinaryPackages); numSourcePackages, numBinaryPackages);
if (numBinaryPackages) { if (!(interfaceFlags & INSTALL_NODEPS)) {
rpmMessage(RPMMESS_DEBUG, _("opening database mode: 0%o\n"), mode); if (rpmdepCheck(rpmdep, &conflicts, &numConflicts)) {
if (rpmdbOpen(rootdir, &db, mode, 0644)) { numFailed = numPackages;
rpmMessage(RPMMESS_ERROR, _("cannot open %s%s/packages.rpm\n"), stopInstall = 1;
rootdir, rpmGetVar(RPMVAR_DBPATH));
exit(EXIT_FAILURE);
} }
rpmdep = rpmdepDependencies(db); if (!stopInstall && conflicts) {
for (i = 0; i < numBinaryPackages; i++) rpmMessage(RPMMESS_ERROR, _("failed dependencies:\n"));
if (installFlags & RPMINSTALL_UPGRADE) printDepProblems(stderr, conflicts, numConflicts);
rpmdepUpgradePackage(rpmdep, binaryHeaders[i], rpmdepFreeConflicts(conflicts, numConflicts);
packages[i]); numFailed = numPackages;
else stopInstall = 1;
rpmdepAddPackage(rpmdep, binaryHeaders[i], }
packages[i]); }
if (!(interfaceFlags & INSTALL_NODEPS)) { if (!(interfaceFlags & INSTALL_NOORDER)) {
if (rpmdepCheck(rpmdep, &conflicts, &numConflicts)) { if (rpmdepOrder(rpmdep, (void ***) &packages)) {
numFailed = numPackages; numFailed = numPackages;
stopInstall = 1; stopInstall = 1;
}
if (!stopInstall && conflicts) {
rpmMessage(RPMMESS_ERROR, _("failed dependencies:\n"));
printDepProblems(stderr, conflicts, numConflicts);
rpmdepFreeConflicts(conflicts, numConflicts);
numFailed = numPackages;
stopInstall = 1;
}
} }
if (!(interfaceFlags & INSTALL_NOORDER)) {
if (rpmdepOrder(rpmdep, (void ***) &packages)) {
numFailed = numPackages;
stopInstall = 1;
}
}
rpmdepDone(rpmdep);
} }
else
db = NULL;
if (!stopInstall) { if (!stopInstall) {
rpmMessage(RPMMESS_DEBUG, _("installing binary packages\n")); rpmMessage(RPMMESS_DEBUG, _("installing binary packages\n"));
numFailed += installPackages(rootdir, packages, numPackages, rc = rpmRunTransactions(rpmdep, showProgress, (void *) notifyFlags,
installFlags, interfaceFlags, db, NULL, &probs, transFlags);
relocations); if (rc < 0) {
numFailed += numPackages;
} else if (rc) {
rpmProblemSetFilter(probs, probFilter);
rc = rpmRunTransactions(rpmdep, showProgress, (void *) notifyFlags,
probs, &finalProbs, transFlags);
rpmProblemSetFree(probs);
if (rc < 0) {
numFailed += numPackages;
} else if (rc) {
numFailed += rc;
for (i = 0; i < finalProbs->numProblems; i++)
if (!finalProbs->probs[i].ignoreProblem)
fprintf(stderr, "error: %s\n",
rpmProblemString(finalProbs->probs[i]));
rpmProblemSetFree(finalProbs);
}
}
} }
rpmtransFree(rpmdep);
for (i = 0; i < numTmpPackages; i++) { for (i = 0; i < numTmpPackages; i++) {
unlink(tmpPackages[i]); unlink(tmpPackages[i]);
free(tmpPackages[i]); free(tmpPackages[i]);
} }
for (i = 0; i < numBinaryPackages; i++) /* FIXME how do we close our various fd's? */
headerFree(binaryHeaders[i]);
if (db != NULL) rpmdbClose(db); if (db != NULL) rpmdbClose(db);
@ -312,21 +270,18 @@ int doUninstall(char * rootdir, char ** argv, int uninstallFlags,
int mode; int mode;
int rc; int rc;
int count; int count;
int numPackages, packageOffsetsAlloced;
int * packageOffsets;
char ** arg; char ** arg;
int numFailed = 0; int numFailed = 0;
rpmDependencies rpmdep; rpmTransactionSet rpmdep;
struct rpmDependencyConflict * conflicts; struct rpmDependencyConflict * conflicts;
int numConflicts; int numConflicts;
int stopUninstall = 0; int stopUninstall = 0;
int transFlags = 0;
int numPackages = 0;
rpmProblemSet probs;
rpmMessage(RPMMESS_DEBUG, _("counting packages to uninstall\n")); if (uninstallFlags & RPMUNINSTALL_TEST)
for (arg = argv, numPackages = 0; *arg; arg++, numPackages++) transFlags |= RPMTRANS_FLAG_TEST;
;
packageOffsetsAlloced = numPackages;
packageOffsets = malloc(sizeof(int *) * packageOffsetsAlloced);
if (uninstallFlags & RPMUNINSTALL_TEST) if (uninstallFlags & RPMUNINSTALL_TEST)
mode = O_RDONLY; mode = O_RDONLY;
@ -340,7 +295,7 @@ int doUninstall(char * rootdir, char ** argv, int uninstallFlags,
} }
j = 0; j = 0;
numPackages = 0; rpmdep = rpmtransCreateSet(db, rootdir);
for (arg = argv; *arg; arg++) { for (arg = argv; *arg; arg++) {
rc = rpmdbFindByLabel(db, *arg, &matches); rc = rpmdbFindByLabel(db, *arg, &matches);
if (rc == 1) { if (rc == 1) {
@ -360,16 +315,11 @@ int doUninstall(char * rootdir, char ** argv, int uninstallFlags,
numFailed++; numFailed++;
} }
else { else {
numPackages += count;
if (numPackages > packageOffsetsAlloced) {
packageOffsetsAlloced = numPackages + 5;
packageOffsets = realloc(packageOffsets,
sizeof(int *) * packageOffsetsAlloced);
}
for (i = 0; i < dbiIndexSetCount(matches); i++) { for (i = 0; i < dbiIndexSetCount(matches); i++) {
unsigned int recOffset = dbiIndexRecordOffset(matches, i); unsigned int recOffset = dbiIndexRecordOffset(matches, i);
if (recOffset) { if (recOffset) {
packageOffsets[j++] = recOffset; rpmtransRemovePackage(rpmdep, recOffset);
numPackages++;
} }
} }
} }
@ -378,20 +328,12 @@ int doUninstall(char * rootdir, char ** argv, int uninstallFlags,
} }
} }
rpmMessage(RPMMESS_DEBUG, _("found %d packages to uninstall\n"), numPackages);
if (!(interfaceFlags & UNINSTALL_NODEPS)) { if (!(interfaceFlags & UNINSTALL_NODEPS)) {
rpmdep = rpmdepDependencies(db);
for (i = 0; i < numPackages; i++)
rpmdepRemovePackage(rpmdep, packageOffsets[i]);
if (rpmdepCheck(rpmdep, &conflicts, &numConflicts)) { if (rpmdepCheck(rpmdep, &conflicts, &numConflicts)) {
numFailed = numPackages; numFailed = numPackages;
stopUninstall = 1; stopUninstall = 1;
} }
rpmdepDone(rpmdep);
if (!stopUninstall && conflicts) { if (!stopUninstall && conflicts) {
rpmMessage(RPMMESS_ERROR, _("removing these packages would break " rpmMessage(RPMMESS_ERROR, _("removing these packages would break "
"dependencies:\n")); "dependencies:\n"));
@ -403,19 +345,13 @@ int doUninstall(char * rootdir, char ** argv, int uninstallFlags,
} }
if (!stopUninstall) { if (!stopUninstall) {
for (i = 0; i < numPackages; i++) { numFailed += rpmRunTransactions(rpmdep, NULL, NULL, NULL, &probs,
rpmMessage(RPMMESS_DEBUG, _("uninstalling record number %d\n"), transFlags);
packageOffsets[i]);
if (rpmRemovePackage(rootdir, db, packageOffsets[i],
uninstallFlags))
numFailed++;
}
} }
rpmtransFree(rpmdep);
rpmdbClose(db); rpmdbClose(db);
free(packageOffsets);
return numFailed; return numFailed;
} }
@ -433,7 +369,8 @@ int doSourceInstall(char * rootdir, char * arg, char ** specFile,
if (rpmIsVerbose()) if (rpmIsVerbose())
fprintf(stdout, _("Installing %s\n"), arg); fprintf(stdout, _("Installing %s\n"), arg);
rc = rpmInstallSourcePackage(rootdir, fd, specFile, NULL, NULL, cookie); rc = rpmInstallSourcePackage(rootdir, fd, specFile, NULL, NULL, NULL,
cookie);
if (rc == 1) { if (rc == 1) {
rpmMessage(RPMMESS_ERROR, _("%s cannot be installed\n"), arg); rpmMessage(RPMMESS_ERROR, _("%s cannot be installed\n"), arg);
if (specFile) FREE(*specFile); if (specFile) FREE(*specFile);

View File

@ -7,12 +7,14 @@
#define INSTALL_HASH (1 << 1) #define INSTALL_HASH (1 << 1)
#define INSTALL_NODEPS (1 << 2) #define INSTALL_NODEPS (1 << 2)
#define INSTALL_NOORDER (1 << 3) #define INSTALL_NOORDER (1 << 3)
#define INSTALL_LABEL (1 << 4) /* set if we're being verbose */
#define INSTALL_UPGRADE (1 << 5)
#define UNINSTALL_NODEPS (1 << 0) #define UNINSTALL_NODEPS (1 << 0)
#define UNINSTALL_ALLMATCHES (1 << 1) #define UNINSTALL_ALLMATCHES (1 << 1)
int doInstall(char * rootdir, char ** argv, int installFlags, int doInstall(char * rootdir, char ** argv, int installFlags,
int interfaceFlags, struct rpmRelocation * relocations); int interfaceFlags, int probFilter, rpmRelocation * relocations);
int doSourceInstall(char * prefix, char * arg, char ** specFile, int doSourceInstall(char * prefix, char * arg, char ** specFile,
char ** cookie); char ** cookie);
int doUninstall(char * rootdir, char ** argv, int uninstallFlags, int doUninstall(char * rootdir, char ** argv, int uninstallFlags,

View File

@ -20,7 +20,7 @@ librpm_a_SOURCES = \
messages.c misc.c oldheader.c package.c query.c \ messages.c misc.c oldheader.c package.c query.c \
rebuilddb.c rpmdb.c rpmerr.c rpmio.c rpmlead.c \ rebuilddb.c rpmdb.c rpmerr.c rpmio.c rpmlead.c \
rpmrc.c signature.c stringbuf.c tagtable.c \ rpmrc.c signature.c stringbuf.c tagtable.c \
tread.c uninstall.c verify.c tread.c uninstall.c verify.c transaction.c problems.c
include ../Makefile.inc include ../Makefile.inc

View File

@ -1,4 +1,4 @@
# Makefile.in generated automatically by automake 1.3b from Makefile.am # Makefile.in generated automatically by automake 1.3 from Makefile.am
# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. # Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation # This Makefile.in is free software; the Free Software Foundation
@ -34,7 +34,7 @@ mandir = @mandir@
includedir = @includedir@ includedir = @includedir@
oldincludedir = /usr/include oldincludedir = /usr/include
DESTDIR = DISTDIR =
pkgdatadir = $(datadir)/@PACKAGE@ pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@
@ -142,7 +142,7 @@ librpm_a_SOURCES = \
messages.c misc.c oldheader.c package.c query.c \ messages.c misc.c oldheader.c package.c query.c \
rebuilddb.c rpmdb.c rpmerr.c rpmio.c rpmlead.c \ rebuilddb.c rpmdb.c rpmerr.c rpmio.c rpmlead.c \
rpmrc.c signature.c stringbuf.c tagtable.c \ rpmrc.c signature.c stringbuf.c tagtable.c \
tread.c uninstall.c verify.c tread.c uninstall.c verify.c transaction.c problems.c
BUILT_SOURCES = tagtable.c BUILT_SOURCES = tagtable.c
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@ -159,10 +159,10 @@ librpm_a_OBJECTS = cpio.o dbindex.o depends.o falloc.o formats.o fs.o \
header.o install.o lookup.o macro.o md5.o md5sum.o messages.o misc.o \ header.o install.o lookup.o macro.o md5.o md5sum.o messages.o misc.o \
oldheader.o package.o query.o rebuilddb.o rpmdb.o rpmerr.o rpmio.o \ oldheader.o package.o query.o rebuilddb.o rpmdb.o rpmerr.o rpmio.o \
rpmlead.o rpmrc.o signature.o stringbuf.o tagtable.o tread.o \ rpmlead.o rpmrc.o signature.o stringbuf.o tagtable.o tread.o \
uninstall.o verify.o uninstall.o verify.o transaction.o problems.o
CFLAGS = @CFLAGS@ CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
LINK = $(CC) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ LINK = $(CC) $(CFLAGS) $(LDFLAGS) -o $@
HEADERS = $(noinst_HEADERS) $(rpminc_HEADERS) HEADERS = $(noinst_HEADERS) $(rpminc_HEADERS)
DIST_COMMON = Makefile.am Makefile.in DIST_COMMON = Makefile.am Makefile.in
@ -170,16 +170,16 @@ DIST_COMMON = Makefile.am Makefile.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = gtar TAR = tar
GZIP = --best GZIP = --best
DEP_FILES = .deps/cpio.P .deps/dbindex.P .deps/depends.P .deps/falloc.P \ DEP_FILES = .deps/cpio.P .deps/dbindex.P .deps/depends.P .deps/falloc.P \
.deps/formats.P .deps/fs.P .deps/header.P .deps/install.P \ .deps/formats.P .deps/fs.P .deps/header.P .deps/install.P \
.deps/lookup.P .deps/macro.P .deps/md5.P .deps/md5sum.P \ .deps/lookup.P .deps/macro.P .deps/md5.P .deps/md5sum.P \
.deps/messages.P .deps/misc.P .deps/oldheader.P .deps/package.P \ .deps/messages.P .deps/misc.P .deps/oldheader.P .deps/package.P \
.deps/query.P .deps/rebuilddb.P .deps/rpmdb.P .deps/rpmerr.P \ .deps/problems.P .deps/query.P .deps/rebuilddb.P .deps/rpmdb.P \
.deps/rpmio.P .deps/rpmlead.P .deps/rpmrc.P .deps/signature.P \ .deps/rpmerr.P .deps/rpmio.P .deps/rpmlead.P .deps/rpmrc.P \
.deps/stringbuf.P .deps/tagtable .deps/tagtable.P .deps/tread.P \ .deps/signature.P .deps/stringbuf.P .deps/tagtable .deps/tagtable.P \
.deps/uninstall.P .deps/verify.P .deps/transaction.P .deps/tread.P .deps/uninstall.P .deps/verify.P
SOURCES = $(librpm_a_SOURCES) SOURCES = $(librpm_a_SOURCES)
OBJECTS = $(librpm_a_OBJECTS) OBJECTS = $(librpm_a_OBJECTS)
@ -207,7 +207,7 @@ maintainer-clean-libLIBRARIES:
install-libLIBRARIES: $(lib_LIBRARIES) install-libLIBRARIES: $(lib_LIBRARIES)
@$(NORMAL_INSTALL) @$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(libdir) $(mkinstalldirs) $(DESTDIR)$(libdir)
@list='$(lib_LIBRARIES)'; for p in $$list; do \ list='$(lib_LIBRARIES)'; for p in $$list; do \
if test -f $$p; then \ if test -f $$p; then \
echo " $(INSTALL_DATA) $$p $(DESTDIR)$(libdir)/$$p"; \ echo " $(INSTALL_DATA) $$p $(DESTDIR)$(libdir)/$$p"; \
$(INSTALL_DATA) $$p $(DESTDIR)$(libdir)/$$p; \ $(INSTALL_DATA) $$p $(DESTDIR)$(libdir)/$$p; \
@ -331,6 +331,7 @@ maintainer-clean-depend:
info: info:
dvi: dvi:
check: all check: all
$(MAKE)
installcheck: installcheck:
install-exec: install-libLIBRARIES install-exec: install-libLIBRARIES
@$(NORMAL_INSTALL) @$(NORMAL_INSTALL)
@ -344,20 +345,24 @@ install: install-exec install-data all
uninstall: uninstall-libLIBRARIES uninstall-rpmincHEADERS uninstall: uninstall-libLIBRARIES uninstall-rpmincHEADERS
install-strip: install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install
installdirs: installdirs:
$(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(rpmincdir) $(mkinstalldirs) $(DATADIR)$(libdir) $(DATADIR)$(rpmincdir)
mostlyclean-generic: mostlyclean-generic:
-test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
clean-generic: clean-generic:
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic: distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES) -rm -f Makefile $(DISTCLEANFILES)
-rm -f config.cache config.log stamp-h stamp-h[0-9]* -rm -f config.cache config.log stamp-h stamp-h[0-9]*
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic: maintainer-clean-generic:
-test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
-test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
mostlyclean: mostlyclean-libLIBRARIES mostlyclean-compile \ mostlyclean: mostlyclean-libLIBRARIES mostlyclean-compile \
mostlyclean-tags mostlyclean-depend mostlyclean-generic mostlyclean-tags mostlyclean-depend mostlyclean-generic

View File

@ -5,72 +5,32 @@
#include "depends.h" #include "depends.h"
#include "misc.h" #include "misc.h"
struct availablePackage {
Header h;
char ** provides;
char ** files;
char * name, * version, * release;
int epoch, hasEpoch, providesCount, filesCount;
void * key;
} ;
enum indexEntryType { IET_NAME, IET_PROVIDES, IET_FILE };
struct availableIndexEntry {
struct availablePackage * package;
char * entry;
enum indexEntryType type;
} ;
struct availableIndex {
struct availableIndexEntry * index ;
int size;
} ;
struct availableList {
struct availablePackage * list;
struct availableIndex index;
int size, alloced;
};
struct rpmDependencyCheck {
rpmdb db; /* may be NULL */
int * removedPackages;
int numRemovedPackages, allocedRemovedPackages;
struct availableList addedPackages, availablePackages;
};
struct problemsSet {
struct rpmDependencyConflict * problems;
int num;
int alloced;
};
static void alMakeIndex(struct availableList * al); static void alMakeIndex(struct availableList * al);
static void alCreate(struct availableList * al); static void alCreate(struct availableList * al);
static void alFreeIndex(struct availableList * al); static void alFreeIndex(struct availableList * al);
static void alFree(struct availableList * al); static void alFree(struct availableList * al);
static void alAddPackage(struct availableList * al, Header h, void * key); static void alAddPackage(struct availableList * al, Header h, void * key,
FD_t fd, rpmRelocation * relocs);
static int intcmp(const void * a, const void *b); static int intcmp(const void * a, const void *b);
static int indexcmp(const void * a, const void *b); static int indexcmp(const void * a, const void *b);
static int unsatisfiedDepend(rpmDependencies rpmdep, char * reqName, static int unsatisfiedDepend(rpmTransactionSet rpmdep, char * reqName,
char * reqVersion, int reqFlags, char * reqVersion, int reqFlags,
struct availablePackage ** suggestion); struct availablePackage ** suggestion);
static int checkDependentPackages(rpmDependencies rpmdep, static int checkDependentPackages(rpmTransactionSet rpmdep,
struct problemsSet * psp, char * key); struct problemsSet * psp, char * key);
static int checkPackageDeps(rpmDependencies rpmdep, struct problemsSet * psp, static int checkPackageDeps(rpmTransactionSet rpmdep, struct problemsSet * psp,
Header h, const char * requirement); Header h, const char * requirement);
static int dbrecMatchesDepFlags(rpmDependencies rpmdep, int recOffset, static int dbrecMatchesDepFlags(rpmTransactionSet rpmdep, int recOffset,
char * reqVersion, int reqFlags); char * reqVersion, int reqFlags);
struct availablePackage * alSatisfiesDepend(struct availableList * al, struct availablePackage * alSatisfiesDepend(struct availableList * al,
char * reqName, char * reqVersion, char * reqName, char * reqVersion,
int reqFlags); int reqFlags);
static int checkDependentConflicts(rpmDependencies rpmdep, static int checkDependentConflicts(rpmTransactionSet rpmdep,
struct problemsSet * psp, char * package); struct problemsSet * psp, char * package);
static int checkPackageSet(rpmDependencies rpmdep, struct problemsSet * psp, static int checkPackageSet(rpmTransactionSet rpmdep, struct problemsSet * psp,
char * package, dbiIndexSet * matches); char * package, dbiIndexSet * matches);
static int addOrderedPack(rpmDependencies rpmdep, static int addOrderedPack(rpmTransactionSet rpmdep,
struct availablePackage * package, struct availablePackage * package,
void ** ordering, int * orderNumPtr, void ** ordering, int * orderNumPtr,
int * selected, int selectionClass, int * selected, int selectionClass,
@ -101,13 +61,15 @@ static void alFree(struct availableList * al) {
free(al->list[i].provides); free(al->list[i].provides);
if (al->list[i].files) if (al->list[i].files)
free(al->list[i].files); free(al->list[i].files);
free(al->list[i].h);
} }
if (al->alloced) free(al->list); if (al->alloced) free(al->list);
alFreeIndex(al); alFreeIndex(al);
} }
static void alAddPackage(struct availableList * al, Header h, void * key) { static void alAddPackage(struct availableList * al, Header h, void * key,
FD_t fd, rpmRelocation * relocs) {
struct availablePackage * p; struct availablePackage * p;
if (al->size == al->alloced) { if (al->size == al->alloced) {
@ -116,7 +78,7 @@ static void alAddPackage(struct availableList * al, Header h, void * key) {
} }
p = al->list + al->size++; p = al->list + al->size++;
p->h = h; p->h = headerLink(h);
headerGetEntry(p->h, RPMTAG_NAME, NULL, (void **) &p->name, NULL); headerGetEntry(p->h, RPMTAG_NAME, NULL, (void **) &p->name, NULL);
headerGetEntry(p->h, RPMTAG_VERSION, NULL, (void **) &p->version, NULL); headerGetEntry(p->h, RPMTAG_VERSION, NULL, (void **) &p->version, NULL);
@ -136,7 +98,17 @@ static void alAddPackage(struct availableList * al, Header h, void * key) {
p->files = NULL; p->files = NULL;
} }
/* We don't use these entries (and rpm >= 2 never have) and they are
pretty misleading. Let's just get rid of them so they don't confuse
anyone. */
if (headerIsEntry(h, RPMTAG_FILEUSERNAME))
headerRemoveEntry(h, RPMTAG_FILEUIDS);
if (headerIsEntry(h, RPMTAG_FILEGROUPNAME))
headerRemoveEntry(h, RPMTAG_FILEGIDS);
p->key = key; p->key = key;
p->relocs = relocs;
p->fd = fd;
alFreeIndex(al); alFreeIndex(al);
} }
@ -222,8 +194,8 @@ int intcmp(const void * a, const void *b) {
return 1; return 1;
} }
rpmDependencies rpmdepDependencies(rpmdb db) { rpmTransactionSet rpmtransCreateSet(rpmdb db, char * root) {
rpmDependencies rpmdep; rpmTransactionSet rpmdep;
rpmdep = malloc(sizeof(*rpmdep)); rpmdep = malloc(sizeof(*rpmdep));
rpmdep->db = db; rpmdep->db = db;
@ -231,6 +203,7 @@ rpmDependencies rpmdepDependencies(rpmdb db) {
rpmdep->allocedRemovedPackages = 5; rpmdep->allocedRemovedPackages = 5;
rpmdep->removedPackages = malloc(sizeof(int) * rpmdep->removedPackages = malloc(sizeof(int) *
rpmdep->allocedRemovedPackages); rpmdep->allocedRemovedPackages);
rpmdep->root = strdup(root);
alCreate(&rpmdep->addedPackages); alCreate(&rpmdep->addedPackages);
alCreate(&rpmdep->availablePackages); alCreate(&rpmdep->availablePackages);
@ -238,22 +211,28 @@ rpmDependencies rpmdepDependencies(rpmdb db) {
return rpmdep; return rpmdep;
} }
void rpmdepUpgradePackage(rpmDependencies rpmdep, Header h, void * key) { void rpmtransAddPackage(rpmTransactionSet rpmdep, Header h, FD_t fd,
void * key, int upgrade, rpmRelocation * relocs) {
/* this is an install followed by uninstalls */ /* this is an install followed by uninstalls */
dbiIndexSet matches; dbiIndexSet matches;
char * name; char * name;
int count, i, j; int count, i, j;
char ** obsoletes; char ** obsoletes;
alAddPackage(&rpmdep->addedPackages, h, key); /* FIXME: handling upgrades like this is *almost* okay. It doesn't
check to make sure we're upgrading to a newer version, and it
makes it difficult to generate a return code based on the number of
packages which failed. */
alAddPackage(&rpmdep->addedPackages, h, key, fd, relocs);
if (rpmdep->db == NULL) return; if (!upgrade || rpmdep->db == NULL) return;
headerGetEntry(h, RPMTAG_NAME, NULL, (void *) &name, &count); headerGetEntry(h, RPMTAG_NAME, NULL, (void *) &name, &count);
if (!rpmdbFindPackage(rpmdep->db, name, &matches)) { if (!rpmdbFindPackage(rpmdep->db, name, &matches)) {
for (i = 0; i < dbiIndexSetCount(matches); i++) { for (i = 0; i < dbiIndexSetCount(matches); i++) {
rpmdepRemovePackage(rpmdep, dbiIndexRecordOffset(matches, i)); rpmtransRemovePackage(rpmdep, dbiIndexRecordOffset(matches, i));
} }
dbiFreeIndexRecord(matches); dbiFreeIndexRecord(matches);
@ -264,7 +243,7 @@ void rpmdepUpgradePackage(rpmDependencies rpmdep, Header h, void * key) {
for (j = 0; j < count; j++) { for (j = 0; j < count; j++) {
if (!rpmdbFindPackage(rpmdep->db, obsoletes[j], &matches)) { if (!rpmdbFindPackage(rpmdep->db, obsoletes[j], &matches)) {
for (i = 0; i < dbiIndexSetCount(matches); i++) { for (i = 0; i < dbiIndexSetCount(matches); i++) {
rpmdepRemovePackage(rpmdep, dbiIndexRecordOffset(matches, i)); rpmtransRemovePackage(rpmdep, dbiIndexRecordOffset(matches, i));
} }
dbiFreeIndexRecord(matches); dbiFreeIndexRecord(matches);
@ -275,15 +254,11 @@ void rpmdepUpgradePackage(rpmDependencies rpmdep, Header h, void * key) {
} }
} }
void rpmdepAddPackage(rpmDependencies rpmdep, Header h, void * key) { void rpmtransAvailablePackage(rpmTransactionSet rpmdep, Header h, void * key) {
alAddPackage(&rpmdep->addedPackages, h, key); alAddPackage(&rpmdep->availablePackages, h, key, NULL, NULL);
} }
void rpmdepAvailablePackage(rpmDependencies rpmdep, Header h, void * key) { void rpmtransRemovePackage(rpmTransactionSet rpmdep, int dboffset) {
alAddPackage(&rpmdep->availablePackages, h, key);
}
void rpmdepRemovePackage(rpmDependencies rpmdep, int dboffset) {
if (rpmdep->numRemovedPackages == rpmdep->allocedRemovedPackages) { if (rpmdep->numRemovedPackages == rpmdep->allocedRemovedPackages) {
rpmdep->allocedRemovedPackages += 5; rpmdep->allocedRemovedPackages += 5;
rpmdep->removedPackages = realloc(rpmdep->removedPackages, rpmdep->removedPackages = realloc(rpmdep->removedPackages,
@ -293,10 +268,11 @@ void rpmdepRemovePackage(rpmDependencies rpmdep, int dboffset) {
rpmdep->removedPackages[rpmdep->numRemovedPackages++] = dboffset; rpmdep->removedPackages[rpmdep->numRemovedPackages++] = dboffset;
} }
void rpmdepDone(rpmDependencies rpmdep) { void rpmtransFree(rpmTransactionSet rpmdep) {
alFree(&rpmdep->addedPackages); alFree(&rpmdep->addedPackages);
alFree(&rpmdep->availablePackages); alFree(&rpmdep->availablePackages);
free(rpmdep->removedPackages); free(rpmdep->removedPackages);
free(rpmdep->root);
free(rpmdep); free(rpmdep);
} }
@ -317,7 +293,7 @@ void rpmdepFreeConflicts(struct rpmDependencyConflict * conflicts, int
free(conflicts); free(conflicts);
} }
int rpmdepCheck(rpmDependencies rpmdep, int rpmdepCheck(rpmTransactionSet rpmdep,
struct rpmDependencyConflict ** conflicts, int * numConflicts) { struct rpmDependencyConflict ** conflicts, int * numConflicts) {
struct availablePackage * p; struct availablePackage * p;
int i, j; int i, j;
@ -427,7 +403,7 @@ int rpmdepCheck(rpmDependencies rpmdep,
/* 2 == error */ /* 2 == error */
/* 1 == dependency not satisfied */ /* 1 == dependency not satisfied */
static int unsatisfiedDepend(rpmDependencies rpmdep, char * reqName, static int unsatisfiedDepend(rpmTransactionSet rpmdep, char * reqName,
char * reqVersion, int reqFlags, char * reqVersion, int reqFlags,
struct availablePackage ** suggestion) { struct availablePackage ** suggestion) {
dbiIndexSet matches; dbiIndexSet matches;
@ -515,7 +491,7 @@ static int unsatisfiedDepend(rpmDependencies rpmdep, char * reqName,
return 1; return 1;
} }
static int checkPackageSet(rpmDependencies rpmdep, struct problemsSet * psp, static int checkPackageSet(rpmTransactionSet rpmdep, struct problemsSet * psp,
char * package, dbiIndexSet * matches) { char * package, dbiIndexSet * matches) {
int i; int i;
Header h; Header h;
@ -545,7 +521,7 @@ static int checkPackageSet(rpmDependencies rpmdep, struct problemsSet * psp,
return 0; return 0;
} }
static int checkDependentPackages(rpmDependencies rpmdep, static int checkDependentPackages(rpmTransactionSet rpmdep,
struct problemsSet * psp, char * key) { struct problemsSet * psp, char * key) {
dbiIndexSet matches; dbiIndexSet matches;
int rc; int rc;
@ -560,7 +536,7 @@ static int checkDependentPackages(rpmDependencies rpmdep,
return rc; return rc;
} }
static int checkDependentConflicts(rpmDependencies rpmdep, static int checkDependentConflicts(rpmTransactionSet rpmdep,
struct problemsSet * psp, char * package) { struct problemsSet * psp, char * package) {
dbiIndexSet matches; dbiIndexSet matches;
int rc; int rc;
@ -576,7 +552,7 @@ static int checkDependentConflicts(rpmDependencies rpmdep,
return rc; return rc;
} }
static int checkPackageDeps(rpmDependencies rpmdep, struct problemsSet * psp, static int checkPackageDeps(rpmTransactionSet rpmdep, struct problemsSet * psp,
Header h, const char * requirement) { Header h, const char * requirement) {
char ** requires, ** requiresVersion; char ** requires, ** requiresVersion;
char * name, * version, * release; char * name, * version, * release;
@ -630,7 +606,7 @@ static int checkPackageDeps(rpmDependencies rpmdep, struct problemsSet * psp,
psp->problems = realloc(psp->problems, sizeof(*psp->problems) * psp->problems = realloc(psp->problems, sizeof(*psp->problems) *
psp->alloced); psp->alloced);
} }
psp->problems[psp->num].byHeader = headerCopy(h); psp->problems[psp->num].byHeader = headerLink(h);
psp->problems[psp->num].byName = strdup(name); psp->problems[psp->num].byName = strdup(name);
psp->problems[psp->num].byVersion = strdup(version); psp->problems[psp->num].byVersion = strdup(version);
psp->problems[psp->num].byRelease = strdup(release); psp->problems[psp->num].byRelease = strdup(release);
@ -673,7 +649,7 @@ static int checkPackageDeps(rpmDependencies rpmdep, struct problemsSet * psp,
psp->problems = realloc(psp->problems, sizeof(*psp->problems) * psp->problems = realloc(psp->problems, sizeof(*psp->problems) *
psp->alloced); psp->alloced);
} }
psp->problems[psp->num].byHeader = headerCopy(h); psp->problems[psp->num].byHeader = headerLink(h);
psp->problems[psp->num].byName = strdup(name); psp->problems[psp->num].byName = strdup(name);
psp->problems[psp->num].byVersion = strdup(version); psp->problems[psp->num].byVersion = strdup(version);
psp->problems[psp->num].byRelease = strdup(release); psp->problems[psp->num].byRelease = strdup(release);
@ -757,7 +733,7 @@ int headerMatchesDepFlags(Header h, char * reqInfo, int reqFlags) {
return result; return result;
} }
static int dbrecMatchesDepFlags(rpmDependencies rpmdep, int recOffset, static int dbrecMatchesDepFlags(rpmTransactionSet rpmdep, int recOffset,
char * reqVersion, int reqFlags) { char * reqVersion, int reqFlags) {
Header h; Header h;
int rc; int rc;
@ -784,7 +760,7 @@ static int dbrecMatchesDepFlags(rpmDependencies rpmdep, int recOffset,
the current selection pass is included as a separate parameter, and is the current selection pass is included as a separate parameter, and is
incremented when satisfying a prerequisite */ incremented when satisfying a prerequisite */
static int addOrderedPack(rpmDependencies rpmdep, static int addOrderedPack(rpmTransactionSet rpmdep,
struct availablePackage * package, struct availablePackage * package,
void ** ordering, int * orderNumPtr, void ** ordering, int * orderNumPtr,
int * selected, int selectionClass, int * selected, int selectionClass,
@ -873,7 +849,7 @@ static int addOrderedPack(rpmDependencies rpmdep,
return 0; return 0;
} }
int rpmdepOrder(rpmDependencies rpmdep, void *** keysListPtr) { int rpmdepOrder(rpmTransactionSet rpmdep, void *** keysListPtr) {
int i; int i;
int * selected; int * selected;
void ** order; void ** order;

View File

@ -5,4 +5,49 @@
int headerMatchesDepFlags(Header h, char * reqInfo, int reqFlags); int headerMatchesDepFlags(Header h, char * reqInfo, int reqFlags);
struct availablePackage {
Header h;
char ** provides;
char ** files;
char * name, * version, * release;
int epoch, hasEpoch, providesCount, filesCount;
void * key;
rpmRelocation * relocs;
FD_t fd;
} ;
enum indexEntryType { IET_NAME, IET_PROVIDES, IET_FILE };
struct availableIndexEntry {
struct availablePackage * package;
char * entry;
enum indexEntryType type;
} ;
struct availableIndex {
struct availableIndexEntry * index ;
int size;
} ;
struct availableList {
struct availablePackage * list;
struct availableIndex index;
int size, alloced;
};
struct rpmTransactionSet_s {
rpmdb db; /* may be NULL */
int * removedPackages;
int numRemovedPackages, allocedRemovedPackages;
struct availableList addedPackages, availablePackages;
char * root;
};
struct problemsSet {
struct rpmDependencyConflict * problems;
int num;
int alloced;
};
#endif /* H_DEPENDS */ #endif /* H_DEPENDS */

View File

@ -42,6 +42,7 @@ struct headerToken {
int sorted; int sorted;
int langNum; int langNum;
int usageCount;
}; };
struct entryInfo { struct entryInfo {
@ -817,6 +818,7 @@ Header headerNew()
h->sorted = 0; h->sorted = 0;
h->langNum = -1; h->langNum = -1;
h->usageCount = 1;
return (Header) h; return (Header) h;
} }
@ -825,6 +827,7 @@ void headerFree(Header h)
{ {
int i; int i;
if (--h->usageCount) return;
for (i = 0; i < h->indexUsed; i++) for (i = 0; i < h->indexUsed; i++)
free(h->index[i].data); free(h->index[i].data);
@ -832,6 +835,12 @@ void headerFree(Header h)
free(h); free(h);
} }
Header headerLink(Header h)
{
h->usageCount++;
return h;
}
unsigned int headerSizeof(Header h, int magicp) unsigned int headerSizeof(Header h, int magicp)
{ {
unsigned int size; unsigned int size;

View File

@ -160,6 +160,7 @@ void headerSetLangPath(Header h, char * lang);
Header headerCopy(Header h); Header headerCopy(Header h);
void headerSort(Header h); void headerSort(Header h);
Header headerLink(Header h);
void headerCopyTags(Header headerFrom, Header headerTo, int *tagstocopy); void headerCopyTags(Header headerFrom, Header headerTo, int *tagstocopy);

View File

@ -17,6 +17,8 @@ struct callbackInfo {
unsigned long archiveSize; unsigned long archiveSize;
rpmNotifyFunction notify; rpmNotifyFunction notify;
char ** specFilePtr; char ** specFilePtr;
Header h;
void * notifyData;
}; };
struct fileMemory { struct fileMemory {
@ -55,25 +57,20 @@ static enum instActions decideFileFate(char * filespec, short dbMode,
int instFlags, int brokenMd5); int instFlags, int brokenMd5);
static int installArchive(FD_t fd, struct fileInfo * files, static int installArchive(FD_t fd, struct fileInfo * files,
int fileCount, rpmNotifyFunction notify, int fileCount, rpmNotifyFunction notify,
void * notifydb, Header h,
char ** specFile, int archiveSize); char ** specFile, int archiveSize);
static int packageAlreadyInstalled(rpmdb db, char * name, char * version,
char * release, int * recOffset, int flags);
static int instHandleSharedFiles(rpmdb db, int ignoreOffset, static int instHandleSharedFiles(rpmdb db, int ignoreOffset,
struct fileInfo * files, struct fileInfo * files,
int fileCount, int * notErrors, int fileCount, int * notErrors,
struct replacedFile ** repListPtr, int flags); struct replacedFile ** repListPtr, int flags);
static int installSources(Header h, char * rootdir, FD_t fd, static int installSources(Header h, char * rootdir, FD_t fd,
char ** specFilePtr, rpmNotifyFunction notify, char ** specFilePtr, rpmNotifyFunction notify,
char * labelFormat); void * notifyData, char * labelFormat);
static int markReplacedFiles(rpmdb db, struct replacedFile * replList); static int markReplacedFiles(rpmdb db, struct replacedFile * replList);
static int archOkay(Header h);
static int osOkay(Header h);
static int ensureOlder(rpmdb db, Header new, int dbOffset); static int ensureOlder(rpmdb db, Header new, int dbOffset);
static int assembleFileList(Header h, struct fileMemory * mem, static int assembleFileList(Header h, struct fileMemory * mem,
int * fileCountPtr, struct fileInfo ** filesPtr, int * fileCountPtr, struct fileInfo ** filesPtr,
int stripPrefixLength, int stripPrefixLength);
struct rpmRelocation * rawRelocations,
int allowRandomRelocations);
static void setFileOwners(Header h, struct fileInfo * files, int fileCount); static void setFileOwners(Header h, struct fileInfo * files, int fileCount);
static void freeFileMemory(struct fileMemory fileMem); static void freeFileMemory(struct fileMemory fileMem);
static void trimChangelog(Header h); static void trimChangelog(Header h);
@ -82,8 +79,8 @@ static void trimChangelog(Header h);
/* 1 bad magic */ /* 1 bad magic */
/* 2 error */ /* 2 error */
int rpmInstallSourcePackage(char * rootdir, FD_t fd, char ** specFile, int rpmInstallSourcePackage(char * rootdir, FD_t fd, char ** specFile,
rpmNotifyFunction notify, char * labelFormat, rpmNotifyFunction notify, void * notifyData,
char ** cookie) { char * labelFormat, char ** cookie) {
int rc, isSource; int rc, isSource;
Header h; Header h;
int major, minor; int major, minor;
@ -110,7 +107,8 @@ int rpmInstallSourcePackage(char * rootdir, FD_t fd, char ** specFile,
} }
} }
rc = installSources(h, rootdir, fd, specFile, notify, labelFormat); rc = installSources(h, rootdir, fd, specFile, notify, notifyData,
labelFormat);
if (h != NULL) headerFree(h); if (h != NULL) headerFree(h);
return rc; return rc;
@ -127,167 +125,27 @@ static void freeFileMemory(struct fileMemory fileMem) {
/* files should not be preallocated */ /* files should not be preallocated */
static int assembleFileList(Header h, struct fileMemory * mem, static int assembleFileList(Header h, struct fileMemory * mem,
int * fileCountPtr, struct fileInfo ** filesPtr, int * fileCountPtr, struct fileInfo ** filesPtr,
int stripPrefixLength, int stripPrefixLength) {
struct rpmRelocation * rawRelocations,
int allowRandomRelocations) {
uint_32 * fileFlags; uint_32 * fileFlags;
uint_32 * fileSizes; uint_32 * fileSizes;
uint_16 * fileModes; uint_16 * fileModes;
struct fileInfo * files; struct fileInfo * files;
struct fileInfo * file; struct fileInfo * file;
int fileCount; int fileCount;
int i, j, numRelocations = 0, madeSwap, len, newLen; int i;
struct rpmRelocation * relocations = NULL;
struct rpmRelocation tmpReloc;
struct rpmRelocation * nextReloc;
char ** validRelocations = NULL, ** actualRelocations;
char ** fileLangs; char ** fileLangs;
char * newName, * chptr; char * chptr;
int rc;
int numValid;
char ** languages, ** lang; char ** languages, ** lang;
if (rawRelocations) { if (!headerGetEntry(h, RPMTAG_ORIGFILENAMES, NULL, (void **) &mem->names,
if (!headerGetEntry(h, RPMTAG_PREFIXES, NULL, fileCountPtr))
(void **) &validRelocations, &numValid)) { headerGetEntry(h, RPMTAG_FILENAMES, NULL, (void **) &mem->names,
numValid = 0; fileCountPtr);
}
for (i = 0; rawRelocations[i].newPath; i++) ;
numRelocations = i;
relocations = alloca(sizeof(*relocations) * numRelocations);
/* XXX this code assumes the validRelocations array won't
have trailing /'s in it */
for (i = 0; i < numRelocations; i++) {
if (!rawRelocations[i].oldPath) {
if (!numValid) {
rpmError(RPMERR_NORELOCATE,
_("package is not relocatable"));
return 1;
} else if (numValid != 1){
rpmError(RPMERR_NORELOCATE,
_("package has multiple relocatable components"));
return 1;
}
relocations[i].oldPath =
alloca(strlen(validRelocations[0]) + 1);
strcpy(relocations[i].oldPath, validRelocations[0]);
} else {
relocations[i].oldPath =
alloca(strlen(rawRelocations[i].oldPath) + 1);
strcpy(relocations[i].oldPath, rawRelocations[i].oldPath);
stripTrailingSlashes(relocations[i].oldPath);
}
relocations[i].newPath =
alloca(strlen(rawRelocations[i].newPath) + 1);
strcpy(relocations[i].newPath, rawRelocations[i].newPath);
stripTrailingSlashes(relocations[i].newPath);
if (!allowRandomRelocations) {
for (j = 0; j < numValid; j++)
if (!strcmp(validRelocations[j],
relocations[i].oldPath)) break;
if (j == numValid) {
rpmError(RPMERR_BADRELOCATE, _("path %s is not relocatable"),
relocations[i].oldPath);
return 1;
}
}
}
/* stupid bubble sort, but it's probably faster here */
for (i = 0; i < numRelocations; i++) {
madeSwap = 0;
for (j = 1; j < numRelocations; j++) {
if (strcmp(relocations[j - 1].oldPath,
relocations[j].oldPath) > 0) {
tmpReloc = relocations[j - 1];
relocations[j - 1] = relocations[j];
relocations[j] = tmpReloc;
madeSwap = 1;
}
}
if (!madeSwap) break;
}
if (validRelocations) free(validRelocations);
}
if (headerGetEntry(h, RPMTAG_PREFIXES, NULL,
(void **) &validRelocations, &numValid)) {
actualRelocations = malloc(sizeof(*actualRelocations) * numValid);
/* handle the special case of oldPath == NULL, which can only happen
when numValid == 1 (which we've tested for when we build the
relocation table above */
for (i = 0; i < numValid; i++) {
for (j = 0; j < numRelocations; j++) {
if (!strcmp(validRelocations[i], relocations[j].oldPath)) {
actualRelocations[i] = relocations[j].newPath;
break;
}
}
if (j == numRelocations)
actualRelocations[i] = validRelocations[i];
}
headerAddEntry(h, RPMTAG_INSTPREFIXES, RPM_STRING_ARRAY_TYPE,
(void **) actualRelocations, numValid);
free(validRelocations);
free(actualRelocations);
}
headerGetEntry(h, RPMTAG_FILENAMES, NULL, (void **) &mem->names,
fileCountPtr);
/* get this before we start mucking with this info */
headerGetEntry(h, RPMTAG_FILENAMES, NULL, (void **) &mem->cpioNames, headerGetEntry(h, RPMTAG_FILENAMES, NULL, (void **) &mem->cpioNames,
fileCountPtr); fileCountPtr);
fileCount = *fileCountPtr; fileCount = *fileCountPtr;
if (relocations) {
/* go through things backwards so that /usr/local relocations take
precedence over /usr ones */
nextReloc = relocations + numRelocations - 1;
len = strlen(nextReloc->oldPath);
newLen = strlen(nextReloc->newPath);
for (i = fileCount - 1; i >= 0 && nextReloc; i--) {
do {
rc = strncmp(nextReloc->oldPath, mem->names[i], len);
if (rc > 0) {
if (nextReloc == relocations) {
nextReloc = 0;
} else {
nextReloc--;
len = strlen(nextReloc->oldPath);
newLen = strlen(nextReloc->newPath);
}
}
} while (rc > 0 && nextReloc);
if (!rc) {
newName = alloca(newLen + strlen(mem->names[i]) + 1);
strcpy(newName, nextReloc->newPath);
strcat(newName, mem->names[i] + len);
rpmMessage(RPMMESS_DEBUG, _("relocating %s to %s\n"),
mem->names[i], newName);
mem->names[i] = newName;
}
}
headerModifyEntry(h, RPMTAG_FILENAMES, RPM_STRING_ARRAY_TYPE,
mem->names, fileCount);
/* make mem->names point to the new data in the header rather
then the old (now modified) data */
free(mem->names);
headerGetEntry(h, RPMTAG_FILENAMES, NULL, (void **) &mem->names,
fileCountPtr);
}
files = *filesPtr = mem->files = malloc(sizeof(*mem->files) * fileCount); files = *filesPtr = mem->files = malloc(sizeof(*mem->files) * fileCount);
headerGetEntry(h, RPMTAG_FILEMD5S, NULL, (void **) &mem->md5s, NULL); headerGetEntry(h, RPMTAG_FILEMD5S, NULL, (void **) &mem->md5s, NULL);
@ -409,19 +267,17 @@ static void trimChangelog(Header h) {
/* 0 success */ /* 0 success */
/* 1 bad magic */ /* 1 bad magic */
/* 2 error */ /* 2 error */
int rpmInstallPackage(char * rootdir, rpmdb db, FD_t fd, int installBinaryPackage(char * rootdir, rpmdb db, FD_t fd, Header h,
struct rpmRelocation * relocations, rpmRelocation * relocations,
int flags, rpmNotifyFunction notify, char * labelFormat) int flags, rpmNotifyFunction notify,
{ void * notifyData) {
int rc, isSource, major, minor; int rc;
char * name, * version, * release; char * name, * version, * release;
Header h;
int fileCount, type, count; int fileCount, type, count;
struct fileInfo * files; struct fileInfo * files;
int_32 installTime; int_32 installTime;
char * fileStates; char * fileStates;
int i, j; int i, j;
int remFlags;
int installFile = 0; int installFile = 0;
int otherOffset = 0; int otherOffset = 0;
char * ext = NULL, * newpath; char * ext = NULL, * newpath;
@ -429,9 +285,6 @@ int rpmInstallPackage(char * rootdir, rpmdb db, FD_t fd,
struct replacedFile * replacedList = NULL; struct replacedFile * replacedList = NULL;
char * defaultPrefix; char * defaultPrefix;
dbiIndexSet matches; dbiIndexSet matches;
int * toRemove = NULL;
int toRemoveAlloced = 1;
int * intptr = NULL;
char * tmpPath; char * tmpPath;
int scriptArg; int scriptArg;
int hasOthers = 0; int hasOthers = 0;
@ -441,66 +294,14 @@ int rpmInstallPackage(char * rootdir, rpmdb db, FD_t fd,
int freeFileMem = 0; int freeFileMem = 0;
char * currDir = NULL, * tmpptr; char * currDir = NULL, * tmpptr;
int currDirLen; int currDirLen;
char ** obsoletes;
if (flags & RPMINSTALL_JUSTDB) if (flags & RPMINSTALL_JUSTDB)
flags |= RPMINSTALL_NOSCRIPTS; flags |= RPMINSTALL_NOSCRIPTS;
rc = rpmReadPackageHeader(fd, &h, &isSource, &major, &minor);
if (rc) return rc;
if (isSource) {
if (flags & RPMINSTALL_TEST) {
rpmMessage(RPMMESS_DEBUG,
_("stopping install as we're running --test\n"));
return 0;
}
if (major == 1) {
notify = NULL;
labelFormat = NULL;
h = NULL;
}
if (flags & RPMINSTALL_JUSTDB) return 0;
rc = installSources(h, rootdir, fd, NULL, notify, labelFormat);
if (h != NULL) headerFree(h);
return rc;
}
headerGetEntry(h, RPMTAG_NAME, &type, (void **) &name, &fileCount); headerGetEntry(h, RPMTAG_NAME, &type, (void **) &name, &fileCount);
headerGetEntry(h, RPMTAG_VERSION, &type, (void **) &version, &fileCount); headerGetEntry(h, RPMTAG_VERSION, &type, (void **) &version, &fileCount);
headerGetEntry(h, RPMTAG_RELEASE, &type, (void **) &release, &fileCount); headerGetEntry(h, RPMTAG_RELEASE, &type, (void **) &release, &fileCount);
/* We don't use these entries (and never have) and they are pretty
misleading. Let's just get rid of them so they don't confuse
anyone. */
if (headerIsEntry(h, RPMTAG_FILEUSERNAME))
headerRemoveEntry(h, RPMTAG_FILEUIDS);
if (headerIsEntry(h, RPMTAG_FILEGROUPNAME))
headerRemoveEntry(h, RPMTAG_FILEGIDS);
if (!(flags & RPMINSTALL_NOARCH) && !archOkay(h)) {
rpmError(RPMERR_BADARCH, _("package %s-%s-%s is for a different "
"architecture"), name, version, release);
headerFree(h);
return 2;
}
if (!(flags & RPMINSTALL_NOOS) && !osOkay(h)) {
rpmError(RPMERR_BADOS, _("package %s-%s-%s is for a different "
"operating system"), name, version, release);
headerFree(h);
return 2;
}
if (packageAlreadyInstalled(db, name, version, release, &otherOffset,
flags)) {
headerFree(h);
return 2;
}
rpmMessage(RPMMESS_DEBUG, _("package: %s-%s-%s files test = %d\n"), rpmMessage(RPMMESS_DEBUG, _("package: %s-%s-%s files test = %d\n"),
name, version, release, flags & RPMINSTALL_TEST); name, version, release, flags & RPMINSTALL_TEST);
@ -525,78 +326,6 @@ int rpmInstallPackage(char * rootdir, rpmdb db, FD_t fd,
scriptArg = dbiIndexSetCount(matches) + 1; scriptArg = dbiIndexSetCount(matches) + 1;
} }
if (flags & RPMINSTALL_UPGRADE) {
/*
We need to get a list of all old version of this package. We let
this install procede normally then, but:
1) we don't report conflicts between the new package and
the old versions installed
2) when we're done, we uninstall the old versions
Note if the version being installed is already installed, we don't
put that in the list -- that situation is handled normally.
We also need to handle packages which were made oboslete.
*/
if (hasOthers) {
toRemoveAlloced = dbiIndexSetCount(matches) + 1;
intptr = toRemove = malloc(toRemoveAlloced * sizeof(int));
for (i = 0; i < dbiIndexSetCount(matches); i++) {
unsigned int recOffset = dbiIndexRecordOffset(matches, i);
if (recOffset != otherOffset) {
if (!(flags & RPMINSTALL_UPGRADETOOLD))
if (ensureOlder(db, h, recOffset)) {
headerFree(h);
dbiFreeIndexRecord(matches);
return 2;
}
*intptr++ = recOffset;
}
}
dbiFreeIndexRecord(matches);
}
if (!(flags & RPMINSTALL_KEEPOBSOLETE) &&
headerGetEntry(h, RPMTAG_OBSOLETES, NULL, (void **) &obsoletes,
&count)) {
for (i = 0; i < count; i++) {
rc = rpmdbFindPackage(db, obsoletes[i], &matches);
if (rc == -1) return 2;
if (rc == 1) continue; /* no matches */
rpmMessage(RPMMESS_DEBUG, _("package %s is now obsolete and will"
" be removed\n"), obsoletes[i]);
toRemoveAlloced += dbiIndexSetCount(matches);
j = toRemove ? intptr - toRemove : 0;
toRemove = realloc(toRemove, toRemoveAlloced * sizeof(int));
intptr = toRemove + j;
for (j = 0; j < dbiIndexSetCount(matches); j++)
*intptr++ = dbiIndexRecordOffset(matches, j);
dbiFreeIndexRecord(matches);
}
free(obsoletes);
}
if (toRemove) {
*intptr++ = 0;
/* this means we don't have to free the list */
intptr = alloca(toRemoveAlloced * sizeof(int));
memcpy(intptr, toRemove, toRemoveAlloced * sizeof(int));
free(toRemove);
toRemove = intptr;
}
} else if (hasOthers) {
dbiFreeIndexRecord(matches);
}
if (rootdir) { if (rootdir) {
currDirLen = 50; currDirLen = 50;
currDir = malloc(currDirLen); currDir = malloc(currDirLen);
@ -646,8 +375,7 @@ int rpmInstallPackage(char * rootdir, rpmdb db, FD_t fd,
defaultPrefix = NULL; defaultPrefix = NULL;
} }
if (assembleFileList(h, &fileMem, &fileCount, &files, stripSize, if (assembleFileList(h, &fileMem, &fileCount, &files, stripSize)) {
relocations, flags & RPMINSTALL_FORCERELOCATE)) {
if (rootdir) { if (rootdir) {
chroot("."); chroot(".");
chdir(currDir); chdir(currDir);
@ -712,7 +440,7 @@ int rpmInstallPackage(char * rootdir, rpmdb db, FD_t fd,
if (netsharedPaths) freeSplitString(netsharedPaths); if (netsharedPaths) freeSplitString(netsharedPaths);
rc = instHandleSharedFiles(db, otherOffset, files, fileCount, rc = instHandleSharedFiles(db, otherOffset, files, fileCount,
toRemove, &replacedList, flags); NULL, &replacedList, flags);
if (rc) { if (rc) {
if (rootdir) { if (rootdir) {
@ -839,13 +567,12 @@ int rpmInstallPackage(char * rootdir, rpmdb db, FD_t fd,
(void *) &archiveSizePtr, &count)) (void *) &archiveSizePtr, &count))
archiveSizePtr = NULL; archiveSizePtr = NULL;
if (labelFormat) { if (notify) {
fprintf(stdout, labelFormat, name, version, release); notify(h, RPMNOTIFY_INST_START, 0, 0, notifyData);
fflush(stdout);
} }
/* the file pointer for fd is pointing at the cpio archive */ /* the file pointer for fd is pointing at the cpio archive */
if (installArchive(fd, files, fileCount, notify, if (installArchive(fd, files, fileCount, notify, notifyData, h,
NULL, archiveSizePtr ? *archiveSizePtr : 0)) { NULL, archiveSizePtr ? *archiveSizePtr : 0)) {
headerFree(h); headerFree(h);
if (replacedList) free(replacedList); if (replacedList) free(replacedList);
@ -929,21 +656,6 @@ int rpmInstallPackage(char * rootdir, rpmdb db, FD_t fd,
} }
} }
if (toRemove && flags & RPMINSTALL_UPGRADE) {
rpmMessage(RPMMESS_DEBUG, _("removing old versions of package\n"));
intptr = toRemove;
if (flags & RPMINSTALL_NOSCRIPTS)
remFlags = RPMUNINSTALL_NOSCRIPTS;
else
remFlags = 0;
while (*intptr) {
rpmRemovePackage(rootdir, db, *intptr, remFlags);
intptr++;
}
}
headerFree(h); headerFree(h);
return 0; return 0;
@ -954,7 +666,9 @@ static void callback(struct cpioCallbackInfo * cpioInfo, void * data) {
char * chptr; char * chptr;
if (ourInfo->notify) if (ourInfo->notify)
ourInfo->notify(cpioInfo->bytesProcessed, ourInfo->archiveSize); ourInfo->notify(ourInfo->h, RPMNOTIFY_INST_PROGRESS,
cpioInfo->bytesProcessed,
ourInfo->archiveSize, ourInfo->notifyData);
if (ourInfo->specFilePtr) { if (ourInfo->specFilePtr) {
chptr = cpioInfo->file + strlen(cpioInfo->file) - 5; chptr = cpioInfo->file + strlen(cpioInfo->file) - 5;
@ -966,6 +680,7 @@ static void callback(struct cpioCallbackInfo * cpioInfo, void * data) {
/* NULL files means install all files */ /* NULL files means install all files */
static int installArchive(FD_t fd, struct fileInfo * files, static int installArchive(FD_t fd, struct fileInfo * files,
int fileCount, rpmNotifyFunction notify, int fileCount, rpmNotifyFunction notify,
void * notifyData, Header h,
char ** specFile, int archiveSize) { char ** specFile, int archiveSize) {
int rc, i; int rc, i;
struct cpioFileMapping * map = NULL; struct cpioFileMapping * map = NULL;
@ -983,7 +698,9 @@ static int installArchive(FD_t fd, struct fileInfo * files,
info.archiveSize = archiveSize; info.archiveSize = archiveSize;
info.notify = notify; info.notify = notify;
info.notifyData = notifyData;
info.specFilePtr = specFile; info.specFilePtr = specFile;
info.h = h;
if (specFile) *specFile = NULL; if (specFile) *specFile = NULL;
@ -1006,7 +723,7 @@ static int installArchive(FD_t fd, struct fileInfo * files,
} }
if (notify) if (notify)
notify(0, archiveSize); notify(h, RPMNOTIFY_INST_PROGRESS, 0, archiveSize, notifyData);
{ CFD_t cfdbuf, *cfd = &cfdbuf; { CFD_t cfdbuf, *cfd = &cfdbuf;
cfd->cpioIoType = cpioIoTypeGzFd; cfd->cpioIoType = cpioIoTypeGzFd;
@ -1027,54 +744,15 @@ static int installArchive(FD_t fd, struct fileInfo * files,
} }
if (notify && archiveSize) if (notify && archiveSize)
notify(archiveSize, archiveSize); notify(h, RPMNOTIFY_INST_PROGRESS, archiveSize, archiveSize,
notifyData);
else if (notify) { else if (notify) {
notify(100, 100); notify(h, RPMNOTIFY_INST_PROGRESS, 100, 100, notifyData);
} }
return 0; return 0;
} }
static int packageAlreadyInstalled(rpmdb db, char * name, char * version,
char * release, int * offset, int flags) {
char * secVersion, * secRelease;
Header sech;
int i;
dbiIndexSet matches;
int type, count;
if (!rpmdbFindPackage(db, name, &matches)) {
for (i = 0; i < dbiIndexSetCount(matches); i++) {
unsigned int recOffset = dbiIndexRecordOffset(matches, i);
sech = rpmdbGetRecord(db, recOffset);
if (sech == NULL) {
return 1;
}
headerGetEntry(sech, RPMTAG_VERSION, &type, (void **) &secVersion,
&count);
headerGetEntry(sech, RPMTAG_RELEASE, &type, (void **) &secRelease,
&count);
if (!strcmp(secVersion, version) && !strcmp(secRelease, release)) {
*offset = recOffset;
if (!(flags & RPMINSTALL_REPLACEPKG)) {
rpmError(RPMERR_PKGINSTALLED,
_("package %s-%s-%s is already installed"),
name, version, release);
headerFree(sech);
return 1;
}
}
headerFree(sech);
}
dbiFreeIndexRecord(matches);
}
return 0;
}
static int filecmp(short mode1, char * md51, char * link1, static int filecmp(short mode1, char * md51, char * link1,
short mode2, char * md52, char * link2) { short mode2, char * md52, char * link2) {
@ -1380,6 +1058,7 @@ static int instHandleSharedFiles(rpmdb db, int ignoreOffset,
/* 2 error */ /* 2 error */
static int installSources(Header h, char * rootdir, FD_t fd, static int installSources(Header h, char * rootdir, FD_t fd,
char ** specFilePtr, rpmNotifyFunction notify, char ** specFilePtr, rpmNotifyFunction notify,
void * notifyData,
char * labelFormat) { char * labelFormat) {
char * specFile; char * specFile;
char * sourceDir, * specDir; char * sourceDir, * specDir;
@ -1429,7 +1108,7 @@ static int installSources(Header h, char * rootdir, FD_t fd,
if (h && headerIsEntry(h, RPMTAG_FILENAMES)) { if (h && headerIsEntry(h, RPMTAG_FILENAMES)) {
/* we can't remap v1 packages */ /* we can't remap v1 packages */
assembleFileList(h, &fileMem, &fileCount, &files, 0, NULL, 0); assembleFileList(h, &fileMem, &fileCount, &files, 0);
for (i = 0; i < fileCount; i++) { for (i = 0; i < fileCount; i++) {
files[i].relativePath = files[i].relativePath; files[i].relativePath = files[i].relativePath;
@ -1484,7 +1163,7 @@ static int installSources(Header h, char * rootdir, FD_t fd,
chdir(realSourceDir); chdir(realSourceDir);
if (installArchive(fd, fileCount > 0 ? files : NULL, if (installArchive(fd, fileCount > 0 ? files : NULL,
fileCount, notify, fileCount, notify, notifyData, h,
specFileIndex >=0 ? NULL : &specFile, specFileIndex >=0 ? NULL : &specFile,
archiveSizePtr ? *archiveSizePtr : 0)) { archiveSizePtr ? *archiveSizePtr : 0)) {
if (fileCount > 0) freeFileMemory(fileMem); if (fileCount > 0) freeFileMemory(fileMem);
@ -1663,46 +1342,3 @@ enum fileTypes whatis(short mode) {
return result; return result;
} }
static int archOkay(Header h) {
int_8 * pkgArchNum;
void * pkgArch;
int type, count, archNum;
/* make sure we're trying to install this on the proper architecture */
headerGetEntry(h, RPMTAG_ARCH, &type, (void **) &pkgArch, &count);
if (type == RPM_INT8_TYPE) {
/* old arch handling */
rpmGetArchInfo(NULL, &archNum);
pkgArchNum = pkgArch;
if (archNum != *pkgArchNum) {
return 0;
}
} else {
/* new arch handling */
if (!rpmMachineScore(RPM_MACHTABLE_INSTARCH, pkgArch)) {
return 0;
}
}
return 1;
}
static int osOkay(Header h) {
void * pkgOs;
int type, count;
/* make sure we're trying to install this on the proper os */
headerGetEntry(h, RPMTAG_OS, &type, (void **) &pkgOs, &count);
if (type == RPM_INT8_TYPE) {
/* v1 packages and v2 packages both used improper OS numbers, so just
deal with it hope things work */
return 1;
} else {
/* new os handling */
if (!rpmMachineScore(RPM_MACHTABLE_INSTOS, pkgOs)) {
return 0;
}
}
return 1;
}

View File

@ -21,5 +21,9 @@ int runTriggers(char * root, rpmdb db, int sense, Header h,
database to calculate arguments to the trigger */ database to calculate arguments to the trigger */
int runImmedTriggers(char * root, rpmdb db, int sense, Header h, int runImmedTriggers(char * root, rpmdb db, int sense, Header h,
int countCorrection); int countCorrection);
int installBinaryPackage(char * rootdir, rpmdb db, FD_t fd, Header h,
rpmRelocation * relocations,
int flags, rpmNotifyFunction notify,
void * notifyData);
#endif /* H_INSTALL */ #endif /* H_INSTALL */

View File

@ -2,9 +2,6 @@
#include "rpmlib.h" #include "rpmlib.h"
static int findMatches(rpmdb db, char * name, char * version, char * release,
dbiIndexSet * matches);
/* 0 found matches */ /* 0 found matches */
/* 1 no matches */ /* 1 no matches */
/* 2 error */ /* 2 error */
@ -57,7 +54,7 @@ int rpmdbFindByLabel(rpmdb db, char * arg, dbiIndexSet * matches) {
/* 0 found matches */ /* 0 found matches */
/* 1 no matches */ /* 1 no matches */
/* 2 error */ /* 2 error */
static int findMatches(rpmdb db, char * name, char * version, char * release, int findMatches(rpmdb db, char * name, char * version, char * release,
dbiIndexSet * matches) { dbiIndexSet * matches) {
int gotMatches; int gotMatches;
int rc; int rc;

View File

@ -11,6 +11,8 @@ void stripTrailingSlashes(char * str);
int rpmfileexists(char * filespec); int rpmfileexists(char * filespec);
int rpmvercmp(char * one, char * two); int rpmvercmp(char * one, char * two);
int findMatches(rpmdb db, char * name, char * version, char * release,
dbiIndexSet * matches);
/* these are like the normal functions, but they malloc() the space which /* these are like the normal functions, but they malloc() the space which
is needed */ is needed */

View File

@ -27,6 +27,7 @@ static int readPackageHeaders(FD_t fd, struct rpmlead * leadPtr,
int isSource; int isSource;
char * defaultPrefix; char * defaultPrefix;
struct stat sb; struct stat sb;
int_32 true = 1;
hdr = hdrPtr ? hdrPtr : &hdrBlock; hdr = hdrPtr ? hdrPtr : &hdrBlock;
lead = leadPtr ? leadPtr : &leadBlock; lead = leadPtr ? leadPtr : &leadBlock;
@ -93,6 +94,12 @@ static int readPackageHeaders(FD_t fd, struct rpmlead * leadPtr,
headerAddEntry(*hdr, RPMTAG_PREFIXES, RPM_STRING_ARRAY_TYPE, headerAddEntry(*hdr, RPMTAG_PREFIXES, RPM_STRING_ARRAY_TYPE,
&defaultPrefix, 1); &defaultPrefix, 1);
} }
if (lead->type == RPMLEAD_SOURCE) {
if (!headerIsEntry(*hdr, RPMTAG_SOURCEPACKAGE))
headerAddEntry(*hdr, RPMTAG_SOURCEPACKAGE, RPM_INT32_TYPE,
&true, 1);
}
} else { } else {
rpmError(RPMERR_NEWPACKAGE, _("only packages with major numbers <= 3 " rpmError(RPMERR_NEWPACKAGE, _("only packages with major numbers <= 3 "
"are supported by this version of RPM")); "are supported by this version of RPM"));

View File

@ -317,8 +317,9 @@ int rpmdbFindByFile(rpmdb db, char * filespec, dbiIndexSet * matches) {
} }
i++; i++;
} while ((i == 0) || (allMatches.recs[i].recOffset == } while ((i < allMatches.count) &&
allMatches.recs[i - 1].recOffset)); ((i == 0) || (allMatches.recs[i].recOffset ==
allMatches.recs[i - 1].recOffset)));
free(fileList); free(fileList);
@ -396,6 +397,7 @@ int rpmdbRemove(rpmdb db, unsigned int offset, int tolerant) {
char ** fileList, ** providesList, ** requiredbyList; char ** fileList, ** providesList, ** requiredbyList;
char ** conflictList, ** triggerList; char ** conflictList, ** triggerList;
int i; int i;
char * basename;
/* structure assignment */ /* structure assignment */
rec = dbiReturnIndexRecordInstance(offset, 0); rec = dbiReturnIndexRecordInstance(offset, 0);
@ -475,10 +477,17 @@ int rpmdbRemove(rpmdb db, unsigned int offset, int tolerant) {
if (headerGetEntry(h, RPMTAG_FILENAMES, &type, (void **) &fileList, if (headerGetEntry(h, RPMTAG_FILENAMES, &type, (void **) &fileList,
&count)) { &count)) {
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
rpmMessage(RPMMESS_DEBUG, _("removing file index for %s\n"), fileList[i]); basename = strrchr(fileList[i], '/');
if (!basename)
basename = fileList[i];
else
basename++;
rpmMessage(RPMMESS_DEBUG, _("removing file index for %s\n"),
basename);
/* structure assignment */ /* structure assignment */
rec = dbiReturnIndexRecordInstance(offset, i); rec = dbiReturnIndexRecordInstance(offset, i);
removeIndexEntry(db->fileIndex, fileList[i], rec, tolerant, removeIndexEntry(db->fileIndex, basename, rec, tolerant,
"file index"); "file index");
} }
free(fileList); free(fileList);

View File

@ -128,6 +128,8 @@ extern const struct headerSprintfExtension rpmHeaderFormats[];
#define RPMTAG_AUTOREQ 1103 /* internal */ #define RPMTAG_AUTOREQ 1103 /* internal */
#define RPMTAG_AUTOPROV 1104 /* internal */ #define RPMTAG_AUTOPROV 1104 /* internal */
#define RPMTAG_CAPABILITY 1105 #define RPMTAG_CAPABILITY 1105
#define RPMTAG_SOURCEPACKAGE 1106 /* internal */
#define RPMTAG_ORIGFILENAMES 1107
#define RPMTAG_EXTERNAL_TAG 1000000 #define RPMTAG_EXTERNAL_TAG 1000000
@ -147,19 +149,14 @@ extern const struct headerSprintfExtension rpmHeaderFormats[];
#define RPMFILE_LICENSE (1 << 7) #define RPMFILE_LICENSE (1 << 7)
#define RPMFILE_README (1 << 8) #define RPMFILE_README (1 << 8)
#define RPMINSTALL_REPLACEPKG (1 << 0)
#define RPMINSTALL_REPLACEFILES (1 << 1) #define RPMINSTALL_REPLACEFILES (1 << 1)
#define RPMINSTALL_TEST (1 << 2) #define RPMINSTALL_TEST (1 << 2)
#define RPMINSTALL_UPGRADE (1 << 3)
#define RPMINSTALL_UPGRADETOOLD (1 << 4) #define RPMINSTALL_UPGRADETOOLD (1 << 4)
#define RPMINSTALL_NODOCS (1 << 5) #define RPMINSTALL_NODOCS (1 << 5)
#define RPMINSTALL_NOSCRIPTS (1 << 6) #define RPMINSTALL_NOSCRIPTS (1 << 6)
#define RPMINSTALL_NOARCH (1 << 7)
#define RPMINSTALL_NOOS (1 << 8)
#define RPMINSTALL_ALLFILES (1 << 9) #define RPMINSTALL_ALLFILES (1 << 9)
#define RPMINSTALL_JUSTDB (1 << 10) #define RPMINSTALL_JUSTDB (1 << 10)
#define RPMINSTALL_KEEPOBSOLETE (1 << 11) #define RPMINSTALL_KEEPOBSOLETE (1 << 11)
#define RPMINSTALL_FORCERELOCATE (1 << 12)
#define RPMINSTALL_NOTRIGGERS (1 << 13) #define RPMINSTALL_NOTRIGGERS (1 << 13)
#define RPMUNINSTALL_TEST (1 << 0) #define RPMUNINSTALL_TEST (1 << 0)
@ -283,8 +280,12 @@ void rpmGetMachine(/*@out@*/char **arch, /*@out@*/char **os);
typedef /*@abstract@*/ struct rpmdb_s * rpmdb; typedef /*@abstract@*/ struct rpmdb_s * rpmdb;
typedef void (*rpmNotifyFunction)(const unsigned long amount, typedef enum rpmNotifyType_e
const unsigned long total); { RPMNOTIFY_INST_PROGRESS, RPMNOTIFY_INST_START } rpmNotifyType;
typedef void (*rpmNotifyFunction)(const Header h, const rpmNotifyType what,
const unsigned long amount,
const unsigned long total,
void * data);
int rpmdbOpen (char * root, rpmdb * dbp, int mode, int perms); int rpmdbOpen (char * root, rpmdb * dbp, int mode, int perms);
/* 0 on error */ /* 0 on error */
@ -310,26 +311,26 @@ int rpmdbFindByLabel(rpmdb db, char * label, dbiIndexSet * matches);
int rpmdbFindByHeader(rpmdb db, Header h, dbiIndexSet * matches); int rpmdbFindByHeader(rpmdb db, Header h, dbiIndexSet * matches);
/* we pass these around as an array with a sentinel */ /* we pass these around as an array with a sentinel */
struct rpmRelocation { typedef struct rpmRelocation_s {
char * oldPath; /* NULL here evals to RPMTAG_DEFAULTPREFIX, this */ char * oldPath; /* NULL here evals to RPMTAG_DEFAULTPREFIX, this */
char * newPath; /* odd behavior is only for backwards compatibility */ char * newPath; /* odd behavior is only for backwards compatibility */
}; } rpmRelocation;
int rpmInstallSourcePackage(char * root, FD_t fd, char ** specFile, int rpmInstallSourcePackage(char * root, FD_t fd, char ** specFile,
rpmNotifyFunction notify, char * labelFormat, rpmNotifyFunction notify, void * notifyData,
char ** cookie); char * labelFormat, char ** cookie);
int rpmInstallPackage(char * rootdir, rpmdb db, FD_t fd,
struct rpmRelocation * relocations,
int flags, rpmNotifyFunction notify, char * labelFormat);
int rpmVersionCompare(Header first, Header second); int rpmVersionCompare(Header first, Header second);
int rpmRemovePackage(char * root, rpmdb db, unsigned int offset, int flags); int removeBinaryPackage(char * root, rpmdb db, unsigned int offset, int flags);
int rpmdbRebuild(char * root); int rpmdbRebuild(char * root);
int rpmVerifyFile(char * root, Header h, int filenum, int * result, int rpmVerifyFile(char * root, Header h, int filenum, int * result,
int omitMask); int omitMask);
int rpmVerifyScript(char * root, Header h, FD_t err); int rpmVerifyScript(char * root, Header h, FD_t err);
typedef struct rpmDependencyCheck * rpmDependencies; /* Transaction sets are inherently unordered! RPM may reorder transaction
sets to reduce errors. In general, installs/upgrades are done before
strict removals, and prerequisite ordering is done on installs/upgrades. */
typedef struct rpmTransactionSet_s * rpmTransactionSet;
struct rpmDependencyConflict { struct rpmDependencyConflict {
char * byName, * byVersion, * byRelease; char * byName, * byVersion, * byRelease;
@ -342,24 +343,63 @@ struct rpmDependencyConflict {
enum { RPMDEP_SENSE_REQUIRES, RPMDEP_SENSE_CONFLICTS } sense; enum { RPMDEP_SENSE_REQUIRES, RPMDEP_SENSE_CONFLICTS } sense;
} ; } ;
/*@only@*/ rpmDependencies rpmdepDependencies(rpmdb db); /* db may be NULL */ /* db may be NULL, but don't do things which require the database! */
void rpmdepAddPackage(rpmDependencies rpmdep, Header h, void * key); /*@only@*/ rpmTransactionSet rpmtransCreateSet(rpmdb db, char * rootdir);
void rpmdepAvailablePackage(rpmDependencies rpmdep, Header h, void * key);
void rpmdepUpgradePackage(rpmDependencies rpmdep, Header h, void * key); /* if fd is NULL, the callback specified in rpmtransCreateSet() is used to
void rpmdepRemovePackage(rpmDependencies rpmdep, int dboffset); open and close the file descriptor. If Header is NULL, the fd is always
used, otherwise fd is only needed (and only opened) for actual package
installation */
void rpmtransAddPackage(rpmTransactionSet rpmdep, Header h, FD_t fd,
void * key, int update, rpmRelocation * relocs);
void rpmtransAvailablePackage(rpmTransactionSet rpmdep, Header h, void * key);
void rpmtransRemovePackage(rpmTransactionSet rpmdep, int dboffset);
void rpmtransFree(/*@only@*/ rpmTransactionSet rpmdep);
/* this checks for dependency satisfaction, but *not* ordering */ /* this checks for dependency satisfaction, but *not* ordering */
int rpmdepCheck(rpmDependencies rpmdep, int rpmdepCheck(rpmTransactionSet rpmdep,
struct rpmDependencyConflict ** conflicts, int * numConflicts); struct rpmDependencyConflict ** conflicts, int * numConflicts);
/* Orders items, returns error on circle, finals keys[] is NULL. No dependency /* Orders items, returns error on circle, finals keys[] is NULL. No dependency
check is done, use rpmdepCheck() for that. If dependencies are not check is done, use rpmdepCheck() for that. If dependencies are not
satisfied a "best-try" ordering is returned. */ satisfied a "best-try" ordering is returned. */
int rpmdepOrder(rpmDependencies order, void *** keysListPtr); int rpmdepOrder(rpmTransactionSet order, void *** keysListPtr);
void rpmdepDone(/*@only@*/ rpmDependencies rpmdep);
void rpmdepFreeConflicts(struct rpmDependencyConflict * conflicts, int void rpmdepFreeConflicts(struct rpmDependencyConflict * conflicts, int
numConflicts); numConflicts);
#define RPMTRANS_FLAG_TEST (1 << 0)
typedef enum rpmProblemType_e { RPMPROB_BADARCH,
RPMPROB_BADOS,
RPMPROB_PKG_INSTALLED,
RPMPROB_BADRELOCATE,
} rpmProblemType;
typedef struct rpmProblem_s {
Header h;
void * key;
rpmProblemType type;
int ignoreProblem;
char * str1;
} rpmProblem;
typedef struct rpmProblemSet_s {
int numProblems;
int numProblemsAlloced;
rpmProblem * probs;
} * rpmProblemSet;
char * rpmProblemString(rpmProblem prob);
void rpmProblemSetFree(rpmProblemSet probs);
void rpmProblemSetFilter(rpmProblemSet ps, int flags);
int rpmRunTransactions(rpmTransactionSet ts, rpmNotifyFunction notify,
void * notifyData, rpmProblemSet okProbs,
rpmProblemSet * newProbs, int flags);
#define RPMPROB_FILTER_IGNOREOS (1 << 0)
#define RPMPROB_FILTER_IGNOREARCH (1 << 1)
#define RPMPROB_FILTER_REPLACEPKG (1 << 2)
#define RPMPROB_FILTER_FORCERELOCATE (1 << 3)
/** messages.c **/ /** messages.c **/
#define RPMMESS_DEBUG 1 #define RPMMESS_DEBUG 1
@ -450,11 +490,11 @@ rpmErrorCallBackType rpmErrorSetCallback(rpmErrorCallBackType);
#define RPMERR_NOTSRPM -26 /* a source rpm was expected */ #define RPMERR_NOTSRPM -26 /* a source rpm was expected */
#define RPMERR_FLOCK -27 /* locking the database failed */ #define RPMERR_FLOCK -27 /* locking the database failed */
#define RPMERR_OLDPACKAGE -28 /* trying upgrading to old version */ #define RPMERR_OLDPACKAGE -28 /* trying upgrading to old version */
#define RPMERR_BADARCH -29 /* bad architecture or arch mismatch */ /*#define RPMERR_BADARCH -29 bad architecture or arch mismatch */
#define RPMERR_CREATE -30 /* failed to create a file */ #define RPMERR_CREATE -30 /* failed to create a file */
#define RPMERR_NOSPACE -31 /* out of disk space */ #define RPMERR_NOSPACE -31 /* out of disk space */
#define RPMERR_NORELOCATE -32 /* tried to do improper relocatation */ #define RPMERR_NORELOCATE -32 /* tried to do improper relocatation */
#define RPMERR_BADOS -33 /* bad architecture or arch mismatch */ /*#define RPMERR_BADOS -33 bad architecture or arch mismatch */
#define RPMMESS_BACKUP -34 /* backup made during [un]install */ #define RPMMESS_BACKUP -34 /* backup made during [un]install */
#define RPMERR_MTAB -35 /* failed to read mount table */ #define RPMERR_MTAB -35 /* failed to read mount table */
#define RPMERR_STAT -36 /* failed to stat something */ #define RPMERR_STAT -36 /* failed to stat something */
@ -462,6 +502,7 @@ rpmErrorCallBackType rpmErrorSetCallback(rpmErrorCallBackType);
#define RPMMESS_ALTNAME -38 /* file written as .rpmnew */ #define RPMMESS_ALTNAME -38 /* file written as .rpmnew */
#define RPMMESS_PREREQLOOP -39 /* loop in prerequisites */ #define RPMMESS_PREREQLOOP -39 /* loop in prerequisites */
#define RPMERR_BADRELOCATE -40 /* bad relocation was specified */ #define RPMERR_BADRELOCATE -40 /* bad relocation was specified */
#define RPMERR_OLDDB -41 /* old format database */
/* spec.c build.c pack.c */ /* spec.c build.c pack.c */
#define RPMERR_UNMATCHEDIF -107 /* unclosed %ifarch or %ifos */ #define RPMERR_UNMATCHEDIF -107 /* unclosed %ifarch or %ifos */

View File

@ -193,7 +193,8 @@ static int handleSharedFiles(rpmdb db, int offset, char ** fileList,
return rc; return rc;
} }
int rpmRemovePackage(char * prefix, rpmdb db, unsigned int offset, int flags) { int removeBinaryPackage(char * prefix, rpmdb db, unsigned int offset,
int flags) {
Header h; Header h;
int i, j; int i, j;
int fileCount; int fileCount;

View File

@ -1,4 +1,4 @@
# Makefile.in generated automatically by automake 1.3b from Makefile.am # Makefile.in generated automatically by automake 1.3 from Makefile.am
# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. # Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation # This Makefile.in is free software; the Free Software Foundation
@ -34,7 +34,7 @@ mandir = @mandir@
includedir = @includedir@ includedir = @includedir@
oldincludedir = /usr/include oldincludedir = /usr/include
DESTDIR = DISTDIR =
pkgdatadir = $(datadir)/@PACKAGE@ pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@
@ -157,8 +157,8 @@ CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@ LDFLAGS = @LDFLAGS@
libmisc_a_OBJECTS = libmisc_a_OBJECTS =
CFLAGS = @CFLAGS@ CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
LINK = $(CC) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ LINK = $(CC) $(CFLAGS) $(LDFLAGS) -o $@
HEADERS = $(noinst_HEADERS) HEADERS = $(noinst_HEADERS)
DIST_COMMON = Makefile.am Makefile.in alloca.c error.c error.h \ DIST_COMMON = Makefile.am Makefile.in alloca.c error.c error.h \
@ -169,7 +169,7 @@ strerror.c strncasecmp.c strspn.c strstr.c strtol.c strtoul.c
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = gtar TAR = tar
GZIP = --best GZIP = --best
DEP_FILES = .deps/alloca.P .deps/error.P .deps/fnmatch.P .deps/getcwd.P \ DEP_FILES = .deps/alloca.P .deps/error.P .deps/fnmatch.P .deps/getcwd.P \
.deps/getmntent.P .deps/getwd.P .deps/glob.P .deps/inet_aton.P \ .deps/getmntent.P .deps/getwd.P .deps/glob.P .deps/inet_aton.P \
@ -290,6 +290,7 @@ maintainer-clean-depend:
info: info:
dvi: dvi:
check: all check: all
$(MAKE)
installcheck: installcheck:
install-exec: install-exec:
@$(NORMAL_INSTALL) @$(NORMAL_INSTALL)
@ -303,19 +304,24 @@ install: install-exec install-data all
uninstall: uninstall:
install-strip: install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install
installdirs: installdirs:
mostlyclean-generic: mostlyclean-generic:
-test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
clean-generic: clean-generic:
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic: distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES) -rm -f Makefile $(DISTCLEANFILES)
-rm -f config.cache config.log stamp-h stamp-h[0-9]* -rm -f config.cache config.log stamp-h stamp-h[0-9]*
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic: maintainer-clean-generic:
-test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
-test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
mostlyclean: mostlyclean-noinstLIBRARIES mostlyclean-compile \ mostlyclean: mostlyclean-noinstLIBRARIES mostlyclean-compile \
mostlyclean-tags mostlyclean-depend mostlyclean-generic mostlyclean-tags mostlyclean-depend mostlyclean-generic

File diff suppressed because it is too large Load Diff

27
rpm.c
View File

@ -493,8 +493,10 @@ int main(int argc, char ** argv) {
int ec = 0; int ec = 0;
int status; int status;
int p[2]; int p[2];
struct rpmRelocation * relocations = NULL; rpmRelocation * relocations = NULL;
int numRelocations = 0; int numRelocations = 0;
int upgrade = 0;
int probFilter = 0;
/* set the defaults for the various command line options */ /* set the defaults for the various command line options */
allFiles = 0; allFiles = 0;
@ -678,7 +680,7 @@ int main(int argc, char ** argv) {
if (bigMode != MODE_UNKNOWN && bigMode != MODE_INSTALL) if (bigMode != MODE_UNKNOWN && bigMode != MODE_INSTALL)
argerror(_("only one major mode may be specified")); argerror(_("only one major mode may be specified"));
bigMode = MODE_INSTALL; bigMode = MODE_INSTALL;
installFlags |= RPMINSTALL_UPGRADE; upgrade = 1;
break; break;
case 'p': case 'p':
@ -1009,7 +1011,7 @@ int main(int argc, char ** argv) {
} }
#endif #endif
if (oldPackage && !(installFlags & RPMINSTALL_UPGRADE)) if (oldPackage && upgrade)
argerror(_("--oldpackage may only be used during upgrades")); argerror(_("--oldpackage may only be used during upgrades"));
if ((ftpProxy || ftpPort) && !(bigMode == MODE_INSTALL || if ((ftpProxy || ftpPort) && !(bigMode == MODE_INSTALL ||
@ -1018,7 +1020,7 @@ int main(int argc, char ** argv) {
argerror(_("ftp options can only be used during package queries, " argerror(_("ftp options can only be used during package queries, "
"installs, and upgrades")); "installs, and upgrades"));
if (oldPackage || (force && (installFlags & RPMINSTALL_UPGRADE))) if (oldPackage || (force && upgrade))
installFlags |= RPMINSTALL_UPGRADETOOLD; installFlags |= RPMINSTALL_UPGRADETOOLD;
if (noPgp && bigMode != MODE_CHECKSIG) if (noPgp && bigMode != MODE_CHECKSIG)
@ -1207,16 +1209,18 @@ int main(int argc, char ** argv) {
break; break;
case MODE_INSTALL: case MODE_INSTALL:
if (force) if (force) {
installFlags |= (RPMINSTALL_REPLACEPKG | RPMINSTALL_REPLACEFILES); probFilter |= RPMPROB_FILTER_REPLACEPKG;
installFlags |= RPMINSTALL_REPLACEFILES;
}
if (replaceFiles) installFlags |= RPMINSTALL_REPLACEFILES; if (replaceFiles) installFlags |= RPMINSTALL_REPLACEFILES;
if (badReloc) installFlags |= RPMINSTALL_FORCERELOCATE; if (badReloc) probFilter |= RPMPROB_FILTER_FORCERELOCATE;
if (replacePackages) installFlags |= RPMINSTALL_REPLACEPKG; if (replacePackages) probFilter |= RPMPROB_FILTER_REPLACEPKG;
if (test) installFlags |= RPMINSTALL_TEST; if (test) installFlags |= RPMINSTALL_TEST;
if (noScripts) installFlags |= RPMINSTALL_NOSCRIPTS; if (noScripts) installFlags |= RPMINSTALL_NOSCRIPTS;
if (noTriggers) installFlags |= RPMINSTALL_NOTRIGGERS; if (noTriggers) installFlags |= RPMINSTALL_NOTRIGGERS;
if (ignoreArch) installFlags |= RPMINSTALL_NOARCH; if (ignoreArch) probFilter |= RPMPROB_FILTER_IGNOREARCH;
if (ignoreOs) installFlags |= RPMINSTALL_NOOS; if (ignoreOs) probFilter |= RPMPROB_FILTER_IGNOREOS;
if (allFiles) installFlags |= RPMINSTALL_ALLFILES; if (allFiles) installFlags |= RPMINSTALL_ALLFILES;
if (justdb) installFlags |= RPMINSTALL_JUSTDB; if (justdb) installFlags |= RPMINSTALL_JUSTDB;
@ -1224,6 +1228,7 @@ int main(int argc, char ** argv) {
if (showHash) interfaceFlags |= INSTALL_HASH; if (showHash) interfaceFlags |= INSTALL_HASH;
if (noDeps) interfaceFlags |= INSTALL_NODEPS; if (noDeps) interfaceFlags |= INSTALL_NODEPS;
if (noOrder) interfaceFlags |= INSTALL_NOORDER; if (noOrder) interfaceFlags |= INSTALL_NOORDER;
if (noOrder) interfaceFlags |= INSTALL_NOORDER;
if (!incldocs) { if (!incldocs) {
if (excldocs) if (excldocs)
@ -1249,7 +1254,7 @@ int main(int argc, char ** argv) {
} }
ec += doInstall(rootdir, poptGetArgs(optCon), installFlags, ec += doInstall(rootdir, poptGetArgs(optCon), installFlags,
interfaceFlags, relocations); interfaceFlags, probFilter, relocations);
break; break;
case MODE_QUERY: case MODE_QUERY:

View File

@ -1,4 +1,4 @@
# Makefile.in generated automatically by automake 1.3b from Makefile.am # Makefile.in generated automatically by automake 1.3 from Makefile.am
# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. # Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation # This Makefile.in is free software; the Free Software Foundation
@ -34,7 +34,7 @@ mandir = @mandir@
includedir = @includedir@ includedir = @includedir@
oldincludedir = /usr/include oldincludedir = /usr/include
DESTDIR = DISTDIR =
pkgdatadir = $(datadir)/@PACKAGE@ pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@
@ -138,7 +138,7 @@ DIST_COMMON = Makefile.am Makefile.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = gtar TAR = tar
GZIP = --best GZIP = --best
all: Makefile $(SCRIPTS) all: Makefile $(SCRIPTS)
@ -192,6 +192,7 @@ distdir: $(DISTFILES)
info: info:
dvi: dvi:
check: all check: all
$(MAKE)
installcheck: installcheck:
install-exec: install-exec:
@$(NORMAL_INSTALL) @$(NORMAL_INSTALL)
@ -205,20 +206,25 @@ install: install-exec install-data all
uninstall: uninstall-configSCRIPTS uninstall: uninstall-configSCRIPTS
install-strip: install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install
installdirs: installdirs:
$(mkinstalldirs) $(DESTDIR)$(configdir) $(mkinstalldirs) $(DATADIR)$(configdir)
mostlyclean-generic: mostlyclean-generic:
-test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
clean-generic: clean-generic:
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic: distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES) -rm -f Makefile $(DISTCLEANFILES)
-rm -f config.cache config.log stamp-h stamp-h[0-9]* -rm -f config.cache config.log stamp-h stamp-h[0-9]*
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic: maintainer-clean-generic:
-test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
-test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
mostlyclean: mostlyclean-generic mostlyclean: mostlyclean-generic
clean: clean-generic mostlyclean clean: clean-generic mostlyclean

View File

@ -1,4 +1,4 @@
# Makefile.in generated automatically by automake 1.3b from Makefile.am # Makefile.in generated automatically by automake 1.3 from Makefile.am
# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. # Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation # This Makefile.in is free software; the Free Software Foundation
@ -32,7 +32,7 @@ mandir = @mandir@
includedir = @includedir@ includedir = @includedir@
oldincludedir = /usr/include oldincludedir = /usr/include
DESTDIR = DISTDIR =
pkgdatadir = $(datadir)/@PACKAGE@ pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@
@ -130,7 +130,7 @@ DIST_COMMON = Makefile.am Makefile.in macros.in rpmrc.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = gtar TAR = tar
GZIP = --best GZIP = --best
all: all-recursive all-am all: all-recursive all-am
@ -143,9 +143,9 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
rpmrc: $(top_builddir)/config.status rpmrc.in rpmrc: $(top_builddir)/config.status rpmrc.in
cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= ./config.status
macros: $(top_builddir)/config.status macros.in macros: $(top_builddir)/config.status macros.in
cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= ./config.status
# This directory's subdirectories are mostly independent; you can cd # This directory's subdirectories are mostly independent; you can cd
# into them and run `make' without going through this Makefile. # into them and run `make' without going through this Makefile.
@ -163,7 +163,7 @@ check-recursive installcheck-recursive info-recursive dvi-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \ list='$(SUBDIRS)'; for subdir in $$list; do \
target=`echo $@ | sed s/-recursive//`; \ target=`echo $@ | sed s/-recursive//`; \
echo "Making $$target in $$subdir"; \ echo "Making $$target in $$subdir"; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$target) \ (cd $$subdir && $(MAKE) $$target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done && test -z "$$fail" done && test -z "$$fail"
@ -176,12 +176,12 @@ maintainer-clean-recursive:
for subdir in $$rev; do \ for subdir in $$rev; do \
target=`echo $@ | sed s/-recursive//`; \ target=`echo $@ | sed s/-recursive//`; \
echo "Making $$target in $$subdir"; \ echo "Making $$target in $$subdir"; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$target) \ (cd $$subdir && $(MAKE) $$target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done && test -z "$$fail" done && test -z "$$fail"
tags-recursive: tags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \ list='$(SUBDIRS)'; for subdir in $$list; do \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ (cd $$subdir && $(MAKE) tags); \
done done
tags: TAGS tags: TAGS
@ -233,13 +233,13 @@ distdir: $(DISTFILES)
|| mkdir $(distdir)/$$subdir \ || mkdir $(distdir)/$$subdir \
|| exit 1; \ || exit 1; \
chmod 777 $(distdir)/$$subdir; \ chmod 777 $(distdir)/$$subdir; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$(top_distdir) distdir=../$(distdir)/$$subdir distdir) \ (cd $$subdir && $(MAKE) top_distdir=../$(top_distdir) distdir=../$(distdir)/$$subdir distdir) \
|| exit 1; \ || exit 1; \
done done
info: info-recursive info: info-recursive
dvi: dvi-recursive dvi: dvi-recursive
check: all-am check: all-am
$(MAKE) $(AM_MAKEFLAGS) check-recursive $(MAKE) check-recursive
installcheck: installcheck-recursive installcheck: installcheck-recursive
all-am: Makefile all-am: Makefile
@ -255,19 +255,24 @@ install: install-recursive
uninstall: uninstall-recursive uninstall: uninstall-recursive
install-strip: install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install
installdirs: installdirs-recursive installdirs: installdirs-recursive
mostlyclean-generic: mostlyclean-generic:
-test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
clean-generic: clean-generic:
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic: distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES) -rm -f Makefile $(DISTCLEANFILES)
-rm -f config.cache config.log stamp-h stamp-h[0-9]* -rm -f config.cache config.log stamp-h stamp-h[0-9]*
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic: maintainer-clean-generic:
-test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
-test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
mostlyclean-am: mostlyclean-tags mostlyclean-generic mostlyclean-am: mostlyclean-tags mostlyclean-generic
clean-am: clean-tags clean-generic mostlyclean-am clean-am: clean-tags clean-generic mostlyclean-am

View File

@ -1,4 +1,4 @@
# Makefile.in generated automatically by automake 1.3b from Makefile.am # Makefile.in generated automatically by automake 1.3 from Makefile.am
# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. # Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation # This Makefile.in is free software; the Free Software Foundation
@ -32,7 +32,7 @@ mandir = @mandir@
includedir = @includedir@ includedir = @includedir@
oldincludedir = /usr/include oldincludedir = /usr/include
DESTDIR = DISTDIR =
pkgdatadir = $(datadir)/@PACKAGE@ pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@
@ -143,7 +143,7 @@ DIST_COMMON = Makefile.am Makefile.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = gtar TAR = tar
GZIP = --best GZIP = --best
all: Makefile $(SCRIPTS) all: Makefile $(SCRIPTS)
@ -203,7 +203,7 @@ check-TESTS: $(TESTS)
info: info:
dvi: dvi:
check: all check: all
$(MAKE) $(AM_MAKEFLAGS) check-TESTS $(MAKE) check-TESTS
installcheck: installcheck:
install-exec: install-exec:
@$(NORMAL_INSTALL) @$(NORMAL_INSTALL)
@ -217,19 +217,24 @@ install: install-exec install-data all
uninstall: uninstall:
install-strip: install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install
installdirs: installdirs:
mostlyclean-generic: mostlyclean-generic:
-test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
clean-generic: clean-generic:
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic: distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES) -rm -f Makefile $(DISTCLEANFILES)
-rm -f config.cache config.log stamp-h stamp-h[0-9]* -rm -f config.cache config.log stamp-h stamp-h[0-9]*
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic: maintainer-clean-generic:
-test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
-test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
mostlyclean: mostlyclean-generic mostlyclean: mostlyclean-generic
clean: clean-generic mostlyclean clean: clean-generic mostlyclean

View File

@ -1,4 +1,4 @@
# Makefile.in generated automatically by automake 1.3b from Makefile.am # Makefile.in generated automatically by automake 1.3 from Makefile.am
# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. # Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation # This Makefile.in is free software; the Free Software Foundation
@ -34,7 +34,7 @@ mandir = @mandir@
includedir = @includedir@ includedir = @includedir@
oldincludedir = /usr/include oldincludedir = /usr/include
DESTDIR = DISTDIR =
pkgdatadir = $(datadir)/@PACKAGE@ pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@
@ -184,14 +184,14 @@ rpmputtext_OBJECTS = rpmgettext.o
rpmputtext_DEPENDENCIES = rpmputtext_DEPENDENCIES =
rpmputtext_LDFLAGS = rpmputtext_LDFLAGS =
CFLAGS = @CFLAGS@ CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
LINK = $(CC) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ LINK = $(CC) $(CFLAGS) $(LDFLAGS) -o $@
DIST_COMMON = Makefile.am Makefile.in DIST_COMMON = Makefile.am Makefile.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = gtar TAR = tar
GZIP = --best GZIP = --best
DEP_FILES = .deps/dump.P .deps/dumpdb.P .deps/rpmarchive.P \ DEP_FILES = .deps/dump.P .deps/dumpdb.P .deps/rpmarchive.P \
.deps/rpmgettext.P .deps/rpmheader.P .deps/rpmlead.P \ .deps/rpmgettext.P .deps/rpmheader.P .deps/rpmlead.P \
@ -336,6 +336,7 @@ maintainer-clean-depend:
info: info:
dvi: dvi:
check: all check: all
$(MAKE)
installcheck: installcheck:
install-exec: install-exec:
@$(NORMAL_INSTALL) @$(NORMAL_INSTALL)
@ -349,19 +350,24 @@ install: install-exec install-data all
uninstall: uninstall:
install-strip: install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install
installdirs: installdirs:
mostlyclean-generic: mostlyclean-generic:
-test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
clean-generic: clean-generic:
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic: distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES) -rm -f Makefile $(DISTCLEANFILES)
-rm -f config.cache config.log stamp-h stamp-h[0-9]* -rm -f config.cache config.log stamp-h stamp-h[0-9]*
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic: maintainer-clean-generic:
-test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
-test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
mostlyclean: mostlyclean-noinstPROGRAMS mostlyclean-compile \ mostlyclean: mostlyclean-noinstPROGRAMS mostlyclean-compile \
mostlyclean-tags mostlyclean-depend mostlyclean-generic mostlyclean-tags mostlyclean-depend mostlyclean-generic

View File

@ -74,17 +74,17 @@ static int verifyHeader(char * prefix, Header h, int verifyFlags) {
} }
static int verifyDependencies(rpmdb db, Header h) { static int verifyDependencies(rpmdb db, Header h) {
rpmDependencies rpmdep; rpmTransactionSet rpmdep;
struct rpmDependencyConflict * conflicts; struct rpmDependencyConflict * conflicts;
int numConflicts; int numConflicts;
char * name, * version, * release; char * name, * version, * release;
int type, count, i; int type, count, i;
rpmdep = rpmdepDependencies(db); rpmdep = rpmtransCreateSet(db, NULL);
rpmdepAddPackage(rpmdep, h, NULL); rpmtransAddPackage(rpmdep, h, NULL, NULL, 0, NULL);
rpmdepCheck(rpmdep, &conflicts, &numConflicts); rpmdepCheck(rpmdep, &conflicts, &numConflicts);
rpmdepDone(rpmdep); rpmtransFree(rpmdep);
if (numConflicts) { if (numConflicts) {
headerGetEntry(h, RPMTAG_NAME, &type, (void **) &name, &count); headerGetEntry(h, RPMTAG_NAME, &type, (void **) &name, &count);
@ -161,7 +161,6 @@ int doVerify(char * prefix, enum verifysources source, char ** argv,
rpmdb db; rpmdb db;
dbiIndexSet matches; dbiIndexSet matches;
char * arg; char * arg;
char path[PATH_MAX];
ec = 0; ec = 0;
if (source == VERIFY_RPM && !(verifyFlags & VERIFY_DEPS)) { if (source == VERIFY_RPM && !(verifyFlags & VERIFY_DEPS)) {