FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 01-12-2008, 03:11 PM
Nagy Gabor
 
Default 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]ackage:_pacman_completions_installed_packages'
'*--ignoregroup[Ignore a group upgrade]ackage 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>
", str_usg, myname, str_opt, str_file);
printf("%s:
", str_opt);
printf(_(" --asdeps install packages as non-explicitly installed
"));
+ printf(_(" --asexplicit install packages as explicitly installed
"));
printf(_(" -d, --nodeps skip dependency checks
"));
printf(_(" -f, --force force install, overwrite conflicting files
"));
} 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>
", str_usg, myname, str_opt, str_file);
printf("%s:
", str_opt);
printf(_(" --asdeps install packages as non-explicitly installed
"));
+ printf(_(" --asexplicit install packages as explicitly installed
"));
printf(_(" -d, --nodeps skip dependency checks
"));
printf(_(" -f, --force force install, overwrite conflicting files
"));
} 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]
", str_usg, myname, str_opt, str_pkg);
printf("%s:
", str_opt);
printf(_(" --asdeps install packages as non-explicitly installed
"));
+ printf(_(" --asexplicit install packages as explicitly installed
"));
printf(_(" -c, --clean remove old packages from cache directory (-cc for all)
"));
printf(_(" -d, --nodeps skip dependency checks
"));
printf(_(" -e, --dependsonly install dependencies only
"));
@@ -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


_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev
 

Thread Tools




All times are GMT. The time now is 01:08 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org