-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.sh
More file actions
53 lines (52 loc) · 1.76 KB
/
functions.sh
File metadata and controls
53 lines (52 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
#-------------------------------------------------------------------------------
#Check if a package is installed------------------------------------------------
function _isInstalled {
package="$1";
check="$(pacman -Qs --color always "${package}" | grep "local" | grep "${package} ")";
if [ -n "${check}" ] ; then
echo 0; #'0' means 'true' in Bash
return; #true
fi;
echo 1; #'1' means 'false' in Bash
return; #false
}
#-------------------------------------------------------------------------------
#Install packages from AUR repository-------------------------------------------
function InstallFromAUR {
#The packages that are not installed will be added to this array.
toInstall=();
#Loop through packages
for pkg; do
# If the package IS installed, skip it.
if [[ $(_isInstalled "${pkg}") == 0 ]]; then
echo "${pkg} is already installed."
continue
fi
#Otherwise, add it to the list of packages to install.
toInstall+=("${pkg}")
done
#Install missing packages
for index in "${!toInstall[@]}"; do
cd $HOME
echo ""
#Git clone the package
if ! [[ -d ${toInstall[$index]} ]]; then
git clone "https://aur.archlinux.org/${toInstall[$index]}.git"
if [[ "$(ls -A "${toInstall[$index]}" | wc -l)" < 2 ]]; then
echo "Package not found on AUR repository: ${toInstall[$index]}"
rm -rf "${toInstall[$index]}"
continue
else
cd ${toInstall[$index]}
fi
else
cd ${toInstall[$index]}
git pull
fi
makepkg -si --noconfirm --skippgpcheck; #Install
cd $HOME; rm -rf "${toInstall[$index]}"; #Remove source
done
}
#-------------------------------------------------------------------------------
"$@"