diff options
author | Nagy Gabor <ngaba@bibl.u-szeged.hu> | 2008-01-13 22:15:10 +0100 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2008-01-22 02:39:26 +0100 |
commit | 2a7101c049dd1874da09d7d120f8855c61e55809 (patch) | |
tree | cd25104f2e775be279c4c49f4cd8579b8d174dbe | |
parent | b2914bf0af388f369865859292b1c7342e785303 (diff) | |
download | pacman-2a7101c049dd1874da09d7d120f8855c61e55809.tar.gz pacman-2a7101c049dd1874da09d7d120f8855c61e55809.tar.xz |
New --asexplicit option
This is the symmetric of --asdeps, install packages explicitly.
Documentation and completion files were updated accordingly.
Added sync301.py and upgrade032.py pactest files to test this.
I also made a little modification in ALLDEPS handling too.
Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
-rw-r--r-- | contrib/bash_completion | 2 | ||||
-rw-r--r-- | contrib/zsh_completion | 1 | ||||
-rw-r--r-- | doc/pacman.8.txt | 7 | ||||
-rw-r--r-- | lib/libalpm/add.c | 17 | ||||
-rw-r--r-- | lib/libalpm/alpm.h | 3 | ||||
-rw-r--r-- | pactest/tests/sync031.py | 19 | ||||
-rw-r--r-- | pactest/tests/upgrade032.py | 19 | ||||
-rw-r--r-- | src/pacman/pacman.c | 7 |
8 files changed, 64 insertions, 11 deletions
diff --git a/contrib/bash_completion b/contrib/bash_completion index 77192858..bb30ffd0 100644 --- a/contrib/bash_completion +++ b/contrib/bash_completion @@ -219,6 +219,7 @@ _pacman () A|U) COMPREPLY=( $( compgen -W '\ --asdeps \ + --asexplicit \ -d --nodeps \ -f --force \ -h --help \ @@ -257,6 +258,7 @@ _pacman () S) COMPREPLY=( $( compgen -W '\ --asdeps \ + --asexplicit \ -c --clean \ -d --nodeps \ -e --dependsonly \ diff --git a/contrib/zsh_completion b/contrib/zsh_completion index 8dec06df..e5ad92b7 100644 --- a/contrib/zsh_completion +++ b/contrib/zsh_completion @@ -91,6 +91,7 @@ _pacman_opts_sync_modifiers=( '*--ignoregroup[Ignore a group upgrade]:package group: _pacman_completions_all_groups' '--asdeps[Install packages as non-explicitly installed]' + '--asexplicit[Install packages as explicitly installed]' ) # handles --action subcommand diff --git a/doc/pacman.8.txt b/doc/pacman.8.txt index f6eb69c3..c17700d7 100644 --- a/doc/pacman.8.txt +++ b/doc/pacman.8.txt @@ -86,11 +86,16 @@ You can also use `pacman -Su` to upgrade all packages that are out of date. See Options ------- *\--asdeps*:: - Install packages non-explicitly; in other works, fake their install reason + Install packages non-explicitly; in other words, fake their install reason to be installed as a dependency. This is useful for makepkg and other build from source tools that need to install dependencies before building the package. +*\--asexplicit*:: + Install packages explicitly; in other words, fake their install reason to + be explicitly installed. This is useful if you want mark a dependency as + explictly installed. + *-b, \--dbpath* <'path'>:: Specify an alternative database location (a typical default is ``/var/lib/pacman''). This should not be used unless you know what you are diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c index 72b89345..5f0fbdef 100644 --- a/lib/libalpm/add.c +++ b/lib/libalpm/add.c @@ -99,10 +99,6 @@ int _alpm_add_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name) } } - if(trans->flags & PM_TRANS_FLAG_ALLDEPS) { - pkg->reason = PM_PKG_REASON_DEPEND; - } - /* add the package to the transaction */ trans->packages = alpm_list_add(trans->packages, pkg); @@ -671,12 +667,8 @@ static int commit_single_pkg(pmpkg_t *newpkg, int pkg_current, int pkg_count, /* we'll need to save some record for backup checks later */ oldpkg = _alpm_pkg_dup(local); - /* copy over the install reason (unless alldeps is set) */ - if(trans->flags & PM_TRANS_FLAG_ALLDEPS) { - newpkg->reason = PM_PKG_REASON_DEPEND; - } else { + /* copy over the install reason */ newpkg->reason = alpm_pkg_get_reason(local); - } /* pre_upgrade scriptlet */ if(alpm_pkg_has_scriptlet(newpkg) && !(trans->flags & PM_TRANS_FLAG_NOSCRIPTLET)) { @@ -697,6 +689,13 @@ static int commit_single_pkg(pmpkg_t *newpkg, int pkg_current, int pkg_count, } } + /* we override any pre-set reason if we have alldeps or allexplicit set */ + if(trans->flags & PM_TRANS_FLAG_ALLDEPS) { + newpkg->reason = PM_PKG_REASON_DEPEND; + } else if(trans->flags & PM_TRANS_FLAG_ALLEXPLICIT) { + newpkg->reason = PM_PKG_REASON_EXPLICIT; + } + if(oldpkg) { /* set up fake remove transaction */ int ret = upgrade_remove(oldpkg, newpkg, trans, db); diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 49580c0e..0d65cff4 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -287,7 +287,8 @@ typedef enum _pmtransflag_t { PM_TRANS_FLAG_NOSCRIPTLET = 0x400, PM_TRANS_FLAG_NOCONFLICTS = 0x800, PM_TRANS_FLAG_PRINTURIS = 0x1000, - PM_TRANS_FLAG_NEEDED = 0x2000 + PM_TRANS_FLAG_NEEDED = 0x2000, + PM_TRANS_FLAG_ALLEXPLICIT = 0x4000 } pmtransflag_t; /* Transaction Events */ diff --git a/pactest/tests/sync031.py b/pactest/tests/sync031.py new file mode 100644 index 00000000..4aa2ee39 --- /dev/null +++ b/pactest/tests/sync031.py @@ -0,0 +1,19 @@ +self.description = "Sync packages explicitly" + +lp1 = pmpkg("pkg1") +lp1.reason = 1 +self.addpkg2db("local", lp1) + +p1 = pmpkg("pkg1", "1.0-2") +p2 = pmpkg("pkg2", "1.0-2") + +for p in p1, p2: + self.addpkg2db("sync", p) + +self.args = "-S --asexplicit %s" % " ".join([p.name for p in p1, p2]) + +self.addrule("PACMAN_RETCODE=0") +self.addrule("PKG_VERSION=pkg1|1.0-2") +self.addrule("PKG_VERSION=pkg2|1.0-2") +self.addrule("PKG_REASON=pkg1|0") +self.addrule("PKG_REASON=pkg2|0") diff --git a/pactest/tests/upgrade032.py b/pactest/tests/upgrade032.py new file mode 100644 index 00000000..85e048e0 --- /dev/null +++ b/pactest/tests/upgrade032.py @@ -0,0 +1,19 @@ +self.description = "Install packages explicitly" + +lp1 = pmpkg("pkg1") +lp1.reason = 1 +self.addpkg2db("local", lp1) + +p1 = pmpkg("pkg1", "1.0-2") +p2 = pmpkg("pkg2", "1.0-2") + +for p in p1, p2: + self.addpkg(p) + +self.args = "-U --asexplicit %s" % " ".join([p.filename() for p in p1, p2]) + +self.addrule("PACMAN_RETCODE=0") +self.addrule("PKG_VERSION=pkg1|1.0-2") +self.addrule("PKG_VERSION=pkg2|1.0-2") +self.addrule("PKG_REASON=pkg1|0") +self.addrule("PKG_REASON=pkg2|0") diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 27130254..61e0042a 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -79,6 +79,7 @@ static void usage(int op, const char * const myname) printf("%s: %s {-A --add} [%s] <%s>\n", str_usg, myname, str_opt, str_file); printf("%s:\n", str_opt); printf(_(" --asdeps install packages as non-explicitly installed\n")); + printf(_(" --asexplicit install packages as explicitly installed\n")); printf(_(" -d, --nodeps skip dependency checks\n")); printf(_(" -f, --force force install, overwrite conflicting files\n")); } else if(op == PM_OP_REMOVE) { @@ -93,6 +94,7 @@ static void usage(int op, const char * const myname) printf("%s: %s {-U --upgrade} [%s] <%s>\n", str_usg, myname, str_opt, str_file); printf("%s:\n", str_opt); printf(_(" --asdeps install packages as non-explicitly installed\n")); + printf(_(" --asexplicit install packages as explicitly installed\n")); printf(_(" -d, --nodeps skip dependency checks\n")); printf(_(" -f, --force force install, overwrite conflicting files\n")); } else if(op == PM_OP_QUERY) { @@ -115,6 +117,7 @@ static void usage(int op, const char * const myname) printf("%s: %s {-S --sync} [%s] [%s]\n", str_usg, myname, str_opt, str_pkg); printf("%s:\n", str_opt); printf(_(" --asdeps install packages as non-explicitly installed\n")); + printf(_(" --asexplicit install packages as explicitly installed\n")); printf(_(" -c, --clean remove old packages from cache directory (-cc for all)\n")); printf(_(" -d, --nodeps skip dependency checks\n")); printf(_(" -e, --dependsonly install dependencies only\n")); @@ -341,6 +344,7 @@ static int parseargs(int argc, char *argv[]) {"logfile", required_argument, 0, 1009}, {"ignoregroup", required_argument, 0, 1010}, {"needed", no_argument, 0, 1011}, + {"asexplicit", no_argument, 0, 1012}, {0, 0, 0, 0} }; @@ -412,6 +416,9 @@ static int parseargs(int argc, char *argv[]) FREELIST(list); break; case 1011: config->flags |= PM_TRANS_FLAG_NEEDED; break; + case 1012: + config->flags |= PM_TRANS_FLAG_ALLEXPLICIT; + break; case 'A': config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_ADD); break; case 'Q': config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_QUERY); break; case 'R': config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_REMOVE); break; |