aboutsummaryrefslogtreecommitdiff
path: root/kiss
diff options
context:
space:
mode:
Diffstat (limited to 'kiss')
-rwxr-xr-xkiss112
1 files changed, 61 insertions, 51 deletions
diff --git a/kiss b/kiss
index 32561a1..663bf65 100755
--- a/kiss
+++ b/kiss
@@ -75,7 +75,7 @@ pop() {
# Remove an item from a "string list". This allows us
# to remove a 'sed' call and reuse this code throughout.
del=$1
- shift "$(($# ? 1 : 0))"
+ shift
for i; do [ "$i" = "$del" ] || printf %s " $i "; done
}
@@ -88,6 +88,14 @@ run_hook() {
TYPE=$1 PKG=$2 DEST=$3 . "$KISS_HOOK"
}
+decompress() {
+ case $1 in
+ *.bz2) bzip2 -d ;;
+ *.xz) xz -dcT 0 ;;
+ *.tgz|*.gz) gzip -d ;;
+ esac < "$1"
+}
+
pkg_lint() {
# Check that each mandatory file in the package entry exists.
log "$1" "Checking repository files"
@@ -120,7 +128,7 @@ pkg_find() {
# '$KISS_PATH' as POSIX 'find' has no '-mindepth'/'-maxdepth'.
# See: https://unix.stackexchange.com/a/330372
IFS=:; set --
- for path in $KISS_PATH; do set "$@" "$path/."; done
+ for path in $KISS_PATH; do set -- "$@" "$path/."; done
IFS=$old_ifs
# Find the repository containing a package.
@@ -172,6 +180,15 @@ pkg_list() {
done
}
+pkg_cache() {
+ read -r version release 2>/dev/null < "$(pkg_find "$1")/version"
+
+ set +f; set -f -- "$bin_dir/$1#$version-$release.tar."*
+ tar_file=$1
+
+ [ -f "$tar_file" ]
+}
+
pkg_sources() {
# Download any remote package sources. The existence of local
# files is also checked.
@@ -287,7 +304,8 @@ pkg_extract() {
# Any other file-types are simply copied to '$mak_dir' which
# allows for manual extraction.
*://*.tar|*://*.tar.??|*://*.tar.???|*://*.tar.????|*://*.tgz)
- "$tar" xf "$src_dir/$1/${src##*/}" --strip-components 1 ||
+ decompress "$src_dir/$1/${src##*/}" |
+ tar xf - --strip-components 1 ||
die "$1" "Couldn't extract ${src##*/}"
;;
@@ -339,8 +357,8 @@ pkg_order() {
for pkg; do
case $pkg in
- *.tar.gz) deps="$deps $pkg " ;;
- *) pkg_depends "$pkg" raw
+ *.tar.*) deps="$deps $pkg " ;;
+ *) pkg_depends "$pkg" raw
esac
done
@@ -446,7 +464,7 @@ pkg_fixdeps() {
# first column.
sort -uk1,1 -o depends depends 2>/dev/null ||:
- # Display a diff of the new dependencies against the old ones.
+ # Display a diff of the new dependencies against the old ones.
diff "$dep_file" depends 2>/dev/null ||:
# Remove the depends file if it is empty.
@@ -493,8 +511,13 @@ pkg_tar() {
read -r version release < "$(pkg_find "$1")/version"
# Create a tar-ball from the contents of the built package.
- "$tar" zpcf "$bin_dir/$1#$version-$release.tar.gz" -C "$pkg_dir/$1" . ||
- die "$1" "Failed to create tar-ball"
+ "$tar" cf - -C "$pkg_dir/$1" . |
+ case ${KISS_COMPRESS:=gz} in
+ bz2) bzip2 -z ;;
+ xz) xz -zT 0 ;;
+ gz) gzip -6 ;;
+ esac \
+ > "$bin_dir/$1#$version-$release.tar.${KISS_COMPRESS:=gz}"
log "$1" "Successfully created tar-ball"
}
@@ -543,23 +566,16 @@ pkg_build() {
# directory and are up to date.
for pkg; do
# Don't check for a pre-built package if it was passed
- # to KISS directly.
- contains "$explicit_build" "$pkg" || {
- # Figure out the version and release.
- read -r version release < "$(pkg_find "$pkg")/version"
-
- # Install any pre-built binaries if they exist.
- # This calls 'args' to inherit a root check
- # to 'su' to elevate permissions.
- [ -f "$bin_dir/$pkg#$version-$release.tar.gz" ] && {
- log "$pkg" "Found pre-built binary, installing"
- (KISS_FORCE=1 args i "$bin_dir/$pkg#$version-$release.tar.gz")
-
- # Remove the now installed package from the build list.
- # See [1] at top of script.
- # shellcheck disable=2046,2086
- set -- $(pop "$pkg" "$@")
- }
+ # to KISS directly and install any pre-built binaries if
+ # they exist.
+ ! contains "$explicit_build" "$pkg" && pkg_cache "$pkg" && {
+ log "$pkg" "Found pre-built binary, installing"
+ (KISS_FORCE=1 args i "$tar_file")
+
+ # Remove the now installed package from the build list.
+ # See [1] at top of script.
+ # shellcheck disable=2046,2086
+ set -- $(pop "$pkg" "$@")
}
done
@@ -712,20 +728,20 @@ pkg_verify() {
pkg_conflicts() {
# Check to see if a package conflicts with another.
- log "$2" "Checking for package conflicts"
+ log "$1" "Checking for package conflicts"
# Filter the tarball's manifest and select only files
# and any files they resolve to on the filesystem
# (/bin/ls -> /usr/bin/ls).
- "$tar" xf "$1" -O "./$pkg_db/$2/manifest" | while read -r file; do
+ while read -r file; do
case $file in */) continue; esac
printf '%s/%s\n' \
"$(readlink -f "$KISS_ROOT/${file%/*}" 2>/dev/null)" \
"${file##*/}"
- done > "$cac_dir/$pid-m"
+ done < "$tar_dir/$1/$sys_db/$1/manifest" > "$cac_dir/$pid-m"
- p_name=$2
+ p_name=$1
# Generate a list of all installed package manifests
# and remove the current package from the list.
@@ -767,7 +783,7 @@ pkg_conflicts() {
# this work.
#
# Pretty nifty huh?
- while IFS=: read -r pro con || [ "$pro" ]; do
+ while IFS=: read -r _ con; do
log "$p_name" "Found conflict ($con), adding choice"
# Create the "choices" directory inside of the tarball.
@@ -898,37 +914,29 @@ pkg_install() {
# Install can also take the full path to a tar-ball.
# We don't need to check the repository if this is the case.
- if [ -f "$1" ] && [ -z "${1%%*.tar.gz}" ] ; then
+ if [ -f "$1" ] && [ -z "${1%%*.tar.*}" ] ; then
tar_file=$1
+ pkg_name=${1##*/}
+ pkg_name=${pkg_name%#*}
else
- # Read the version information to name the package.
- read -r version release < "$(pkg_find "$1")/version"
+ pkg_cache "$1" ||
+ die "package has not been built, run 'kiss b pkg'"
- # Construct the name of the package tarball.
- tar_file=$bin_dir/$1\#$version-$release.tar.gz
-
- [ -f "$tar_file" ] ||
- die "Package '$1' has not been built, run 'kiss build $1'"
+ pkg_name=$1
fi
- # Figure out which package the tar-ball installs by checking for
- # a database entry inside the tar-ball. If no database entry exists,
- # exit here as the tar-ball is *most likely* not a KISS package.
- pkg_name=$("$tar" tf "$tar_file" | "$grep" -x "\./$pkg_db/.*/version") ||
- die "'${tar_file##*/}' is not a valid KISS package"
-
- pkg_name=${pkg_name%/*}
- pkg_name=${pkg_name##*/}
-
mkdir -p "$tar_dir/$pkg_name"
+ log "$pkg_name" "Extracting $tar_file"
# Extract the tar-ball to catch any errors before installation begins.
- "$tar" pxf "$tar_file" -C "$tar_dir/$pkg_name" ||
- die "$pkg_name" "Failed to extract tar-ball"
+ decompress "$tar_file" | "$tar" pxf - -C "$tar_dir/$pkg_name"
log "$pkg_name" "Checking that all dependencies are installed"
+ [ -f "$tar_dir/$pkg_name/$pkg_db/$pkg_name/manifest" ] ||
+ die "'${tar_file##*/}' is not a valid KISS package"
+
# Make sure that all run-time dependencies are installed prior to
# installing the package.
[ -f "$tar_dir/$pkg_name/$pkg_db/$pkg_name/depends" ] &&
@@ -943,7 +951,7 @@ pkg_install() {
run_hook pre-install "$pkg_name" "$tar_dir/$pkg_name"
- pkg_conflicts "$tar_file" "$pkg_name"
+ pkg_conflicts "$pkg_name"
log "$pkg_name" "Installing package incrementally"
@@ -1059,6 +1067,8 @@ pkg_install() {
"$sys_db/$pkg_name/post-install" ||:
fi
+ run_hook post-install "$pkg_name" "$sys_db/$pkg_name"
+
log "$pkg_name" "Installed successfully"
}
@@ -1319,7 +1329,7 @@ args() {
l|list) pkg_list "$@" ;;
u|update) pkg_updates ;;
s|search) for pkg; do pkg_find "$pkg" all; done ;;
- v|version) log kiss 1.7.7 ;;
+ v|version) log kiss 1.8.1 ;;
h|help|-h|--help|'')
log 'kiss [a|b|c|f|i|l|r|s|u|v] [pkg] [pkg] [pkg]'