From e19da6452af79722bcfad8fb97a8c366eccb2aad Mon Sep 17 00:00:00 2001 From: bluesky Date: Sun, 4 Feb 2024 15:01:21 +0800 Subject: [PATCH] chore: new releases v1.2.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * beta3 发布重新构建 * 新增 riscv64、loong64、i386 架构 * 取消 systemd 预装 * 使用 mmdebstrap 构建根文件系统 * 将 usr 内容合并到根目录 Log: new releases --- .github/workflows/build-rootfs.yml | 50 +++++++++++--- .github/workflows/cancel-workflow-action.yml | 2 +- .gitignore | 1 + build.sh | 72 ++++++++++---------- config/apt/sources.list | 1 + config/hooks.chroot/second-stage | 26 +++++++ config/packages.list/packages.list | 3 + version.txt | 2 +- 8 files changed, 111 insertions(+), 46 deletions(-) create mode 100644 .gitignore create mode 100644 config/apt/sources.list create mode 100755 config/hooks.chroot/second-stage create mode 100644 config/packages.list/packages.list diff --git a/.github/workflows/build-rootfs.yml b/.github/workflows/build-rootfs.yml index b0006f4..ef7e071 100644 --- a/.github/workflows/build-rootfs.yml +++ b/.github/workflows/build-rootfs.yml @@ -2,28 +2,56 @@ name: build rootfs on: push: - branches: [ 'master', 'dev' ] + 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 - strategy: - matrix: - arch: [ amd64, arm64 ] env: GITHUB_TOKEN: ${{ secrets.ACTION_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@v3 + uses: actions/checkout@v4 + + - name: update source and add binfmts # 更新源到 noble + run: | + curl https://community-packages.deepin.com/deepin/beige/pool/main/d/deepin-keyring/deepin-keyring_2024.01.16_all.deb --output deepin-keyring.deb + sudo apt install ./deepin-keyring.deb && rm ./deepin-keyring.deb + echo "deb https://community-packages.deepin.com/beige/ beige main commercial community" | sudo tee -a /etc/apt/sources.list + + 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 ${{ matrix.arch }} + sudo bash build.sh - name: Read version id: read_version @@ -33,8 +61,12 @@ jobs: uses: "marvinpinto/action-automatic-releases@latest" with: repo_token: "${{ env.GITHUB_TOKEN }}" - automatic_release_tag: "v${{ env.VERSION }}-${{ matrix.arch }}" + automatic_release_tag: "v${{ env.VERSION }}" prerelease: true - title: "v${{ env.VERSION }}-${{ matrix.arch }}" + title: "v${{ env.VERSION }}" files: | - deepin-rootfs-${{ matrix.arch }}.tar.gz + rootfs/deepin-rootfs-amd64.tar.gz + rootfs/deepin-rootfs-arm64.tar.gz + rootfs/deepin-rootfs-riscv64.tar.gz + rootfs/deepin-rootfs-loong64.tar.gz + rootfs/deepin-rootfs-i386.tar.gz diff --git a/.github/workflows/cancel-workflow-action.yml b/.github/workflows/cancel-workflow-action.yml index 8b2f7da..afe6d90 100644 --- a/.github/workflows/cancel-workflow-action.yml +++ b/.github/workflows/cancel-workflow-action.yml @@ -10,5 +10,5 @@ jobs: steps: - uses: styfle/cancel-workflow-action@0.9.0 with: - workflow_id: auto-build-rootfs.yml,backup-to-gitlab.yml + workflow_id: build-rootfs.yml,backup-to-gitlab.yml access_token: ${{ secrets.ACTION_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a62ab22 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +rootfs \ No newline at end of file diff --git a/build.sh b/build.sh index bcf8fd7..2a87965 100755 --- a/build.sh +++ b/build.sh @@ -1,41 +1,43 @@ #!/bin/bash -set -e +set -e -u -x -apt update +sudo apt update # 不进行交互安装 export DEBIAN_FRONTEND=noninteractive - -apt install multistrap -y - -mkdir -p /beige-rootfs/etc/apt/trusted.gpg.d -cp deepin.gpg /beige-rootfs/etc/apt/trusted.gpg.d - -arch=${1} -echo -e "[General]\n\ -arch=$arch\n\ -directory=/beige-rootfs/\n\ -cleanup=true\n\ -noauth=false\n\ -unpack=true\n\ -explicitsuite=false\n\ -multiarch=\n\ -aptsources=Debian\n\ -bootstrap=Deepin\n\ -[Deepin]\n\ -packages=apt ca-certificates locales-all sudo systemd\n\ -source=https://community-packages.deepin.com/beige/\n\ -suite=beige\n\ -" >/beige.multistrap - -multistrap -f /beige.multistrap - -echo "deb https://community-packages.deepin.com/beige/ beige main commercial community" > /beige-rootfs/etc/apt/sources.list && \ -echo "deb-src https://community-packages.deepin.com/beige/ beige main commercial community" >> /beige-rootfs/etc/apt/sources.list - -# 微软提供的 wsl 启动器会调用adduser,需要将 USERS_GID 和 USERS_GROUP 注释。 -sed -i -e 's/USERS_GID=100/#USERS_GID=100/' -e 's/USERS_GROUP=users/#USERS_GROUP=users/' /beige-rootfs/etc/adduser.conf - -# 生成压缩包 -tar -cf deepin-rootfs-$arch.tar.gz -C /beige-rootfs . +ROOTFS=`mktemp -d` +dist_version="beige" +dist_name="deepin" +SOURCES_FILE=config/apt/sources.list +PACKAGES_FILE=config/packages.list/packages.list +readarray -t REPOS < $SOURCES_FILE +PACKAGES=`cat $PACKAGES_FILE | grep -v "^-" | xargs | sed -e 's/ /,/g'` +OUT_DIR=rootfs + +mkdir -p $OUT_DIR + +sudo apt update -y && sudo apt install -y curl git mmdebstrap qemu-user-static usrmerge systemd-container +# 开启异架构支持 +sudo systemctl start systemd-binfmt + +# for arch in amd64 arm64 riscv64 loong64 i386; do +for arch in amd64; do + 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[@]}" + # 生成压缩包 + pushd $OUT_DIR + rm -rf $dist_name-rootfs-$arch.tar.gz + sudo tar -cf $dist_name-rootfs-$arch.tar.gz -C $ROOTFS . + # 删除临时文件夹 + sudo rm -rf $ROOTFS + popd +done diff --git a/config/apt/sources.list b/config/apt/sources.list new file mode 100644 index 0000000..7665a43 --- /dev/null +++ b/config/apt/sources.list @@ -0,0 +1 @@ +deb https://community-packages.deepin.com/beige/ beige main commercial community \ No newline at end of file diff --git a/config/hooks.chroot/second-stage b/config/hooks.chroot/second-stage new file mode 100755 index 0000000..af6bd89 --- /dev/null +++ b/config/hooks.chroot/second-stage @@ -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/* +" diff --git a/config/packages.list/packages.list b/config/packages.list/packages.list new file mode 100644 index 0000000..aa9fbd4 --- /dev/null +++ b/config/packages.list/packages.list @@ -0,0 +1,3 @@ +ca-certificates +locales +sudo \ No newline at end of file diff --git a/version.txt b/version.txt index 1cc5f65..867e524 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.1.0 \ No newline at end of file +1.2.0 \ No newline at end of file