-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathupdateversions.sh
More file actions
executable file
·179 lines (157 loc) · 4.32 KB
/
updateversions.sh
File metadata and controls
executable file
·179 lines (157 loc) · 4.32 KB
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#!/bin/bash
#Saner and safer environment
set -Eeuo pipefail
set -o pipefail -o noclobber -o nounset
debug=n
# #Set flags
# # -e : Exit immediately on command failure
# # -o pipefail : propagate exit codes on pipes to right most.
# # -u : treat unset variables as an error
# # -x : print each command prior to executing it.
# # -E : ensure that errors are caught and cleaned up.
function print_help() {
echo "$0 -[f|s|m|w|e] REVISION"
echo " Version Update Helper"
echo " -----------------------------------------------------------------------------------------------"
echo " -h | --help | Print this help."
echo " -f | --fpga | FPGA"
echo " -s | --server | server"
echo " | --firmware | firmware"
echo " -m | --mcu | mcu"
echo " -w | --website | website"
echo " -e | --meta | metapervices"
}
#####
# Pretty Terminal
#####
bold=$(tput -T xterm-256color bold)
normal=$(tput -T xterm-256color sgr0)
##############################################
# Parse the CmdLine arguments
##############################################
if [ $# -eq 0 ]; then
print_help
exit 22
fi
! getopt --test > /dev/null
if [[ ${PIPESTATUS[0]} -ne 4 ]]; then
echo "ERROR: `getopt --test` failed in this environment."
exit 1
fi
OPTIONS=fsmweh
LONGOPTS=fpga:,server:,firmware:,mcu:,website:,meta:
# -use ! and PIPESTATUS to get exit code with errexit set
# -temporarily store output to be able to check for errors
# -activate quoting/enhanced mode (e.g. by writing out “--options”)
# -pass arguments only via -- "$@" to separate them correctly
! PARSED=$(getopt --options=$OPTIONS --longoptions=$LONGOPTS --name "$0" -- "$@")
if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
# e.g. return value is 1
# then getopt has complained about wrong arguments to stdout
print_help
exit 22
fi
# read getopt’s output this way to handle the quoting right:
eval set -- "$PARSED"
help=n
fpga=n
fpga_rev=0
server=n
server_rev=0
mcu=n
mcu_rev=0
website=n
website_rev=0
meta=n
meta_rev=0
# now enjoy the options in order and nicely split until we see --
while true; do
case "$1" in
-f|--fpga)
fpga=y
fpga_rev="$2"
shift 2
;;
-s|--server|--firmware)
server=y
server_rev="$2"
shift 2
;;
-m|--mcu)
mcu=y
mcu_rev="$2"
shift 2
;;
-w|--website)
website=y
website_rev="$2"
shift 2
;;
-e|--meta)
meta=y
meta_rev="$2"
shift 2
;;
-h|--help)
print_help
exit
;;
--)
shift
break
;;
*)
echo "${bold}ERROR: Invalid option.${normal}"
echo ""
print_help
exit 22
;;
esac
done
if [ $debug == y ]; then
echo fpga: $fpga $fpga_rev
echo server: $server $server_rev
echo mcu: $mcu $mcu_rev
echo meta: $meta $meta_rev
echo website: $website $website_rev
if [ $fpga == y ]; then
echo "INFO: Apply FPGA $fpga_rev"
fi
if [ $server == y ]; then
echo "INFO: Apply FIRMWARE $server_rev"
fi
if [ $mcu == y ]; then
echo "INFO: Apply MCU $mcu_rev"
fi
if [ $meta == y ]; then
echo "INFO: Apply META $meta_rev"
fi
if [ $website == y ]; then
echo "INFO: Apply WEBSITE $website_rev"
fi
fi
for dir in crimson-rtm*; do
if [ $dir == crimson-rtm4-325msps ]; then
echo "INFO: Skipping $dir"
continue
fi
if [ $dir == crimson-rtm5-325msps ]; then
echo "INFO: Skipping $dir"
continue
fi
if [ $fpga == y ]; then
sed -i "s/FPGA.*/FPGA $fpga_rev/g" $dir/versions
fi
if [ $server == y ]; then
sed -i "s/FIRMWARE.*/FIRMWARE $server_rev/g" $dir/versions
fi
if [ $mcu == y ]; then
sed -i "s/MCU.*/MCU $mcu_rev/g" $dir/versions
fi
if [ $meta == y ]; then
sed -i "s/META.*/META $meta_rev/g" $dir/versions
fi
if [ $website == y ]; then
sed -i "s/WEBSITE.*/WEBSITE $website_rev/g" $dir/versions
fi
done