-
Notifications
You must be signed in to change notification settings - Fork 0
/
refresh
executable file
·94 lines (77 loc) · 2.24 KB
/
refresh
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
#!/bin/sh
### v3.0
###
### This script updates the ports collection and
### creates a summary which lists the installed
### ports for which an update is available.
## INIT section (don't change)
WP=$(dirname $0)
ME=$(basename $0)
udate=$(stat -f %Sa -t %Y%m%d $WP/$0.meta)
if [ -z "$(pkg info -qo portmaster)" ]; then
echo "ports-mgmt/portmaster not installed (required)" > /dev/stderr
exit 1;
fi
if [ -z "$(pkg info -qo git)" ]; then
echo "devel/git not installed (required)" > /dev/stderr
exit 1;
fi
if [ "$1" == "reset" -o "$1" == "clear" -o "$2" == "reset" ]; then
> $WP/$ME-updating.log;
if [ "$1" == "clear" ]; then exit; fi;
fi
if [ ! -z $(fuser portmaster.log 2> /dev/null) ]; then
echo "Portmaster logfile still in use, exiting!" > /dev/stderr
echo "(ran refresh recently?)" > /dev/stderr
exit 1;
fi
if [ -n "$udate" ]; then
ucmd="-d $udate";
fi;
## FUNCTIONS section
log_full() {
portmaster -L > $WP/portmaster.log &
log_new
}
log_new() {
echo " >Checking for new port versions using PKG..."
pkg version -Pol\< | tee $WP/$ME.log
}
log_updating() {
for a in $(cat $WP/$ME.log | cut -d '-' -f1); do
pkg updating $ucmd $a >> $WP/$ME-updating.log;
done
}
ports_update() {
cd /usr/ports
echo " >Updating ports collection using Git..."
git pull origin main
cd -
}
## MAIN section
if [ -z $1 ] || [ "$1" == "reset" ]; then
#portsnap fetch update && log_full && log_updating
ports_update && log_full && log_updating
touch $0.meta
elif [ "$1" == "update" ]; then
log_new
elif [ "$1" == "full" ]; then
log_full
elif [ "$1" == "help" ]; then
echo "Usage: $0 [reset|update|full|clear|help] [clear]"
echo
echo "reset => Clears $ME-updating.log and performs update."
echo "update => Quickly refreshes the list of available port updates."
echo "full => Fully refreshes the list of available port updates."
echo " \* This includes regeneration of portmaster.log."
echo "clear => Clears $ME-updating.log and exits."
echo " \* Can also be used as extra parameter."
echo "help => Display this message."
echo
else
echo "Wrong parameter!" > /dev/stderr
echo "Usage: $0 [reset|update|full|clear|help]" > /dev/stderr
fi
if [ -n "$(jobs -p)" ]; then
echo " >Warning: background job still running!" > /dev/stderr
fi