diff --git a/build/build-iso.ps1 b/build/build-iso.ps1 index dea56ad5..78ccd4de 100755 --- a/build/build-iso.ps1 +++ b/build/build-iso.ps1 @@ -1,6 +1,17 @@ -if (!((Split-Path -Path (Get-Location) -Leaf) -eq "build")) +# make sure we are in the correct directory +$currentDir=Get-Location +if ("$currentDir" -ne "$PSScriptRoot") { - Write-Output "This script must be run inside the build folder. Press ENTER to exit."; Read-Host; exit + try + { + pushd "$PSScriptRoot" + . $PSCommandPath $args + } + finally + { + popd + } + exit } if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) diff --git a/build/build-iso.sh b/build/build-iso.sh index c5900179..ae6eca77 100755 --- a/build/build-iso.sh +++ b/build/build-iso.sh @@ -2,7 +2,16 @@ # Build Distro ISO using AUTO.ISO minimal auto-install as bootstrap to merge codebase, recompile system, and export ISO -# Run this script inside build/ directory +# make sure we are in the correct directory +SCRIPT_DIR=$(realpath "$(dirname "$0")") +SCRIPT_NAME=$(basename "$0") +EXPECTED_DIR=$(realpath "$PWD") + +if test "${EXPECTED_DIR}" != "${SCRIPT_DIR}" +then + ( cd "$SCRIPT_DIR" || exit ; "./$SCRIPT_NAME" "$@" ); + exit +fi # Uncomment if you use doas instead of sudo #alias sudo=doas diff --git a/build/sync.ps1 b/build/sync.ps1 index 1338aee7..472b7838 100755 --- a/build/sync.ps1 +++ b/build/sync.ps1 @@ -1,4 +1,20 @@ -$choice = $args[0] +# make sure we are in the correct directory +$currentDir=Get-Location +if ("$currentDir" -ne "$PSScriptRoot") +{ + try + { + pushd "$PSScriptRoot" + . $PSCommandPath $args + } + finally + { + popd + } + exit +} + +$choice = $args[0] function print_usage() { @@ -19,11 +35,6 @@ if ($choice -ne 'repo' -and $choice -ne "vm") print_usage } -if (!((Split-Path -Path (Get-Location) -Leaf) -eq "build")) -{ - Write-Output "This script must be run inside the build folder. Press ENTER to exit."; Read-Host; exit -} - if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { Write-Output "This script must be run as Adminstrator. Press ENTER to exit."; Read-Host; exit @@ -41,9 +52,9 @@ Write-Output "QEMU installation found." # Set this $ZEALDISK="" -# Examples: -#$ZEALDISK = "$HOME\VirtualBox VMs\ZEAL\ZEAL.vdi" -#$ZEALDISK="$HOME\vmware\ZealOS\ZealOS.vmdk" +# Examples: +#$ZEALDISK = "$HOME\VirtualBox VMs\ZEAL\ZEAL.vdi" +#$ZEALDISK="$HOME\vmware\ZealOS\ZealOS.vmdk" #$ZEALDISK="ZealOS.qcow2" if ($ZEALDISK -eq "") diff --git a/build/sync.sh b/build/sync.sh index a8d4af1d..000afbf6 100755 --- a/build/sync.sh +++ b/build/sync.sh @@ -1,12 +1,23 @@ #!/bin/sh # # Sync VM <--> Repo. -# Run this script inside build/ directory. # # On copying from virtual disk to src/, the directory is emptied before copy. Comment out "rm -rf ../src/*" to copy onto src. # # +# make sure we are in the correct directory +SCRIPT_DIR=$(realpath "$(dirname "$0")") +SCRIPT_NAME=$(basename "$0") +EXPECTED_DIR=$(realpath "$PWD") + +if test "${EXPECTED_DIR}" != "${SCRIPT_DIR}" +then + ( cd "$SCRIPT_DIR" || exit ; "./$SCRIPT_NAME" "$@" ); + exit +fi + + # Uncomment if you use doas instead of sudo #alias sudo=doas