From 6745db5251a30d96ffa20b33288beba6602be368 Mon Sep 17 00:00:00 2001 From: Elysia Date: Fri, 18 Oct 2024 21:04:04 +0800 Subject: [PATCH 01/12] Reformat Tools --- Configs/lingmo-archive-keyring.json | 6 ------ Modules/BuildUtils.psm1 | 17 +++++++---------- Modules/CommonUtils.psm1 | 28 ++++++++++++++++++++++++++++ Modules/GitModule.psm1 | 7 +++++-- Modules/SourceRepoTools.psm1 | 4 ++-- build.ps1 | 1 + 6 files changed, 43 insertions(+), 20 deletions(-) delete mode 100644 Configs/lingmo-archive-keyring.json create mode 100644 Modules/CommonUtils.psm1 diff --git a/Configs/lingmo-archive-keyring.json b/Configs/lingmo-archive-keyring.json deleted file mode 100644 index 20d85f8..0000000 --- a/Configs/lingmo-archive-keyring.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Name": "lingmo-archive-keyring", - "Repository": "https://github.com/LingmoOS/lingmo-archive-keyring.git", - "BuildType": "Debian", - "Tag": "2024.8.0+fix1" -} diff --git a/Modules/BuildUtils.psm1 b/Modules/BuildUtils.psm1 index 6dbc18f..9e82d45 100644 --- a/Modules/BuildUtils.psm1 +++ b/Modules/BuildUtils.psm1 @@ -5,6 +5,7 @@ Import-Module "$PSScriptRoot/GlobalConfig" Import-Module "$PSScriptRoot/GitModule" Import-Module "$PSScriptRoot/SourceRepoTools" +Import-Module "$PSScriptRoot/CommonUtils" function Get-SudoPrivilege { Write-Host "Now checking for root privileges." @@ -28,22 +29,17 @@ function Get-SudoPrivilege { function Install-GlobalDepends { Write-Host "Installing Common build dependencies" - $Env:LC_ALL="C.UTF-8" + $env:LC_ALL="C.UTF-8" - sudo apt-get --yes install git devscripts equivs | Out-Null - - # Assuming Windows has "LingmoOSBuildDeps" directory support - $repoPath = Import-LingmoRepo "https://github.com/LingmoOS/LingmoOSBuildDeps.git" "LingmoOSBuildDeps" $true - Set-Location $repoPath - sudo mk-build-deps -i -t "apt-get -y" -r | Out-Null + Start-ShellProcess "sudo" @("apt-get", "--yes", "install", "git devscripts equivs") } function Install-RepoDepends($repoPath) { - $Env:LC_ALL="C.UTF-8" + $env:LC_ALL="C.UTF-8" # Assuming Windows has "LingmoOSBuildDeps" directory support Set-Location $repoPath - sudo mk-build-deps -i -t "apt-get -y" -r | Out-Null + Start-ShellProcess "sudo" @("mk-build-deps", "-i -t", "`"apt-get -y`"", "-r") } function Start-CompileDeb($repo) { @@ -55,7 +51,8 @@ function Start-CompileDeb($repo) { Install-RepoDepends $repo.m_repoPath Write-Host "Build $($repo.repoName) ..." - dpkg-buildpackage -b -uc -us -tc -j"$(nproc)" | Out-Null + $totalCPUS = (nproc).ToString() + Start-ShellProcess "dpkg-buildpackage" @("-b", "-uc", "-us", "-tc", "-j$($totalCPUS)") Write-Host "$($repo.repoName) Complete!" diff --git a/Modules/CommonUtils.psm1 b/Modules/CommonUtils.psm1 new file mode 100644 index 0000000..a069d3b --- /dev/null +++ b/Modules/CommonUtils.psm1 @@ -0,0 +1,28 @@ +<# + .DESCRIPTION + Contain commonly used funcions. +#> + +<# + .DESCRIPTION + Execute a process and throw an error if not exit correctly + .OUTPUTS + True if sucess. Throw error if failed +#> +function Start-ShellProcess { + param ( + [Parameter(Mandatory)] + [string] $execName, + [System.Collections.ArrayList] $params + ) + + $proc = Start-Process $execName -ArgumentList $params -Wait -PassThru + + if ($proc.ExitCode -ne 0) { + # 如果非正常结束,就会报错 + throw "Error executing $($repoURL) with param: $($cloneDst)" + } + + return $true +} +Export-ModuleMember -Function Start-ShellProcess diff --git a/Modules/GitModule.psm1 b/Modules/GitModule.psm1 index 2734d67..d2fd9ee 100644 --- a/Modules/GitModule.psm1 +++ b/Modules/GitModule.psm1 @@ -4,6 +4,7 @@ #> Import-Module "$PSScriptRoot/GlobalConfig" +Import-Module "$PSScriptRoot/CommonUtils" <# .DESCRIPTION @@ -44,9 +45,11 @@ function Import-LingmoRepo { Remove-DirIfExist $cloneDst if ($cloneDevGit -eq $true) { - git clone $repoURL $cloneDst | Out-Null + $params = @("clone", "$($repoURL)", "$($cloneDst)") + $ret = Start-ShellProcess "git" $params } else { - git clone -b $Tag $repoURL $cloneDst | Out-Null + $params = @("clone", "-b", "$($Tag)", "$($repoURL)", "$($cloneDst)") + $ret = Start-ShellProcess "git" $params } return $cloneDst diff --git a/Modules/SourceRepoTools.psm1 b/Modules/SourceRepoTools.psm1 index f57f5f3..b8d7663 100644 --- a/Modules/SourceRepoTools.psm1 +++ b/Modules/SourceRepoTools.psm1 @@ -101,9 +101,9 @@ function Get-AllRepoConfigs { $fullPath = "$(Get-ConfigPath)/$name" $item = Get-ConfigFromFile $fullPath $cloneDevGit if ($clone) { - $item.CloneRepo() | Out-Null + $item.CloneRepo() } - $results.Add($item) | Out-Null + $results.Add($item) } return $results diff --git a/build.ps1 b/build.ps1 index d1824ce..0a9fa38 100755 --- a/build.ps1 +++ b/build.ps1 @@ -15,6 +15,7 @@ $LingMainScriptPath = $MyInvocation.MyCommand.Definition $LingMainScriptDirectory = Split-Path $LingMainScriptPath -Parent # Import modules +Import-Module (Join-Path $LingMainScriptDirectory "/Modules/CommonUtils") Import-Module (Join-Path $LingMainScriptDirectory "/Modules/GlobalConfig") Import-Module (Join-Path $LingMainScriptDirectory "/Modules/GitModule") Import-Module (Join-Path $LingMainScriptDirectory "/Modules/SourceRepoTools") From 5e601a09509e873ed5b020c04c82cf57a8594100 Mon Sep 17 00:00:00 2001 From: Elysia Date: Fri, 18 Oct 2024 21:07:55 +0800 Subject: [PATCH 02/12] Added "--recursive", --- Modules/GitModule.psm1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/GitModule.psm1 b/Modules/GitModule.psm1 index d2fd9ee..95bed2d 100644 --- a/Modules/GitModule.psm1 +++ b/Modules/GitModule.psm1 @@ -45,10 +45,10 @@ function Import-LingmoRepo { Remove-DirIfExist $cloneDst if ($cloneDevGit -eq $true) { - $params = @("clone", "$($repoURL)", "$($cloneDst)") + $params = @("clone", "--recursive", "$($repoURL)", "$($cloneDst)") $ret = Start-ShellProcess "git" $params } else { - $params = @("clone", "-b", "$($Tag)", "$($repoURL)", "$($cloneDst)") + $params = @("clone", "--recursive", "-b", "$($Tag)", "$($repoURL)", "$($cloneDst)") $ret = Start-ShellProcess "git" $params } From f3359e08f099b7a5fb6d6acb2b9006d5fe85bbcb Mon Sep 17 00:00:00 2001 From: Elysia Date: Fri, 18 Oct 2024 21:10:42 +0800 Subject: [PATCH 03/12] Added lingmo-plymouth-theme --- Configs/lingmo-plymouth-theme.json | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 Configs/lingmo-plymouth-theme.json diff --git a/Configs/lingmo-plymouth-theme.json b/Configs/lingmo-plymouth-theme.json new file mode 100644 index 0000000..b07a141 --- /dev/null +++ b/Configs/lingmo-plymouth-theme.json @@ -0,0 +1,6 @@ +{ + "Name": "lingmo-plymouth-theme", + "Repository": "https://github.com/LingmoOS/lingmo-plymouth-theme.git", + "Tag": "2.0.1", + "BuildType": "Debian" +} From fa881009660e8b05954d81752018cb80f37e94f7 Mon Sep 17 00:00:00 2001 From: Elysia Date: Fri, 18 Oct 2024 21:19:33 +0800 Subject: [PATCH 04/12] Update CI --- .github/workflows/ci.yml | 78 +++++++--------------------------------- 1 file changed, 12 insertions(+), 66 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8ac5d9c..30956d8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,6 +15,9 @@ defaults: jobs: build-trixie: + strategy: + matrix: + devbuild: [0, 1] runs-on: ubuntu-latest container: docker.io/library/debian:trixie-slim name: Build Trixie @@ -42,75 +45,18 @@ jobs: run: | git config --global http.sslVerify false git config --global advice.detachedHead false - pwsh ./build.ps1 + pwsh ./build.ps1 -BuildFromGit ${{ matrix.devbuild }} - uses: actions/upload-artifact@v4 with: - name: Lingmo Artifacts hydrogen + if: ${{ matrix.devbuild == 0 }} + name: Lingmo Artifacts Latest Tag Build path: BuildArtifacts compression-level: 9 # maximum compression - - # upload: - # needs: build - # runs-on: ubuntu-latest - # name: Update to repo - # steps: - # - uses: actions/checkout@v4 - - # - uses: actions/download-artifact@v4 - # with: - # # Destination path. Supports basic tilde expansion. - # # Optional. Default is $GITHUB_WORKSPACE - # path: ./zips - - # # The repository owner and the repository name joined together by "/". - # # If github-token is specified, this is the repository that artifacts will be downloaded from. - # # Optional. Default is ${{ github.repository }} - # repository: ${{ github.repository }} - - # # The id of the workflow run where the desired download artifact was uploaded from. - # # If github-token is specified, this is the run that artifacts will be downloaded from. - # # Optional. Default is ${{ github.run_id }} - # run-id: ${{ github.run_id }} - - # - name: Prepare envs - # run: | - # sudo apt update && sudo apt install reprepro gnupg - # echo "${{ secrets.GPG_SIGN_KEY }}" >> key.key - # gpg --import key.key - - # - name: Clone repo - # run: | - # git clone https://github.com/LingmoOS-Testing/lingmo-rolling-mirror.git pkg_site - # DEB_FILE_DIR="$(pwd)/zips" - - # rm -rf pkg_site/devrepo/* - # cd pkg_site/helpers - # bash init_repo.sh - - # git checkout --orphan latest_branch - - # DEB_FILES=$(find $DEB_FILE_DIR -type f -name '*.deb') - # for debfile in $DEB_FILES; do - # bash add_deb.sh "$debfile" - # done - # cd .. - - # git config --global user.email "automation@lingmo.org" - # git config --global user.name "Lingmo Automation Packer" - # git add . && git commit -m "Update Packages By Actions $(date)" - - # git branch -D master - # git branch -m master - - # - name: Push changes - # uses: ad-m/github-push-action@9870d48124da805820c70ebc6ba563c715551019 - # with: - # github_token: ${{ secrets.API_GITHUB_TOKEN }} - # repository: "LingmoOS-Testing/lingmo-rolling-mirror" - # directory: "./pkg_site" - # branch: 'master' - # force: true - - + - uses: actions/upload-artifact@v4 + with: + if: ${{ matrix.devbuild == 1 }} + name: Lingmo Artifacts Nightly Build + path: BuildArtifacts + compression-level: 9 # maximum compression From c771c25fc0bb20889365ad7779892f55812aaab2 Mon Sep 17 00:00:00 2001 From: Elysia Date: Fri, 18 Oct 2024 21:23:16 +0800 Subject: [PATCH 05/12] Update CI --- .github/workflows/ci.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 30956d8..f0a32f4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: build-trixie: strategy: matrix: - devbuild: [0, 1] + devbuild: ["$false", "$true"] runs-on: ubuntu-latest container: docker.io/library/debian:trixie-slim name: Build Trixie @@ -45,18 +45,19 @@ jobs: run: | git config --global http.sslVerify false git config --global advice.detachedHead false - pwsh ./build.ps1 -BuildFromGit ${{ matrix.devbuild }} + chmod +x ./build.ps1 + pwsh -c "./build.ps1 -BuildFromGit ${{ matrix.devbuild }}" - uses: actions/upload-artifact@v4 with: - if: ${{ matrix.devbuild == 0 }} + if: ${{ matrix.devbuild == "$false" }} name: Lingmo Artifacts Latest Tag Build path: BuildArtifacts compression-level: 9 # maximum compression - uses: actions/upload-artifact@v4 with: - if: ${{ matrix.devbuild == 1 }} + if: ${{ matrix.devbuild == "$true" }} name: Lingmo Artifacts Nightly Build path: BuildArtifacts compression-level: 9 # maximum compression From 84342bb1fa0b8f394e142ee0cc9e0b88759078fb Mon Sep 17 00:00:00 2001 From: Elysia Date: Fri, 18 Oct 2024 21:24:29 +0800 Subject: [PATCH 06/12] $ --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f0a32f4..2c99289 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,14 +50,14 @@ jobs: - uses: actions/upload-artifact@v4 with: - if: ${{ matrix.devbuild == "$false" }} + if: ${{ matrix.devbuild == "\$false" }} name: Lingmo Artifacts Latest Tag Build path: BuildArtifacts compression-level: 9 # maximum compression - uses: actions/upload-artifact@v4 with: - if: ${{ matrix.devbuild == "$true" }} + if: ${{ matrix.devbuild == "\$true" }} name: Lingmo Artifacts Nightly Build path: BuildArtifacts compression-level: 9 # maximum compression From bae9fc7411ec231e30a4df3614c637d1e35464e5 Mon Sep 17 00:00:00 2001 From: Elysia Date: Fri, 18 Oct 2024 21:26:32 +0800 Subject: [PATCH 07/12] fix --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2c99289..21671aa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,14 +50,14 @@ jobs: - uses: actions/upload-artifact@v4 with: - if: ${{ matrix.devbuild == "\$false" }} + if: ${{ matrix.devbuild == '$false' }} name: Lingmo Artifacts Latest Tag Build path: BuildArtifacts compression-level: 9 # maximum compression - uses: actions/upload-artifact@v4 with: - if: ${{ matrix.devbuild == "\$true" }} + if: ${{ matrix.devbuild == '$true' }} name: Lingmo Artifacts Nightly Build path: BuildArtifacts compression-level: 9 # maximum compression From 1ad3e9ddebc7252c34c3a041606a67fdbf8b9892 Mon Sep 17 00:00:00 2001 From: Elysia Date: Fri, 18 Oct 2024 21:28:44 +0800 Subject: [PATCH 08/12] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=BD=AC=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 21671aa..48ccc65 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,7 +46,7 @@ jobs: git config --global http.sslVerify false git config --global advice.detachedHead false chmod +x ./build.ps1 - pwsh -c "./build.ps1 -BuildFromGit ${{ matrix.devbuild }}" + pwsh -c "./build.ps1 -BuildFromGit \${{ matrix.devbuild }}" - uses: actions/upload-artifact@v4 with: From 865e114df20a5855aaa9170ab5815760a8abca7e Mon Sep 17 00:00:00 2001 From: Elysia Date: Fri, 18 Oct 2024 21:33:22 +0800 Subject: [PATCH 09/12] Fix --- .github/workflows/ci.yml | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 48ccc65..8016019 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: build-trixie: strategy: matrix: - devbuild: ["$false", "$true"] + devbuild: ["enabled", "disabled"] runs-on: ubuntu-latest container: docker.io/library/debian:trixie-slim name: Build Trixie @@ -41,23 +41,24 @@ jobs: apt-get install -y ./powershell.deb rm powershell.deb - - name: Build Lingmo + - name: Build Lingmo Nightly + if: ${{ matrix.devbuild = "enabled" }} run: | git config --global http.sslVerify false git config --global advice.detachedHead false chmod +x ./build.ps1 - pwsh -c "./build.ps1 -BuildFromGit \${{ matrix.devbuild }}" + pwsh -c "./build.ps1 -BuildFromGit" + + - name: Build Lingmo Using Tag + if: ${{ matrix.devbuild = "disabled" }} + run: | + git config --global http.sslVerify false + git config --global advice.detachedHead false + chmod +x ./build.ps1 + pwsh -c "./build.ps1" - uses: actions/upload-artifact@v4 with: - if: ${{ matrix.devbuild == '$false' }} - name: Lingmo Artifacts Latest Tag Build - path: BuildArtifacts - compression-level: 9 # maximum compression - - - uses: actions/upload-artifact@v4 - with: - if: ${{ matrix.devbuild == '$true' }} - name: Lingmo Artifacts Nightly Build + name: Lingmo Artifacts With Nightly ${{ matrix.devbuild }} path: BuildArtifacts compression-level: 9 # maximum compression From f502aff9ca486a342beb7e9d480eef0860ffcfad Mon Sep 17 00:00:00 2001 From: Elysia Date: Fri, 18 Oct 2024 21:34:00 +0800 Subject: [PATCH 10/12] Fix --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8016019..b6babe0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,7 +42,7 @@ jobs: rm powershell.deb - name: Build Lingmo Nightly - if: ${{ matrix.devbuild = "enabled" }} + if: ${{ matrix.devbuild == "enabled" }} run: | git config --global http.sslVerify false git config --global advice.detachedHead false @@ -50,7 +50,7 @@ jobs: pwsh -c "./build.ps1 -BuildFromGit" - name: Build Lingmo Using Tag - if: ${{ matrix.devbuild = "disabled" }} + if: ${{ matrix.devbuild == "disabled" }} run: | git config --global http.sslVerify false git config --global advice.detachedHead false From 533ed7019c26c92de2eb86d34df367faa3f95dea Mon Sep 17 00:00:00 2001 From: Elysia Date: Fri, 18 Oct 2024 21:35:02 +0800 Subject: [PATCH 11/12] fix " --- .github/workflows/ci.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b6babe0..467cb1a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: build-trixie: strategy: matrix: - devbuild: ["enabled", "disabled"] + devbuild: ['enabled', 'disabled'] runs-on: ubuntu-latest container: docker.io/library/debian:trixie-slim name: Build Trixie @@ -42,7 +42,7 @@ jobs: rm powershell.deb - name: Build Lingmo Nightly - if: ${{ matrix.devbuild == "enabled" }} + if: ${{ matrix.devbuild == 'enabled' }} run: | git config --global http.sslVerify false git config --global advice.detachedHead false @@ -50,7 +50,8 @@ jobs: pwsh -c "./build.ps1 -BuildFromGit" - name: Build Lingmo Using Tag - if: ${{ matrix.devbuild == "disabled" }} + if: ${{ matrix.devbuild == 'disabled' }} + if: ${{ matrix.devbuild == 'disabled' }} run: | git config --global http.sslVerify false git config --global advice.detachedHead false From 11c2d9c68a20bdb48479cb2a9d538f72abeaa969 Mon Sep 17 00:00:00 2001 From: Elysia Date: Fri, 18 Oct 2024 21:35:36 +0800 Subject: [PATCH 12/12] fix --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 467cb1a..5eaef19 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,6 @@ jobs: pwsh -c "./build.ps1 -BuildFromGit" - name: Build Lingmo Using Tag - if: ${{ matrix.devbuild == 'disabled' }} if: ${{ matrix.devbuild == 'disabled' }} run: | git config --global http.sslVerify false