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 02-14-2008, 09:04 PM
Chantry Xavier
 
Default Rework of check-for-new-pacman-version

This patch is primarily a fix for FS#9228.

The -Sy operation was moved to its own transaction, which allows us to do
the following steps :
1) refresh the database if asked
2) check if a new pacman version if available
if yes, initialize a "-S pacman" transaction.
If no, initialize the original -S or -Su transaction.

Note that the newversion check was extended to the "-S target" operation,
which is helpful in case of syncdb syntax change (see versioned provisions
for example)

Original-work-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
---
src/pacman/sync.c | 129 +++++++++++++++++++++++++++--------------------------
1 files changed, 66 insertions(+), 63 deletions(-)

diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index 27218d6..2dd03f3 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -202,6 +202,17 @@ static int sync_synctree(int level, alpm_list_t *syncs)
alpm_list_t *i;
int success = 0, ret;

+ if(alpm_trans_init(PM_TRANS_TYPE_SYNC, 0, cb_trans_evt,
+ cb_trans_conv, cb_trans_progress) == -1) {
+ fprintf(stderr, _("error: failed to init transaction (%s)
"),
+ alpm_strerrorlast());
+ if(pm_errno == PM_ERR_HANDLE_LOCK) {
+ printf(_(" if you're sure a package manager is not already
"
+ " running, you can remove %s.
"), alpm_option_get_lockfile());
+ }
+ return(0);
+ }
+
for(i = syncs; i; i = alpm_list_next(i)) {
pmdb_t *db = alpm_list_getdata(i);

@@ -229,10 +240,18 @@ static int sync_synctree(int level, alpm_list_t *syncs)
}
}

+ if(alpm_trans_release() == -1) {
+ fprintf(stderr, _("error: failed to release transaction (%s)
"),
+ alpm_strerrorlast());
+ return(0);
+ }
/* We should always succeed if at least one DB was upgraded - we may possibly
* fail later with unresolved deps, but that should be rare, and would be
* expected
*/
+ if(!success) {
+ fprintf(stderr, _("error: failed to synchronize any databases
"));
+ }
return(success > 0);
}

@@ -469,7 +488,22 @@ static int sync_list(alpm_list_t *syncs, alpm_list_t *targets)
return(0);
}

-static int sync_trans(alpm_list_t *targets, int sync_only)
+static int pacman_isoutofdate(void)
+{
+ pmpkg_t *pacman = alpm_db_get_pkg(alpm_option_get_localdb(), "pacman");
+ if(pacman == NULL) {
+ printf(_("Warning: no installed pacman package was found
"));
+ return(0);
+ }
+
+ if(alpm_sync_newversion(pacman, alpm_option_get_syncdbs())) {
+ return(1);
+ } else {
+ return(0);
+ }
+}
+
+static int sync_trans(alpm_list_t *targets)
{
int retval = 0;
alpm_list_t *data = NULL;
@@ -487,23 +521,8 @@ static int sync_trans(alpm_list_t *targets, int sync_only)
return(1);
}

- if(config->op_s_sync) {
- /* grab a fresh package list */
- printf(_(":: Synchronizing package databases...
"));
- alpm_logaction("synchronizing package lists
");
- if(!sync_synctree(config->op_s_sync, sync_dbs)) {
- fprintf(stderr, _("error: failed to synchronize any databases
"));
- retval = 1;
- goto cleanup;
- }
- if(sync_only) {
- goto cleanup;
- }
- }
-
if(config->op_s_upgrade) {
- alpm_list_t *pkgs, *i;
-
+ /* sysupgrade */
printf(_(":: Starting full system upgrade...
"));
alpm_logaction("starting full system upgrade
");
if(alpm_trans_sysupgrade() == -1) {
@@ -511,46 +530,6 @@ static int sync_trans(alpm_list_t *targets, int sync_only)
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(alpm_trans_release() == -1) {
- fprintf(stderr, _("error: failed to release transaction (%s)
"),
- alpm_strerrorlast());
- retval = 1;
- goto cleanup;
- }
- if(alpm_trans_init(PM_TRANS_TYPE_SYNC, config->flags,
- cb_trans_evt, cb_trans_conv, cb_trans_progress) == -1) {
- fprintf(stderr, _("error: failed to init transaction (%s)
"),
- alpm_strerrorlast());
- return(1);
- }
- if(alpm_trans_addtarget("pacman") == -1) {
- fprintf(stderr, _("error: pacman: %s
"), alpm_strerrorlast());
- retval = 1;
- goto cleanup;
- }
- break;
- }
- }
- }
- }
} else {
alpm_list_t *i;

@@ -756,7 +735,6 @@ cleanup:
int pacman_sync(alpm_list_t *targets)
{
alpm_list_t *sync_dbs = NULL;
- int sync_only = 0;

/* clean the cache */
if(config->op_s_clean) {
@@ -772,18 +750,43 @@ int pacman_sync(alpm_list_t *targets)
return(1);
}

- if(config->op_s_search || config->group
- || config->op_s_info || config->op_q_list) {
- sync_only = 1;
- } else if(targets == NULL && !(config->op_s_sync || config->op_s_upgrade)) {
+ if(targets == NULL && !(config->op_s_sync || config->op_s_upgrade)) {
/* don't proceed here unless we have an operation that doesn't require
* a target list */
pm_printf(PM_LOG_ERROR, _("no targets specified (use -h for help)
"));
return(1);
}

+ if(config->op_s_sync) {
+ /* grab a fresh package list */
+ printf(_(":: Synchronizing package databases...
"));
+ alpm_logaction("synchronizing package lists
");
+ if(!sync_synctree(config->op_s_sync, sync_dbs)) {
+ return(1);
+ }
+ config->op_s_sync = 0;
+ }
+
if(needs_transaction()) {
- if(sync_trans(targets, sync_only) == 1) {
+ alpm_list_t *targs = alpm_list_strdup(targets);
+ if(!(config->flags & (PM_TRANS_FLAG_DOWNLOADONLY | PM_TRANS_FLAG_PRINTURIS))) {
+ /* check for new pacman version */
+ if(pacman_isoutofdate()) {
+ 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] "))) {
+ FREELIST(targs);
+ targs = alpm_list_add(targs, strdup("pacman"));
+ config->flags = 0;
+ config->op_s_upgrade = 0;
+ }
+ }
+ }
+
+ int ret = sync_trans(targs);
+ FREELIST(targs);
+ if(ret == 1) {
return(1);
}
}
--
1.5.4


_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev
 
Old 02-14-2008, 09:10 PM
Xavier
 
Default Rework of check-for-new-pacman-version

Chantry Xavier wrote:
> This patch is primarily a fix for FS#9228.
>
> The -Sy operation was moved to its own transaction, which allows us to do
> the following steps :
> 1) refresh the database if asked
> 2) check if a new pacman version if available
> if yes, initialize a "-S pacman" transaction.
> If no, initialize the original -S or -Su transaction.
>
> Note that the newversion check was extended to the "-S target" operation,
> which is helpful in case of syncdb syntax change (see versioned provisions
> for example)
>
> Original-work-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
> Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
> ---
> src/pacman/sync.c | 129 +++++++++++++++++++++++++++--------------------------
> 1 files changed, 66 insertions(+), 63 deletions(-)
>

Here is a comment from Nagy in bug 9228 :
> Well, maybe a bit off here, this check-for-new-version could be more
> general, with simple "-S foo" can be useful imho (can be
> enabled/disabled in pacman.conf).
>
> So we could implement a check_for_new_version() function to the
> back-end [with parameters repo (or NULL for all), and pkgname]; and
> this could be called by the front-end before transaction start.

Dan seemed to think this was a good idea:
19:09 toofishes >> i guess i just don't like hardcoded things like this
19:10 toofishes >> and what if we (or someone else) has a libalpm
package and a pacman package
19:10 toofishes >> and only libalpm gets updated
19:10 toofishes >> then it wouldn't stop and say "do this alone"
19:10 toofishes >> like...maybe this should be a config file thing.
19:10 toofishes >> AlonePkg or some nonsense :P

Well, if we can find a decent config option name for that, I am willing
to implement it (by making the above patch more general).

_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev
 
Old 02-15-2008, 10:48 AM
Nagy Gabor
 
Default Rework of check-for-new-pacman-version

> Dan seemed to think this was a good idea:
> 19:09 toofishes >> i guess i just don't like hardcoded things like this
> 19:10 toofishes >> and what if we (or someone else) has a libalpm
> package and a pacman package
> 19:10 toofishes >> and only libalpm gets updated
> 19:10 toofishes >> then it wouldn't stop and say "do this alone"
> 19:10 toofishes >> like...maybe this should be a config file thing.
> 19:10 toofishes >> AlonePkg or some nonsense :P
>
> Well, if we can find a decent config option name for that, I am willing
> to implement it (by making the above patch more general).
>

Since we can use long names in pacman.conf here too, a descriptive
CheckNewVersion=pacman or something like this is OK to me. (Empty
CheckNewVersion list will disable newversion check, cool.)

Bye


----------------------------------------------------
SZTE Egyetemi Könyvtár - http://www.bibl.u-szeged.hu
This mail sent through IMP: http://horde.org/imp/


_______________________________________________
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 09:54 PM.

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