kiss: move as_root out of git

This commit is contained in:
Dylan Araps 2021-07-24 22:19:50 +03:00
parent f09f0d6ec1
commit cb54b59f98
No known key found for this signature in database
GPG Key ID: 13295DAC2CF13B5C
2 changed files with 21 additions and 14 deletions

View File

@ -193,7 +193,7 @@ features or conditionally do things on a per-package basis.
| pre-install | Type | Package | Extracted package | |
| pre-remove | Type | Package | Installed database | |
| pre-source | Type | Package | Verbatim source | Resolved source |
| pre-update | Type | [7] | | |
| pre-update | Type | [8] | | |
| queue-status | Type | Package | Number in queue | Total in queue |
| | | | | |
+---------------+--------+----------+--------------------+-----------------+
@ -201,6 +201,10 @@ features or conditionally do things on a per-package basis.
[7] The -update hooks start in the current repository. In other words, you
can operate on the repository directly or grab the value from '$PWD'.
[8] The second argument of pre-update is '0' if the current user owns the
repository and '1' if they do not. In the latter case, privilege
escalation is required to preserve ownership.
[5.0] Package Manager Extensions
________________________________________________________________________________

29
kiss
View File

@ -1548,9 +1548,6 @@ pkg_update() {
if git -C "$repo" remote >/dev/null 2>&1; then
repo_type=git
# 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)
@ -1559,28 +1556,34 @@ pkg_update() {
continue
fi
pkg_update_repo "$repo" "$repo_type" "${repo_sig:-false}"
pkg_update_repo
done
pkg_upgrade
}
pkg_update_repo() {
cd "$1" || die "Repository '$1' inaccessible"
cd "$repo" || die "Repository '$repo' inaccessible"
# NULL function for unsupported repository types.
pkg_update_null() { log "$PWD" "Repository has no remote"; }
pkg_update_null() { printf 'Repository has no remote\n'; }
contains "$repos" "$PWD" || {
repos="$repos $PWD"
log "$PWD" "[verify: $3]"
log "Updating" "$PWD"
am_owner "$PWD" || {
printf 'Need "%s" to update\n' "$user"
set -- as_user
}
# arg1: pre-update
# arg2: need su?
# env: PWD is path to repository
run_hook pre-update
run_hook pre-update "$#"
"pkg_update_$2"
"pkg_update_$repo_type" "$@"
# arg1: post-update
# env: PWD is path to repository
@ -1589,10 +1592,10 @@ pkg_update_repo() {
}
pkg_update_git() {
am_owner "$PWD" || {
log "$PWD" "Need '$user' to update"
set -- as_user
}
# Display whether or not signature verification is enabled.
case $(git config --get merge.verifySignatures) in true)
printf 'Signature verification enabled.\n'
esac
"$@" git pull
"$@" git submodule update --remote --init -f