forked from kiss-community/kiss
kiss: update clean up
- Update hooks now fire for non-Git repositories. This allows hooks to add support for other update methods. - Foundational work to explore other update methods in the package manager itself. - Added 'U|upgrade' to update the system without pulling new changes from remotes. - Other minor changes.
This commit is contained in:
parent
cb73d80ccb
commit
dfd000e9c5
109
kiss
109
kiss
@ -1545,62 +1545,66 @@ pkg_update() {
|
|||||||
|
|
||||||
# Update each repository in '$KISS_PATH'.
|
# Update each repository in '$KISS_PATH'.
|
||||||
for repo do
|
for repo do
|
||||||
ok "$repo" || continue
|
repo_type=null repo_sig=false
|
||||||
|
|
||||||
[ -d "$repo" ] || {
|
if git -C "$repo" remote >/dev/null 2>&1; then
|
||||||
log "$repo" " "
|
repo_type=git
|
||||||
printf 'Skipping repository, not a directory\n'
|
|
||||||
|
# Display whether or not signature verification is enabled.
|
||||||
|
repo_sig=$(git -C "$repo" config --get merge.verifySignatures) || :
|
||||||
|
|
||||||
|
# Get the Git repository root directory.
|
||||||
|
subm=$(git -C "$repo" rev-parse --show-superproject-working-tree)
|
||||||
|
repo=$(git -C "${subm:-"$repo"}" rev-parse --show-toplevel)
|
||||||
|
|
||||||
|
elif ! [ -d "$repo" ]; then
|
||||||
continue
|
continue
|
||||||
}
|
fi
|
||||||
|
|
||||||
cd "$repo"
|
pkg_update_repo "$repo" "$repo_type" "${repo_sig:-false}"
|
||||||
|
done
|
||||||
|
|
||||||
git remote >/dev/null 2>&1 || {
|
pkg_upgrade
|
||||||
log "$repo" " "
|
}
|
||||||
printf 'Skipping git pull, not a repository\n'
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
# Go to the repository's root directory.
|
pkg_update_repo() {
|
||||||
git_root=$(git rev-parse --show-toplevel)
|
cd "$1" || die "Repository '$1' inaccessible"
|
||||||
cd "${git_root:?"failed to find git root for '$PWD'"}"
|
|
||||||
|
|
||||||
# Go to the real root directory if this is a submodule.
|
# NULL function for unsupported repository types.
|
||||||
git_root=$(git rev-parse --show-superproject-working-tree)
|
pkg_update_null() { log "$PWD" "Repository has no remote"; }
|
||||||
cd "${git_root:-"$PWD"}"
|
|
||||||
|
|
||||||
contains "$repos" "$PWD" || {
|
contains "$repos" "$PWD" || {
|
||||||
repos="$repos $PWD "
|
repos="$repos $PWD"
|
||||||
|
|
||||||
|
log "$PWD" "[verify: $3]"
|
||||||
|
|
||||||
# arg1: pre-update
|
# arg1: pre-update
|
||||||
# env: PWD is path to repository
|
# env: PWD is path to repository
|
||||||
run_hook pre-update
|
run_hook pre-update
|
||||||
|
|
||||||
# Display whether or not signature verification is enabled.
|
"pkg_update_$2"
|
||||||
_sig=$(git config --get --default false merge.verifySignatures)
|
|
||||||
|
|
||||||
log "$PWD" "[verify: $_sig]"
|
|
||||||
|
|
||||||
if ! am_owner "$PWD"; then
|
|
||||||
log "$PWD" "Need '$user' to update"
|
|
||||||
as_user git pull
|
|
||||||
as_user git submodule update --remote --init -f
|
|
||||||
else
|
|
||||||
git pull
|
|
||||||
git submodule update --remote --init -f
|
|
||||||
fi
|
|
||||||
|
|
||||||
# arg1: post-update
|
# arg1: post-update
|
||||||
# env: PWD is path to repository
|
# env: PWD is path to repository
|
||||||
run_hook post-update
|
run_hook post-update
|
||||||
}
|
}
|
||||||
done
|
}
|
||||||
|
|
||||||
|
pkg_update_git() {
|
||||||
|
am_owner "$PWD" || {
|
||||||
|
log "$PWD" "Need '$user' to update"
|
||||||
|
set -- as_user
|
||||||
|
}
|
||||||
|
|
||||||
|
"$@" git pull
|
||||||
|
"$@" git submodule update --remote --init -f
|
||||||
|
}
|
||||||
|
|
||||||
|
pkg_upgrade() {
|
||||||
log "Checking for new package versions"
|
log "Checking for new package versions"
|
||||||
|
set +f
|
||||||
|
|
||||||
set +f --
|
for pkg in "$sys_db/"*; do set -f
|
||||||
|
|
||||||
for pkg in "$sys_db/"*; do
|
|
||||||
pkg_find_version "${pkg##*/}" "" "" "$sys_db"
|
pkg_find_version "${pkg##*/}" "" "" "$sys_db"
|
||||||
pkg_find_version "${pkg##*/}"
|
pkg_find_version "${pkg##*/}"
|
||||||
|
|
||||||
@ -1612,21 +1616,20 @@ pkg_update() {
|
|||||||
|
|
||||||
# Compare installed packages to repository packages.
|
# Compare installed packages to repository packages.
|
||||||
equ "$ver_pre-$rel_pre" "$repo_ver-$repo_rel" || {
|
equ "$ver_pre-$rel_pre" "$repo_ver-$repo_rel" || {
|
||||||
printf '%s\n' "${pkg##*/} $ver_pre-$rel_pre ==> $repo_ver-$repo_rel"
|
|
||||||
set -- "$@" "${pkg##*/}"
|
set -- "$@" "${pkg##*/}"
|
||||||
|
|
||||||
|
printf '%s %s => %s\n' \
|
||||||
|
"${pkg##*/}" "$ver_pre-$rel_pre" "$repo_ver-$repo_rel"
|
||||||
}
|
}
|
||||||
done
|
done
|
||||||
|
|
||||||
log "Checking for orphaned repository packages"
|
|
||||||
case $_repo_orp in *?*)
|
case $_repo_orp in *?*)
|
||||||
war "Packages without repository$_repo_orp"
|
war "Installed packages without repository$_repo_orp"
|
||||||
esac
|
esac
|
||||||
|
|
||||||
set -f
|
|
||||||
pkg_update=1
|
pkg_update=1
|
||||||
|
|
||||||
case " $* " in
|
! contains "$*" kiss || {
|
||||||
*" kiss "*)
|
|
||||||
log "Detected package manager update"
|
log "Detected package manager update"
|
||||||
log "The package manager will be updated first"
|
log "The package manager will be updated first"
|
||||||
|
|
||||||
@ -1635,25 +1638,24 @@ pkg_update() {
|
|||||||
|
|
||||||
log "Updated the package manager"
|
log "Updated the package manager"
|
||||||
log "Re-run 'kiss update' to update your system"
|
log "Re-run 'kiss update' to update your system"
|
||||||
;;
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
" ")
|
for _ do
|
||||||
log "Everything is up to date"
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
log "Packages to update: $*"
|
|
||||||
|
|
||||||
prompt
|
|
||||||
pkg_order "$@"
|
pkg_order "$@"
|
||||||
|
|
||||||
# Intentional, globbing disabled.
|
# Intentional, globbing disabled.
|
||||||
# shellcheck disable=2046,2086
|
# shellcheck disable=2046,2086
|
||||||
pkg_build_all $order
|
set -- $order
|
||||||
|
|
||||||
|
log "Packages to update ($#): $*"
|
||||||
|
prompt
|
||||||
|
pkg_build_all "$@"
|
||||||
log "Updated all packages"
|
log "Updated all packages"
|
||||||
;;
|
return 0
|
||||||
esac
|
done
|
||||||
|
|
||||||
|
log "Nothing to do"
|
||||||
}
|
}
|
||||||
|
|
||||||
pkg_clean() {
|
pkg_clean() {
|
||||||
@ -1787,6 +1789,7 @@ args() {
|
|||||||
r|remove) for pkg in $redro; do pkg_remove "$pkg"; done ;;
|
r|remove) for pkg in $redro; do pkg_remove "$pkg"; done ;;
|
||||||
s|search) for pkg do pkg_find "$pkg" all; done ;;
|
s|search) for pkg do pkg_find "$pkg" all; done ;;
|
||||||
u|update) pkg_update ;;
|
u|update) pkg_update ;;
|
||||||
|
U|upgrade) pkg_upgrade ;;
|
||||||
v|version) printf '5.5.18\n' ;;
|
v|version) printf '5.5.18\n' ;;
|
||||||
|
|
||||||
'')
|
'')
|
||||||
|
Loading…
Reference in New Issue
Block a user