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>
This commit is contained in:
Nagy Gabor 2008-01-13 22:15:10 +01:00 committed by Dan McGee
parent b2914bf0af
commit 2a7101c049
8 changed files with 64 additions and 11 deletions

View File

@ -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 \

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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 */

19
pactest/tests/sync031.py Normal file
View File

@ -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")

View File

@ -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")

View File

@ -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;