This commit is contained in:
dupa 2024-01-08 18:50:39 +01:00
commit 1692cafd01
3 changed files with 67 additions and 0 deletions

11
README.md Normal file
View File

@ -0,0 +1,11 @@
# nicpkg
nicpkgs is simple package manager wirten in sh(it's just script)
<br>
it doesn't support deps 'cuz i'm lazy
how to install it?
use this command:
```sh
cd /usr/bin/; sudo curl -O https://git.aey.ovh/whoami/nicpkg/raw/branch/main/nicpkg; sudo chmod +x nicpkg
```

5
config Normal file
View File

@ -0,0 +1,5 @@
repos=(
"https://files.aey.ovh/nicpkg"
)
root="sudo"
downloader="curl -O"

51
nicpkg Executable file
View File

@ -0,0 +1,51 @@
#!/bin/sh
. /etc/nicpkg/config
Install() {
pkgAvail=()
for repo in "${repos[@]}"; do
y=$(curl -o /dev/null -s -w "%{http_code}\n" $repo/$1/$1.sh)
[[ $y = 200 ]] && pkgAvail+=($repo)
if [ ${repos[-1]} = $repo ] && [ ${#pkgAvail[@]} = 0 ]; then
echo "package not found"
return 0
fi
done
sex() {
cd /etc/nicpkg/pkgs; $root $downloader $1/$2/$2.sh; . /etc/nicpkg/pkgs/$2.sh; install
}
sexo() {
echo "package is available in:"
echo "==========================="
z=0
for x in ${pkgAvail[@]}; do
z=$(($z+1))
echo "$z - $x"
done
echo "==========================="
echo "from which repository do you want to install this package?"
read -p ": " choose
sex ${pkgAvail[(($choose-1))]} $e
}
[[ ${#pkgAvail[@]} = 1 ]] && sex ${pkgAvail[0]} $1
[[ ${#pkgAvail[@]} != 1 ]] && sexo
}
Uninstall() {
if [ ! -f /etc/nicpkg/pkgs/$1.sh ]; then
echo "package isn't installed"
return
fi
. /etc/nicpkg/pkgs/$1.sh; uninstall; sudo rm /etc/nicpkg/pkgs/$1.sh
echo "package removed"
}
case $1 in
"install" | "i") Install $2 ;;
"uninstall" | "u" | "r") Uninstall $2 ;;
*) printf "nicpkg is simple package manager wrote in sh\nthat's all what i had to say";;
esac