[pacman-dev] [PATCH] New --asexplicit option
From 99a8136cb82d75795a3224baf09ab5ca728e6bd9 Mon Sep 17 00:00:00 2001 From: Nagy Gabor <ngaba@bibl.u-szeged.hu> Date: Sat, 12 Jan 2008 17:08:03 +0100 Subject: [PATCH] New --asexplicit option This is the brother 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. A typo was also fixed in the manual. Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> --- contrib/bash_completion | 2 ++ contrib/zsh_completion | 1 + doc/pacman.8.txt | 7 ++++++- lib/libalpm/add.c | 17 ++++++++--------- lib/libalpm/alpm.h | 3 ++- pactest/tests/sync031.py | 19 +++++++++++++++++++ pactest/tests/upgrade032.py | 19 +++++++++++++++++++ src/pacman/pacman.c | 7 +++++++ 8 files changed, 64 insertions(+), 11 deletions(-) create mode 100644 pactest/tests/sync031.py create mode 100644 pactest/tests/upgrade032.py diff --git a/contrib/bash_completion b/contrib/bash_completion index 7719285..bb30ffd 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 5ea6c33..d0b9e8d 100644 --- a/contrib/zsh_completion +++ b/contrib/zsh_completion @@ -90,6 +90,7 @@ _pacman_opts_sync_modifiers=( '*--ignore[Ignore a package upgrade]:package:_pacman_completions_installed_packages' '*--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 0da83a6..5a64f1a 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, force their install reason to + explicit. 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 72b8934..5f0fbde 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 4797fcf..002cabc 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 0000000..4aa2ee3 --- /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 0000000..85e048e --- /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 1aa2968..da68f1d 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; -- 1.5.3.7
Nagy Gabor wrote:
diff --git a/doc/pacman.8.txt b/doc/pacman.8.txt index 0da83a6..5a64f1a 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, force their install reason to + explicit. 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
It would be nice if native english speakers could review the formulation of these two options. For example what is better between : in other words, fake their install reason to be installed as a dependency. and in other words, force their install reason to explicit Both sound a bit strange to me. Also, I believe it should be : 'if you want *to* mark a dependency...'
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c index 72b8934..5f0fbde 100644 --- a/lib/libalpm/add.c +++ b/lib/libalpm/add.c
@@ -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)) {
Just leaving that comment alone here looks strange : /* copy over the install reason */ Why not simply remove it? The rest looks fine to me, thanks for the patch.
2008/1/12, Nagy Gabor <ngaba@bibl.u-szeged.hu>:
From 99a8136cb82d75795a3224baf09ab5ca728e6bd9 Mon Sep 17 00:00:00 2001 From: Nagy Gabor <ngaba@bibl.u-szeged.hu> Date: Sat, 12 Jan 2008 17:08:03 +0100 Subject: [PATCH] New --asexplicit option
This is the brother 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.
A typo was also fixed in the manual.
Can you give an example of --asexplicit usage? For --asdeps (as I see it): if one did -Rd pkg (or replaced with pkg2 that conflicts/privides pkg) then -U/-S pkg --asdeps will restore the "installed as a dependency of another package" status. But for --asexplicit I'm a bit confused. I can think only about -S pkg --asexplicit when pkg _is_already_installed_ as a dependency - that would turn that package to "explicitly installed". But this is the same as -Rd then -S... :-/ Please enlighten me. -- Roman Kyrylych (Роман Кирилич)
Roman Kyrylych wrote:
2008/1/12, Nagy Gabor<ngaba@bibl.u-szeged.hu>:
From 99a8136cb82d75795a3224baf09ab5ca728e6bd9 Mon Sep 17 00:00:00 2001 From: Nagy Gabor<ngaba@bibl.u-szeged.hu> Date: Sat, 12 Jan 2008 17:08:03 +0100 Subject: [PATCH] New --asexplicit option
This is the brother 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.
A typo was also fixed in the manual.
Can you give an example of --asexplicit usage?
For --asdeps (as I see it): if one did -Rd pkg (or replaced with pkg2 that conflicts/privides pkg) then -U/-S pkg --asdeps will restore the "installed as a dependency of another package" status.
But for --asexplicit I'm a bit confused. I can think only about -S pkg --asexplicit when pkg _is_already_installed_ as a dependency - that would turn that package to "explicitly installed". But this is the same as -Rd then -S... :-/ Please enlighten me.
It's exactly for that second case, and it can indeed probably be achieved with -Rd then -S. But it would be possible without using -Rd, so it would be nicer.
2008/1/12, Xavier <shiningxc@gmail.com>:
Roman Kyrylych wrote:
2008/1/12, Nagy Gabor<ngaba@bibl.u-szeged.hu>:
From 99a8136cb82d75795a3224baf09ab5ca728e6bd9 Mon Sep 17 00:00:00 2001 From: Nagy Gabor<ngaba@bibl.u-szeged.hu> Date: Sat, 12 Jan 2008 17:08:03 +0100 Subject: [PATCH] New --asexplicit option
This is the brother 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.
A typo was also fixed in the manual.
Can you give an example of --asexplicit usage?
For --asdeps (as I see it): if one did -Rd pkg (or replaced with pkg2 that conflicts/privides pkg) then -U/-S pkg --asdeps will restore the "installed as a dependency of another package" status.
But for --asexplicit I'm a bit confused. I can think only about -S pkg --asexplicit when pkg _is_already_installed_ as a dependency - that would turn that package to "explicitly installed". But this is the same as -Rd then -S... :-/ Please enlighten me.
It's exactly for that second case, and it can indeed probably be achieved with -Rd then -S. But it would be possible without using -Rd, so it would be nicer.
Ah, ok. I agree -S --asexplicit looks more cleaner. -- Roman Kyrylych (Роман Кирилич)
But for --asexplicit I'm a bit confused. I can think only about -S pkg --asexplicit when pkg _is_already_installed_ as a dependency - that would turn that package to "explicitly installed". But this is the same as -Rd then -S... :-/ Please enlighten me.
And theoretically you can mark all the pulled dependencies as explicit. I don't know any reason for doing that, but it is also possible now. Bye ---------------------------------------------------- SZTE Egyetemi Könyvtár - http://www.bibl.u-szeged.hu This mail sent through IMP: http://horde.org/imp/
participants (3)
-
Nagy Gabor
-
Roman Kyrylych
-
Xavier