From 284897af22fa4ed2284af37fb21046696b0a8738 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 24 Jul 2020 18:30:53 +0300 Subject: [PATCH] kiss: Support relative input to the install action. This adds support for relative paths when passing tarballs to kiss directly and removes a prevents a misleading and confusing error message from appearing (a false 'file not found'). --- kiss | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/kiss b/kiss index f25239a..03e0f7a 100755 --- a/kiss +++ b/kiss @@ -361,14 +361,16 @@ pkg_order() { order=; redro=; deps= for pkg do case $pkg in - *.tar.*) deps="$deps $pkg " ;; - *) pkg_depends "$pkg" raw + /*.tar.*) deps="$deps $pkg " ;; + *.tar.*) deps="$deps $ppwd/$pkg " ;; + *) pkg_depends "$pkg" raw esac done # Filter the list, only keeping explicit packages. The purpose of these # two loops is to order the argument list based on dependence. for pkg in $deps; do - contains "$*" "$pkg" && order="$order $pkg " redro=" $pkg $redro" + contains "$*" "$pkg" || contains "$*" "${pkg##"$ppwd/"}" && + order="$order $pkg " redro=" $pkg $redro" done deps= @@ -1064,7 +1066,7 @@ pkg_install() { # Install can also take the full path to a tarball. We don't need to check # the repository if this is the case. - if [ -f "$1" ] && [ -z "${1%%*.tar.*}" ] && [ -z "${1##*/*}" ]; then + if [ -f "$1" ] && [ -z "${1%%*.tar.*}" ]; then tar_file=$1 pkg_name=${1##*/} pkg_name=${pkg_name%#*} elif pkg_cache "$1" 2>/dev/null; then @@ -1487,6 +1489,11 @@ main() { # Check this once so as to not slow down printing. [ "$KISS_COLOR" = 0 ] || lcol='\033[1;33m' lcol2='\033[1;36m' lclr='\033[m' + # Store the original working directory to ensure that relative paths + # passed by the user on the command-line properly resolve to locations + # in the filesystem. + ppwd=$PWD + # The PID of the current shell process is used to isolate directories # to each specific KISS instance. This allows multiple package manager # instances to be run at once. Store the value in another variable so