Skip to content

Commit

Permalink
chore: new releases v1.2.0
Browse files Browse the repository at this point in the history
* beta3 发布重新构建
* 新增 riscv64、loong64、i386 架构
* 取消 systemd 预装
* 使用 mmdebstrap 构建根文件系统
* 将 usr 内容合并到根目录

Log: new releases
  • Loading branch information
chenchongbiao committed Feb 20, 2024
1 parent 86090a4 commit 53b69c8
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 46 deletions.
50 changes: 41 additions & 9 deletions .github/workflows/build-rootfs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
Expand All @@ -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
2 changes: 1 addition & 1 deletion .github/workflows/cancel-workflow-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootfs
70 changes: 35 additions & 35 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
#!/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
sudo mmdebstrap \
--hook-dir=/usr/share/mmdebstrap/hooks/merged-usr \
--include=$PACKAGES \
--components="main,commercial,community" \
--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
1 change: 1 addition & 0 deletions config/apt/sources.list
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
deb https://community-packages.deepin.com/beige/ beige main commercial community
28 changes: 28 additions & 0 deletions config/hooks.chroot/second-stage
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh

set -x

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/*
"
3 changes: 3 additions & 0 deletions config/packages.list/packages.list
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ca-certificates
locales
sudo
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.0
1.2.0

0 comments on commit 53b69c8

Please sign in to comment.