-
Notifications
You must be signed in to change notification settings - Fork 0
/
stage
executable file
·60 lines (50 loc) · 1.6 KB
/
stage
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
#!/bin/sh
# send of list of ports to update to a build host
#
# Usage: stage [-a]
# -a: append to the list on the build server rather than overwriting
#
# globals expected in ${HOME}/.ports.conf with sample values
# bhost='storage2.mathstat.dal.ca' # build host
# listf='ports.txt' # list file of ports to build, relative to $HOME
. "$HOME/.ports.conf"
stage () {
hostname=$(hostname)
of="$(pkg info -oAq | \
awk -F'[[:blank:]]*:[[:blank:]]*' \
'/^(Origin|flavor)/ {
if ( $1 == "Origin" ) {
if ( system("test -d /usr/ports/"$2) ) { io=1 }
else { io=0; print $2 }
}
else if ( $1 == "flavor" && !io && $2 != "default" ) { print "@"$2 }
}')"
printf "%s\\n" "$of" | tr '\n' ' ' | sed 's/ @/@/g' | tr ' ' '\n' > "$listf"
if [ "$hostname" != "$bhost" ]; then
if [ "$1" = 'yes' ]; then
#printf "Appending the list of ports to %s:%s...\\n" "$bhost" "$listf"
printf "* ssh %s \"cat >> %s\" < %s\\n" "$bhost" "$listf" "$listf"
ssh "$bhost" "cat >> $listf" < "$listf"
ret=$?
else
#printf "Sending the list of ports to %s:%s...\\n" "$bhost" "$listf"
printf "* scp %s %s:%s\\n" "$listf" "$bhost" "$listf"
scp "$listf" "${bhost}:${listf}"
ret=$?
fi
else
ret=0
fi
return "$ret"
}
############################################ main
[ -n "${listf##/*}" ] && listf="${HOME}/$listf"
appendp=no
while getopts ":a" opt; do
case $opt in
a) appendp=yes ;;
*) printf "Invalid option: -%s\\n." "$opt" ;;
esac
done
listf="$listf.$(hostname -s)"
stage "$appendp"