Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
alpine
apk-tools
Commits
695a2f82
Commit
695a2f82
authored
Dec 10, 2019
by
byrn
Committed by
Timo Teräs
Dec 12, 2019
Browse files
upgrade: implement --ignore to exclude some packages from upgrade
parent
cfa8b736
Changes
5
Show whitespace changes
Inline
Side-by-side
src/apk_solver.h
View file @
695a2f82
...
...
@@ -35,6 +35,7 @@ struct apk_changeset {
#define APK_SOLVERF_REINSTALL 0x0004
#define APK_SOLVERF_LATEST 0x0008
#define APK_SOLVERF_IGNORE_CONFLICT 0x0010
#define APK_SOLVERF_IGNORE_UPGRADE 0x0020
void
apk_solver_set_name_flags
(
struct
apk_name
*
name
,
unsigned
short
solver_flags
,
...
...
src/apk_solver_data.h
View file @
695a2f82
...
...
@@ -49,8 +49,8 @@ struct apk_solver_package_state {
unsigned
short
max_dep_chain
;
unsigned
short
pinning_allowed
;
unsigned
short
pinning_preferred
;
unsigned
solver_flags
:
4
;
unsigned
solver_flags_inheritable
:
4
;
unsigned
solver_flags
:
6
;
unsigned
solver_flags_inheritable
:
6
;
unsigned
seen
:
1
;
unsigned
pkg_available
:
1
;
unsigned
pkg_selectable
:
1
;
...
...
src/solver.c
View file @
695a2f82
...
...
@@ -551,7 +551,8 @@ static int compare_providers(struct apk_solver_state *ss,
return
r
;
/* 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
))
{
r
=
(
pkgA
->
ipkg
!=
NULL
)
-
(
pkgB
->
ipkg
!=
NULL
);
if
(
r
)
return
r
;
...
...
@@ -580,7 +581,8 @@ static int compare_providers(struct apk_solver_state *ss,
return
r
;
/* 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
);
if
(
r
)
return
r
;
...
...
src/upgrade.c
View file @
695a2f82
...
...
@@ -22,6 +22,7 @@ struct upgrade_ctx {
unsigned
short
solver_flags
;
int
no_self_upgrade
:
1
;
int
self_upgrade_only
:
1
;
int
ignore
:
1
;
};
static
int
option_parse_applet
(
void
*
ctx
,
struct
apk_db_options
*
dbopts
,
int
optch
,
const
char
*
optarg
)
...
...
@@ -35,6 +36,9 @@ static int option_parse_applet(void *ctx, struct apk_db_options *dbopts, int opt
case
0x10001
:
uctx
->
self_upgrade_only
=
1
;
break
;
case
0x10002
:
uctx
->
ignore
=
1
;
break
;
case
'a'
:
uctx
->
solver_flags
|=
APK_SOLVERF_AVAILABLE
;
break
;
...
...
@@ -59,6 +63,8 @@ static const struct apk_option options_applet[] = {
{
0x10000
,
"no-self-upgrade"
,
"Do not do early upgrade of 'apk-tools' package"
},
{
0x10001
,
"self-upgrade-only"
,
"Only do self-upgrade"
},
{
0x10002
,
"ignore"
,
"Ignore the upgrade of PACKAGE. Partial "
"upgrades not supported, this might break your system."
},
};
static
const
struct
apk_option_group
optgroup_applet
=
{
...
...
@@ -158,6 +164,15 @@ static int upgrade_main(void *ctx, struct apk_database *db, struct apk_string_ar
if
(
uctx
->
self_upgrade_only
)
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
)
{
apk_dependency_array_copy
(
&
world
,
db
->
world
);
foreach_array_item
(
dep
,
world
)
{
...
...
test/upgrade2.test
0 → 100644
View file @
695a2f82
@
ARGS
--
test
-
repo
upgrade
.
repo
--
test
-
instdb
upgrade
.
installed
--
test
-
world
app
upgrade
--
ignore
app
@
EXPECT
OK
:
0
MiB
in
2
packages
Timo Teräs
@fabled
mentioned in issue
#8792 (closed)
·
Dec 27, 2019
mentioned in issue
#8792 (closed)
mentioned in issue #8792
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment