-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use mmdebstrap to build rootfs
* 使用 mmdebstrap 制作根文件系统,定制化更小。 * 添加多架构支持。 * 修改为 nile 版本 Log: new rootfs
- Loading branch information
1 parent
8a23bb3
commit 7a0dc6b
Showing
10 changed files
with
159 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: build rootfs | ||
|
||
on: | ||
push: | ||
branches: [ 'master' ] | ||
paths: | ||
- 'build.sh' | ||
- 'config/**' | ||
- 'version.txt' | ||
pull_request: | ||
branches: [ 'master' ] | ||
paths: | ||
- 'build.sh' | ||
- 'config/**' | ||
- 'version.txt' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
name: Build tar file | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.TOKEN }} | ||
|
||
steps: | ||
- name: Maximize build space | ||
uses: easimon/maximize-build-space@master | ||
with: | ||
# 这个值是保留给系统的空间大小,之前设置太小,总会在安装依赖或者编译过程中报设备空间不足的错误而导致编译失败 | ||
root-reserve-mb: 4096 | ||
swap-size-mb: 512 | ||
remove-dotnet: 'true' | ||
remove-android: 'true' | ||
remove-codeql: 'true' | ||
|
||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: update source and add binfmts # 更新源到 noble | ||
run: | | ||
sudo sed -i 's/jammy/noble/g' /etc/apt/sources.list | ||
sudo apt update -y && sudo apt install mmdebstrap qemu-user-static usrmerge qemu-user systemd | ||
sudo apt-mark hold usrmerge | ||
sudo cp -v /usr/lib/arch-test/riscv64 /usr/lib/arch-test/loong64 | ||
sudo sed -i "/riscv64 => 'riscv64',/a\ loong64 => 'loongarch64'," /usr/bin/mmdebstrap | ||
sudo systemctl restart systemd-binfmt | ||
- name: Run build.sh | ||
run: | | ||
sudo bash build.sh | ||
- name: Read version | ||
id: read_version | ||
run: echo "VERSION=$(cat version.txt)" >> $GITHUB_ENV | ||
|
||
- name: Upload file to release | ||
uses: "marvinpinto/action-automatic-releases@latest" | ||
with: | ||
repo_token: "${{ env.GITHUB_TOKEN }}" | ||
automatic_release_tag: "v${{ env.VERSION }}" | ||
prerelease: true | ||
title: "v${{ env.VERSION }}" | ||
files: | | ||
rootfs/openkylin-rootfs-amd64.tar.gz | ||
rootfs/openkylin-rootfs-arm64.tar.gz | ||
rootfs/openkylin-rootfs-riscv64.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,11 @@ | ||
# 介绍 | ||
|
||
使用 Multistrap 工具制作根文件系统,Multistrap是一个工具,可以用来构建一个完整的、可启动的、根文件系统。这个根文件系统可以被 Docker 和 WSL 使用。 | ||
|
||
使用 mmdebstrap 工具制作根文件系统,mmdebstrap 是一个工具,允许你选择性地包含或排除某些软件包,这样可以创建更小的、定制化的根文件系统。这个根文件系统可以被 Docker 和 WSL 使用。 | ||
|
||
# 使用 | ||
|
||
yangtze.multistrap 是配置文件。 | ||
|
||
```bash | ||
bash build.sh | ||
sudo tar -cf yangtze-rootfs.tar -C /yangtze-rootfs . | ||
``` | ||
|
||
# 声明 | ||
|
||
参考 [deepin-docker](https://github.com/BLumia/deepin-docker) 制作 | ||
支持多加个架构 amd64 arm64 riscv64 架构。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,47 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
set -e -u | ||
|
||
apt update | ||
sudo apt update | ||
|
||
# 不进行交互安装 | ||
export DEBIAN_FRONTEND=noninteractive | ||
ROOTFS=`mktemp -d` | ||
dist_version="nile" | ||
dist_name="openkylin" | ||
readarray -t REPOS < ./config/apt/sources.list | ||
PACKAGES=`cat ./config/packages.list/packages.list | grep -v "^-" | xargs | sed -e 's/ /,/g'` | ||
OUT_DIR=$(dirname "$(realpath "$0")")/rootfs | ||
|
||
apt install multistrap -y | ||
mkdir -p $OUT_DIR | ||
sudo apt install -y curl git mmdebstrap qemu-user-static usrmerge usr-is-merged binfmt-support systemd-container | ||
# 开启异架构支持 | ||
sudo systemctl start systemd-binfmt | ||
|
||
multistrap -f yangtze.multistrap | ||
# 安装软件包签名公钥 | ||
curl http://archive.build.openkylin.top/openkylin/pool/main/o/openkylin-keyring/openkylin-keyring_2022.05.12-ok1_all.deb --output openkylin-keyring.deb | ||
sudo apt install ./openkylin-keyring.deb && rm ./openkylin-keyring.deb | ||
|
||
cp sources.list /yangtze-rootfs/etc/apt/sources.list | ||
cp openkylin-anything.list /yangtze-rootfs/etc/apt/sources.list.d/openkylin-anything.list | ||
curl http://archive.build.openkylin.top/openkylin/pool/main/o/openkylin-archive-anything/openkylin-archive-anything_2023.02.06-ok4_all.deb --output openkylin-archive-anything.deb | ||
sudo apt install ./openkylin-archive-anything.deb && rm ./openkylin-archive-anything.deb | ||
|
||
for arch in amd64 arm64 riscv64; do | ||
sudo mmdebstrap \ | ||
--hook-dir=/usr/share/mmdebstrap/hooks/merged-usr \ | ||
--include=$PACKAGES \ | ||
--components="main,cross,pty" \ | ||
--variant=minbase \ | ||
--architectures=${arch} \ | ||
--customize=./config/hooks.chroot/second-stage \ | ||
$dist_version \ | ||
$ROOTFS \ | ||
"${REPOS[@]}" | ||
|
||
# 生成压缩包 | ||
pushd $OUT_DIR | ||
rm -rf $dist_name-rootfs-$arch.tar.gz | ||
sudo tar -zcf $dist_name-rootfs-$arch.tar.gz -C $ROOTFS . | ||
# 删除临时文件夹 | ||
sudo rm -rf $ROOTFS | ||
popd | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
deb http://archive.build.openkylin.top/openkylin nile main cross pty | ||
deb http://archive.build.openkylin.top/openkylin nile-security main cross pty | ||
deb http://archive.build.openkylin.top/openkylin nile-updates main cross pty | ||
deb http://archive.build.openkylin.top/openkylin nile-proposed main cross pty | ||
deb http://ppa.build.openkylin.top/kylinsoft/anything/openkylin/ yangtze main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/sh | ||
|
||
rootdir="$1" | ||
|
||
# 执行命令的辅助函数 | ||
run_in_chroot() { | ||
systemd-nspawn -D "$rootdir" bash -c "$@" | ||
} | ||
|
||
# 设置语言 | ||
run_in_chroot " | ||
sed -i -E 's/#[[:space:]]?(en_US.UTF-8[[:space:]]+UTF-8)/\1/g' /etc/locale.gen | ||
sed -i -E 's/#[[:space:]]?(zh_CN.UTF-8[[:space:]]+UTF-8)/\1/g' /etc/locale.gen | ||
locale-gen | ||
DEBIAN_FRONTEND=noninteractive dpkg-reconfigure locales | ||
" | ||
|
||
# 微软提供的 wsl 启动器会调用adduser,需要将 USERS_GID 和 USERS_GROUP 注释。 | ||
run_in_chroot "sed -i -e 's/USERS_GID=100/#USERS_GID=100/' -e 's/USERS_GROUP=users/#USERS_GROUP=users/' /etc/adduser.conf" | ||
|
||
# 清理缓存 | ||
run_in_chroot " | ||
apt clean | ||
rm -rf /var/cache/apt/archives/* | ||
" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
ca-certificates | ||
locales | ||
sudo | ||
apt | ||
adduser | ||
polkitd | ||
systemd | ||
dbus-daemon | ||
parted | ||
curl | ||
vim | ||
init | ||
iputils-ping | ||
net-tools | ||
pciutils | ||
lshw | ||
iproute2 | ||
iptables | ||
locales | ||
openkylin-archive-anything |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.1.0 |
This file was deleted.
Oops, something went wrong.