-
Notifications
You must be signed in to change notification settings - Fork 0
/
update
executable file
·87 lines (69 loc) · 1.87 KB
/
update
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
#!/bin/sh
### v3.0
###
### This script upgrades all the installed ports
### for which a new version is available.
## INIT section (don't change)
# Where the script resides
WP=$(dirname $0)
# Config file to use
CONF=$WP/$(basename $0).conf
if [ -z "$(pkg info -qo portmaster)" ]; then
echo "ports-mgmt/portmaster not installed (required)" > /dev/stderr
exit 1;
fi
if [ -f $CONF ]; then
# Check for ports to ignore.
for a in $(cat update.conf | grep -e '^ignore' | cut -d '=' -f2-); do
if [ ! -z $a ]; then IGNORE="$IGNORE -x $a"; fi
done;
else
# Create new config file.
echo "## Update config file (autogenerated)" > $CONF
echo "# Ports to ignore (see also portmaster(8))" > $CONF
echo "#ignore=screen nvidia-driver" > $CONF
fi
if [ ! -z $(fuser portmaster.log 2> /dev/null) ]; then
echo "Portmaster logfile currently in use, exiting!" > /dev/stderr
echo "(did you run refresh recently?)" > /dev/stderr
exit 1;
fi
if [ "$(grep moved $WP/portmaster.log)" ]; then
echo "Moved ports detected, please handle those first!" > /dev/stderr
read -p "Run pmmove? (Y/n) " ansmove
if [ "$ansmove/" == "/" -o "$ansmove" != "n" ]; then
./pmmove;
else
echo "Exiting; please run pmmove manually." > /dev/stderr
fi
exit 1
fi
## FUNCTIONS
build() {
portmaster -a $IGNORE\
| tee $WP/$0$1.log
}
build_failed() {
portmaster $(cut -f2 -d '>' ~/portmasterfail.txt)\
| tee $WP/$0_failed.log
}
## MAIN section
if [ -e ~/portmasterfail.txt -a "$1" != "failed" ]; then
echo "I detected ~/portmasterfail.txt."
read -p "Use? (y/N) " answer
if [ "$answer" == "y" ]; then
failed=1;
echo "Using ~/portmasterfail.txt"
fi;
if [ "$failed" != "1" ]; then
read -p "Remove? (Y/n) " answer2
if [ "$answer2/" == "/" -o "$answer2" != "n" ]; then
rm ~/portmasterfail.txt && echo "Removed."
fi;
fi;
fi
if [ -z $1 ]; then
build
elif [ "$1" == "failed" -o $failed ]; then
build_failed
fi