feat: rename managers to handlers and respect environment

This commit is contained in:
xeruf 2022-02-08 15:57:42 +01:00
parent 94d562489c
commit d00b178f1c
14 changed files with 49 additions and 34 deletions

7
handlers.available Normal file
View file

@ -0,0 +1,7 @@
apt
deb
snap
flatpak
script
make
custom

2
handlers/apt/install Normal file
View file

@ -0,0 +1,2 @@
#!/bin/sh
xargs sudo apt install

2
handlers/arch/install Normal file
View file

@ -0,0 +1,2 @@
#!/bin/sh
xargs sudo pacman -S

2
handlers/aur/install Normal file
View file

@ -0,0 +1,2 @@
#!/bin/sh
xargs sudo yay -S

11
handlers/deb/install Normal file
View file

@ -0,0 +1,11 @@
#!/bin/sh
# Install a package from a local or downloaded .deb-file and remove it
loc="/tmp/install.deb"
arg="$(read)"
case "$arg" in
(http*) sudo wget -O "$loc" "$arg";;
(*) loc="$arg";;
esac
sudo dpkg -i "$loc"
sudo apt -f install
sudo rm -f "$loc"

3
managers/make/install → handlers/make/install Executable file → Normal file
View file

@ -1,3 +1,4 @@
#!/usr/bin/env sh
cd $1
arg="$(read)"
cd "$arg"
sudo checkinstall

7
handlers/script/install Normal file
View file

@ -0,0 +1,7 @@
#!/bin/sh
read arg
read name
location="/usr/local/bin/${name:-$(basename "$arg")}"
curl "$arg" | sudo tee "$location" > /dev/null
sudo chmod +x "$location"
test "$INSTALEE_VERBOSE" -lt 3 || echo "Installed $name to $location"

31
instalee Executable file → Normal file
View file

@ -1,31 +1,33 @@
#!/bin/sh
home="${XDG_CONFIG_HOME:-$HOME/.config}/instalee"
home="${INSTALEE_HOME:-${XDG_CONFIG_HOME:-$HOME/.config}/instalee}"
underline() { echo "$1"; }
# Get the content of a file or the output of its execution
getcontent() { test -x "$1" && "$1" || cat "$1"; }
# Get available package entries for given package
get() {
result=$(cat "$home/sources" | while read source
do find "$home/packages/$1" -name "$source*" 2>/dev/null
done)
test ! "$result" && echo "No source for package '$1'" >>/dev/stderr && exit 1
result="$(cat "$home/handlers.available" | while read handler
do find "$home/packages/$1" -name "$handler*" 2>/dev/null
done)"
test ! "$result" && echo "No handler for package '$1'" >>/dev/stderr && exit 1
echo "$result"
}
getcontent() {
case "$(file "$1")" in
*executable*) $1;;
*) cat "$1";;
esac
}
case $1 in
-a)
case "$1" in
(--version)
printf "instalee r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
# TODO license https://www.gnu.org/prep/standards/html_node/_002d_002dversion.html#g_t_002d_002dversion
;;
(-a|--add)
dir="$home/packages/$2"
mkdir -p "$dir"
test $# -gt 3 && echo "$4">"$dir/$3" || $EDITOR "$dir/$3"
;;
*)
(*)
set -e
pkgs=$(get "$1")
echo "$pkgs" | while read pkg; do
@ -42,4 +44,3 @@ case $1 in
done
;;
esac

View file

@ -1,2 +0,0 @@
#!/bin/sh
sudo apt install "$@"

View file

@ -1,9 +0,0 @@
#!/bin/sh
loc="/tmp/install.deb"
case $1 in
(http*) sudo wget -O "$loc" $1 ;;
(*) loc="$1" ;;
esac
sudo dpkg -i "$loc"
sudo apt -f install
sudo rm -f "$loc"

View file

@ -1,2 +0,0 @@
#!/bin/sh
pac -S "$@"

View file

@ -1,5 +0,0 @@
#!/bin/sh
location="/usr/local/bin/$(basename $1)"
curl "$1" | sudo tee "$location" > /dev/null
sudo chmod +x "$location"
echo "Installed to $location"