From ae67161de61f14b1305f908dd35a63c9f133dabc Mon Sep 17 00:00:00 2001
From: gfdgd_xi <3025613752@qq.com>
Date: Tue, 4 Jul 2023 16:26:36 +0800
Subject: [PATCH] xanmod yml

---
 .github/workflows/build-xanmod-hwe0.yml |  29 ++++++
 .github/workflows/build-xanmod-hwe1.yml |  29 ++++++
 .github/workflows/build-xanmod-hwe2.yml |  29 ++++++
 .github/workflows/build-xanmod-hwe3.yml |  29 ++++++
 build_action_xanmod.sh                  | 131 ++++++++++++++++++------
 5 files changed, 216 insertions(+), 31 deletions(-)
 create mode 100644 .github/workflows/build-xanmod-hwe0.yml
 create mode 100644 .github/workflows/build-xanmod-hwe1.yml
 create mode 100644 .github/workflows/build-xanmod-hwe2.yml
 create mode 100644 .github/workflows/build-xanmod-hwe3.yml

diff --git a/.github/workflows/build-xanmod-hwe0.yml b/.github/workflows/build-xanmod-hwe0.yml
new file mode 100644
index 0000000..03c9fd7
--- /dev/null
+++ b/.github/workflows/build-xanmod-hwe0.yml
@@ -0,0 +1,29 @@
+name: Build HWE Xanmod kernel deb packages(0)
+on:
+  schedule:
+    - cron: '0 1 * * *'
+  workflow_dispatch:
+
+jobs:
+  build:
+    name: Build kernel
+    runs-on: ubuntu-latest
+    steps:
+
+ # 由于默认的 Ubuntu 环境只有 17G 左右的剩余空间,所以我们需要先利用如下 action 对编译环境进行扩容
+      - 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'
+
+      - name: Checkout
+        uses: actions/checkout@v3
+
+      - name: Build
+        env: 
+          PASSWORD: ${{ secrets.PASSWORD }}
+        run: bash build_action_xanmod.sh 0 1
diff --git a/.github/workflows/build-xanmod-hwe1.yml b/.github/workflows/build-xanmod-hwe1.yml
new file mode 100644
index 0000000..142a49d
--- /dev/null
+++ b/.github/workflows/build-xanmod-hwe1.yml
@@ -0,0 +1,29 @@
+name: Build HWE Xanmod kernel deb packages(1)
+on:
+  schedule:
+    - cron: '0 4 * * *'
+  workflow_dispatch:
+
+jobs:
+  build:
+    name: Build kernel
+    runs-on: ubuntu-latest
+    steps:
+
+ # 由于默认的 Ubuntu 环境只有 17G 左右的剩余空间,所以我们需要先利用如下 action 对编译环境进行扩容
+      - 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'
+
+      - name: Checkout
+        uses: actions/checkout@v3
+
+      - name: Build
+        env: 
+          PASSWORD: ${{ secrets.PASSWORD }}
+        run: bash build_action_xanmod.sh 1 1
diff --git a/.github/workflows/build-xanmod-hwe2.yml b/.github/workflows/build-xanmod-hwe2.yml
new file mode 100644
index 0000000..498dab3
--- /dev/null
+++ b/.github/workflows/build-xanmod-hwe2.yml
@@ -0,0 +1,29 @@
+name: Build HWE Xanmod kernel deb packages(2)
+on:
+  schedule:
+    - cron: '0 7 * * *'
+  workflow_dispatch:
+
+jobs:
+  build:
+    name: Build kernel
+    runs-on: ubuntu-latest
+    steps:
+
+ # 由于默认的 Ubuntu 环境只有 17G 左右的剩余空间,所以我们需要先利用如下 action 对编译环境进行扩容
+      - 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'
+
+      - name: Checkout
+        uses: actions/checkout@v3
+
+      - name: Build
+        env: 
+          PASSWORD: ${{ secrets.PASSWORD }}
+        run: bash build_action_xanmod.sh 2 1
diff --git a/.github/workflows/build-xanmod-hwe3.yml b/.github/workflows/build-xanmod-hwe3.yml
new file mode 100644
index 0000000..9aa7962
--- /dev/null
+++ b/.github/workflows/build-xanmod-hwe3.yml
@@ -0,0 +1,29 @@
+name: Build HWE Xanmod kernel deb packages(3)
+on:
+  schedule:
+    - cron: '0 10 * * *'
+  workflow_dispatch:
+
+jobs:
+  build:
+    name: Build kernel
+    runs-on: ubuntu-latest
+    steps:
+
+ # 由于默认的 Ubuntu 环境只有 17G 左右的剩余空间,所以我们需要先利用如下 action 对编译环境进行扩容
+      - 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'
+
+      - name: Checkout
+        uses: actions/checkout@v3
+
+      - name: Build
+        env: 
+          PASSWORD: ${{ secrets.PASSWORD }}
+        run: bash build_action_xanmod.sh 3 1
diff --git a/build_action_xanmod.sh b/build_action_xanmod.sh
index 38adfef..e3c9033 100644
--- a/build_action_xanmod.sh
+++ b/build_action_xanmod.sh
@@ -11,7 +11,12 @@ python3 get-newest-version-xanmod.py $1
 VERSION=`cat /tmp/kernelversion.txt`
 URL=`cat /tmp/kernelurl.txt`
 MAINVERSION=`expr substr $VERSION 1 1`
