fix, simplify and document upgrade --ignore
parent
f3cf824948
commit
e2afc7e7a9
|
@ -11,7 +11,9 @@ apk upgrade - upgrade installed packages
|
||||||
# DESCRIPTION
|
# DESCRIPTION
|
||||||
|
|
||||||
*apk upgrade* upgrades installed packages to the latest version available from
|
*apk upgrade* upgrades installed packages to the latest version available from
|
||||||
configured package repositories (see *apk-repositories*(5)).
|
configured package repositories (see *apk-repositories*(5)). When no packages
|
||||||
|
are specified, all packages are upgraded if possible. If list of packages is
|
||||||
|
provided, only those packages are upgraded along with needed dependencies.
|
||||||
|
|
||||||
# OPTIONS
|
# OPTIONS
|
||||||
|
|
||||||
|
@ -27,6 +29,10 @@ following options:
|
||||||
This is useful to reset system against new set of packages after updating
|
This is useful to reset system against new set of packages after updating
|
||||||
repositories.
|
repositories.
|
||||||
|
|
||||||
|
*--ignore*
|
||||||
|
Upgrade all other packages than the ones listed. This inverts the given
|
||||||
|
package name list to mean packages that should not be upgraded.
|
||||||
|
|
||||||
*-l, --latest*
|
*-l, --latest*
|
||||||
Always choose the latest package by version. However, the versions
|
Always choose the latest package by version. However, the versions
|
||||||
considered are based on the package pinning. Primarily this overrides
|
considered are based on the package pinning. Primarily this overrides
|
||||||
|
|
|
@ -96,15 +96,11 @@ struct apk_installed_package {
|
||||||
|
|
||||||
struct apk_package {
|
struct apk_package {
|
||||||
apk_hash_node hash_node;
|
apk_hash_node hash_node;
|
||||||
|
unsigned int foreach_genid;
|
||||||
union {
|
union {
|
||||||
struct apk_solver_package_state ss;
|
struct apk_solver_package_state ss;
|
||||||
struct {
|
int state_int;
|
||||||
unsigned int foreach_genid;
|
void *state_ptr;
|
||||||
union {
|
|
||||||
int state_int;
|
|
||||||
void *state_ptr;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
struct apk_name *name;
|
struct apk_name *name;
|
||||||
struct apk_installed_package *ipkg;
|
struct apk_installed_package *ipkg;
|
||||||
|
|
|
@ -33,7 +33,7 @@ struct apk_changeset {
|
||||||
#define APK_SOLVERF_REINSTALL 0x0004
|
#define APK_SOLVERF_REINSTALL 0x0004
|
||||||
#define APK_SOLVERF_LATEST 0x0008
|
#define APK_SOLVERF_LATEST 0x0008
|
||||||
#define APK_SOLVERF_IGNORE_CONFLICT 0x0010
|
#define APK_SOLVERF_IGNORE_CONFLICT 0x0010
|
||||||
#define APK_SOLVERF_IGNORE_UPGRADE 0x0020
|
#define APK_SOLVERF_INSTALLED 0x0020
|
||||||
|
|
||||||
void apk_solver_set_name_flags(struct apk_name *name,
|
void apk_solver_set_name_flags(struct apk_name *name,
|
||||||
unsigned short solver_flags,
|
unsigned short solver_flags,
|
||||||
|
|
|
@ -138,8 +138,10 @@ static void set_upgrade_for_name(struct apk_database *db, const char *match, str
|
||||||
if (!name) {
|
if (!name) {
|
||||||
apk_error("Package '%s' not found", match);
|
apk_error("Package '%s' not found", match);
|
||||||
uctx->errors++;
|
uctx->errors++;
|
||||||
} else
|
return;
|
||||||
apk_solver_set_name_flags(name, APK_SOLVERF_UPGRADE, 0);
|
}
|
||||||
|
|
||||||
|
apk_solver_set_name_flags(name, uctx->ignore ? APK_SOLVERF_INSTALLED : APK_SOLVERF_UPGRADE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int upgrade_main(void *ctx, struct apk_database *db, struct apk_string_array *args)
|
static int upgrade_main(void *ctx, struct apk_database *db, struct apk_string_array *args)
|
||||||
|
@ -157,7 +159,7 @@ static int upgrade_main(void *ctx, struct apk_database *db, struct apk_string_ar
|
||||||
}
|
}
|
||||||
|
|
||||||
solver_flags = APK_SOLVERF_UPGRADE | uctx->solver_flags;
|
solver_flags = APK_SOLVERF_UPGRADE | uctx->solver_flags;
|
||||||
if (!uctx->no_self_upgrade) {
|
if (!uctx->no_self_upgrade && !args->num) {
|
||||||
r = apk_do_self_upgrade(db, solver_flags, uctx->self_upgrade_only);
|
r = apk_do_self_upgrade(db, solver_flags, uctx->self_upgrade_only);
|
||||||
if (r != 0)
|
if (r != 0)
|
||||||
return r;
|
return r;
|
||||||
|
@ -165,15 +167,6 @@ static int upgrade_main(void *ctx, struct apk_database *db, struct apk_string_ar
|
||||||
if (uctx->self_upgrade_only)
|
if (uctx->self_upgrade_only)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (uctx->ignore) {
|
|
||||||
char **pkg_name;
|
|
||||||
struct apk_name *name;
|
|
||||||
foreach_array_item(pkg_name, args) {
|
|
||||||
name = apk_db_get_name(db, APK_BLOB_STR(*pkg_name));
|
|
||||||
apk_solver_set_name_flags(name, solver_flags | APK_SOLVERF_IGNORE_UPGRADE, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (solver_flags & APK_SOLVERF_AVAILABLE) {
|
if (solver_flags & APK_SOLVERF_AVAILABLE) {
|
||||||
apk_dependency_array_copy(&world, db->world);
|
apk_dependency_array_copy(&world, db->world);
|
||||||
foreach_array_item(dep, world) {
|
foreach_array_item(dep, world) {
|
||||||
|
@ -188,12 +181,9 @@ static int upgrade_main(void *ctx, struct apk_database *db, struct apk_string_ar
|
||||||
|
|
||||||
if (args->num > 0) {
|
if (args->num > 0) {
|
||||||
/* if specific packages are listed, we don't want to upgrade world. */
|
/* if specific packages are listed, we don't want to upgrade world. */
|
||||||
solver_flags &= ~APK_SOLVERF_UPGRADE;
|
if (!uctx->ignore) solver_flags &= ~APK_SOLVERF_UPGRADE;
|
||||||
|
apk_name_foreach_matching(db, args, apk_foreach_genid(), set_upgrade_for_name, uctx);
|
||||||
apk_name_foreach_matching(db, args, apk_foreach_genid(), set_upgrade_for_name, &uctx);
|
if (uctx->errors) return uctx->errors;
|
||||||
|
|
||||||
if (uctx->errors)
|
|
||||||
return uctx->errors;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
r = apk_solver_commit(db, solver_flags, world);
|
r = apk_solver_commit(db, solver_flags, world);
|
||||||
|
|
|
@ -53,6 +53,8 @@ void apk_solver_set_name_flags(struct apk_name *name,
|
||||||
|
|
||||||
foreach_array_item(p, name->providers) {
|
foreach_array_item(p, name->providers) {
|
||||||
struct apk_package *pkg = p->pkg;
|
struct apk_package *pkg = p->pkg;
|
||||||
|
dbg_printf("marking '" PKG_VER_FMT "' = 0x%04x / 0x%04x\n",
|
||||||
|
PKG_VER_PRINTF(pkg), solver_flags, solver_flags_inheritable);
|
||||||
pkg->ss.solver_flags |= solver_flags;
|
pkg->ss.solver_flags |= solver_flags;
|
||||||
pkg->ss.solver_flags_inheritable |= solver_flags_inheritable;
|
pkg->ss.solver_flags_inheritable |= solver_flags_inheritable;
|
||||||
}
|
}
|
||||||
|
@ -564,10 +566,10 @@ static int compare_providers(struct apk_solver_state *ss,
|
||||||
|
|
||||||
/* Prefer installed on self-upgrade */
|
/* Prefer installed on self-upgrade */
|
||||||
if ((db->performing_self_upgrade && !(solver_flags & APK_SOLVERF_UPGRADE)) ||
|
if ((db->performing_self_upgrade && !(solver_flags & APK_SOLVERF_UPGRADE)) ||
|
||||||
(solver_flags & APK_SOLVERF_IGNORE_UPGRADE)) {
|
(solver_flags & APK_SOLVERF_INSTALLED)) {
|
||||||
r = (pkgA->ipkg != NULL) - (pkgB->ipkg != NULL);
|
r = (pkgA->ipkg != NULL) - (pkgB->ipkg != NULL);
|
||||||
if (r) {
|
if (r) {
|
||||||
dbg_printf(" prefer installed on self-upgrade\n");
|
dbg_printf(" prefer installed\n");
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -603,8 +605,7 @@ static int compare_providers(struct apk_solver_state *ss,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Prefer installed */
|
/* Prefer installed */
|
||||||
if (!(solver_flags & APK_SOLVERF_UPGRADE) ||
|
if (!(solver_flags & APK_SOLVERF_UPGRADE)) {
|
||||||
(solver_flags & APK_SOLVERF_IGNORE_UPGRADE)) {
|
|
||||||
r = (pkgA->ipkg != NULL) - (pkgB->ipkg != NULL);
|
r = (pkgA->ipkg != NULL) - (pkgB->ipkg != NULL);
|
||||||
if (r) {
|
if (r) {
|
||||||
dbg_printf(" prefer installed\n");
|
dbg_printf(" prefer installed\n");
|
||||||
|
|
Loading…
Reference in New Issue