aboutsummaryrefslogtreecommitdiff
path: root/kiss
diff options
context:
space:
mode:
authordylan.araps@gmail.com <dylan.araps@gmail.com>2020-03-15 10:50:48 +0000
committerdylan.araps@gmail.com <dylan.araps@gmail.com>2020-03-15 10:50:48 +0000
commit1e8c2c8b4a99173fe2a511fd76a60204197c748c (patch)
treee986cbfdb2f285144f2520ee8d4115b0817eb6f7 /kiss
parent3b5cd15c9910f9008db1fce2ef3c119bb1bbf6bd (diff)
downloadcpt-1e8c2c8b4a99173fe2a511fd76a60204197c748c.tar.gz
kiss: Configurable and dynamic tarball compression.
This allows you to swap between gzip and xz compression via the new environment variable ('KISS_COMPRESS'). As of this commit, new builds will use xz compression (making use of all cores on the machine). Other compression methods can easily be added by adding two simple lines to the script. Your existing package cache will continue to be used as the package manager will use whatever tarball is available (for the package and version it is looking for). FossilOrigin-Name: 96eb74f812edb60748ad9bf8450fab4a28494672482fd1ac19fc8397853629f3
Diffstat (limited to 'kiss')
-rwxr-xr-xkiss66
1 files changed, 34 insertions, 32 deletions
diff --git a/kiss b/kiss
index 18eabc9..68cdcee 100755
--- a/kiss
+++ b/kiss
@@ -172,6 +172,15 @@ pkg_list() {
done
}
+pkg_cache() {
+ read -r version release < "$(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.
@@ -339,8 +348,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
@@ -493,8 +502,12 @@ 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:=xz} in
+ xz) xz -zT 0 ;;
+ gz) gzip -6 ;;
+ esac \
+ > "$bin_dir/$1#$version-$release.tar.${KISS_COMPRESS:=xz}"
log "$1" "Successfully created tar-ball"
}
@@ -543,23 +556,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
@@ -898,18 +904,11 @@ 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
else
- # Read the version information to name the package.
- read -r version release < "$(pkg_find "$1")/version"
-
- # 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_cache "$1" || die "$1" "has not been built, run 'kiss b $1'"
fi
# Figure out which package the tar-ball installs by checking for
@@ -922,10 +921,13 @@ pkg_install() {
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"
+ case $tar_file in
+ *.xz) xz -dcT 0 ;;
+ *.gz) gzip -d ;;
+ esac < "$tar_file" | "$tar" pxf - -C "$tar_dir/$pkg_name"
log "$pkg_name" "Checking that all dependencies are installed"