OSDN Git Service

fix instantinstall
[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     if ! imenu -c "the extra package $i is required. Download now?"; then
25         echo "package will not be installed"
26         exit 1
27     fi
28     INSTALLPACKAGES="true"
29     if ! checkinternet; then
30         imenu -e "internet is required"
31         exit 1
32     fi
33 done
34
35 if [ -n "$INSTALLPACKAGES" ]
36 then
37     echo "running command: yay -S --needed --noconfirm $@; sleep 2; exit"
38     st -e "bash" -c "yay -S --needed --noconfirm $@; sleep 2; exit"
39 fi
40
41
42 for i in $@
43 do
44     checkpackage "$i" || exit 1
45 done
46