Skip to content

Commit

Permalink
Merge pull request #27 from LingmoOS/new
Browse files Browse the repository at this point in the history
Reformat Tools
  • Loading branch information
chun-awa authored Oct 18, 2024
2 parents 13dd1ee + 11c2d9c commit ff96203
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 88 deletions.
84 changes: 16 additions & 68 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ defaults:

jobs:
build-trixie:
strategy:
matrix:
devbuild: ['enabled', 'disabled']
runs-on: ubuntu-latest
container: docker.io/library/debian:trixie-slim
name: Build Trixie
Expand All @@ -38,79 +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
pwsh ./build.ps1
chmod +x ./build.ps1
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:
name: Lingmo Artifacts hydrogen
name: Lingmo Artifacts With Nightly ${{ matrix.devbuild }}
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 "[email protected]"
# 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


6 changes: 0 additions & 6 deletions Configs/lingmo-archive-keyring.json

This file was deleted.

6 changes: 6 additions & 0 deletions Configs/lingmo-plymouth-theme.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"Name": "lingmo-plymouth-theme",
"Repository": "https://github.com/LingmoOS/lingmo-plymouth-theme.git",
"Tag": "2.0.1",
"BuildType": "Debian"
}
17 changes: 7 additions & 10 deletions Modules/BuildUtils.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand All @@ -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) {
Expand All @@ -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!"

Expand Down
28 changes: 28 additions & 0 deletions Modules/CommonUtils.psm1
Original file line number Diff line number Diff line change
@@ -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
7 changes: 5 additions & 2 deletions Modules/GitModule.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#>

Import-Module "$PSScriptRoot/GlobalConfig"
Import-Module "$PSScriptRoot/CommonUtils"

<#
.DESCRIPTION
Expand Down Expand Up @@ -44,9 +45,11 @@ function Import-LingmoRepo {
Remove-DirIfExist $cloneDst

if ($cloneDevGit -eq $true) {
git clone $repoURL $cloneDst | Out-Null
$params = @("clone", "--recursive", "$($repoURL)", "$($cloneDst)")
$ret = Start-ShellProcess "git" $params
} else {
git clone -b $Tag $repoURL $cloneDst | Out-Null
$params = @("clone", "--recursive", "-b", "$($Tag)", "$($repoURL)", "$($cloneDst)")
$ret = Start-ShellProcess "git" $params
}

return $cloneDst
Expand Down
4 changes: 2 additions & 2 deletions Modules/SourceRepoTools.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit ff96203

Please sign in to comment.