OSDN Git Service

Merge branch 'master' of https://github.com/instantos/instantOS into master
[instantos/instantOS.git] / programs / instantinstall
1 #!/usr/bin/dash
2
3 # program that prompts the user to install a package if it is not already installed
4
5 if [ -z "$1" ]; then
6     echo "no package to check"
7     exit
8 fi
9
10 checkpackage() {
11     if command -v "$1" || pacman -Qi "$1"; then
12         echo "package $1 is installed"
13         return 0
14     else
15         echo "package $1 missing"
16         return 1
17     fi
18 }
19
20 for i in $@
21 do
22     echo "processing package $i"
23     checkpackage "$i" && continue
24
25     if ! imenu -c "the extra package $i is required. Download now?"; then
26         echo "package will not be installed"
27         exit 1
28     fi
29
30     if ! checkinternet; then
31         imenu -e "internet is required"
32         exit 1
33     fi
34
35
36 done
37
38 st -e "bash" -c "yay -S --needed --noconfirm $@ && sleep 2 && exit"
39
40 for i in $@
41 do
42     checkpackage "$i" || exit 1
43 done
44