upgrade: add --available option
That will make the upgrade prefer packages available in repositories. This is good if one want's to downgrade packages by removing an experimental repository. Or to force re-install of locally built vs. repository version when the package version are same, but checksum is different. Fixes #51.cute-signatures
parent
4d04bd8a46
commit
3a48856475
|
@ -4,7 +4,7 @@
|
||||||
* Copyright (C) 2008 Timo Teräs <timo.teras@iki.fi>
|
* Copyright (C) 2008 Timo Teräs <timo.teras@iki.fi>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
* under the terms of the GNU General Public License version 2 as published
|
* under the terms of the GNU General Public License version 2 as published
|
||||||
* by the Free Software Foundation. See http://www.gnu.org/ for details.
|
* by the Free Software Foundation. See http://www.gnu.org/ for details.
|
||||||
*/
|
*/
|
||||||
|
@ -59,6 +59,7 @@ extern unsigned int apk_flags;
|
||||||
#define APK_PROGRESS 0x0008
|
#define APK_PROGRESS 0x0008
|
||||||
#define APK_UPGRADE 0x0010
|
#define APK_UPGRADE 0x0010
|
||||||
#define APK_RECURSIVE 0x0020
|
#define APK_RECURSIVE 0x0020
|
||||||
|
#define APK_PREFER_AVAILABLE 0x0040
|
||||||
|
|
||||||
#define apk_error(args...) apk_log("ERROR: ", args);
|
#define apk_error(args...) apk_log("ERROR: ", args);
|
||||||
#define apk_warning(args...) if (apk_verbosity > 0) { apk_log("WARNING: ", args); }
|
#define apk_warning(args...) if (apk_verbosity > 0) { apk_log("WARNING: ", args); }
|
||||||
|
|
23
src/state.c
23
src/state.c
|
@ -4,7 +4,7 @@
|
||||||
* Copyright (C) 2008 Timo Teräs <timo.teras@iki.fi>
|
* Copyright (C) 2008 Timo Teräs <timo.teras@iki.fi>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
* under the terms of the GNU General Public License version 2 as published
|
* under the terms of the GNU General Public License version 2 as published
|
||||||
* by the Free Software Foundation. See http://www.gnu.org/ for details.
|
* by the Free Software Foundation. See http://www.gnu.org/ for details.
|
||||||
*/
|
*/
|
||||||
|
@ -232,8 +232,25 @@ int apk_state_lock_dependency(struct apk_state *state,
|
||||||
if (apk_pkg_get_state(c->pkgs[i]) == APK_PKG_INSTALLED)
|
if (apk_pkg_get_state(c->pkgs[i]) == APK_PKG_INSTALLED)
|
||||||
installed = pkg;
|
installed = pkg;
|
||||||
|
|
||||||
if (latest == NULL ||
|
if (latest == NULL) {
|
||||||
apk_pkg_version_compare(pkg, latest) == APK_VERSION_GREATER)
|
latest = pkg;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (apk_flags & APK_PREFER_AVAILABLE) {
|
||||||
|
if (latest->repos != 0 && pkg->repos == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (latest->repos == 0 && pkg->repos != 0) {
|
||||||
|
latest = pkg;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Otherwise both are not available, or both are
|
||||||
|
* available and we just compare the versions then */
|
||||||
|
}
|
||||||
|
|
||||||
|
if (apk_pkg_version_compare(pkg, latest) == APK_VERSION_GREATER)
|
||||||
latest = pkg;
|
latest = pkg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,18 @@
|
||||||
#include "apk_database.h"
|
#include "apk_database.h"
|
||||||
#include "apk_state.h"
|
#include "apk_state.h"
|
||||||
|
|
||||||
|
static int upgrade_parse(void *ctx, int optch, int optindex, const char *optarg)
|
||||||
|
{
|
||||||
|
switch (optch) {
|
||||||
|
case 'a':
|
||||||
|
apk_flags |= APK_PREFER_AVAILABLE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int upgrade_main(void *ctx, int argc, char **argv)
|
static int upgrade_main(void *ctx, int argc, char **argv)
|
||||||
{
|
{
|
||||||
struct apk_database db;
|
struct apk_database db;
|
||||||
|
@ -45,9 +57,16 @@ err:
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct option upgrade_options[] = {
|
||||||
|
{ "available", no_argument, NULL, 'a' },
|
||||||
|
};
|
||||||
|
|
||||||
static struct apk_applet apk_upgrade = {
|
static struct apk_applet apk_upgrade = {
|
||||||
.name = "upgrade",
|
.name = "upgrade",
|
||||||
.usage = "",
|
.usage = "[-a|--available]",
|
||||||
|
.num_options = ARRAY_SIZE(upgrade_options),
|
||||||
|
.options = upgrade_options,
|
||||||
|
.parse = upgrade_parse,
|
||||||
.main = upgrade_main,
|
.main = upgrade_main,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue