-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrelease.sh
executable file
·70 lines (60 loc) · 1.7 KB
/
release.sh
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
#!/usr/bin/env bash
## Validate NuttX Release: ~/nuttx-release/release.sh milkvduos / ox64 / star64 / pinephone
## TODO: Update for the release
export release=12.8.0
export candidate=RC0
export hash=3bf704ad13
set -e ## Exit when any command fails
set -x ## Echo commands
device=$1
echo ----- Validate NuttX Release for $device
echo https://github.com/lupyuen/nuttx-release/blob/main/release-$1.sh
## Get the Script Directory
script_path="${BASH_SOURCE}"
script_dir="$(cd -P "$(dirname -- "${script_path}")" >/dev/null 2>&1 && pwd)"
log_file=/tmp/release-$device.log
## Get the `script` option
if [ "`uname`" == "Linux" ]; then
script_option=-c
else
script_option=
fi
## Close the `screen` session
$script_dir/close.exp
## Run the script
pushd /tmp
script $log_file \
$script_option \
$script_dir/release-$device.sh
popd
## Strip the control chars
tmp_file=/tmp/release-tmp.log
cat $log_file \
| tr -d '\r' \
| tr -d '\r' \
| sed 's/\x08/ /g' \
| sed 's/\x1B(B//g' \
| sed 's/\x1B\[K//g' \
| sed 's/\x1B[<=>]//g' \
| sed 's/\x1B\[[0-9:;<=>?]*[!]*[A-Za-z]//g' \
| sed 's/\x1B[@A-Z\\\]^_]\|\x1B\[[0-9:;<=>?]*[-!"#$%&'"'"'()*+,.\/]*[][\\@A-Z^_`a-z{|}~]//g' \
| cat -v \
>$tmp_file
mv $tmp_file $log_file
echo ----- "Done! $log_file"
## Upload to GitHub Gist
cat $log_file | \
gh gist create \
--public \
--desc "Validate NuttX Release for $device ($release / $candidate / $hash)" \
--filename "validate-nuttx-release-$device-$release-$candidate-$hash.log"
## Check for hash
grep $hash $log_file || true
matches=$(grep $hash $log_file | grep -v "hash=" | wc -c)
if [ "$matches" -eq "0" ]; then
echo ----- "ERROR: Hash $hash not found!"
exit 1
else
echo ----- "Hash $hash OK"
exit 0
fi