feat: rename managers to handlers and respect environment
This commit is contained in:
parent
94d562489c
commit
d00b178f1c
14 changed files with 49 additions and 34 deletions
7
handlers.available
Normal file
7
handlers.available
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
apt
|
||||||
|
deb
|
||||||
|
snap
|
||||||
|
flatpak
|
||||||
|
script
|
||||||
|
make
|
||||||
|
custom
|
2
handlers/apt/install
Normal file
2
handlers/apt/install
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
#!/bin/sh
|
||||||
|
xargs sudo apt install
|
2
handlers/arch/install
Normal file
2
handlers/arch/install
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
#!/bin/sh
|
||||||
|
xargs sudo pacman -S
|
2
handlers/aur/install
Normal file
2
handlers/aur/install
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
#!/bin/sh
|
||||||
|
xargs sudo yay -S
|
11
handlers/deb/install
Normal file
11
handlers/deb/install
Normal 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
3
managers/make/install → handlers/make/install
Executable file → Normal file
|
@ -1,3 +1,4 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
cd $1
|
arg="$(read)"
|
||||||
|
cd "$arg"
|
||||||
sudo checkinstall
|
sudo checkinstall
|
7
handlers/script/install
Normal file
7
handlers/script/install
Normal 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
31
instalee
Executable file → Normal file
|
@ -1,31 +1,33 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
home="${XDG_CONFIG_HOME:-$HOME/.config}/instalee"
|
home="${INSTALEE_HOME:-${XDG_CONFIG_HOME:-$HOME/.config}/instalee}"
|
||||||
|
|
||||||
underline() { echo "[4m$1[0m"; }
|
underline() { echo "[4m$1[0m"; }
|
||||||
|
|
||||||
|
# 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() {
|
get() {
|
||||||
result=$(cat "$home/sources" | while read source
|
result="$(cat "$home/handlers.available" | while read handler
|
||||||
do find "$home/packages/$1" -name "$source*" 2>/dev/null
|
do find "$home/packages/$1" -name "$handler*" 2>/dev/null
|
||||||
done)
|
done)"
|
||||||
test ! "$result" && echo "No source for package '$1'" >>/dev/stderr && exit 1
|
test ! "$result" && echo "No handler for package '$1'" >>/dev/stderr && exit 1
|
||||||
echo "$result"
|
echo "$result"
|
||||||
}
|
}
|
||||||
|
|
||||||
getcontent() {
|
|
||||||
case "$(file "$1")" in
|
|
||||||
*executable*) $1;;
|
|
||||||
*) cat "$1";;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
case $1 in
|
case "$1" in
|
||||||
-a)
|
(--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"
|
dir="$home/packages/$2"
|
||||||
mkdir -p "$dir"
|
mkdir -p "$dir"
|
||||||
test $# -gt 3 && echo "$4">"$dir/$3" || $EDITOR "$dir/$3"
|
test $# -gt 3 && echo "$4">"$dir/$3" || $EDITOR "$dir/$3"
|
||||||
;;
|
;;
|
||||||
*)
|
(*)
|
||||||
set -e
|
set -e
|
||||||
pkgs=$(get "$1")
|
pkgs=$(get "$1")
|
||||||
echo "$pkgs" | while read pkg; do
|
echo "$pkgs" | while read pkg; do
|
||||||
|
@ -42,4 +44,3 @@ case $1 in
|
||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
sudo apt install "$@"
|
|
|
@ -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"
|
|
|
@ -1,2 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
pac -S "$@"
|
|
|
@ -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"
|
|
Loading…
Add table
Reference in a new issue