From 01fde65ade4626864d7cdd8024fcb7a0dd04c440 Mon Sep 17 00:00:00 2001 From: he3als <65787561+he3als@users.noreply.github.com> Date: Fri, 6 Sep 2024 00:19:29 +0100 Subject: [PATCH] feat: make it more clear how to build the playbook --- .github/workflows/apbx.yaml | 2 +- .vscode/launch.json | 6 +++--- src/README.md | 7 +++++++ src/{ => dependencies}/local-build.ps1 | 28 +++++++++++++------------- src/playbook/build-playbook.cmd | 8 ++++++++ src/playbook/build-playbook.sh | 11 ++++++++++ src/playbook/local-build.cmd | 8 -------- src/playbook/local-build.sh | 11 ---------- 8 files changed, 44 insertions(+), 37 deletions(-) create mode 100644 src/README.md rename src/{ => dependencies}/local-build.ps1 (91%) create mode 100644 src/playbook/build-playbook.cmd create mode 100644 src/playbook/build-playbook.sh delete mode 100644 src/playbook/local-build.cmd delete mode 100644 src/playbook/local-build.sh diff --git a/.github/workflows/apbx.yaml b/.github/workflows/apbx.yaml index e7380fc35a..9ae24d5ba3 100644 --- a/.github/workflows/apbx.yaml +++ b/.github/workflows/apbx.yaml @@ -119,7 +119,7 @@ jobs: run: | echo "Making a renamed password protected (malte) ZIP of playbook files..." $pbName = "Atlas Playbook $($env:GITHUB_SHA.Substring(0,8))" - & ..\local-build.ps1 -ReplaceOldPlaybook -AddLiveLog -Removals Verification, WinverRequirement -FileName $pbName + & ..\dependencies\local-build.ps1 -ReplaceOldPlaybook -AddLiveLog -Removals Verification, WinverRequirement -FileName $pbName echo "Move the .apbx playbook into 'Release ZIP' to be released as an artifact with the additional files..." Move-Item "$pbName.apbx" "../release-zip" working-directory: src\playbook diff --git a/.vscode/launch.json b/.vscode/launch.json index ba3c301a41..051d7ff69f 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -5,7 +5,7 @@ "type": "PowerShell", "request": "launch", "name": "Build Playbook (Test)", - "script": "& \"$(Join-Path '${workspaceFolder}' 'src/local-build.ps1')\" -AddLiveLog -ReplaceOldPlaybook -Removals WinverRequirement, Verification", + "script": "& \"$(Join-Path '${workspaceFolder}' 'src/dependencies/local-build.ps1')\" -AddLiveLog -ReplaceOldPlaybook -Removals WinverRequirement, Verification", "cwd": "${workspaceFolder}/src/playbook", "args": [] }, @@ -13,7 +13,7 @@ "type": "PowerShell", "request": "launch", "name": "Build Playbook (Test w/o deps)", - "script": "& \"$(Join-Path '${workspaceFolder}' 'src/local-build.ps1')\" -AddLiveLog -ReplaceOldPlaybook -Removals Dependencies, WinverRequirement, Verification", + "script": "& \"$(Join-Path '${workspaceFolder}' 'src/dependencies/local-build.ps1')\" -AddLiveLog -ReplaceOldPlaybook -Removals Dependencies, WinverRequirement, Verification", "cwd": "${workspaceFolder}/src/playbook", "args": [] }, @@ -21,7 +21,7 @@ "type": "PowerShell", "request": "launch", "name": "Build Playbook (Release)", - "script": "& \"$(Join-Path '${workspaceFolder}' 'src/local-build.ps1')\"", + "script": "& \"$(Join-Path '${workspaceFolder}' 'src/dependencies/local-build.ps1')\"", "cwd": "${workspaceFolder}/src/playbook", "args": [] } diff --git a/src/README.md b/src/README.md new file mode 100644 index 0000000000..8f51534bfb --- /dev/null +++ b/src/README.md @@ -0,0 +1,7 @@ +# Welcome to the source code! 😊 + +Here, you'll find all of Atlas' modifications in plain text. See our development documentation for more info: + +- [Building the Playbook](https://docs.atlasos.net/contributing/playbook/#how-to-build-a-playbook) +- [Testing the Playbook](https://docs.atlasos.net/contributing/playbook/#how-to-run-your-built-playbooks) +- [What to test (for general testing)](https://docs.atlasos.net/contributing/testing/what-to-test/) \ No newline at end of file diff --git a/src/local-build.ps1 b/src/dependencies/local-build.ps1 similarity index 91% rename from src/local-build.ps1 rename to src/dependencies/local-build.ps1 index 1a9aef8c26..44cdef0e41 100644 --- a/src/local-build.ps1 +++ b/src/dependencies/local-build.ps1 @@ -10,8 +10,8 @@ param ( $removals | % { Set-Variable -Name "remove$_" -Value $true } -# Convert paths for convienience, needed for Linux/macOS -function Seperator { +# Convert paths for convenience, needed for Linux/macOS +function Separator { return $args -replace '\\', "$([IO.Path]::DirectorySeparatorChar)" } @@ -89,7 +89,7 @@ function GetNewName { } if ($replaceOldPlaybook -and (Test-Path -Path $apbxFileName)) { try { - $stream = [System.IO.File]::Open($(Seperator "$PWD\$apbxFileName"), 'Open', 'Read', 'Write') + $stream = [System.IO.File]::Open($(Separator "$PWD\$apbxFileName"), 'Open', 'Read', 'Write') $stream.Close() Remove-Item -Path $apbxFileName -Force -EA 0 } catch { @@ -99,12 +99,12 @@ if ($replaceOldPlaybook -and (Test-Path -Path $apbxFileName)) { } elseif (Test-Path -Path $apbxFileName) { GetNewName } -$apbxPath = Seperator "$PWD\$apbxFileName" +$apbxPath = Separator "$PWD\$apbxFileName" # make temp directories $rootTemp = New-Item (Join-Path -Path $([System.IO.Path]::GetTempPath()) -ChildPath $([System.Guid]::NewGuid())) -ItemType Directory -Force if (!(Test-Path -Path "$rootTemp")) { throw "Failed to create temporary directory!" } -$playbookTemp = New-Item $(Seperator "$rootTemp\playbook") -Type Directory +$playbookTemp = New-Item $(Separator "$rootTemp\playbook") -Type Directory try { # remove entries in playbook config that make it awkward for testing @@ -115,13 +115,13 @@ try { if ($removeWinverRequirement) {$patterns += "", "", ""} if ($removeVerification) {$patterns += ""} - $tempPbConfPath = Seperator "$playbookTemp\playbook.conf" + $tempPbConfPath = Separator "$playbookTemp\playbook.conf" if ($patterns.Count -gt 0) { Get-Content "playbook.conf" | Where-Object { $_ -notmatch ($patterns -join '|') } | Set-Content $tempPbConfPath } - $customYmlPath = Seperator "Configuration\custom.yml" - $tempCustomYmlPath = Seperator "$playbookTemp\$customYmlPath" + $customYmlPath = Separator "Configuration\custom.yml" + $tempCustomYmlPath = Separator "$playbookTemp\$customYmlPath" if ($AddLiveLog) { if (Test-Path $customYmlPath -PathType Leaf) { New-Item (Split-Path $tempCustomYmlPath -Parent) -ItemType Directory -Force | Out-Null @@ -147,8 +147,8 @@ while ($true) { Get-Content -Wait -LiteralPath $a -EA 0 | Write-Output; Start-Sl } } - $startYmlPath = Seperator "Configuration\atlas\start.yml" - $tempStartYmlPath = Seperator "$playbookTemp\$startYmlPath" + $startYmlPath = Separator "Configuration\atlas\start.yml" + $tempStartYmlPath = Separator "$playbookTemp\$startYmlPath" if ($removeDependencies) { if (Test-Path $startYmlPath -PathType Leaf) { New-Item (Split-Path $tempStartYmlPath -Parent) -ItemType Directory -Force | Out-Null @@ -166,8 +166,8 @@ while ($true) { Get-Content -Wait -LiteralPath $a -EA 0 | Write-Output; Start-Sl } } - $oemYmlPath = Seperator "Configuration\tweaks\misc\config-oem-information.yml" - $tempOemYmlPath = Seperator "$playbookTemp\$oemYmlPath" + $oemYmlPath = Separator "Configuration\tweaks\misc\config-oem-information.yml" + $tempOemYmlPath = Separator "$playbookTemp\$oemYmlPath" if (Test-Path $oemYmlPath -PathType Leaf) { $confXml = ([xml](Get-Content "playbook.conf" -Raw -EA 0)).Playbook $version = "v$($confXml.Version)" @@ -201,13 +201,13 @@ while ($true) { Get-Content -Wait -LiteralPath $a -EA 0 | Write-Output; Start-Sl if (Test-Path $tempCustomYmlPath) { $excludeFiles += "custom.yml" } if (Test-Path $tempStartYmlPath) { $excludeFiles += "start.yml" } if (Test-Path $tempPbConfPath) { $excludeFiles += "playbook.conf" } - $files = Seperator "$rootTemp\7zFiles.txt" + $files = Separator "$rootTemp\7zFiles.txt" (Get-ChildItem -File -Exclude $excludeFiles -Recurse).FullName | Resolve-Path -Relative | ForEach-Object {$_.Substring(2)} | Out-File $files -Encoding utf8 if (!$NoPassword) { $pass = '-pmalte' } & $7zPath a -spf -y -mx1 $pass -tzip "$apbxPath" `@"$files" | Out-Null # add edited files - if (Test-Path $(Seperator "$playbookTemp\*.*")) { + if (Test-Path $(Separator "$playbookTemp\*.*")) { Push-Location "$playbookTemp" & $7zPath u $pass "$apbxPath" * | Out-Null Pop-Location diff --git a/src/playbook/build-playbook.cmd b/src/playbook/build-playbook.cmd new file mode 100644 index 0000000000..889ef45904 --- /dev/null +++ b/src/playbook/build-playbook.cmd @@ -0,0 +1,8 @@ +@echo off +pushd "%~dp0" +echo Building Playbook... +powershell -nop -ep bypass ^& "%cd%\..\dependencies\local-build.ps1" -AddLiveLog -ReplaceOldPlaybook -Removals WinverRequirement, Verification -DontOpenPbLocation +if %errorlevel% neq 0 ( + if "%*"=="" pause +) +popd \ No newline at end of file diff --git a/src/playbook/build-playbook.sh b/src/playbook/build-playbook.sh new file mode 100644 index 0000000000..6404305b7d --- /dev/null +++ b/src/playbook/build-playbook.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +pushd "$(dirname "$0")" +echo "Building Playbook..." +pwsh -NoP -EP Bypass -C "& \"$(dirname "$PWD")/dependencies/local-build.ps1\" -AddLiveLog -ReplaceOldPlaybook -Removals WinverRequirement, Verification -DontOpenPbLocation" +if [ $? -ne 0 ]; then + if [ -z "$*" ]; then + read -p "Press Enter to exit...: " + fi +fi +popd \ No newline at end of file diff --git a/src/playbook/local-build.cmd b/src/playbook/local-build.cmd deleted file mode 100644 index effda43527..0000000000 --- a/src/playbook/local-build.cmd +++ /dev/null @@ -1,8 +0,0 @@ -@echo off -pushd "%~dp0" -echo Building Playbook... -powershell -nop -ep bypass ^& "%cd%\..\local-build.ps1" -AddLiveLog -ReplaceOldPlaybook -Removals WinverRequirement, Verification -DontOpenPbLocation -if %errorlevel% neq 0 ( - if "%*"=="" pause -) -popd \ No newline at end of file diff --git a/src/playbook/local-build.sh b/src/playbook/local-build.sh deleted file mode 100644 index 90111f0bdb..0000000000 --- a/src/playbook/local-build.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -pushd "$(dirname "$0")" -echo "Building Playbook..." -pwsh -NoP -EP Bypass -C "& \"$(dirname "$PWD")/local-build.ps1\" -AddLiveLog -ReplaceOldPlaybook -Removals WinverRequirement, Verification -DontOpenPbLocation" -if [ $? -ne 0 ]; then - if [ -z "$*" ]; then - read -p "Press Enter to exit...: " - fi -fi -popd \ No newline at end of file