From 88c73d4d65d7f3fd7bd9a9777f6816d5896cfa4a Mon Sep 17 00:00:00 2001 From: Judd Vinet Date: Tue, 2 Mar 2004 04:49:15 +0000 Subject: Imported from pacman-2.7.5.tar.gz --- ChangeLog | 5 +++ Makefile.in | 2 +- doc/pacman.8.in | 12 ++++-- etc/pacman.conf | 1 - scripts/gensync | 2 +- scripts/makepkg | 2 +- scripts/makeworld | 2 +- src/convertdb.c | 2 +- src/db.c | 2 +- src/db.h | 2 +- src/list.c | 2 +- src/list.h | 2 +- src/package.c | 5 ++- src/package.h | 2 +- src/pacman.c | 124 ++++++++++++++++++++++++++++++++++++++++++++++-------- src/pacman.h | 5 ++- src/pacsync.c | 4 +- src/pacsync.h | 2 +- src/rpmvercmp.c | 2 +- src/rpmvercmp.h | 2 +- src/util.c | 2 +- src/util.h | 2 +- src/vercmp.c | 2 +- 23 files changed, 146 insertions(+), 42 deletions(-) diff --git a/ChangeLog b/ChangeLog index f1b87d4c..6d6608fd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ VERSION DESCRIPTION ----------------------------------------------------------------------------- +2.7.5 - "replaces" packages were ignoring IgnorePkg in pacman.conf + - fixed another bug in conflict handling + - found an out-dated reference to /usr/abs, fixed + - added a --recursive option for package removal, which removes + all deps of a target that aren't required by other packages 2.7.4 - fixed a bug in conflict handling, where installing a conflicting package would fail even if the new package "provided" it diff --git a/Makefile.in b/Makefile.in index d9fa642b..6ebe3928 100644 --- a/Makefile.in +++ b/Makefile.in @@ -34,7 +34,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) INSTALL_DATA = @INSTALL_DATA@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ -PACVER = 2.7.4 +PACVER = 2.7.5 TOPDIR = @srcdir@ SRCDIR = $(TOPDIR)/src/ diff --git a/doc/pacman.8.in b/doc/pacman.8.in index 622b6860..a8393fd9 100644 --- a/doc/pacman.8.in +++ b/doc/pacman.8.in @@ -87,6 +87,12 @@ which is "owned" by another system. By using this option you not only specify where the software should be installed, but you also specify which package database to use. .TP +.B "\-s, \-\-recursive" +(only used with \fB--remove\fP) +For each target specified, remove it and all its dependencies, provided +they are not required by other packages. This option is analagous to +a backwards --sync operation. +.TP .B "\-v, \-\-verbose" Output more status and error messages. .SH SYNC OPTIONS @@ -240,16 +246,16 @@ want to use a local directory, you can specify the full path with a 'file://' pr shown above. .SH USING YOUR OWN REPOSITORY Let's say you have a bunch of custom packages in \fI/home/pkgs\fP and their respective PKGBUILD -files are all in \fI/usr/abs/local\fP. All you need to do is generate a compressed package database +files are all in \fI/var/abs/local\fP. All you need to do is generate a compressed package database in the \fI/home/pkgs\fP directory so pacman can find it when run with --refresh. .RS .nf -# gensync /usr/abs/local /home/pkgs/custom.db.tar.gz +# gensync /var/abs/local /home/pkgs/custom.db.tar.gz .fi .RE -The above command will read all PKGBUILD files in /usr/abs/local and generate a compressed +The above command will read all PKGBUILD files in /var/abs/local and generate a compressed database called /home/pkgs/custom.db.tar.gz. Note that the database must be of the form \fI{treename}.db.tar.gz\fP, where {treename} is the name of the section defined in the configuration file. diff --git a/etc/pacman.conf b/etc/pacman.conf index 7117c85d..bdf9de0e 100644 --- a/etc/pacman.conf +++ b/etc/pacman.conf @@ -23,7 +23,6 @@ NoUpgrade = etc/fstab etc/raidtab NoUpgrade = etc/rc.conf etc/rc.local NoUpgrade = etc/modprobe.conf etc/modules.conf NoUpgrade = etc/lilo.conf boot/grub/menu.lst -#IgnorePkg = lilo kernel # # REPOSITORIES diff --git a/scripts/gensync b/scripts/gensync index 4af3a86b..dd7e50a1 100755 --- a/scripts/gensync +++ b/scripts/gensync @@ -20,7 +20,7 @@ # USA. # -myver='2.7.4' +myver='2.7.5' usage() { echo "gensync $myver" diff --git a/scripts/makepkg b/scripts/makepkg index f3922b2b..f28da232 100755 --- a/scripts/makepkg +++ b/scripts/makepkg @@ -20,7 +20,7 @@ # USA. # -myver='2.7.4' +myver='2.7.5' startdir=`pwd` USE_COLOR="n" diff --git a/scripts/makeworld b/scripts/makeworld index bf273472..67c58ec2 100755 --- a/scripts/makeworld +++ b/scripts/makeworld @@ -21,7 +21,7 @@ # toplevel=`pwd` -version="2.7.4" +version="2.7.5" usage() { echo "makeworld version $version" diff --git a/src/convertdb.c b/src/convertdb.c index 0a414e54..cd6be3db 100644 --- a/src/convertdb.c +++ b/src/convertdb.c @@ -1,7 +1,7 @@ /* * convertdb.c * - * Copyright (c) 2002 by Judd Vinet + * Copyright (c) 2002-2004 by Judd Vinet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/db.c b/src/db.c index e70d0196..0f8b5a9e 100644 --- a/src/db.c +++ b/src/db.c @@ -1,7 +1,7 @@ /* * db.c * - * Copyright (c) 2002 by Judd Vinet + * Copyright (c) 2002-2004 by Judd Vinet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/db.h b/src/db.h index a26ad1c2..8d5282cf 100644 --- a/src/db.h +++ b/src/db.h @@ -1,7 +1,7 @@ /* * db.h * - * Copyright (c) 2002 by Judd Vinet + * Copyright (c) 2002-2004 by Judd Vinet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/list.c b/src/list.c index 8d1d2820..41d36d6a 100644 --- a/src/list.c +++ b/src/list.c @@ -1,7 +1,7 @@ /* * list.c * - * Copyright (c) 2002 by Judd Vinet + * Copyright (c) 2002-2004 by Judd Vinet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/list.h b/src/list.h index 929c7d91..4d24570b 100644 --- a/src/list.h +++ b/src/list.h @@ -1,7 +1,7 @@ /* * list.h * - * Copyright (c) 2002 by Judd Vinet + * Copyright (c) 2002-2004 by Judd Vinet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/package.c b/src/package.c index 6eeccd01..1c7359bd 100644 --- a/src/package.c +++ b/src/package.c @@ -1,7 +1,7 @@ /* * package.c * - * Copyright (c) 2002-2003 by Judd Vinet + * Copyright (c) 2002-2004 by Judd Vinet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -289,6 +289,9 @@ int is_pkgin(pkginfo_t *needle, PMList *haystack) { PMList *lp; pkginfo_t *info; + if(needle == NULL || haystack == NULL) { + return(0); + } for(lp = haystack; lp; lp = lp->next) { info = (pkginfo_t*)lp->data; diff --git a/src/package.h b/src/package.h index 4246486b..16678858 100644 --- a/src/package.h +++ b/src/package.h @@ -1,7 +1,7 @@ /* * package.h * - * Copyright (c) 2002 by Judd Vinet + * Copyright (c) 2002-2004 by Judd Vinet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/pacman.c b/src/pacman.c index 18e36395..0fc5eefa 100644 --- a/src/pacman.c +++ b/src/pacman.c @@ -69,6 +69,7 @@ unsigned short pmo_q_list = 0; unsigned short pmo_q_orphans = 0; unsigned short pmo_q_owns = 0; unsigned short pmo_r_cascade = 0; +unsigned short pmo_r_recurse = 0; unsigned short pmo_s_upgrade = 0; unsigned short pmo_s_downloadonly = 0; unsigned short pmo_s_sync = 0; @@ -549,10 +550,14 @@ int pacman_sync(pacdb_t *db, PMList *targets) for(m = pm_packages; m; m = m->next) { pkginfo_t *p = (pkginfo_t*)m->data; if(!strcmp(k->data, p->name)) { - /* if confirmed, add this to the 'final' list, designating 'p' as - * the package to replace. - */ - if(yesno(":: Replace %s with %s from \"%s\"? [Y/n] ", p->name, pkg->name, dbs->db->treename)) { + if(is_in(p->name, pmo_ignorepkg)) { + fprintf(stderr, ":: %s-%s: ignoring package upgrade (to be replaced by %s-%s)\n", + p->name, p->version, pkg->name, pkg->version); + ignore = 1; + } else if(yesno(":: Replace %s with %s from \"%s\"? [Y/n] ", p->name, pkg->name, dbs->db->treename)) { + /* if confirmed, add this to the 'final' list, designating 'p' as + * the package to replace. + */ syncpkg_t *sync = NULL; /* we save the dependency info so we can move p's requiredby stuff * over to the replacing package @@ -909,6 +914,15 @@ int pacman_sync(pacdb_t *db, PMList *targets) /* any packages in rmtargs need to be removed from final. */ /* rather than ripping out nodes from final, we just copy over */ /* our "good" nodes to a new list and reassign. */ + + /* XXX: this fails for cases where a requested package wants + * a dependency that conflicts with an older version of + * the package. It will be removed from final, and the user + * has to re-request it to get it installed properly. + * + * Not gonna happen very often, but should be dealt with... + * + */ k = NULL; for(i = final; i; i = i->next) { syncpkg_t *s = (syncpkg_t*)i->data; @@ -1114,11 +1128,36 @@ int pacman_sync(pacdb_t *db, PMList *targets) } } + if(allgood) { + /* Check dependencies of packages in rmtargs and make sure + * we won't be breaking anything by removing them. + * If a broken dep is detected, make sure it's not from a + * package that's in our final (upgrade) list. + */ + vprint("checking dependencies...\n"); + i = checkdeps(db, PM_REMOVE, rmtargs); + for(j = i; j; j = j->next) { + depmissing_t* miss = (depmissing_t*)j->data; + syncpkg_t *s = find_pkginsync(miss->depend.name, final); + if(s == NULL) { + if(allgood) { + fprintf(stderr, "error: this will break the following dependencies:\n"); + allgood = 0; + } + printf(" %s: is required by %s\n", miss->target, miss->depend.name); + } + } + FREELIST(i); + } + if(!pmo_s_downloadonly && allgood) { - /* remove any conflicting packages (WITH dep checks) */ + /* remove any conflicting packages (WITHOUT dep checks) */ if(rmtargs) { int retcode; + int oldupg = pmo_upgrade; + pmo_upgrade = 1; retcode = pacman_remove(db, rmtargs); + pmo_upgrade = oldupg; FREELIST(rmtargs); if(retcode == 1) { fprintf(stderr, "\nupgrade aborted.\n"); @@ -1820,20 +1859,12 @@ int pacman_remove(pacdb_t *db, PMList *targets) depmissing_t* miss = (depmissing_t*)j->data; info = db_scan(db, miss->depend.name, INFRQ_ALL); if(!is_pkgin(info, alltargs)) { - list_add(alltargs, info); + alltargs = list_add(alltargs, info); } } list_free(lp); lp = checkdeps(db, PM_REMOVE, alltargs); } - /* list targets */ - list_display("\nTargets:", alltargs); - /* get confirmation */ - if(yesno("\nDo you want to remove these packages? [Y/n] ") == 0) { - list_free(alltargs); - list_free(lp); - return(1); - } } else { fprintf(stderr, "error: this will break the following dependencies:\n"); for(j = lp; j; j = j->next) { @@ -1845,7 +1876,21 @@ int pacman_remove(pacdb_t *db, PMList *targets) return(1); } } - list_free(lp); + + if(pmo_r_recurse) { + vprint("finding removable dependencies...\n"); + alltargs = removedeps(db, alltargs); + } + + if(pmo_r_recurse || pmo_r_cascade) { + /* list targets */ + list_display("\nTargets:", alltargs); + /* get confirmation */ + if(yesno("\nDo you want to remove these packages? [Y/n] ") == 0) { + list_free(alltargs); + return(1); + } + } } for(targ = alltargs; targ; targ = targ->next) { @@ -2289,6 +2334,49 @@ PMList* sortbydeps(PMList *targets) return(targets); } +/* return a new PMList target list containing all packages in the original + * target list, as well as all their un-needed dependencies. By un-needed, + * I mean dependencies that are *only* required for packages in the target + * list, so they can be safely removed. This function is recursive. + */ +PMList* removedeps(pacdb_t *db, PMList *targs) +{ + PMList *i, *j, *k; + PMList *newtargs = targs; + + for(i = targs; i; i = i->next) { + pkginfo_t *pkg = (pkginfo_t*)i->data; + for(j = pkg->depends; j; j = j->next) { + depend_t depend; + pkginfo_t *dep; + int needed = 0; + if(splitdep(j->data, &depend)) { + continue; + } + dep = db_scan(db, depend.name, INFRQ_DESC | INFRQ_DEPENDS); + if(is_pkgin(dep, targs)) { + continue; + } + /* see if other packages need it */ + for(k = dep->requiredby; k && !needed; k = k->next) { + pkginfo_t *dummy = db_scan(db, k->data, INFRQ_DESC); + if(!is_pkgin(dummy, targs)) { + needed = 1; + } + } + if(!needed) { + /* add it to the target list */ + freepkg(dep); + dep = db_scan(db, depend.name, INFRQ_ALL); + newtargs = list_add(newtargs, dep); + newtargs = removedeps(db, newtargs); + } + } + } + + return(newtargs); +} + /* populates *list with packages that need to be installed to satisfy all * dependencies (recursive) for *syncpkg->pkg * @@ -2814,6 +2902,7 @@ int parseargs(int op, int argc, char **argv) {"downloadonly", no_argument, 0, 'w'}, {"refresh", no_argument, 0, 'y'}, {"cascade", no_argument, 0, 'c'}, + {"recursive", no_argument, 0, 's'}, {"groups", no_argument, 0, 'g'}, {0, 0, 0, 0} }; @@ -2850,7 +2939,7 @@ int parseargs(int op, int argc, char **argv) perror("bad root path"); return(1); } break; - case 's': pmo_s_search = 1; break; + case 's': pmo_s_search = 1; pmo_r_recurse = 1; break; case 'u': pmo_s_upgrade = 1; break; case 'v': pmo_verbose = 1; break; case 'w': pmo_s_downloadonly = 1; break; @@ -3113,6 +3202,7 @@ void usage(int op, char *myname) printf(" -c, --cascade remove packages and all packages that depend on them\n"); printf(" -d, --nodeps skip dependency checks\n"); printf(" -n, --nosave remove configuration files as well\n"); + printf(" -s, --recursive remove dependencies also (that won't break packages)\n"); } else if(op == PM_UPGRADE) { if(pmo_freshen) { printf("usage: %s {-F --freshen} [options] \n", myname); @@ -3157,7 +3247,7 @@ void version(void) { printf("\n"); printf(" .--. Pacman v%s\n", PACVER); - printf("/ _.-' .-. .-. .-. Copyright (C) 2002-2003 Judd Vinet \n"); + printf("/ _.-' .-. .-. .-. Copyright (C) 2002-2004 Judd Vinet \n"); printf("\\ '-. '-' '-' '-' \n"); printf(" '--' This program may be freely redistributed under\n"); printf(" the terms of the GNU General Public License\n\n"); diff --git a/src/pacman.h b/src/pacman.h index 9c693a69..05775fd8 100644 --- a/src/pacman.h +++ b/src/pacman.h @@ -1,7 +1,7 @@ /* * pacman.h * - * Copyright (c) 2002 by Judd Vinet + * Copyright (c) 2002-2004 by Judd Vinet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,7 +22,7 @@ #define _PAC_PACMAN_H #ifndef PACVER -#define PACVER "2.7.4" +#define PACVER "2.7.5" #endif #ifndef PKGDIR @@ -53,6 +53,7 @@ int pacman_deptest(pacdb_t *db, PMList *targets); PMList* sortbydeps(PMList *targets); PMList* checkdeps(pacdb_t *db, unsigned short op, PMList *targets); +PMList* removedeps(pacdb_t *db, PMList *targs); int resolvedeps(pacdb_t *local, PMList *databases, syncpkg_t *sync, PMList *list, PMList *trail); int splitdep(char *depstr, depend_t *depend); diff --git a/src/pacsync.c b/src/pacsync.c index 196e1c92..b171565c 100644 --- a/src/pacsync.c +++ b/src/pacsync.c @@ -1,7 +1,7 @@ /* * pacsync.c * - * Copyright (c) 2002 by Judd Vinet + * Copyright (c) 2002-2004 by Judd Vinet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -346,7 +346,7 @@ static int log_progress(netbuf *ctl, int xfered, void *arg) syncpkg_t* find_pkginsync(char *needle, PMList *haystack) { PMList *i; - syncpkg_t *sync; + syncpkg_t *sync = NULL; int found = 0; for(i = haystack; i && !found; i = i->next) { diff --git a/src/pacsync.h b/src/pacsync.h index fe9b5ba3..9a4846e2 100644 --- a/src/pacsync.h +++ b/src/pacsync.h @@ -1,7 +1,7 @@ /* * pacsync.h * - * Copyright (c) 2002 by Judd Vinet + * Copyright (c) 2002-2004 by Judd Vinet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/rpmvercmp.c b/src/rpmvercmp.c index 7805be0c..3de46fd7 100644 --- a/src/rpmvercmp.c +++ b/src/rpmvercmp.c @@ -1,7 +1,7 @@ /* * rpmvercmp.c * - * Copyright (c) 2002 by Judd Vinet + * Copyright (c) 2002-2004 by Judd Vinet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/rpmvercmp.h b/src/rpmvercmp.h index ab5594d8..be030c6c 100644 --- a/src/rpmvercmp.h +++ b/src/rpmvercmp.h @@ -1,7 +1,7 @@ /* * rpmvercmp.h * - * Copyright (c) 2002 by Judd Vinet + * Copyright (c) 2002-2004 by Judd Vinet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/util.c b/src/util.c index 32852816..c5f4d28d 100644 --- a/src/util.c +++ b/src/util.c @@ -1,7 +1,7 @@ /* * util.c * - * Copyright (c) 2002 by Judd Vinet + * Copyright (c) 2002-2004 by Judd Vinet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/util.h b/src/util.h index 7c1556aa..94114d4e 100644 --- a/src/util.h +++ b/src/util.h @@ -1,7 +1,7 @@ /* * util.h * - * Copyright (c) 2002 by Judd Vinet + * Copyright (c) 2002-2004 by Judd Vinet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/vercmp.c b/src/vercmp.c index 25172086..dc3833fb 100644 --- a/src/vercmp.c +++ b/src/vercmp.c @@ -1,7 +1,7 @@ /* * vercmp.c * - * Copyright (c) 2002 by Judd Vinet + * Copyright (c) 2002-2004 by Judd Vinet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by -- cgit v1.2.3-24-g4f1b