add elf_package "manager"
This commit is contained in:
104
private_dot_local/bin/executable_elf_packages
Normal file
104
private_dot_local/bin/executable_elf_packages
Normal file
@@ -0,0 +1,104 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
SCRIPTS_DIR="$HOME/.local/share/elfos"
|
||||
|
||||
function print_help() {
|
||||
echo "usage: elf_packages <ACTION>"
|
||||
echo
|
||||
echo "ACTION:"
|
||||
echo " list list available scripts"
|
||||
echo " install <script> execute install script"
|
||||
echo " uninstall <script> execute remove script"
|
||||
echo " help display this help"
|
||||
}
|
||||
|
||||
function check_if_script_exists() {
|
||||
script="$1"
|
||||
|
||||
if [[ ! -f "$SCRIPTS_DIR/$script.sh" ]]
|
||||
then
|
||||
echo "ERROR: $script does not exists"
|
||||
print_help
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
function install_pacman_deps() {
|
||||
deps="$1"
|
||||
|
||||
pacman -Sy --noconfirm $deps
|
||||
}
|
||||
|
||||
function update() {
|
||||
script="$1"
|
||||
|
||||
check_if_script_exists "$script" || return 1
|
||||
|
||||
. "$SCRIPTS_DIR/$script.sh"
|
||||
|
||||
if package_check_installed
|
||||
then
|
||||
package_update
|
||||
else
|
||||
echo "package not installed"
|
||||
fi
|
||||
}
|
||||
|
||||
function uninstall() {
|
||||
script="$1"
|
||||
|
||||
check_if_script_exists "$script" || return 1
|
||||
|
||||
. "$SCRIPTS_DIR/$script.sh"
|
||||
|
||||
if package_check_installed
|
||||
then
|
||||
package_remove
|
||||
else
|
||||
echo "package not installed"
|
||||
fi
|
||||
}
|
||||
|
||||
function update() {
|
||||
script="$1"
|
||||
|
||||
check_if_script_exists "$script" && return 1
|
||||
|
||||
. "$SCRIPTS_DIR/$script"
|
||||
package_update
|
||||
}
|
||||
|
||||
case $1 in
|
||||
list)
|
||||
find "$SCRIPTS_DIR" -maxdepth 1 -name '*.sh' \
|
||||
-exec basename "{}" ';' \
|
||||
| sed -e 's/\.sh$//'
|
||||
;;
|
||||
install)
|
||||
shift
|
||||
install $*
|
||||
;;
|
||||
uninstall)
|
||||
shift
|
||||
uninstall $*
|
||||
;;
|
||||
update)
|
||||
shift
|
||||
update $*
|
||||
;;
|
||||
help)
|
||||
print_help
|
||||
;;
|
||||
"--help")
|
||||
print_help
|
||||
;;
|
||||
"-h")
|
||||
print_help
|
||||
;;
|
||||
*)
|
||||
echo "ERROR: invalid action $1"
|
||||
print_help
|
||||
;;
|
||||
esac
|
||||
Reference in New Issue
Block a user