-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuild.bash
More file actions
executable file
·87 lines (74 loc) · 2.97 KB
/
build.bash
File metadata and controls
executable file
·87 lines (74 loc) · 2.97 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
#!/bin/bash
set -e
set -x
LOCAL_CONFIG=mkosi.local.conf
rm $LOCAL_CONFIG || true
ARCH=$1
apt_tree=mkosi.apt.deepin
case $ARCH in
amd64)
LINGLONG_ARCH="x86_64"
TRIPLET_LIST="x86_64-linux-gnu"
;;
arm64)
LINGLONG_ARCH="arm64"
TRIPLET_LIST="aarch64-linux-gnu"
;;
loongarch64)
LINGLONG_ARCH="loongarch64"
TRIPLET_LIST="loongarch64-linux-gnu"
;;
loong64)
LINGLONG_ARCH="loong64"
TRIPLET_LIST="loongarch64-linux-gnu"
;;
sw64)
LINGLONG_ARCH="sw64"
TRIPLET_LIST="sw_64-linux-gnu"
apt_tree="mkosi.apt.uniontech"
;;
mips64)
LINGLONG_ARCH="mips64"
TRIPLET_LIST="mips64el-linux-gnuabi64"
apt_tree="mkosi.apt.uniontech"
;;
"") echo "enter an architecture, like ./build_base.sh amd64" && exit ;;
*) echo "unknow arch \"$ARCH\", supported arch: amd64, arm64, loongarch64, loong64" && exit ;;
esac
export LINGLONG_ARCH
export TRIPLET_LIST
rm -rf output || true
# 旧版本使用skeleton-tree新版本使用sandbox-tree
apt_tree_args_name=$(mkosi --help|grep sandbox &>/dev/null && echo --sandbox-tree || echo --skeleton-tree)
mkosi --force "$apt_tree_args_name" $apt_tree --output=image_binary
echo "[Content]" >> $LOCAL_CONFIG
echo "Packages=apt,elfutils,file,gcc,g++,gdb,gdbserver,cmake,make,automake,patchelf" >> $LOCAL_CONFIG
mkosi --force "$apt_tree_args_name" $apt_tree --output=image_develop
# 清理仓库中已存在的base
# shellcheck source=/dev/null
source version.bash
# 在项目目录生成linglong.yaml,用于ll-builder push
envsubst <templates/linglong.template.yaml >"linglong.yaml"
for module in binary develop; do
# mkosi使用subuid,为避免权限问题,先制作tar格式的rootfs,再手动解压
mkdir -p output/$module/files
tar --no-same-permissions -xf output/image_$module -C output/$module/files
# 保存清单文件
cp output/image_binary.manifest records/image_binary_${LINGLONG_ARCH}.manifest
cp output/image_develop.manifest records/image_develop_${LINGLONG_ARCH}.manifest
# 生成linglong-triplet-list(记录架构信息)
echo "$TRIPLET_LIST" >"output/$module/files/etc/linglong-triplet-list"
# 生成packages.list(记录deb包列表信息)
packagesFile="output/$module/files/packages.list"
cat output/$module/files/var/lib/dpkg/status | awk '/^Package:/ {pkg=$2} /^Version:/ {print "Package: " pkg " " $2}' >"$packagesFile"
# 生成info.json(记录玲珑包信息)
MODULE=$module envsubst <templates/info.template.json >"output/$module/info.json"
# 生成appid.install(记录玲珑包文件列表)
bash -c "cd output/$module/files && find | sed 's|^.||'" >"output/$module/$APPID.install"
# 保存linglong.yaml(记录玲珑包构建信息)
cp "linglong.yaml" "output/$module/"
# 处理仓库sources.list, mkosi的不同版本表现不一致
rm output/$module/files/etc/apt/sources.list || true
rm output/$module/files/etc/apt/sources.list.d/* || true
cp $apt_tree/etc/apt/sources.list output/$module/files/etc/apt/sources.list
done