Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
apk-tools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
59
Issues
59
List
Boards
Labels
Service Desk
Milestones
Merge Requests
14
Merge Requests
14
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
alpine
apk-tools
Commits
c538509a
Commit
c538509a
authored
Sep 28, 2020
by
Timo Teräs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement upgrade --prune to remove stale world dependencies
parent
fa63e46a
Pipeline
#50149
passed with stage
in 42 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
6 deletions
+68
-6
doc/apk-upgrade.8.scd
doc/apk-upgrade.8.scd
+4
-0
src/app_upgrade.c
src/app_upgrade.c
+26
-6
test/upgrade4.repo
test/upgrade4.repo
+26
-0
test/upgrade4.test
test/upgrade4.test
+12
-0
No files found.
doc/apk-upgrade.8.scd
View file @
c538509a
...
...
@@ -42,6 +42,10 @@ following options:
*--
no
-
self
-
upgrade
*
Do
not
do
an
early
upgrade
of
the
'apk-tools'
package
.
*--
prune
*
Prune
the
_world_
by
removing
packages
which
are
no
longer
available
from
any
configured
repository
.
*--
self
-
upgrade
-
only
*
Only
perform
a
self
-
upgrade
of
the
'apk-tools'
package
.
...
...
src/app_upgrade.c
View file @
c538509a
...
...
@@ -21,6 +21,7 @@ struct upgrade_ctx {
int
no_self_upgrade
:
1
;
int
self_upgrade_only
:
1
;
int
ignore
:
1
;
int
prune
:
1
;
int
errors
;
};
...
...
@@ -29,6 +30,7 @@ struct upgrade_ctx {
OPT(OPT_UPGRADE_ignore, "ignore") \
OPT(OPT_UPGRADE_latest, APK_OPT_SH("l") "latest") \
OPT(OPT_UPGRADE_no_self_upgrade, "no-self-upgrade") \
OPT(OPT_UPGRADE_prune, "prune") \
OPT(OPT_UPGRADE_self_upgrade_only, "self-upgrade-only")
APK_OPT_APPLET
(
option_desc
,
UPGRADE_OPTIONS
);
...
...
@@ -47,6 +49,9 @@ static int option_parse_applet(void *ctx, struct apk_db_options *dbopts, int opt
case
OPT_UPGRADE_ignore
:
uctx
->
ignore
=
1
;
break
;
case
OPT_UPGRADE_prune
:
uctx
->
prune
=
1
;
break
;
case
OPT_UPGRADE_available
:
uctx
->
solver_flags
|=
APK_SOLVERF_AVAILABLE
;
break
;
...
...
@@ -149,6 +154,7 @@ static int upgrade_main(void *ctx, struct apk_database *db, struct apk_string_ar
struct
upgrade_ctx
*
uctx
=
(
struct
upgrade_ctx
*
)
ctx
;
unsigned
short
solver_flags
;
struct
apk_dependency
*
dep
;
struct
apk_provider
*
p
;
struct
apk_dependency_array
*
world
=
NULL
;
int
r
=
0
;
...
...
@@ -167,13 +173,27 @@ static int upgrade_main(void *ctx, struct apk_database *db, struct apk_string_ar
if
(
uctx
->
self_upgrade_only
)
return
0
;
if
(
solver_flags
&
APK_SOLVERF_AVAILABLE
)
{
if
(
uctx
->
prune
||
(
solver_flags
&
APK_SOLVERF_AVAILABLE
)
)
{
apk_dependency_array_copy
(
&
world
,
db
->
world
);
foreach_array_item
(
dep
,
world
)
{
if
(
dep
->
result_mask
==
APK_DEPMASK_CHECKSUM
)
{
dep
->
result_mask
=
APK_DEPMASK_ANY
;
dep
->
version
=
&
apk_atom_null
;
if
(
solver_flags
&
APK_SOLVERF_AVAILABLE
)
{
foreach_array_item
(
dep
,
world
)
{
if
(
dep
->
result_mask
==
APK_DEPMASK_CHECKSUM
)
{
dep
->
result_mask
=
APK_DEPMASK_ANY
;
dep
->
version
=
&
apk_atom_null
;
}
}
}
if
(
uctx
->
prune
)
{
int
i
,
j
;
for
(
i
=
j
=
0
;
i
<
world
->
num
;
i
++
)
{
foreach_array_item
(
p
,
world
->
item
[
i
].
name
->
providers
)
{
if
(
p
->
pkg
->
repos
&
~
APK_REPOSITORY_CACHED
)
{
world
->
item
[
j
++
]
=
world
->
item
[
i
];
break
;
}
}
}
apk_dependency_array_resize
(
&
world
,
j
);
}
}
else
{
world
=
db
->
world
;
...
...
@@ -188,7 +208,7 @@ static int upgrade_main(void *ctx, struct apk_database *db, struct apk_string_ar
r
=
apk_solver_commit
(
db
,
solver_flags
,
world
);
if
(
solver_flags
&
APK_SOLVERF_AVAILABLE
)
if
(
world
!=
db
->
world
)
apk_dependency_array_free
(
&
world
);
return
r
;
...
...
test/upgrade4.repo
0 → 100644
View file @
c538509a
C:Q1EyN5AdpAOBJWKMR89pp/C66o+OE=
P:libold
V:1
S:1
I:1
C:Q1EyN5AdpAOBJWKMR89pp/C66o+FE=
P:libnew
V:1
S:1
I:1
D:!libold
C:Q1eVpkasfqZAukAXFYbgwt4xAEEEe=
P:app
V:1
S:1
I:1
D:libold
C:Q1EyN5AdpAOBJWKMR89pp/C77FFFF=
P:app
V:2
S:1
I:1
D:libnew
test/upgrade4.test
0 → 100644
View file @
c538509a
@
ARGS
--
test
-
repo
upgrade4
.
repo
--
test
-
instdb
upgrade3
.
installed
--
test
-
world
"app b"
--
prune
upgrade
@
EXPECT
(
1
/
4
)
Purging
b
(
1
)
(
2
/
4
)
Purging
libold
(
1
)
(
3
/
4
)
Installing
libnew
(
1
)
(
4
/
4
)
Upgrading
app
(
1
->
2
)
OK
:
0
MiB
in
3
packages
Write
Preview
Markdown
is supported
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