kiss: Clean up pkg_install()

This commit is contained in:
Dylan Araps 2020-06-10 11:23:34 +03:00
parent 2ca86ee2c0
commit b0a460fcf6
No known key found for this signature in database
GPG Key ID: 46D62DD9F1DE636E
1 changed files with 6 additions and 11 deletions

17
kiss
View File

@ -1097,32 +1097,27 @@ pkg_install() {
fi fi
mkdir -p "$tar_dir/$pkg_name" mkdir -p "$tar_dir/$pkg_name"
log "$pkg_name" "Extracting $tar_file" cd "$tar_dir/$pkg_name"
# The tarball is extracted to a temporary directory where its contents are # The tarball is extracted to a temporary directory where its contents are
# then "installed" to the filesystem. Running this step as soon as possible # then "installed" to the filesystem. Running this step as soon as possible
# allows us to also check the validity of the tarball and bail out early # allows us to also check the validity of the tarball and bail out early
# if needed. # if needed.
( decompress "$tar_file" | tar xf -
cd "$tar_dir/$pkg_name"
decompress "$tar_file" | tar xf -
)
# Naively assume that the existence of a manifest file is all that # Naively assume that the existence of a manifest file is all that
# determines a valid KISS package from an invalid one. This should be a # determines a valid KISS package from an invalid one. This should be a
# fine assumption to make in 99.99% of cases. # fine assumption to make in 99.99% of cases.
[ -f "$tar_dir/$pkg_name/$pkg_db/$pkg_name/manifest" ] || [ -f "./$pkg_db/$pkg_name/manifest" ] || die "Not a valid KISS package"
die "'${tar_file##*/}' is not a valid KISS package"
# Ensure that the tarball's manifest is correct by checking that each file # Ensure that the tarball's manifest is correct by checking that each file
# and directory inside of it actually exists. # and directory inside of it actually exists.
[ "$KISS_FORCE" = 1 ] || { [ "$KISS_FORCE" = 1 ] || {
log "$pkg_name" "Checking that manifest is valid" log "$pkg_name" "Checking that manifest is valid"
while read -r line; do while read -r line; do
[ -h "$tar_dir/$pkg_name/$line" ] || [ -h "./$line" ] || [ -e "./$line" ] ||
[ -e "$tar_dir/$pkg_name/$line" ] ||
die "File $line missing from tarball but mentioned in manifest" die "File $line missing from tarball but mentioned in manifest"
done < "$tar_dir/$pkg_name/$pkg_db/$pkg_name/manifest" done < "$pkg_db/$pkg_name/manifest"
log "$pkg_name" "Resolving dependencies"; ( log "$pkg_name" "Resolving dependencies"; (
pkg_depends "$pkg_name" explicit filter pkg_depends "$pkg_name" explicit filter
@ -1134,7 +1129,7 @@ pkg_install() {
run_hook pre-install "$pkg_name" "$tar_dir/$pkg_name" run_hook pre-install "$pkg_name" "$tar_dir/$pkg_name"
pkg_conflicts "$pkg_name" pkg_conflicts "$pkg_name"
log "$pkg_name" "Installing package incrementally" log "$pkg_name" "Installing package"
# Block being able to abort the script with Ctrl+C during installation. # Block being able to abort the script with Ctrl+C during installation.
# Removes all risk of the user aborting a package installation leaving # Removes all risk of the user aborting a package installation leaving