aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornoreply@github.com <noreply@github.com>2019-09-11 05:42:26 +0000
committernoreply@github.com <noreply@github.com>2019-09-11 05:42:26 +0000
commit00fbd879daae21ea238bec57b64d4e32d8c85e29 (patch)
tree4f097a7fd6aa8f01563ec39c836602f3e4cfb5b0
parentbbb27e032d2a10741d5f6f6ba27a4ea7356fb2ba (diff)
parent58b1e1c7616867d0f9496b4d9b44da66f348303c (diff)
downloadcpt-00fbd879daae21ea238bec57b64d4e32d8c85e29.tar.gz
Merge pull request #52 from kisslinux/install_change
kiss: make pkg_install operate on a single package at a time FossilOrigin-Name: aef7599bc6bde3ee61237c987ca53a8fe0bc2e03cf2b314d6d50767bfb5af740
-rwxr-xr-xkiss215
1 files changed, 106 insertions, 109 deletions
diff --git a/kiss b/kiss
index 62386a6..30e30db 100755
--- a/kiss
+++ b/kiss
@@ -642,134 +642,132 @@ pkg_remove() {
pkg_install() {
# Install a built package tar-ball.
- for pkg; do
- # 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 "$pkg" ] && [ -z "${pkg%%*.tar.gz}" ] ; then
- tar_file=$pkg
-
- else
- # Read the version information to name the package.
- read -r version release < "$(pkg_find "$pkg")/version"
+ # 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
+ tar_file=$1
- # Construct the name of the package tarball.
- tar_name=$pkg\#$version-$release.tar.gz
+ else
+ # Read the version information to name the package.
+ read -r version release < "$(pkg_find "$1")/version"
- [ -f "$bin_dir/$tar_name" ] ||
- die "Package '$pkg' has not been built" \
- "Run 'kiss build $pkg'"
+ # Construct the name of the package tarball.
+ tar_name=$1\#$version-$release.tar.gz
- tar_file=$bin_dir/$tar_name
- fi
+ [ -f "$bin_dir/$tar_name" ] ||
+ die "Package '$1' has not been built" \
+ "Run 'kiss build $1'"
- # 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"
+ tar_file=$bin_dir/$tar_name
+ fi
- pkg_name=${pkg_name%/*}
- pkg_name=${pkg_name##*/}
+ # 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_conflicts "$tar_file" "$pkg_name"
+ pkg_name=${pkg_name%/*}
+ pkg_name=${pkg_name##*/}
- mkdir -p "$tar_dir/$pkg_name"
+ pkg_conflicts "$tar_file" "$pkg_name"
- # 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"
+ mkdir -p "$tar_dir/$pkg_name"
- log "[$pkg_name] Checking that all dependencies are installed"
+ # 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"
- # Make sure that all run-time dependencies are installed prior to
- # installing the package.
- [ -f "$tar_dir/$pkg_name/$pkg_db/$pkg_name/depends" ] &&
- while read -r dep dep_type; do
- [ "${dep##\#*}" ] || continue
- [ "$dep_type" ] || pkg_list "$dep" >/dev/null ||
- install_dep="$install_dep'$dep', "
- done < "$tar_dir/$pkg_name/$pkg_db/$pkg_name/depends"
+ log "[$pkg_name] Checking that all dependencies are installed"
- [ "$install_dep" ] && die "[$1] Package requires ${install_dep%, }"
+ # Make sure that all run-time dependencies are installed prior to
+ # installing the package.
+ [ -f "$tar_dir/$pkg_name/$pkg_db/$pkg_name/depends" ] &&
+ while read -r dep dep_type; do
+ [ "${dep##\#*}" ] || continue
+ [ "$dep_type" ] || pkg_list "$dep" >/dev/null ||
+ install_dep="$install_dep'$dep', "
+ done < "$tar_dir/$pkg_name/$pkg_db/$pkg_name/depends"
- log "[$pkg_name] Installing package"
+ [ "$install_dep" ] && die "[$1] Package requires ${install_dep%, }"
- # Block being able to abort the script with Ctrl+C during installation.
- # Removes all risk of the user aborting a package installation leaving
- # an incomplete package installed.
- trap '' INT
+ log "[$pkg_name] Installing package"
- # If the package is already installed (and this is an upgrade) make a
- # backup of the manifest file.
- if [ -f "$sys_db/$pkg_name/manifest" ]; then
- old_manifest=$(cat "$sys_db/$pkg_name/manifest")
- else
- old_manifest=
- fi
+ # Block being able to abort the script with Ctrl+C during installation.
+ # Removes all risk of the user aborting a package installation leaving
+ # an incomplete package installed.
+ trap '' INT
- # This is repeated multiple times. Better to make it a function.
- pkg_rsync() {
- rsync --chown=root:root -HKav --exclude etc -- \
- "$tar_dir/$pkg_name/" "$KISS_ROOT/"
- }
+ # If the package is already installed (and this is an upgrade) make a
+ # backup of the manifest file.
+ if [ -f "$sys_db/$pkg_name/manifest" ]; then
+ old_manifest=$(cat "$sys_db/$pkg_name/manifest")
+ else
+ old_manifest=
+ fi
+
+ # This is repeated multiple times. Better to make it a function.
+ pkg_rsync() {
+ rsync --chown=root:root -HKav --exclude etc -- \
+ "$tar_dir/$pkg_name/" "$KISS_ROOT/"
+ }
- # Install the package by using 'rsync' and overwrite any existing files
- # (excluding '/etc/').
- pkg_rsync
+ # Install the package by using 'rsync' and overwrite any existing files
+ # (excluding '/etc/').
+ pkg_rsync
- # If '/etc/' exists in the package, install it but don't overwrite.
- [ -d "$tar_dir/$pkg_name/etc" ] &&
- rsync --chown=root:root -HKav --ignore-existing \
- "$tar_dir/$pkg_name/etc" "$KISS_ROOT/"
+ # If '/etc/' exists in the package, install it but don't overwrite.
+ [ -d "$tar_dir/$pkg_name/etc" ] &&
+ rsync --chown=root:root -HKav --ignore-existing \
+ "$tar_dir/$pkg_name/etc" "$KISS_ROOT/"
- # Remove any leftover files if this is an upgrade.
- [ "$old_manifest" ] && {
- printf '%s\n' "$old_manifest" |
- grep -vFxf "$sys_db/$pkg_name/manifest" - |
+ # Remove any leftover files if this is an upgrade.
+ [ "$old_manifest" ] && {
+ printf '%s\n' "$old_manifest" |
+ grep -vFxf "$sys_db/$pkg_name/manifest" - |
- while read -r file; do
- # Skip deleting some leftover files.
- case $file in
- /etc/*|*bin/rm|*bin/busybox|*bin/rsync) continue ;;
- esac
+ while read -r file; do
+ # Skip deleting some leftover files.
+ case $file in
+ /etc/*|*bin/rm|*bin/busybox|*bin/rsync) continue ;;
+ esac
- file=$KISS_ROOT/$file
+ file=$KISS_ROOT/$file
- # Remove files.
- if [ -f "$file" ] && [ ! -L "$file" ]; then
- rm -f "$file"
+ # Remove files.
+ if [ -f "$file" ] && [ ! -L "$file" ]; then
+ rm -f "$file"
- # Remove file symlinks.
- elif [ -L "$file" ] && [ ! -d "$file" ]; then
- unlink "$file" ||:
+ # Remove file symlinks.
+ elif [ -L "$file" ] && [ ! -d "$file" ]; then
+ unlink "$file" ||:
- # Skip directory symlinks.
- elif [ -L "$file" ] && [ -d "$file" ]; then
- :
+ # Skip directory symlinks.
+ elif [ -L "$file" ] && [ -d "$file" ]; then
+ :
- # Remove directories if empty.
- elif [ -d "$file" ]; then
- rmdir "$file" 2>/dev/null ||:
- fi
- done ||:
- }
+ # Remove directories if empty.
+ elif [ -d "$file" ]; then
+ rmdir "$file" 2>/dev/null ||:
+ fi
+ done ||:
+ }
- # Install the package again to fix any non-leftover files being
- # removed above.
- pkg_rsync ||:
- pkg_rsync ||:
+ # Install the package again to fix any non-leftover files being
+ # removed above.
+ pkg_rsync ||:
+ pkg_rsync ||:
- # Reset 'trap' to its original value. Installation is done so
- # we no longer need to block 'Ctrl+C'.
- trap pkg_clean EXIT INT
+ # Reset 'trap' to its original value. Installation is done so
+ # we no longer need to block 'Ctrl+C'.
+ trap pkg_clean EXIT INT
- [ -x "$sys_db/$pkg_name/post-install" ] && {
- log "[$pkg_name] Running post-install script"
- "$sys_db/$pkg_name/post-install" ||:
- }
+ [ -x "$sys_db/$pkg_name/post-install" ] && {
+ log "[$pkg_name] Running post-install script"
+ "$sys_db/$pkg_name/post-install" ||:
+ }
- log "[$pkg_name] Installed successfully"
- done
+ log "[$pkg_name] Installed successfully"
}
pkg_updates() {
@@ -947,21 +945,20 @@ args() {
i|install)
# Create a list of each package's dependencies.
for pkg; do
- if [ "${pkg%%*.tar.gz}" ]; then
- pkg_depends "$pkg"
- else
- missing_deps="$missing_deps $pkg "
- fi
+ case $pkg in
+ *.tar.gz) missing_deps="$missing_deps $pkg " ;;
+ *) pkg_depends "$pkg"
+ esac
done
- # Filter the list, only including explicit packages.
+ # Filter the list, only installing explicit packages.
+ # The purpose of these two loops is to order the
+ # argument list based on dependence.
for pkg in $missing_deps; do
case " $* " in
- *" $pkg "*) install_pkgs="$install_pkgs $pkg " ;;
+ *" $pkg "*) pkg_install "$pkg" ;;
esac
done
-
- pkg_install $install_pkgs
;;
r|remove)