-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmake_armbian_for_hubv3.sh
More file actions
executable file
·172 lines (143 loc) · 5.62 KB
/
Copy pathmake_armbian_for_hubv3.sh
File metadata and controls
executable file
·172 lines (143 loc) · 5.62 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
#!/bin/bash
# 在 GitHub Actions 中使用标准工作目录
if [ -d "/__w/LinuxBox/LinuxBox" ]; then
current_dir="/__w/LinuxBox/LinuxBox"
else
current_dir=$(pwd)
fi
echo "Working directory: $current_dir"
board="trhubv3"
destination=""
r3version="v1.14.01.40"
# 显示使用说明的函数
usage() {
echo "Usage: $0 [-b board:trhubv3|trhubv3b|linuxbox] -d [cn|us|kr] -r [revision]"
exit 1
}
while getopts ":b:d:r:v:h" opt; do
case ${opt} in
b)
if [[ "$OPTARG" == "trhubv3" || "$OPTARG" == "trhubv3b" || "$OPTARG" == "linuxbox" ]]; then
board=$OPTARG
else
echo "Invalid board type: $OPTARG"
usage
fi
;;
d)
if [[ "$OPTARG" == "cn" ]]; then
# TODO
destination="china"
elif [[ "$OPTARG" == "us" || "$OPTARG" == "kr" ]]; then
# TODO
destination=""
else
echo "Invalid destination: $OPTARG"
usage
fi
;;
r)
r3version=$OPTARG
;;
h)
usage
exit 0
;;
\?)
echo "Invalid option: -$OPTARG"
usage
;;
:)
echo "Option -$OPTARG requires an argument."
usage
;;
esac
done
if [ -z "$board" ]; then
echo "board name required."
usage
fi
# 在开始构建前清理旧的缓存文件(安全)
echo "Cleaning up old cache files before build..."
#rm -rf ${current_dir}/cache/sources/u-boot
#rm -rf ${current_dir}/cache/sources/linux-*
rm -rf ${current_dir}/.tmp
#rm -rf ${current_dir}/output
# 显示清理后的磁盘使用情况
echo "Disk usage after initial cleanup:"
df -h ${current_dir}
df -h /
# 默认用 r3version
ver_no_v=${r3version#v}
IFS='.' read -r major minor patch build <<< "$ver_no_v"
r3_version_id=$((10#$major * 1000000 + 10#$minor * 10000 + 10#$patch * 100 + 10#$build))
# 输出参数
echo "** Board selected: [ $board ]"
echo "** Destination selected: [ $destination ]"
echo "** R3 Version selected: [ $r3version ]"
echo "** VERSION_ID calculated: [ $r3_version_id ]"
URL_APPARMOR_PROFILE="https://version.home-assistant.io/apparmor.txt"
if [ ! -d "$current_dir/userpatches" ]; then
mkdir -p $current_dir/userpatches/overlay/
#mkdir -p $current_dir/userpatches/overlay/docker-deb/
if [ -d "$current_dir/custom/" ]; then
cp $current_dir/custom/config-hubv3-images.conf $current_dir/userpatches
cp $current_dir/custom/config-jethubj100-images.conf $current_dir/userpatches
cp $current_dir/custom/customize-image.sh $current_dir/userpatches
#cp $current_dir/custom/*.deb $current_dir/userpatches/overlay/
cp $current_dir/custom/bl706_cache $current_dir/userpatches/overlay/ -R
fi
else
cp $current_dir/custom/config-hubv3-images.conf $current_dir/userpatches
cp $current_dir/custom/config-jethubj100-images.conf $current_dir/userpatches
cp $current_dir/custom/customize-image.sh $current_dir/userpatches
#cp $current_dir/custom/*.deb $current_dir/userpatches/overlay/
cp $current_dir/custom/bl706_cache $current_dir/userpatches/overlay/ -R
fi
rm -rf $current_dir/output/images
mkdir -p $current_dir/output/images
# Build uses apt-cacher-ng (localhost:3142) to cache/proxy package downloads,
# which also avoids chroot DNS issues (systemd-resolved rewrites resolv.conf).
# The acng service must be running on the host: `systemctl start apt-cacher-ng`.
#export NO_APT_CACHER=yes
$(pwd)/compile.sh hubv3-images BOARD=${board} BRANCH=current RELEASE=bookworm R3VERSION=${r3version} R3VERSION_ID=${r3_version_id} \
BUILD_MINIMAL=no BUILD_DESKTOP=no KERNEL_ONLY=no KERNEL_CONFIGURE=no \
COMPRESS_OUTPUTIMAGE=sha,gpg,img INSTALL_HEADERS=no WIREGUARD=no \
UBOOT_MIRROR=github \
DOWNLOAD_MIRROR=${destination}
IMG_FILE=$(find "$current_dir/output/images" -maxdepth 1 -type f -name "*.img")
if [[ -n "$IMG_FILE" ]]; then
echo "Enter convert directory Armbian_Convert ..."
#sudo rm -rf ${current_dir}/output/usr
#sudo rm -rf ${current_dir}/output/debs
#sudo rm -rf ${current_dir}/cache/sources/*/build/*
#sudo rm -rf ${current_dir}/cache/rootfs/*
UBOOT=`find ${current_dir}/cache/sources/u-boot/ -name u-boot.bin -type f -print -quit`
IMAGE=`find ${current_dir}/output/images -name '*.img' -type f -print -quit`
echo "UBOOT: ${UBOOT}"
echo "Image: ${IMAGE}"
mkdir -p $current_dir/tools/Armbian_Convert/output
$current_dir/tools/Armbian_Convert/convert.sh ${IMAGE} ${board} armbian no ${UBOOT}
IMGBURN=$(find ${current_dir}/tools -maxdepth 8 -type f -name "*.burn.img")
if [[ -n "$IMGBURN" && -f "$IMGBURN" ]]; then
mkdir -p ${current_dir}/output/images/
mv "$IMGBURN" ${current_dir}/output/images/
IMGBURN=$(find ${current_dir}/output -maxdepth 4 -type f -name "*.burn.img")
# 重命名 .burn.img 为 .${r3version}.img
new_imgburn="${IMGBURN/.burn.img/.${r3version}.img}"
mv "$IMGBURN" "$new_imgburn"
rm -rf "${IMAGE}"
echo "File build: $new_imgburn"
# 转换完成后,清理不需要的文件
echo "Cleaning up after successful conversion..."
#rm -rf ${current_dir}/cache/sources/u-boot
#rm -rf ${current_dir}/cache/sources/linux-*
sudo rm -rf ${current_dir}/.tmp
sudo rm -rf ${current_dir}/tools/Armbian_Convert/output/*.zip
echo "Disk usage after final cleanup:"
df -h ${current_dir}
df -h /
else
echo "Fail: No burn.img file exist."
fi
fi