Skip to content

Commit

Permalink
feat: make it more clear how to build the playbook
Browse files Browse the repository at this point in the history
  • Loading branch information
he3als committed Sep 5, 2024
1 parent f685c1c commit 01fde65
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/apbx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@
"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": []
},
{
"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": []
},
{
"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": []
}
Expand Down
7 changes: 7 additions & 0 deletions src/README.md
Original file line number Diff line number Diff line change
@@ -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/)
28 changes: 14 additions & 14 deletions src/local-build.ps1 → src/dependencies/local-build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
}

Expand Down Expand Up @@ -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 {
Expand All @@ -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
Expand All @@ -115,13 +115,13 @@ try {
if ($removeWinverRequirement) {$patterns += "<string>", "</SupportedBuilds>", "<SupportedBuilds>"}
if ($removeVerification) {$patterns += "<ProductCode>"}

$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
Expand All @@ -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
Expand All @@ -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)"
Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions src/playbook/build-playbook.cmd
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions src/playbook/build-playbook.sh
Original file line number Diff line number Diff line change
@@ -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
8 changes: 0 additions & 8 deletions src/playbook/local-build.cmd

This file was deleted.

11 changes: 0 additions & 11 deletions src/playbook/local-build.sh

This file was deleted.

0 comments on commit 01fde65

Please sign in to comment.