-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathap.osx-brew
executable file
·84 lines (78 loc) · 2.37 KB
/
ap.osx-brew
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
#!/usr/bin/env bash
# common apt use
# As this script may be called from sudo, suggest safer permissions
l=($(ls -l `readlink -f $0`))
[ ${l[0]:2:1} != "-" ] && [ "${l[2]}" != "root" ] ||
[ ${l[0]:5:1} != "-" ] && [ "${l[3]}" != "root" ] ||
[ ${l[0]:8:1} != "-" ] && {
echo -e "Script uses or is called from sudo often.\nOnly root should be able to modify.\n${l[@]}\n";}
# Get usage_self()
# handle cases where user has linked script into their bin
if ! type usage_self >/dev/null 2>&1 ; then
if readlink $0 >/dev/null 2>&1 ; then
source $(dirname $(readlink $0))/humanism.sh usage_self
else
source $(dirname $0)/humanism.sh usage_self
fi
fi
if [ $# -eq -0 ]; then
usage_self
exit
fi
case "$1" in
install)
#Install package
brew install ${@:2}
;;
reinstall)
#Re-install package
!!apt-get install --reinstall ${@:2}
;;
remove)
#Uninstall and purge of all deps no longer required
# purge removes configs as well, install just the bin
brew remove ${@:2}
# now remove any unneeded deps globlly
#apt-get -y autoremove
;;
updatesecurity)
#Install security updates
echo "Feature not supported with homebrew"
;;
search)
#Show packages available or already installed
echo -e "\nAVAILABLE:"
brew search /$2/ | grep --color -i "$2"
echo -e "\nINSTALLED:"
brew list | grep --color -i "$2"
;;
ownerof)
#Show package for file
/usr/bin/env find $(brew --cellar) -iname "*$2*" | grep --color -i "$2"
;;
ineed)
#Show packages that would provide a file if installed
echo "Feature not supported with homebrew"
echo "Showing results from Debian packages"
echo -en $(echo $(curl -s "https://packages.debian.org/search?suite=default§ion=all&arch=any&searchon=contents&keywords=$2") | sed 's%</*tr>%\\n%g') | grep 'class="file"' | sed 's/<[^>]*>//g' | column -t | grep --color -i -w "$2"
;;
ineedbadly)
#Show any package that contains string
echo "Feature not supported with homebrew"
echo "Showing results from Debian packages"
echo -en $(echo $(curl -s "https://packages.debian.org/search?suite=default§ion=all&arch=any&searchon=contents&keywords=$2") | sed 's%</*tr>%\\n%g') | grep 'class="file"' | sed 's/<[^>]*>//g' | column -t | grep --color -i "$2"
;;
info)
#information about package
brew info $2
;;
list)
#show files installed by package
brew list $2
;;
*)
#pass through any other command on to apt-get
brew $*
;;
esac
exit 0