-curl https://github.com/gfdgd-xi/dclc-kernel/raw/main/$VERSION/index.html | grep 404
+SHOWVERSION=$VERSION
+# 使用 deepin hwe config编译
+if [[ $2 == 1 ]]; then
+    SHOWVERSION=$VERSION-hwe
+fi
+curl https://github.com/gfdgd-xi/dclc-kernel/raw/main/$SHOWVERSION/index.html | grep 404
 if [[ $? != 0 ]]; then
     exit
 fi
@@ -28,7 +33,11 @@ tar -xvf "$VERSION".tar.bz2
 cd linux-"$VERSION"* || exit
 
 # copy config file
-cp ../config .config
+if [[ $2 == 1 ]]; then
+    cp ../config-6.1.11-amd64-desktop-hwe .config
+else
+    cp ../config .config
+fi
 #
 # disable DEBUG_INFO to speedup build
 scripts/config --set-str SYSTEM_TRUSTED_KEYS ""
@@ -47,20 +56,79 @@ scripts/config --set-val  DEBUG_INFO_NONE       y
 # build deb packages
 CPU_CORES=$(($(grep -c processor < /proc/cpuinfo)*2))
 sudo make bindeb-pkg -j"$CPU_CORES"
-
-# move deb packages to artifact dir
-cd ..
-mkdir "artifact"
-#cp ./*.deb artifact/
-git clone https://gfdgd-xi:$PASSWORD@github.com/gfdgd-xi/dclc-kernel
-#cd dclc-kernel
-mkdir dclc-kernel/$VERSION
-rm -rfv *dbg*.deb
-mv ./*.deb dclc-kernel/$VERSION
-cd dclc-kernel/$VERSION
-cd ..
-cd head
-cat > deb/DEBIAN/control <<EOF
+if [[ $2 == 1 ]]; then
+    # move deb packages to artifact dir
+    cd ..
+    mkdir "artifact"
+    #cp ./*.deb artifact/
+    git clone https://gfdgd-xi:$PASSWORD@github.com/gfdgd-xi/dclc-kernel
+    #cd dclc-kernel
+    mkdir dclc-kernel/$SHOWVERSION
+    rm -rfv *dbg*.deb
+    mv ./*.deb dclc-kernel/$SHOWVERSION
+    cd dclc-kernel/$SHOWVERSION
+    cd ..
+    cd head
+    cat > deb/DEBIAN/control <<EOF
+Package: linux-kernel-dclc-gfdgdxi-xanmod-hwe
+Version: $VERSION
+Maintainer: gfdgd xi <3025613752@qq.com>
+Homepage: https://github.com/gfdgd-xi/dclc-kernel
+Architecture: amd64
+Severity: serious
+Certainty: possible
+Check: binaries
+Type: binary, udeb
+Priority: optional
+Depends: linux-headers-$VERSION-amd64-desktop-hwe, linux-image-$VERSION-amd64-desktop-hwe
+Section: utils
+Installed-Size: 0
+Description: 内核(虚包)
+EOF
+    if [[ ! -d deb-$MAINVERSION-xanmod ]]; then
+        mkdir -pv deb-$MAINVERSION-xanmod/DEBIAN
+    fi
+    cat > deb-$MAINVERSION-xanmod/DEBIAN/control <<EOF
+Package: linux-kernel-dclc-gfdgdxi-$MAINVERSION-xanmod-hwe
+Version: $VERSION
+Maintainer: gfdgd xi <3025613752@qq.com>
+Homepage: https://github.com/gfdgd-xi/dclc-kernel
+Architecture: amd64
+Severity: serious
+Certainty: possible
+Check: binaries
+Type: binary, udeb
+Priority: optional
+Depends: linux-headers-$VERSION-amd64-desktop-hwe, linux-image-$VERSION-amd64-desktop-hwe
+Section: utils
+Installed-Size: 0
+Description: 内核(虚包)
+EOF
+    dpkg -b deb linux-kernel-dclc-gfdgdxi-xanmod-hwe_${VERSION}_amd64.deb
+    dpkg -b deb-$MAINVERSION-xanmod linux-kernel-dclc-gfdgdxi-xanmod-$MAINVERSION-hwe_${VERSION}_amd64.deb
+    cd ..
+    bash ./repack-zstd --scan .
+    ./build.py
+    git add .
+    git pull
+    git config --global user.email 3025613752@qq.com
+    git config --global user.name gfdgd-xi
+    git commit -m 提交$VERSION
+    git push
+else
+    # move deb packages to artifact dir
+    cd ..
+    mkdir "artifact"
+    #cp ./*.deb artifact/
+    git clone https://gfdgd-xi:$PASSWORD@github.com/gfdgd-xi/dclc-kernel
+    #cd dclc-kernel
+    mkdir dclc-kernel/$VERSION
+    rm -rfv *dbg*.deb
+    mv ./*.deb dclc-kernel/$VERSION
+    cd dclc-kernel/$VERSION
+    cd ..
+    cd head
+    cat > deb/DEBIAN/control <<EOF
 Package: linux-kernel-dclc-gfdgdxi-xanmod
 Version: $VERSION
 Maintainer: gfdgd xi <3025613752@qq.com>
@@ -76,10 +144,10 @@ Section: utils
 Installed-Size: 0
 Description: 内核(虚包)
 EOF
-if [[ ! -d deb-$MAINVERSION-xanmod ]]; then
-    mkdir -pv deb-$MAINVERSION-xanmod/DEBIAN
-fi
-cat > deb-$MAINVERSION-xanmod/DEBIAN/control <<EOF
+    if [[ ! -d deb-$MAINVERSION-xanmod ]]; then
+        mkdir -pv deb-$MAINVERSION-xanmod/DEBIAN
+    fi
+    cat > deb-$MAINVERSION-xanmod/DEBIAN/control <<EOF
 Package: linux-kernel-dclc-gfdgdxi-$MAINVERSION-xanmod
 Version: $VERSION
 Maintainer: gfdgd xi <3025613752@qq.com>
@@ -95,14 +163,15 @@ Section: utils
 Installed-Size: 0
 Description: 内核(虚包)
 EOF
-dpkg -b deb linux-kernel-dclc-gfdgdxi-xanmod_${VERSION}_amd64.deb
-dpkg -b deb-$MAINVERSION-xanmod linux-kernel-dclc-gfdgdxi-xanmod-$MAINVERSION_${VERSION}_amd64.deb
-cd ..
-bash ./repack-zstd --scan .
-./build.py
-git add .
-git pull
-git config --global user.email 3025613752@qq.com
-git config --global user.name gfdgd-xi
-git commit -m 提交$VERSION
-git push
\ No newline at end of file
+    dpkg -b deb linux-kernel-dclc-gfdgdxi-xanmod_${VERSION}_amd64.deb
+    dpkg -b deb-$MAINVERSION-xanmod linux-kernel-dclc-gfdgdxi-xanmod-$MAINVERSION_${VERSION}_amd64.deb
+    cd ..
+    bash ./repack-zstd --scan .
+    ./build.py
+    git add .
+    git pull
+    git config --global user.email 3025613752@qq.com
+    git config --global user.name gfdgd-xi
+    git commit -m 提交$VERSION
+    git push
+fi
\ No newline at end of file