feat: enable bootstrapping of handlers
This commit is contained in:
parent
8256a99018
commit
e2e5ea97a9
1 changed files with 17 additions and 5 deletions
22
instalee
22
instalee
|
@ -3,6 +3,7 @@
|
||||||
## DEFINITIONS
|
## DEFINITIONS
|
||||||
name="$(basename "$0")"
|
name="$(basename "$0")"
|
||||||
homedir="$(find "$INSTALEE_HOME" "${XDG_CONFIG_HOME:-$HOME/.config}/$name" "$HOME/.$name" "$PWD" -maxdepth 0 2>/dev/null | head -1)"
|
homedir="$(find "$INSTALEE_HOME" "${XDG_CONFIG_HOME:-$HOME/.config}/$name" "$HOME/.$name" "$PWD" -maxdepth 0 2>/dev/null | head -1)"
|
||||||
|
handlers="$homedir/handlers.available"
|
||||||
packagedir="$homedir/packages"
|
packagedir="$homedir/packages"
|
||||||
|
|
||||||
highlight() { echo "[4m[1m$1[0m"; }
|
highlight() { echo "[4m[1m$1[0m"; }
|
||||||
|
@ -18,7 +19,7 @@ getcontent() {
|
||||||
|
|
||||||
# Get available package entries for given package
|
# Get available package entries for given package
|
||||||
getentries() {
|
getentries() {
|
||||||
cat "$homedir/handlers.available" | while read handler
|
cat "$handlers" | while read handler
|
||||||
do find "$packagedir/$1/" -depth -type f -name "$handler*" | tac 2>/dev/null
|
do find "$packagedir/$1/" -depth -type f -name "$handler*" | tac 2>/dev/null
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
@ -29,10 +30,10 @@ installpkg() {
|
||||||
local pkgs=$(getentries "$1")
|
local pkgs=$(getentries "$1")
|
||||||
local pkgdir="$packagedir/$1/"
|
local pkgdir="$packagedir/$1/"
|
||||||
if test -z "$pkgs"; then
|
if test -z "$pkgs"; then
|
||||||
local handlers=$(find "$pkgdir" -type f -printf "%f\n" 2>/dev/null)
|
local pkghandlers=$(find "$pkgdir" -type f -printf "%f\n" 2>/dev/null)
|
||||||
for handler in $handlers
|
for handler in $pkghandlers
|
||||||
do installpkg --quiet "$handler" &&
|
do installpkg --quiet "$handler" &&
|
||||||
echo "$handler" >> "$homedir/handlers.available" &&
|
echo "$handler" >>"$pkghandlers" &&
|
||||||
installpkg "$1" &&
|
installpkg "$1" &&
|
||||||
return $?
|
return $?
|
||||||
done
|
done
|
||||||
|
@ -117,12 +118,23 @@ runinstalee() {
|
||||||
if test -f "$groupfile"
|
if test -f "$groupfile"
|
||||||
then for pkg in $(getcontent "$groupfile")
|
then for pkg in $(getcontent "$groupfile")
|
||||||
do runinstalee "$pkg" ||
|
do runinstalee "$pkg" ||
|
||||||
"$homedir/handlers/$(head -1 handlers.available)/install" "$pkg"
|
"$homedir/handlers/$(head -1 "$handlers")/install" "$pkg"
|
||||||
|
# TODO apply noexec to how handlers are run - via sh
|
||||||
done
|
done
|
||||||
else installpkg "$1"
|
else installpkg "$1"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ! test -f "$handlers"
|
||||||
|
then copy="$(find "$homedir" -name "handlers.available.*" -exec sh -c "echo {} | rev | cut -d'.' -f1 | rev | xargs -i% expr $(lsb_release -s -i | tr 'A-Z' 'a-z') : % >/dev/null" \; -a -print)" &&
|
||||||
|
test -n "$copy" &&
|
||||||
|
echo "Bootstrapping available handlers from $copy" &&
|
||||||
|
cp "$copy" "$handlers" || {
|
||||||
|
echo "Missing available handlers in $handlers!"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
|
||||||
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