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
f51aa6d4
Commit
f51aa6d4
authored
Sep 14, 2011
by
Timo Teräs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
upgrade: reimplement self-upgrade (after solver merge)
parent
1817b0a3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
17 deletions
+42
-17
src/apk_database.h
src/apk_database.h
+1
-0
src/solver.c
src/solver.c
+13
-1
src/upgrade.c
src/upgrade.c
+28
-16
No files found.
src/apk_database.h
View file @
f51aa6d4
...
@@ -123,6 +123,7 @@ struct apk_database {
...
@@ -123,6 +123,7 @@ struct apk_database {
char
*
cache_remount_dir
;
char
*
cache_remount_dir
;
apk_blob_t
*
arch
;
apk_blob_t
*
arch
;
unsigned
int
local_repos
;
unsigned
int
local_repos
;
int
performing_self_update
:
1
;
int
permanent
:
1
;
int
permanent
:
1
;
int
compat_newfeatures
:
1
;
int
compat_newfeatures
:
1
;
int
compat_notinstallable
:
1
;
int
compat_notinstallable
:
1
;
...
...
src/solver.c
View file @
f51aa6d4
...
@@ -745,6 +745,17 @@ static int free_state(apk_hash_item item, void *ctx)
...
@@ -745,6 +745,17 @@ static int free_state(apk_hash_item item, void *ctx)
return
0
;
return
0
;
}
}
static
int
free_package
(
apk_hash_item
item
,
void
*
ctx
)
{
struct
apk_package
*
pkg
=
(
struct
apk_package
*
)
item
;
if
(
pkg
->
state_ptr
!=
NULL
)
{
free
(
pkg
->
state_ptr
);
pkg
->
state_ptr
=
NULL
;
}
return
0
;
}
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
)
{
{
...
@@ -816,6 +827,7 @@ int apk_solver_solve(struct apk_database *db,
...
@@ -816,6 +827,7 @@ int apk_solver_solve(struct apk_database *db,
apk_package_array_free
(
&
ss
->
best_solution
);
apk_package_array_free
(
&
ss
->
best_solution
);
apk_hash_foreach
(
&
db
->
available
.
names
,
free_state
,
NULL
);
apk_hash_foreach
(
&
db
->
available
.
names
,
free_state
,
NULL
);
apk_hash_foreach
(
&
db
->
available
.
packages
,
free_package
,
NULL
);
free
(
ss
);
free
(
ss
);
return
r
;
return
r
;
...
@@ -1066,7 +1078,7 @@ all_done:
...
@@ -1066,7 +1078,7 @@ all_done:
apk_dependency_array_copy
(
&
db
->
world
,
world
);
apk_dependency_array_copy
(
&
db
->
world
,
world
);
apk_db_write_config
(
db
);
apk_db_write_config
(
db
);
if
(
r
==
0
)
{
if
(
r
==
0
&&
!
db
->
performing_self_update
)
{
apk_message
(
"OK: %d packages, %d dirs, %d files"
,
apk_message
(
"OK: %d packages, %d dirs, %d files"
,
db
->
installed
.
stats
.
packages
,
db
->
installed
.
stats
.
packages
,
db
->
installed
.
stats
.
dirs
,
db
->
installed
.
stats
.
dirs
,
...
...
src/upgrade.c
View file @
f51aa6d4
...
@@ -36,28 +36,36 @@ static int upgrade_parse(void *ctx, struct apk_db_options *dbopts,
...
@@ -36,28 +36,36 @@ static int upgrade_parse(void *ctx, struct apk_db_options *dbopts,
return
0
;
return
0
;
}
}
int
apk_do_self_upgrade
(
struct
apk_database
*
db
)
int
apk_do_self_upgrade
(
struct
apk_database
*
db
,
unsigned
short
solver_flags
)
{
{
#if 0
struct
apk_name
*
name
;
/* FIXME: Reimplement self-upgrade. */
struct
apk_changeset
changeset
=
{};
struct apk_
dependency dep
;
struct
apk_
package_array
*
solution
=
NULL
;
int
r
;
int
r
;
apk_dep_from_blob(&dep, db, APK_BLOB_STR("apk-tools"));
name
=
apk_db_get_name
(
db
,
APK_BLOB_STR
(
"apk-tools"
));
apk_solver_set_name_flags
(
name
,
solver_flags
);
db
->
performing_self_update
=
1
;
r
=
apk_solver_solve
(
db
,
0
,
db
->
world
,
&
solution
,
&
changeset
);
if
(
r
!=
0
)
{
if
(
apk_flags
&
APK_FORCE
)
r
=
0
;
else
apk_solver_print_errors
(
db
,
solution
,
db
->
world
,
r
);
goto
ret
;
}
r = apk_state_lock_dependency(state, &dep);
if
(
changeset
.
changes
->
num
==
0
)
if (r != 0 || state->num_changes == 0)
goto
ret
;
return r;
if
(
apk_flags
&
APK_SIMULATE
)
{
if
(
apk_flags
&
APK_SIMULATE
)
{
apk_warning
(
"This simulation is not reliable as apk-tools upgrade is available."
);
apk_warning
(
"This simulation is not reliable as apk-tools upgrade is available."
);
return 0
;
goto
ret
;
}
}
apk_message
(
"Upgrading critical system libraries and apk-tools:"
);
apk_message
(
"Upgrading critical system libraries and apk-tools:"
);
state->print_ok = 0;
apk_solver_commit_changeset
(
db
,
&
changeset
,
db
->
world
);
r = apk_state_commit(state);
apk_state_unref(state);
apk_db_close
(
db
);
apk_db_close
(
db
);
apk_message
(
"Continuing the upgrade transaction with new apk-tools:"
);
apk_message
(
"Continuing the upgrade transaction with new apk-tools:"
);
...
@@ -65,9 +73,13 @@ int apk_do_self_upgrade(struct apk_database *db)
...
@@ -65,9 +73,13 @@ int apk_do_self_upgrade(struct apk_database *db)
apk_error
(
"PANIC! Failed to re-execute new apk-tools!"
);
apk_error
(
"PANIC! Failed to re-execute new apk-tools!"
);
exit
(
1
);
exit
(
1
);
#else
return
0
;
ret:
#endif
apk_package_array_free
(
&
solution
);
apk_change_array_free
(
&
changeset
.
changes
);
db
->
performing_self_update
=
0
;
return
r
;
}
}
static
int
upgrade_main
(
void
*
ctx
,
struct
apk_database
*
db
,
int
argc
,
char
**
argv
)
static
int
upgrade_main
(
void
*
ctx
,
struct
apk_database
*
db
,
int
argc
,
char
**
argv
)
...
@@ -78,7 +90,7 @@ static int upgrade_main(void *ctx, struct apk_database *db, int argc, char **arg
...
@@ -78,7 +90,7 @@ static int upgrade_main(void *ctx, struct apk_database *db, int argc, char **arg
solver_flags
=
APK_SOLVERF_UPGRADE
|
uctx
->
solver_flags
;
solver_flags
=
APK_SOLVERF_UPGRADE
|
uctx
->
solver_flags
;
r
=
apk_do_self_upgrade
(
db
);
r
=
apk_do_self_upgrade
(
db
,
solver_flags
);
if
(
r
!=
0
)
if
(
r
!=
0
)
return
r
;
return
r
;
...
...
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