-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.sh
executable file
·62 lines (52 loc) · 1.56 KB
/
build.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
#!/bin/bash
set -e -u -x
sudo apt update
# 不进行交互安装
export DEBIAN_FRONTEND=noninteractive
ROOTFS=`mktemp -d`
dist_version="beige"
dist_name="deepin"
SOURCES_FILE=config/apt/sources.list
readarray -t REPOS < $SOURCES_FILE
OUT_DIR=rootfs
mkdir -p $OUT_DIR
sudo apt update -y && sudo apt install -y curl git mmdebstrap qemu-user-static usrmerge systemd-container usrmerge
# 开启异架构支持
sudo systemctl start systemd-binfmt
function build_rootfs() {
sudo mmdebstrap \
--hook-dir=/usr/share/mmdebstrap/hooks/merged-usr \
--include=$PACKAGES \
--components="main,commercial,community" \
--variant=minbase \
--architectures=${arch} \
--customize=./config/hooks.chroot/second-stage \
$dist_version \
$ROOTFS \
"${REPOS[@]}"
# 判断是否构建 wsl 的根文件系统,体内钾 wsl.conf 默认开启systemd
if [[ $TARGET=="wsl" ]];
then
sudo tee $ROOTFS/etc/wsl.conf <<EOF
[boot]
systemd=true
EOF
fi
# 生成压缩包
pushd $OUT_DIR
rm -rf $dist_name-$TARGET-rootfs-$arch.tar.gz
sudo tar -zcf $dist_name-$TARGET-rootfs-$arch.tar.gz -C $ROOTFS .
# 删除临时文件夹
sudo rm -rf $ROOTFS
popd
}
TARGET=wsl
PACKAGES=`cat config/packages.list/$TARGET-packages.list | grep -v "^-" | xargs | sed -e 's/ /,/g'`
for arch in amd64 arm64; do
build_rootfs
done
TARGET=docker
PACKAGES=`cat config/packages.list/$TARGET-packages.list | grep -v "^-" | xargs | sed -e 's/ /,/g'`
for arch in amd64 arm64 riscv64 loong64 i386; do
build_rootfs
done