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').
This commit is contained in:
Dylan Araps 2020-07-24 18:30:53 +03:00
parent 528b3023a9
commit 284897af22
No known key found for this signature in database
GPG Key ID: 46D62DD9F1DE636E

15
kiss
View File

@ -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