kiss: Minor clean up

This commit is contained in:
Dylan Araps 2020-05-16 09:26:34 +03:00
parent 507143ad21
commit a08b796f79
No known key found for this signature in database
GPG Key ID: 46D62DD9F1DE636E

58
kiss
View File

@ -638,19 +638,24 @@ pkg_build() {
log "Resolving dependencies" log "Resolving dependencies"
# Mark packages passed on the command-line separately from those
# detected as dependencies. We need to treat explicitly passed packages
# differently from those pulled in as dependencies.
#
# This also resolves all dependencies and stores the result in '$deps'.
# Any duplicates are also filtered out.
for pkg do contains "$explicit" "$pkg" || { for pkg do contains "$explicit" "$pkg" || {
pkg_depends "$pkg" explicit pkg_depends "$pkg" explicit
# Mark packages passed on the command-line
# separately from those detected as dependencies.
explicit="$explicit $pkg " explicit="$explicit $pkg "
} done } done
# If this is an update, don't always build explicitly passsed packages
# and instead install pre-built binaries if they exist.
[ "$pkg_update" ] || explicit_build=$explicit [ "$pkg_update" ] || explicit_build=$explicit
# If an explicit package is a dependency of another explicit # If an explicit package is a dependency of another explicit package,
# package, remove it from the explicit list as it needs to be # remove it from the explicit list as it needs to be installed as a
# installed as a dependency. # dependency.
# shellcheck disable=2086 # shellcheck disable=2086
for pkg do contains "$deps" "$pkg" && for pkg do contains "$deps" "$pkg" &&
explicit=$(pop "$pkg" from $explicit) explicit=$(pop "$pkg" from $explicit)
@ -682,9 +687,7 @@ pkg_build() {
} done } done
for pkg do pkg_sources "$pkg"; done for pkg do pkg_sources "$pkg"; done
pkg_verify "$@" pkg_verify "$@"
log "$pkg" "Verified all checksums"
# Finally build and create tarballs for all passed packages and # Finally build and create tarballs for all passed packages and
# dependencies. # dependencies.
@ -739,8 +742,7 @@ pkg_build() {
# If the package contains '/etc', add a file called # If the package contains '/etc', add a file called
# 'etcsums' to the manifest. See comment directly above. # 'etcsums' to the manifest. See comment directly above.
[ -d "$pkg_dir/$pkg/etc" ] && [ -d "$pkg_dir/$pkg/etc" ] && : > "$pkg_dir/$pkg/$pkg_db/$pkg/etcsums"
: > "$pkg_dir/$pkg/$pkg_db/$pkg/etcsums"
pkg_strip "$pkg" pkg_strip "$pkg"
pkg_fixdeps "$pkg" pkg_fixdeps "$pkg"
@ -748,12 +750,11 @@ pkg_build() {
pkg_etcsums "$pkg" pkg_etcsums "$pkg"
pkg_tar "$pkg" pkg_tar "$pkg"
# Install only dependencies of passed packages. # Install only dependencies of passed packages. If this is an update,
# Skip this check if this is a package update. # install the built package regardless.
contains "$explicit" "$pkg" && [ -z "$pkg_update" ] && continue contains "$explicit" "$pkg" && [ -z "$pkg_update" ] && continue
log "$pkg" "Needed as a dependency or has an update, installing" log "$pkg" "Needed as a dependency or has an update, installing"
(KISS_FORCE=1 args i "$pkg") (KISS_FORCE=1 args i "$pkg")
done done
@ -789,8 +790,8 @@ pkg_checksums() {
continue continue
# File is local to the package. # File is local to the package.
elif [ -f "$(pkg_find "$1")/$src" ]; then elif [ -f "$repo_dir/$src" ]; then
src_path=$(pkg_find "$1")/${src%/*} src_path=$repo_dir/${src%/*}
# File is remote and was downloaded. # File is remote and was downloaded.
elif [ -f "$src_dir/$1/${src##*/}" ]; then elif [ -f "$src_dir/$1/${src##*/}" ]; then
@ -831,16 +832,18 @@ pkg_verify() {
done done
[ -z "$mismatch" ] || die "Checksum mismatch with: ${mismatch% }" [ -z "$mismatch" ] || die "Checksum mismatch with: ${mismatch% }"
log "Verified all checksums"
} }
pkg_conflicts() { pkg_conflicts() {
# Check to see if a package conflicts with another. # Check to see if a package conflicts with another.
log "$1" "Checking for package conflicts" log "$1" "Checking for package conflicts"
# Filter the tarball's manifest and select only files # Filter the tarball's manifest and select only files. Resolve all
# and any files they resolve to on the filesystem # symlinks in file paths as well.
# (/bin/ls -> /usr/bin/ls).
while read -r file; do while read -r file; do
# Skip all directories.
case $file in */) continue; esac case $file in */) continue; esac
# False positive. # False positive.
@ -852,19 +855,26 @@ pkg_conflicts() {
# directory. # directory.
cd -P "${file%/*}" 2>/dev/null || PWD=${file%/*} cd -P "${file%/*}" 2>/dev/null || PWD=${file%/*}
# Print the file with all symlinks in its path
# resolved to their real locations.
printf '%s\n' "${PWD#$KISS_ROOT}/${file##*/}" printf '%s\n' "${PWD#$KISS_ROOT}/${file##*/}"
cd "$old_PWD" cd "$old_PWD"
done < "$tar_dir/$1/$pkg_db/$1/manifest" > "$cac_dir/$pid-m" done < "$tar_dir/$1/$pkg_db/$1/manifest" > "$cac_dir/$pid-m"
[ -s "$cac_dir/$pid-m" ] || return 0
p_name=$1 p_name=$1
set +f
set -f "$sys_db"/*/manifest
# Generate a list of all installed package manifests # Generate a list of all installed package manifests and remove the
# and remove the current package from the list. # current package from the list. This is the simplest method of
# shellcheck disable=2046,2086 # dropping an item from the argument list. The one downside is that
set -- $(set +f; pop "$sys_db/$1/manifest" from "$sys_db"/*/manifest) # it cannot live in a function due to scoping.
for manifest do shift
[ "$sys_db/$p_name/manifest" = "$manifest" ] && continue
set -- "$@" "$manifest"
done
# Store the list of found conflicts in a file as we'll be using the # Store the list of found conflicts in a file as we'll be using the
# information multiple times. Storing things in the cache dir allows # information multiple times. Storing things in the cache dir allows