This patch offers a way to fix FS#9228.
By putting "UpgradeFirst = pacman" in pacman.conf, the version check will
happen before the transaction really starts, and before any replacements is
made.
Otherwise, no version check is done.
The sync301 pactest was updated to use this UpgradeFirst option.
Example session with UpgradeFirst = pacman, and a newer pacman version
available :
$ pacman -Su (or pacman -S <any targets>)
:: the following packages should be upgraded first :
pacman
:: Do you want to cancel the current operation
:: and upgrade these packages now? [Y/n]
resolving dependencies...
looking for inter-conflicts...
Targets: pacman-x.y.z-t
Total Download Size: x.xx MB
Total Installed Size: x.xx MB
Proceed with installation? [Y/n] n
As Nagy previously noted, doing this check on any -S operations might look
intrusive, but it can be required.
For example, the case where you want to install a package with versioned
provisions, using a pacman version which didn't support that feature yet
(and there is already a newer pacman in sync db supporting it).
diff --git a/doc/pacman.conf.5.txt b/doc/pacman.conf.5.txt
index e8f7454..c3bbb02 100644
--- a/doc/pacman.conf.5.txt
+++ b/doc/pacman.conf.5.txt
@@ -80,6 +80,12 @@ Options
Instructs pacman to ignore any upgrades for this package when performing
a '--sysupgrade'.
+*UpgradeFirst =* package ...::
+ Instructs pacman to check for newer version of these packages before any
+ '-S' or '-Su' operation. The user will then have the choice to either cancel
+ the current operation and upgrade these packages first or go on with the
+ current operation. This could typically be done for pacman itself.
+
*IgnoreGroup =* group ...::
Instructs pacman to ignore any upgrades for all packages in this
group when performing a '--sysupgrade'.
diff --git a/pactest/pmtest.py b/pactest/pmtest.py
index d54d7ba..db27410 100755
--- a/pactest/pmtest.py
+++ b/pactest/pmtest.py
@@ -83,7 +83,8 @@ class pmtest:
"noupgrade": [],
"ignorepkg": [],
"ignoregroup": [],
- "noextract": []
+ "noextract": [],
+ "upgradefirst": []
}
+ FREELIST(oldconfig->upgradefirst);
free(oldconfig->configfile);
free(oldconfig->rootdir);
free(oldconfig->dbpath);
diff --git a/src/pacman/conf.h b/src/pacman/conf.h
index f804f56..936abc3 100644
--- a/src/pacman/conf.h
+++ b/src/pacman/conf.h
@@ -70,6 +70,7 @@ typedef struct __config_t {
unsigned short totaldownload; /* When downloading, display the amount
downloaded, rate, ETA, and percent
downloaded of the total download list */
+ alpm_list_t *upgradefirst;
} config_t;
if(config->op_s_upgrade) {
- alpm_list_t *pkgs, *i;
printf(_(":: Starting full system upgrade...
"));
alpm_logaction("starting full system upgrade
");
if(alpm_trans_sysupgrade() == -1) {
@@ -521,39 +538,6 @@ static int sync_trans(alpm_list_t *targets)
retval = 1;
goto cleanup;
}
-
- if(!(alpm_trans_get_flags() & (PM_TRANS_FLAG_DOWNLOADONLY | PM_TRANS_FLAG_PRINTURIS))) {
- /* check if pacman itself is one of the packages to upgrade.
- * this can prevent some of the "syntax error" problems users can have
- * when sysupgrade'ing with an older version of pacman.
- */
- pkgs = alpm_trans_get_pkgs();
- for(i = pkgs; i; i = alpm_list_next(i)) {
- pmsyncpkg_t *sync = alpm_list_getdata(i);
- pmpkg_t *spkg = alpm_sync_get_pkg(sync);
- /* TODO pacman name should probably not be hardcoded. In addition, we
- * have problems on an -Syu if pacman has to pull in deps, so recommend
- * an '-S pacman' operation */
- if(strcmp("pacman", alpm_pkg_get_name(spkg)) == 0) {
- printf("
");
- printf(_(":: pacman has detected a newer version of itself.
"));
- if(yesno(_(":: Do you want to cancel the current operation
"
- ":: and install the new pacman version now? [Y/n] "))) {
- if(sync_trans_release() == -1) {
- return(1);
- }
- if(sync_trans_init(0) == -1) {
- return(1);
- }
- if(alpm_trans_addtarget("pacman") == -1) {
- fprintf(stderr, _("error: pacman: %s
"), alpm_strerrorlast());
- return(1);
- }
- break;
- }
- }
- }
- }
} else {
alpm_list_t *i;
@@ -792,7 +776,27 @@ int pacman_sync(alpm_list_t *targets)
}
if(needs_transaction()) {
- if(sync_trans(targets) == 1) {
+ alpm_list_t *targs = alpm_list_strdup(targets);
+ if(!(config->flags & (PM_TRANS_FLAG_DOWNLOADONLY | PM_TRANS_FLAG_PRINTURIS))) {
+ /* check for newer versions of packages to be upgraded first */
+ alpm_list_t *packages = upgradefirst();
+ if(packages) {
+ printf(_(":: the following packages should be upgraded first :
"));
+ list_display(" ", packages);
+ if(yesno(_(":: Do you want to cancel the current operation
"
+ ":: and upgrade these packages now? [Y/n] "))) {
+ FREELIST(targs);
+ targs = packages;
+ config->flags = 0;
+ config->op_s_upgrade = 0;
+ }
+ printf("
");
+ }
+ }
+
+ int ret = sync_trans(targs);
+ FREELIST(targs);
+ if(ret == 1) {
return(1);
}
}
--
1.5.4.2
_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev