-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_complete.sh
More file actions
executable file
·115 lines (98 loc) · 3.02 KB
/
build_complete.sh
File metadata and controls
executable file
·115 lines (98 loc) · 3.02 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
#!/bin/bash
set -e
if [ ! "$1" ]; then
echo "usage: build_complete.sh <board_name>"
exit 1
fi
if [ "$EUID" != "0" ]; then
echo "error: this script must be run as root"
fi
declare -A special_boards=(
["brask"]="mmcblk0 nvme0n1"
["brya"]="mmcblk0 nvme0n1"
["cherry"]="mmcblk0"
["corsola"]="mmcblk0"
["guybrush"]="mmcblk0 nvme0n1"
["nissa"]="mmcblk0"
["nissa_2"]="sda sdb"
["rex"]="nvme0n1"
["skyrim"]="mmcblk0 nvme0n1"
["staryu"]="mmcblk0"
)
board="$1"
if [ "$board" = "nissa_2" ]; then board=nissa; fi
base_dir="$(realpath -m $(dirname "$0"))"
data_dir="$base_dir/data"
images_file="$data_dir/images.json"
images_url="https://raw.githubusercontent.com/MercuryWorkshop/chromeos-releases-data/refs/heads/main/data.json"
cd "$base_dir"
mkdir -p "$data_dir"
echo "downloading list of recovery images from https://github.com/MercuryWorkshop/chromeos-releases-data"
if [ ! -f "$images_file" ]; then
wget -q "$images_url" -O "$images_file"
fi
echo "finding recovery image url"
image_url="$(cat "$images_file" | python3 -c '
import json, sys
images = json.load(sys.stdin)
board_name = sys.argv[1]
board = images[board_name]
for image in reversed(board["images"]):
major_ver = image["chrome_version"].split(".")[0]
if not major_ver.isdigit():
continue
if image["channel"] != "stable-channel":
continue
if int(major_ver) != 129:
continue
print(image["url"])
break
else:
print(f"error: could not find suitable recovery image for {board_name}", file=sys.stderr)
sys.exit(1)
' "$board")"
image_zip_name="$(echo "$image_url" | rev | cut -f1 -d'/' | rev)"
image_zip_file="$data_dir/$image_zip_name"
echo "found recovery image url: $image_url"
echo "downloading recovery image"
if [ ! -f "$image_zip_file" ]; then
if [ "$QUIET" ]; then
wget -q "$image_url" -O "$image_zip_file"
else
wget "$image_url" -O "$image_zip_file"
fi
fi
echo "extracting recovery image"
image_bin_name="$(unzip -Z1 "$image_zip_file")"
image_bin_file="$data_dir/$image_bin_name"
if [ ! -f "$image_bin_file" ]; then
unzip -j "$image_zip_file" -d "$data_dir"
fi
rm -f "$image_zip_file"
image_variants="${special_boards[$board]}"
if [ ! "$image_variants" ]; then
echo "copying recovery image"
out_file="$data_dir/goodsilver_$board.bin"
cp "$image_bin_file" "$out_file"
echo "building goodsilver"
chmod +x ./build_goodsilver.sh
./build_goodsilver.sh -i "$out_file"
echo "done! the finished image is located at $out_file"
else
amounts=$(echo "${special_boards["nissa"]}" | wc -w)
count=1
for variant in $image_variants; do
echo "copying recovery image (internal_disk=$variant)"
out_file="$data_dir/goodsilver_${board}_${variant}.bin"
if [ "$amounts" = "$count" ]; then
mv "$image_bin_file" "$out_file" || continue
else
cp "$image_bin_file" "$out_file" || continue
fi
echo "building goodsilver (internal_disk=$variant)"
chmod +x ./build_goodsilver.sh
./build_goodsilver.sh -i "$out_file"
echo "done! the finished image is located at $out_file"
count=$((count+1))
done
fi