blob: d4c8ab83ce58a7cb037ac997ace33d98637714df (
plain)
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
#!/bin/bash
if test -t 1; then
# see if it supports colors...
ncolors=$(tput colors)
if test -n "$ncolors" && test $ncolors -ge 8; then
bold="$(tput bold)"
underline="$(tput smul)"
standout="$(tput smso)"
normal="$(tput sgr0)"
black="$(tput setaf 0)"
red="$(tput setaf 1)"
green="$(tput setaf 2)"
yellow="$(tput setaf 3)"
blue="$(tput setaf 4)"
magenta="$(tput setaf 5)"
cyan="$(tput setaf 6)"
white="$(tput setaf 7)"
fi
fi
REMOVE=false
CLEAR_CACHE=false
for arg in "$@"; do
shift
case "$arg" in
"--remove") set -- "$@" "-r" ;;
"--clear-cache") set -- "$@" "-c" ;;
"--help") set -- "$@" "-h" ;;
*) set -- "$@" "$arg"
esac
done
shift $((OPTIND -1))
while getopts ":rch" opt; do
case $opt in
r )
REMOVE=true
;;
c )
CLEAR_CACHE=true
;;
h )
echo "Usage: haur [--remove | -r] | [--clear-cache | -c] <package names>"
exit 0
;;
\?)
echo "${red}Invalid Option: -$OPTARG${normal}" 1>&2
exit 1
;;
esac
done
shift $((OPTIND -1))
if [ $REMOVE == true ]; then
for PACKAGE_NAME in "$@"; do
echo "${blue}Removing $PACKAGE_NAME...${normal}"
sudo pacman -Rns $PACKAGE_NAME
echo $PACKAGE_NAME > ~/.haur_cache
done
if [ $CLEAR_CACHE == true ]; then
if test -f "$HOME/.haur_cache"; then
echo "${blue}Clearing cache...${normal}"
while IFS= read -r line || [[ -n "$line" ]]; do
echo "${blue}Removing $line${normal}"
rm -rf $HOME/.haur/$line
done < "$HOME/.haur_cache"
rm ~/.haur_cache
else
echo "${blue}Nothing to clear${normal}"
fi
fi
else
if [ $CLEAR_CACHE == true ]; then
if test -f "$HOME/.haur_cache"; then
echo "${blue}Clearing cache...${normal}"
while IFS= read -r line || [[ -n "$line" ]]; do
echo "${blue}Removing $line${normal}"
rm -rf $HOME/.haur/$line
done < "$HOME/.haur_cache"
rm ~/.haur_cache
else
echo "${blue}Nothing to clear${normal}"
fi
fi
for PACKAGE_NAME in "$@"; do
echo "${blue}Installing $PACKAGE_NAME...${normal}"
mkdir -p ~/.haur
cd ~/.haur
git clone https://aur.archlinux.org/$PACKAGE_NAME.git
cd $PACKAGE_NAME
makepkg -si
done
fi
|