diff options
author | Timo Teräs <timo.teras@iki.fi> | 2011-09-14 11:07:45 +0300 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2011-09-14 11:07:45 +0300 |
commit | f95e7e585087aa6677978205f4ae8ebb9dfd1851 (patch) | |
tree | f67a75eb5206176a5cde1e897f8dd899fa64a492 | |
parent | f51aa6d42d0dc53ac58c6d5bce23ddc464051f91 (diff) | |
download | apk-tools-f95e7e585087aa6677978205f4ae8ebb9dfd1851.tar.gz apk-tools-f95e7e585087aa6677978205f4ae8ebb9dfd1851.tar.bz2 apk-tools-f95e7e585087aa6677978205f4ae8ebb9dfd1851.tar.xz apk-tools-f95e7e585087aa6677978205f4ae8ebb9dfd1851.zip |
upgrade: --no-self-upgrade option
Use it to avoid self-upgrade loops in case something fails during
the initial upgrade attempt.
-rw-r--r-- | src/apk.c | 3 | ||||
-rw-r--r-- | src/upgrade.c | 21 |
2 files changed, 18 insertions, 6 deletions
@@ -272,9 +272,10 @@ int main(int argc, char **argv) struct apk_database db; struct apk_db_options dbopts; - apk_argv = malloc(sizeof(char*[argc+1])); + apk_argv = malloc(sizeof(char*[argc+2])); memcpy(apk_argv, argv, sizeof(char*[argc])); apk_argv[argc] = NULL; + apk_argv[argc+1] = NULL; memset(&dbopts, 0, sizeof(dbopts)); list_init(&dbopts.repository_list); diff --git a/src/upgrade.c b/src/upgrade.c index 38c5496..dd53c19 100644 --- a/src/upgrade.c +++ b/src/upgrade.c @@ -11,7 +11,8 @@ #include <errno.h> #include <stdio.h> -#include <zlib.h> +#include <stdlib.h> +#include <unistd.h> #include "apk_applet.h" #include "apk_database.h" #include "apk_print.h" @@ -19,6 +20,7 @@ struct upgrade_ctx { unsigned short solver_flags; + int no_self_upgrade : 1; }; static int upgrade_parse(void *ctx, struct apk_db_options *dbopts, @@ -27,6 +29,9 @@ static int upgrade_parse(void *ctx, struct apk_db_options *dbopts, struct upgrade_ctx *uctx = (struct upgrade_ctx *) ctx; switch (optch) { + case 0x10000: + uctx->no_self_upgrade = 1; + break; case 'a': uctx->solver_flags |= APK_SOLVERF_AVAILABLE; break; @@ -69,6 +74,9 @@ int apk_do_self_upgrade(struct apk_database *db, unsigned short solver_flags) apk_db_close(db); apk_message("Continuing the upgrade transaction with new apk-tools:"); + for (r = 0; apk_argv[r] != NULL; r++) + ; + apk_argv[r] = "--no-self-upgrade"; execvp(apk_argv[0], apk_argv); apk_error("PANIC! Failed to re-execute new apk-tools!"); @@ -89,10 +97,11 @@ static int upgrade_main(void *ctx, struct apk_database *db, int argc, char **arg int r; solver_flags = APK_SOLVERF_UPGRADE | uctx->solver_flags; - - r = apk_do_self_upgrade(db, solver_flags); - if (r != 0) - return r; + if (!uctx->no_self_upgrade) { + r = apk_do_self_upgrade(db, solver_flags); + if (r != 0) + return r; + } return apk_solver_commit(db, solver_flags, db->world); } @@ -101,6 +110,8 @@ static struct apk_option upgrade_options[] = { { 'a', "available", "Re-install or downgrade if currently installed package is not " "currently available from any repository" }, + { 0x10000, "no-self-upgrade", + "Do not do early upgrade of 'apk-tools' package" }, }; static struct apk_applet apk_upgrade = { |