aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormerakor <cem@ckyln.com>2021-11-03 23:43:46 +0000
committermerakor <cem@ckyln.com>2021-11-03 23:43:46 +0000
commit6b379a572b8fd924f7c43211910822494b6811b7 (patch)
tree696f39bfafc9100893db9344aefd51760c5f654e /src
parenta6bd92be280f4b8ed955873e8996f120b3dca79f (diff)
parent5f89b67931ee91eefc1fee6310cf3ac84a79c252 (diff)
downloadcpt-6b379a572b8fd924f7c43211910822494b6811b7.tar.gz
merge branch update-exec
FossilOrigin-Name: a606391d8820d8496734661765ba66cb2ccee8d38c72326349058e3ddae9864a
Diffstat (limited to 'src')
-rw-r--r--src/cpt-lib.in35
1 files changed, 23 insertions, 12 deletions
diff --git a/src/cpt-lib.in b/src/cpt-lib.in
index 517f198..a881d0e 100644
--- a/src/cpt-lib.in
+++ b/src/cpt-lib.in
@@ -1947,7 +1947,12 @@ pkg_updates(){
# an update.
[ "$CPT_FETCH" = 0 ] || pkg_fetch
- log "Checking for new package versions"
+ # Be quiet if we are doing self update, no need to print the same
+ # information twice. We add this basic function, because we will be using it
+ # more than once.
+ _not_update () { [ "$cpt_self_update" ] || "$@" ;}
+
+ _not_update log "Checking for new package versions"
set +f
@@ -1961,7 +1966,7 @@ pkg_updates(){
# Compare installed packages to repository packages.
[ "$db_ver-$db_rel" != "$re_ver-$re_rel" ] && {
- printf '%s\n' "$pkg_name $db_ver-$db_rel ==> $re_ver-$re_rel"
+ _not_update printf '%s\n' "$pkg_name $db_ver-$db_rel ==> $re_ver-$re_rel"
outdated="$outdated$pkg_name "
}
done
@@ -1982,6 +1987,13 @@ pkg_updates(){
exit 0
}
+ [ "$outdated" ] || {
+ log "Everything is up to date"
+ return
+ }
+
+ _not_update log "Packages to update: ${outdated% }"
+
contains "$outdated" cpt && {
log "Detected package manager update"
log "The package manager will be updated first"
@@ -1992,18 +2004,17 @@ pkg_updates(){
cpt-install cpt
log "Updated the package manager"
- log "Re-run 'cpt update' to update your system"
-
- exit 0
+ log "Re-executing the package manager to continue the update"
+
+ # We export this variable so that cpt knows it's running for the second
+ # time. We make the new process promptless, and we avoid fetching
+ # repositories. We are assuming that the user was already prompted once,
+ # and that their repositories are up to date, or they have also passed
+ # the '-y' or '-n' flags themselves which leads to the same outcome.
+ export cpt_self_update=1
+ exec cpt-update -yn
}
- [ "$outdated" ] || {
- log "Everything is up to date"
- return
- }
-
- log "Packages to update: ${outdated% }"
-
# Tell 'pkg_build' to always prompt before build.
pkg_update=1