feat: allow installing via default handler and auto-amend package list
This commit is contained in:
parent
570c142ade
commit
f216c40334
1 changed files with 23 additions and 20 deletions
43
instalee
43
instalee
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
## DEFINITIONS
|
## DEFINITIONS
|
||||||
name="$(basename "$0")"
|
name="$(basename "$0")"
|
||||||
homedir="$(find "$INSTALEE_HOME" "${XDG_CONFIG_HOME:-$HOME/.config}/$name" "$HOME/.$name" "$(dirname $0)" "$PWD" -maxdepth 0 2>/dev/null | head -1)"
|
self="$(realpath "$0")"
|
||||||
|
homedir="$(find "$INSTALEE_HOME" "${XDG_CONFIG_HOME:-$HOME/.config}/$name" "$HOME/.$name" "$(dirname "$0")" "$PWD" -maxdepth 0 2>/dev/null | head -1)"
|
||||||
handlers="$homedir/handlers.available"
|
handlers="$homedir/handlers.available"
|
||||||
packagedir="$homedir/packages"
|
packagedir="$homedir/packages"
|
||||||
|
|
||||||
|
@ -74,8 +75,8 @@ installpkg() {
|
||||||
}
|
}
|
||||||
|
|
||||||
## EXECUTION
|
## EXECUTION
|
||||||
chmod +rx "$homedir/handlers" -R
|
|
||||||
|
|
||||||
|
# TODO getopt
|
||||||
case "$1" in
|
case "$1" in
|
||||||
(-V|--version|"")
|
(-V|--version|"")
|
||||||
printf "$name r%s.%s\n" "$(git rev-list --count HEAD 2>/dev/null)" "$(git rev-parse --short HEAD 2>/dev/null)"
|
printf "$name r%s.%s\n" "$(git rev-list --count HEAD 2>/dev/null)" "$(git rev-parse --short HEAD 2>/dev/null)"
|
||||||
|
@ -110,30 +111,26 @@ case "$1" in
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
(-v|--verbose)
|
(-v|--verbose) set -x; shift;;
|
||||||
set -x
|
(-d|--default) default=true; shift;;
|
||||||
shift
|
(-x|--noexec) noexec=true; shift;;
|
||||||
;;
|
|
||||||
(-x|--noexec)
|
|
||||||
noexec=true
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
|
noexec=true
|
||||||
|
|
||||||
|
installdefault() {
|
||||||
|
local defaulthandler="$(head -1 "$handlers")"
|
||||||
|
highlight "Attempting install of $1 via default handler"
|
||||||
|
$(test "$noexec" && echo "sh") "$homedir/handlers/$defaulthandler/install" "$1" &&
|
||||||
|
$(test "$noexec" && echo "sh") "$self" --add "$1" "$defaulthandler" ""
|
||||||
|
}
|
||||||
|
|
||||||
execdir=/tmp/instalee.%(date +%s)
|
|
||||||
mkdir -p $execdir
|
|
||||||
cd $execdir
|
|
||||||
runinstalee() {
|
runinstalee() {
|
||||||
groupfile="$homedir/groups/$1"
|
local groupfile="$homedir/groups/$1"
|
||||||
if test -f "$groupfile"
|
if test -f "$groupfile"
|
||||||
then for pkg in $(getcontent "$groupfile")
|
then for pkg in $(getcontent "$groupfile")
|
||||||
do if ! runinstalee "$pkg"
|
do runinstalee "$pkg" || installdefault "$pkg"
|
||||||
then highlight "Attempting install of $pkg via default handler"
|
|
||||||
"$homedir/handlers/$(head -1 "$handlers")/install" "$pkg"
|
|
||||||
# TODO apply noexec to how handlers are run - via sh
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
else installpkg "$1"
|
else installpkg "$1" || { test "$default" && installdefault "$1"; }
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,6 +144,12 @@ then copy="$(find "$homedir" -name "handlers.available.*" -exec sh -c "echo {} |
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
chmod +rx "$homedir/handlers" -R
|
||||||
|
|
||||||
|
execdir=/tmp/instalee.$(date +%s)
|
||||||
|
mkdir -p $execdir
|
||||||
|
cd $execdir
|
||||||
|
|
||||||
exitcode=0
|
exitcode=0
|
||||||
while test $# -gt 0; do
|
while test $# -gt 0; do
|
||||||
runinstalee "$1"
|
runinstalee "$1"
|
||||||
|
|
Loading…
Add table
Reference in a new issue