[pacman-dev] pacman cold caches performance, too much stat()ing
Dimitrios Apostolou
jimis at gmx.net
Sat Dec 12 12:51:43 EST 2009
On Sat, 12 Dec 2009, Dimitrios Apostolou wrote:
> P.S. Is there some option --pretend I might have missed? What I need is to
> get exactly the same actions of "pacman -S blah" or "pacman -Su" until the
> Y/N prompt, as non-root user.
Regarding this issue, it's the first I tried to fix since I didn't want to
run my random changes as root. Fortunately I accidentaly found about -p
option (--print-uris) which does exactly what I need, so I quickly hacked
a -P (--pretend) version for sync operations, which runs as user and only
outputs package list and sizes.
I /think/ that this functionality is required by packagekit, so that it
can automatically notify the user when updates become available. I
remember on fedora something similar is "yum check-update".
Ofcourse it would be much nicer if it worked for all operations, not only
sync. For example in a recursive remove it could notify the user of all
packages that would be removed, the size to be freed etc without needing
root or locking the db. But I'll skip that part, since my focus is
elsewhere.
What do you think?
Dimitris
-------------- next part --------------
diff --git a/src/pacman/conf.h b/src/pacman/conf.h
index c97e5d7..26a4e37 100644
--- a/src/pacman/conf.h
+++ b/src/pacman/conf.h
@@ -60,6 +60,7 @@ typedef struct __config_t {
unsigned short op_s_search;
unsigned short op_s_upgrade;
unsigned short op_s_printuris;
+ unsigned short op_s_pretend;
unsigned short group;
pmtransflag_t flags;
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index ff6ef5c..02c93d0 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -130,6 +130,7 @@ static void usage(int op, const char * const myname)
printf(_(" -i, --info view package information\n"));
printf(_(" -l, --list <repo> view a list of packages in a repo\n"));
printf(_(" -p, --print-uris print out URIs for given packages and their dependencies\n"));
+ printf(_(" -P, --pretend just print what it /would/ do\n"));
printf(_(" -s, --search <regex> search remote repositories for matching strings\n"));
printf(_(" -u, --sysupgrade upgrade installed packages (-uu allows downgrade)\n"));
printf(_(" -w, --downloadonly download packages but do not install/upgrade anything\n"));
@@ -370,6 +371,7 @@ static int parseargs(int argc, char *argv[])
{"owns", no_argument, 0, 'o'},
{"file", no_argument, 0, 'p'},
{"print-uris", no_argument, 0, 'p'},
+ {"pretend", no_argument, 0, 'P'},
{"quiet", no_argument, 0, 'q'},
{"root", required_argument, 0, 'r'},
{"recursive", no_argument, 0, 's'},
@@ -398,7 +400,7 @@ static int parseargs(int argc, char *argv[])
{0, 0, 0, 0}
};
- while((opt = getopt_long(argc, argv, "RUQSTr:b:vkhscVfmnoldepqituwygz", opts, &option_index))) {
+ while((opt = getopt_long(argc, argv, "RUQSTr:b:vkhscVfmnoldepPqituwygz", opts, &option_index))) {
alpm_list_t *list = NULL, *item = NULL; /* lists for splitting strings */
if(opt < 0) {
@@ -512,6 +514,10 @@ static int parseargs(int argc, char *argv[])
config->flags |= PM_TRANS_FLAG_NOCONFLICTS;
config->flags |= PM_TRANS_FLAG_NOLOCK;
break;
+ case 'P':
+ config->op_s_pretend = 1;
+ config->flags |= PM_TRANS_FLAG_NOCONFLICTS;
+ config->flags |= PM_TRANS_FLAG_NOLOCK;
case 'q':
config->quiet = 1;
break;
diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index a2ef616..d32d30d 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -690,6 +690,9 @@ static int sync_trans(alpm_list_t *targets)
display_targets(alpm_trans_get_remove(), 0);
display_targets(alpm_trans_get_add(), 1);
+ if(config->op_s_pretend) {
+ goto cleanup;
+ }
printf("\n");
int confirm;
@@ -757,8 +760,8 @@ int pacman_sync(alpm_list_t *targets)
{
alpm_list_t *sync_dbs = NULL;
- /* Display only errors with -Sp and -Sw operations */
- if((config->flags & PM_TRANS_FLAG_DOWNLOADONLY) || config->op_s_printuris) {
+ /* Display only errors with -SP, -Sp and -Sw operations */
+ if((config->flags & PM_TRANS_FLAG_DOWNLOADONLY) || config->op_s_printuris || config->op_s_pretend) {
config->logmask &= ~PM_LOG_WARNING;
}
@@ -831,7 +834,7 @@ int pacman_sync(alpm_list_t *targets)
}
alpm_list_t *targs = alpm_list_strdup(targets);
- if(!(config->flags & PM_TRANS_FLAG_DOWNLOADONLY) && !config->op_s_printuris) {
+ if(!(config->flags & PM_TRANS_FLAG_DOWNLOADONLY) && !config->op_s_printuris && !config->op_s_pretend) {
/* check for newer versions of packages to be upgraded first */
alpm_list_t *packages = syncfirst();
if(packages) {
diff --git a/src/pacman/util.c b/src/pacman/util.c
index 115b367..1bd8be9 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -75,7 +75,8 @@ int needs_root(void)
if(config->op == PM_OP_UPGRADE || config->op == PM_OP_REMOVE || /* -U, -R */
(config->op == PM_OP_SYNC && (config->op_s_clean || config->op_s_sync || /* -Sc, -Sy */
(!config->group && !config->op_s_info && !config->op_q_list /* all other -S combinations, where */
- && !config->op_s_search && !config->op_s_printuris)))) { /* -g, -i, -l, -s, -p is not set */
+ && !config->op_s_search && !config->op_s_printuris
+ && !config->op_s_pretend)))) { /* -g, -i, -l, -s, -p, -P is not set */
return(1);
} else {
return(0);
More information about the pacman-dev
mailing list