-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathap.freebsd-pkg
executable file
·99 lines (93 loc) · 2.39 KB
/
ap.freebsd-pkg
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
99
#!/usr/bin/env bash
# common pkg use
# honestly one probably doesn't need this script for freebsd. the pkgng manager
# is rather humanistic already
# 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
pkg install ${@:2}
;;
reinstall)
# Re-install package
pkg install --force ${@:2}
;;
remove)
# Uninstall and purge of all deps no longer required
# purge removes configs as well, install just the bin
pkg delete -R ${@:2}
# now remove any unneeded deps globlly
pkg autoremove --yes
;;
updatesecurity)
# Install security updates
if pkg audit -F; then
echo -e "\nTHE FOLLOWING PACKAGES WILL BE UPDATED:\n"
pkg upgrade --yes --dry-run
read -p "Run update? " answer
while true; do
case $answer in
[yY]* )
echo "Running"
pkg upgrade --yes
break;;
[nN]* ) exit;;
* ) echo "Enter Y or N, please."; break ;;
esac
done
fi
;;
search)
#Show packages available or already installed
echo -e "\nAVAILABLE:"
pkg search $2 | grep -E -i "$2"
echo -e "\nINSTALLED:"
pkg info | grep -E -i "$2"
echo -e "\nIf results empty run pkg update -f"
;;
ownerof)
#Show package for file
pkg which "$2"
;;
ineed)
#Show packages that would provide a file if installed
echo "couldn't find a method for this functionality in freebsd with pkgng"
# apt-file search "/$2" | grep -i -w "$2"
;;
ineedbadly)
#Show any package that contains string
echo "couldn't find a method for this functionality in freebsd with pkgng"
# apt-file search "$2" | grep -i "$2" # grep adds the coloring
;;
info)
#information about package
pkg which $2 | grep $2
;;
list)
#show files installed by package
pkg info -l $2
;;
*)
#pass through any other command on to apt-get
pkg $*
;;
esac
exit 0