Skip to content

Commit

Permalink
Improvements in local build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
EduardGomezEscandell committed Sep 22, 2023
1 parent 26559f8 commit ecf0342
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
14 changes: 11 additions & 3 deletions tools/build/build-appx.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ function Update-Certificate {
# Finding local certificate
$certificate_path = "${PSScriptRoot}\.certificate_thumbprint"
if (! (Test-Path "${certificate_path}") ) {
Write-Error "You need a certificate to build and install the Appx. `
Write-Warning "You need a certificate to build and install the Appx. `
Create and install a certificate, and write its thumbprint in ${certificate_path}.`
See https://learn.microsoft.com/en-us/windows/win32/appxpkg/how-to-create-a-package-signing-certificate for more details"
exit 1

Write-Output "Continuing with default certificate"
return
}

$certificate_thumbprint = Get-Content ${certificate_path}
Expand All @@ -62,6 +64,8 @@ function Update-Certificate {
}

function Install-Appx {
Get-AppxPackage -Name "CanonicalGroupLimited.UbuntuProForWindows" | Remove-AppxPackage

$artifacts = (
Get-ChildItem ".\msix\UbuntuProForWindows\AppPackages\UbuntuProForWindows_*" `
| Sort-Object LastWriteTime `
Expand All @@ -84,7 +88,11 @@ Push-Location "${PSScriptRoot}\..\.."

Update-Certificate

Start-VsDevShell
try {
msbuild.exe --version
} catch {
Start-VsDevShell
}

msbuild.exe `
.\msix\msix.sln `
Expand Down
20 changes: 13 additions & 7 deletions tools/build/build-deb.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#>

param(
[Parameter(Mandatory=$False,HelpMessage="The directory where the debian build artifacts will be stored in")]
[Parameter(Mandatory = $False, HelpMessage = "The directory where the debian build artifacts will be stored in")]
[string]$OutputDir
)

Expand All @@ -21,20 +21,22 @@ if ( $appx -eq "" ) {
Write-Error "Ubuntu Preview is not installed"
}

$env:WSL_UTF8=1
$env:WSL_UTF8 = 1

if ( "$(wsl --list --verbose | Select-String Ubuntu-Preview)" -eq "" ) {
ubuntupreview.exe install --root --ui=none
if ( "${LastExitCode}" -ne "0" ) {
Write-Error "could not install Ubuntu-Preview"
exit 1
}

Copy-Item -Path "${HOME}/.gitconfig" -Destination "\\wsl$\Ubuntu-Preview\etc\gitconfig"
}

# Write script to run
$scriptWindows=New-TemporaryFile
$scriptWindows = New-TemporaryFile

$scriptLinux=( wsl.exe -d Ubuntu-Preview -- wslpath -ua `'${scriptWindows}`' )
$scriptLinux = ( wsl.exe -d Ubuntu-Preview -- wslpath -ua `'${scriptWindows}`' )
if ( "${LastExitCode}" -ne "0" ) {
Write-Error "could not get build script's linux path"
exit 1
Expand All @@ -47,9 +49,13 @@ set -eu
git config --global --add safe.directory "$(pwd)"
# Update internal dependencies in the repo
# (we need git to work, and .git is not rsync'd)
# Update internal dependencies in the repo because
# we need git to work, and .git is not rsync'd.
cd wsl-pro-service
go version || (
sudo DEBIAN_FRONTEND=noninteractive apt update
sudo DEBIAN_FRONTEND=noninteractive apt install -y golang-go
)
./debian/update-internal-dependencies
go mod tidy
go mod vendor
Expand Down Expand Up @@ -79,7 +85,7 @@ cp -f ${build_dir}/wsl-pro-service_* "${OutputDir}"
# Set up output directory
New-Item -Force -ItemType "Directory" -Path "${OutputDir}" | Out-Null

$outputLinux=( wsl.exe -d Ubuntu-Preview -- wslpath -ua `'${OutputDir}`' )
$outputLinux = ( wsl.exe -d Ubuntu-Preview -- wslpath -ua `'${OutputDir}`' )
if ( "${LastExitCode}" -ne "0" ) {
Write-Error "could not get output dir's linux path"
exit 1
Expand Down
2 changes: 1 addition & 1 deletion wsl-pro-service/debian/update-internal-dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -eu

# Add repo as private
go env -w GOPRIVATE=github.com/canonical/ubuntu-pro-for-windows
go env -w "GOPRIVATE=github.com/canonical/ubuntu-pro-for-windows"

UP4W_SKIP_INTERNAL_DEPENDENCY_UPDATE=${UP4W_SKIP_INTERNAL_DEPENDENCY_UPDATE:-""}

Expand Down

0 comments on commit ecf0342

Please sign in to comment.