diff --git a/.github/actions/download-rootfs/action.yaml b/.github/actions/download-rootfs/action.yaml index 7cd5d69bd..4e260bb31 100644 --- a/.github/actions/download-rootfs/action.yaml +++ b/.github/actions/download-rootfs/action.yaml @@ -5,28 +5,28 @@ inputs: distros: description: Space-separated list of distros to download required: true - default: "Ubuntu" + default: 'Ubuntu' path: description: Directory to store the rootfs in (${path}\${distro}.tar.gz) required: true - default: "Ubuntu" + default: 'Ubuntu' runs: - using: "composite" + using: 'composite' steps: - name: Check out repo - uses: actions/checkout@v3 + uses: actions/checkout@v6 - name: Install python uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: '3.10' - name: Install dependencies shell: powershell run: python -m pip install launchpadlib - name: Set up Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v6 with: - go-version: "1.21.4" + go-version-file: go.work - name: Generate WSL release info shell: powershell # Repository root @@ -45,6 +45,7 @@ runs: } Write-Output "::endgroup::" + New-Item -Type Directory -Path "${{ inputs.path }}" -ErrorAction Ignore | Out-Null Write-Output "::group::Fetch release info" python .\wsl-builder\lp-distro-info -o "${{ inputs.path }}\ubuntu-releases.csv" Get-Content "${{ inputs.path }}\ubuntu-releases.csv" diff --git a/.github/workflows/build-pr.yaml b/.github/workflows/build-pr.yaml index f1001b5f0..d26f9488d 100644 --- a/.github/workflows/build-pr.yaml +++ b/.github/workflows/build-pr.yaml @@ -15,11 +15,11 @@ jobs: runs-on: windows-latest if: ${{ !github.event.pull_request.draft }} env: - rootfs64: 'http://cloud-images.ubuntu.com/wsl/jammy/current/ubuntu-jammy-wsl-amd64-ubuntu22.04lts.rootfs.tar.gz' + rootfs64: 'https://releases.ubuntu.com/resolute/ubuntu-26.04-wsl-amd64.wsl' workDir: 'C:/Temp/builddir' steps: - name: Checkout WSL - uses: actions/checkout@v3 + uses: actions/checkout@v6 with: # we need to use a subdirectory as we can't move back base GITHUB_WORKSPACE directory path: repo @@ -42,7 +42,7 @@ jobs: $client = new-object System.Net.WebClient $client.DownloadFile("${{ env.rootfs64}}","x64/install.tar.gz") - name: Setup MSBuild (PATH) - uses: microsoft/setup-msbuild@v1.0.2 + uses: microsoft/setup-msbuild@v3 - name: Install certificate shell: powershell working-directory: ${{ env.workDir }} @@ -58,7 +58,7 @@ jobs: working-directory: ${{ env.workDir }} run: msbuild .\DistroLauncher.sln /t:Build /m /nr:false /p:Configuration=Release /p:AppxBundle=Always /p:AppxBundlePlatforms="x64" /p:UapAppxPackageBuildMode=SideloadOnly -verbosity:normal - name: Allow downloading sideload appxbundle - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: sideload-build path: | diff --git a/.github/workflows/build-wsl.yaml b/.github/workflows/build-wsl.yaml index c6bccb772..7234ee471 100644 --- a/.github/workflows/build-wsl.yaml +++ b/.github/workflows/build-wsl.yaml @@ -19,9 +19,6 @@ on: required: true default: 'yes' -env: - goversion: '1.21.4' - jobs: build-matrix: name: Build Matrix for AppIDs to run on with rootfses, which can be manually supplied or automatically. @@ -33,16 +30,16 @@ jobs: run: | sudo DEBIAN_FRONTEND=noninteractive apt update sudo DEBIAN_FRONTEND=noninteractive apt install -y jq - - uses: actions/checkout@v3 - - uses: actions/setup-go@v3 + - uses: actions/checkout@v6 + - uses: actions/setup-go@v6 with: - go-version: ${{ env.goversion }} + go-version-file: go.work - name: Build Matrix for AppIDs to run on with rootfses, which can be manually supplied or automatically id: build-matrix-release run: | set -eux # Manual build - if [ ${{ github.event_name }} = 'workflow_dispatch' ]; then + if [ "${{ github.event_name }}" = 'workflow_dispatch' ]; then appID="${{ github.event.inputs.appID }}" if [ -z "${appID}" ]; then appID="UbuntuPreview" @@ -65,7 +62,7 @@ jobs: wsl-builder/lp-distro-info > /tmp/all-releases.csv go build ./wsl-builder/prepare-build builds_config="$(./prepare-build build-github-matrix /tmp/all-releases.csv)" - if [ "${builds_config}" == "null" ]; then + if [ "${builds_config}" = "null" ]; then echo "No active application to build" exit 0 fi @@ -73,7 +70,7 @@ jobs: fi echo "${builds}" - echo "::set-output name=matrix::${builds}" + echo "matrix=${builds}" >> $GITHUB_OUTPUT echo "::notice::Building for: $(echo "${builds}" | jq '.include[] | "\(.AppID): \(.Rootfses). RootfsesChecksum: \(.RootfsesChecksum). Upload to store: \(.Upload)"')" build-wsl: @@ -102,9 +99,9 @@ jobs: run: | mkdir -p ${{ env.workDir }}/wiki/ git clone https://github.com/ubuntu/wsl.wiki ${{ env.workDir }}/wiki --depth 1 - - uses: actions/setup-go@v3 + - uses: actions/setup-go@v6 with: - go-version: ${{ env.goversion }} + go-version-file: ${{ env.workDir }}/go.work - name: Prepare project metadata, assets and download rootfses working-directory: ${{ env.workDir }} shell: bash @@ -113,7 +110,7 @@ jobs: # Download rootfses, checksum and place them at the correct place go build ./wsl-builder/prepare-build extraArgs="" - if [ ${{ matrix.RootfsesChecksum }} != "yes" ]; then + if [ "${{ matrix.RootfsesChecksum }}" != "yes" ]; then extraArgs="--no-checksum" fi archsBundle="$(./prepare-build prepare ${{ env.buildInfoPath }}/${{ matrix.AppID }}-buildid.md ${{ matrix.AppID }} ${{ matrix.Rootfses }} ${extraArgs})" @@ -123,7 +120,7 @@ jobs: buildMode="StoreUpload" echo "UapAppxPackageBuildMode=${buildMode}" >> $GITHUB_ENV - name: Setup MSBuild (PATH) - uses: microsoft/setup-msbuild@v1.0.2 + uses: microsoft/setup-msbuild@v3 - name: Install certificate shell: powershell working-directory: ${{ env.workDir }} @@ -145,7 +142,6 @@ jobs: set -eu # Launcher PDBs - for arch in "x64" "ARM64"; do collectTo="debug-database-${{ matrix.AppID }}/launcher/$arch/" mkdir -p "$collectTo" @@ -160,14 +156,14 @@ jobs: done - name: Allow downloading sideload appxbundle - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: sideload-${{ matrix.AppID }} path: | ${{ env.workDir }}/AppPackages/Ubuntu/Ubuntu_*/* retention-days: 7 - name: Allow downloading store appxupload - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: store-${{ matrix.AppID }} path: | @@ -189,8 +185,8 @@ jobs: build_id=$(cat "${{ env.buildInfoPath }}/${{ matrix.AppID }}-buildid.md") - echo "::set-output name=has-changes::false" - echo "::set-output name=should-upload::false" + echo "has-changes=false" >> $GITHUB_OUTPUT + echo "should-upload=false" >> $GITHUB_OUTPUT # Store md5sum of rootfs, launcher and assets related code fingerprint_file="${{ matrix.AppID }}-fingerprint.md" @@ -220,7 +216,7 @@ jobs: exit 0 fi - echo "::set-output name=has-changes::true" + echo "has-changes=true" >> $GITHUB_OUTPUT if [ ${{ matrix.Upload }} != "yes" ]; then echo "::notice::${{ matrix.AppID }} build ${build_id} ready for sideload or manual submission to the Microsoft Store" @@ -235,7 +231,7 @@ jobs: exit 0 fi echo "::notice::Uploading to the store ${{ matrix.AppID }} build ${build_id}" - echo "::set-output name=should-upload::true" + echo "should-upload=true" >> $GITHUB_OUTPUT echo "Uploading new version as some files have changed:" echo "${hasChanges}" @@ -308,7 +304,7 @@ jobs: mkdir -p build-info/ cp -a ${{ env.artifactsPath }}/build-artifacts-*/*.md build-info/ || exit 0 - echo "::set-output name=needs-wiki-update::true" + echo "needs-wiki-update=true" >> $GITHUB_OUTPUT # Pushing PDB's to the wiki only makes sense if we uploaded new app versions to the store. - name: Copy debug databases to base wiki @@ -322,7 +318,7 @@ jobs: find ${{ env.artifactsPath }} -name "debug-database-*" -maxdepth 1 -exec sh -c 'tar -cavf debug-databases/"$(basename $1)".tar.zst' sh '{}' \; || \ exit 0 - echo "::set-output name=needs-wiki-update::true" + echo "needs-wiki-update=true" >> $GITHUB_OUTPUT - name: Sync wiki to repository documentation if: ${{ steps.modified-artifacts.outputs.needs-wiki-update == 'true' }} @@ -341,17 +337,3 @@ jobs: git clone https://github.com/ubuntu/wsl.git ${{ env.codeDir }} --depth 1 mkdir -p ${{ env.codeDir }}/uat git clone https://git.launchpad.net/ubuntu-archive-tools ${{ env.codeDir }}/uat --depth 1 - - - name: Notify ISO Tracker - if: ${{ steps.modified-artifacts.outputs.needs-wiki-update == 'true' }} - env: - ISOTRACKER_USERNAME: ${{ secrets.ISOTRACKER_USERNAME }} - ISOTRACKER_PASSWORD: ${{ secrets.ISOTRACKER_PASSWORD }} - run: | - [ -f /tmp/all-releases.csv ] || ${{ env.codeDir }}/wsl-builder/lp-distro-info > /tmp/all-releases.csv - # There might have been more than one build in the latest commit - for build in $(git diff-tree --no-commit-id --name-only -r HEAD | grep buildid); do - AppID=$(basename $build); - AppID=${AppID%-buildid.md}; - PYTHONPATH=${{ env.codeDir }}/uat ${{ env.codeDir }}/wsl-builder/notify-isotracker --debug $AppID $GITHUB_RUN_ID - done diff --git a/.github/workflows/detect-update-releases.yaml b/.github/workflows/detect-update-releases.yaml index 3b67596c8..d052508df 100644 --- a/.github/workflows/detect-update-releases.yaml +++ b/.github/workflows/detect-update-releases.yaml @@ -11,15 +11,15 @@ on: - '.github/workflows/detect-update-releases.yaml' - 'wsl-builder/**' -env: - goversion: '1.21.4' - jobs: update-releases: name: Update and create metadata and assets for releases runs-on: ubuntu-latest container: image: ubuntu:rolling + permissions: + contents: write + pull-requests: write # To create PRs steps: - name: Install git and dependencies run: | @@ -28,10 +28,10 @@ jobs: apt install -y python3-launchpadlib libmagickwand-dev git pngquant fonts-ubuntu - name: work around permission issue with git vulnerability (we are local here). TO REMOVE run: git config --global --add safe.directory /__w/WSL/WSL - - uses: actions/checkout@v3 - - uses: actions/setup-go@v3 + - uses: actions/checkout@v6 + - uses: actions/setup-go@v6 with: - go-version: ${{ env.goversion }} + go-version-file: go.work - name: Fetch current available releases from launchpad run: | wsl-builder/lp-distro-info > /tmp/all-releases.csv @@ -47,14 +47,14 @@ jobs: - name: Get destination branch for branch name id: get-branch-name shell: bash - run: echo "::set-output name=branch::${GITHUB_REF#refs/heads/}" + run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT - name: Create Pull Request - uses: peter-evans/create-pull-request@v3 + uses: peter-evans/create-pull-request@v8 with: commit-message: Refreshes releases and assets title: Refresh releases and assets labels: automated pr - body: "[Auto-generated pull request](https://github.com/ubuntu/WSL/actions/workflows/detect-update-releases.yaml) by GitHub Action" + body: '[Auto-generated pull request](https://github.com/ubuntu/WSL/actions/workflows/detect-update-releases.yaml) by GitHub Action' branch: auto-update-releases-${{ steps.get-branch-name.outputs.branch }} token: ${{ secrets.GITHUB_TOKEN }} delete-branch: true diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index d5163700d..01597b237 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -4,41 +4,22 @@ on: pull_request: paths-ignore: - docs/** - - "*.md" -concurrency: azure-vm - -env: - az_name: wsl-ci - az_resource_group: wsl + - '*.md' jobs: - vm-setup: - runs-on: ubuntu-latest - steps: - - uses: azure/login@v1 - with: - creds: ${{ secrets.AZURE_VM_CREDS }} - - name: Start the Runner - shell: bash - run: | - az vm start --name ${{ env.az_name }} --resource-group ${{ env.az_resource_group }} - end-to-end-tests: - runs-on: self-hosted - needs: vm-setup + runs-on: windows-2025 env: rootFsCache: "${env:USERPROFILE}\\Downloads\\rootfs" # TODO: Move this to "Ubuntu" once we have backported everything and Ubuntu is transitionned to 24.04 - distroName: Ubuntu-24.04 - appID: Ubuntu24.04LTS - launcher: ubuntu2404.exe + distroName: Ubuntu + appID: Ubuntu + launcher: ubuntu.exe steps: - name: Checkout - uses: actions/checkout@v3 - with: - submodules: 'recursive' + uses: actions/checkout@v6 - name: Set up MSBuild (PATH) - uses: microsoft/setup-msbuild@v1.0.2 + uses: microsoft/setup-msbuild@v3 - name: Install certificate shell: powershell run: | @@ -50,14 +31,14 @@ jobs: Import-PfxCertificate -Password $pwd -CertStoreLocation Cert:LocalMachine\Trust -FilePath certificate\certificate.pfx Import-PfxCertificate -Password $pwd -CertStoreLocation Cert:CurrentUser\My -FilePath certificate\certificate.pfx - name: Set up Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v6 with: - go-version-file: ./e2e/go.work + go-version-file: go.work - name: Install or update WSL uses: ./.github/actions/wsl-install - name: Download rootfs uses: ./.github/actions/download-rootfs - with: + with: distros: ${{ env.distroName }} path: ${{ env.rootFsCache }} - name: Build and install the appxbundle for testing @@ -99,16 +80,3 @@ jobs: shell: powershell run: | Remove-AppxPackage "$(Get-AppxPackage | Where-Object PackageFullName -like *${{ env.appID }}*)" - - stop-vm: - runs-on: ubuntu-latest - needs: [vm-setup, end-to-end-tests] - if: always() - steps: - - uses: azure/login@v1 - with: - creds: ${{ secrets.AZURE_VM_CREDS }} - - name: Deallocate the Runner - shell: bash - run: | - az vm deallocate --name ${{ env.az_name }} --resource-group ${{ env.az_resource_group }} diff --git a/.github/workflows/wsl-example.yaml b/.github/workflows/wsl-example.yaml index 84bf38442..cc04c741c 100644 --- a/.github/workflows/wsl-example.yaml +++ b/.github/workflows/wsl-example.yaml @@ -4,7 +4,7 @@ concurrency: azure-vm on: pull_request: - paths: + paths: # We run it when changing one if its dependencies - .github/workflows/wsl-example.yaml - .github/actions/** @@ -12,28 +12,12 @@ on: branches: [main] workflow_dispatch: -env: - az_name: wsl-ci - az_resource_group: wsl - jobs: - vm-setup: - runs-on: ubuntu-latest - steps: - - uses: azure/login@v1 - with: - creds: ${{ secrets.AZURE_VM_CREDS }} - - name: Start the Runner - shell: bash - run: | - az vm start --name ${{ env.az_name }} --resource-group ${{ env.az_resource_group }} - run-script: - needs: vm-setup - runs-on: self-hosted + runs-on: windows-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v6 - name: Install or update WSL uses: ./.github/actions/wsl-install @@ -44,32 +28,19 @@ jobs: uses: ./.github/actions/wsl-checkout with: distro: Ubuntu - working-dir: "~/myrepo" + working-dir: '~/myrepo' # You'll probably use this action if you program runs entirely inside WSL - name: Run bash inside WSL uses: ./.github/actions/wsl-bash with: distro: Ubuntu - working-dir: "~/myrepo" + working-dir: '~/myrepo' exec: | echo "Hello from $(lsb_release -ds)" - name: Run powershell on Windows shell: powershell env: - WSL_UTF8: "1" # Recommended otherwise it's hard to read on Github + WSL_UTF8: '1' # Recommended otherwise it's hard to read on Github run: wsl --list --verbose - - stop-vm: - runs-on: ubuntu-latest - needs: [vm-setup, run-script] - if: always() - steps: - - uses: azure/login@v1 - with: - creds: ${{ secrets.AZURE_VM_CREDS }} - - name: Deallocate the Runner - shell: bash - run: | - az vm deallocate --name ${{ env.az_name }} --resource-group ${{ env.az_resource_group }} \ No newline at end of file diff --git a/DistroLauncher-Appx/DistroLauncher-Appx.vcxproj b/DistroLauncher-Appx/DistroLauncher-Appx.vcxproj index 7e75a0d7e..c97b24a92 100644 --- a/DistroLauncher-Appx/DistroLauncher-Appx.vcxproj +++ b/DistroLauncher-Appx/DistroLauncher-Appx.vcxproj @@ -7,7 +7,7 @@ 14.0 true Windows Store - 10.0.22000.0 + 10.0.26100.0 10.0.16299.0 10.0 UbuntuDev.LauncherName.Dev diff --git a/DistroLauncher/DistroLauncher.vcxproj b/DistroLauncher/DistroLauncher.vcxproj index 616ff9bc6..bce10de64 100644 --- a/DistroLauncher/DistroLauncher.vcxproj +++ b/DistroLauncher/DistroLauncher.vcxproj @@ -22,7 +22,7 @@ {BA627106-E5F7-46EE-B8D7-2D5A760F2FB2} Win32Proj DistroLauncher - 10.0.22000.0 + 10.0.26100.0 launcher diff --git a/e2e/launchertester/go.mod b/e2e/go.mod similarity index 76% rename from e2e/launchertester/go.mod rename to e2e/go.mod index a7c505454..795a67223 100644 --- a/e2e/launchertester/go.mod +++ b/e2e/go.mod @@ -1,19 +1,20 @@ -module github.com/ubuntu/wsl/e2e/launchertester +module github.com/ubuntu/wsl/e2e go 1.23.0 require ( github.com/stretchr/testify v1.9.0 + github.com/ubuntu/gowsl v0.0.0-20240621022151-0ca2385d9153 gopkg.in/ini.v1 v1.67.0 ) require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/google/uuid v1.6.0 // indirect + github.com/kr/text v0.2.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/sirupsen/logrus v1.9.0 // indirect github.com/ubuntu/decorate v0.0.0-20230125165522-2d5b0a9bb117 // indirect - github.com/ubuntu/gowsl v0.0.0-20240621022151-0ca2385d9153 // indirect golang.org/x/sys v0.20.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/e2e/launchertester/go.sum b/e2e/go.sum similarity index 71% rename from e2e/launchertester/go.sum rename to e2e/go.sum index c8af9cdc1..9dfd6fc45 100644 --- a/e2e/launchertester/go.sum +++ b/e2e/go.sum @@ -1,20 +1,24 @@ +github.com/0xrawsec/golang-utils v1.3.2 h1:ww4jrtHRSnX9xrGzJYbalx5nXoZewy4zPxiY+ubJgtg= +github.com/0xrawsec/golang-utils v1.3.2/go.mod h1:m7AzHXgdSAkFCD9tWWsApxNVxMlyy7anpPVOyT/yM7E= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/ubuntu/decorate v0.0.0-20230125165522-2d5b0a9bb117 h1:XQpsQG5lqRJlx4mUVHcJvyyc1rdTI9nHvwrdfcuy8aM= github.com/ubuntu/decorate v0.0.0-20230125165522-2d5b0a9bb117/go.mod h1:mx0TjbqsaDD9DUT5gA1s3hw47U6RIbbIBfvGzR85K0g= @@ -23,9 +27,9 @@ github.com/ubuntu/gowsl v0.0.0-20240621022151-0ca2385d9153/go.mod h1:t74qqYMKvTn golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/e2e/go.work b/e2e/go.work deleted file mode 100644 index 729350fd2..000000000 --- a/e2e/go.work +++ /dev/null @@ -1,5 +0,0 @@ -go 1.23.0 - -toolchain go1.23.2 - -use ./launchertester diff --git a/e2e/go.work.sum b/e2e/go.work.sum deleted file mode 100644 index 594145dc9..000000000 --- a/e2e/go.work.sum +++ /dev/null @@ -1,6 +0,0 @@ -github.com/0xrawsec/golang-utils v1.3.2/go.mod h1:m7AzHXgdSAkFCD9tWWsApxNVxMlyy7anpPVOyT/yM7E= -github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= -github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= -github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/e2e/launchertester/basic_setup_test.go b/e2e/launchertester/basic_setup_test.go index 819ff2174..53ee16167 100644 --- a/e2e/launchertester/basic_setup_test.go +++ b/e2e/launchertester/basic_setup_test.go @@ -43,6 +43,9 @@ func TestBasicSetup(t *testing.T) { // TestSetupWithCloudInit runs a battery of assertions after installing with the distro launcher and cloud-init. func TestSetupWithCloudInit(t *testing.T) { + // TODO: Re-enable those tests after further investigation of what assumptions no longer + // hold, see UDENG-10742. + t.Skip("Broken tests, need further investigation of what assumptiosn no longer hold") testCases := map[string]struct { install_root bool withRegistryUser string diff --git a/e2e/launchertester/test_cases.go b/e2e/launchertester/test_cases.go index f65dd58dd..aafa853b4 100644 --- a/e2e/launchertester/test_cases.go +++ b/e2e/launchertester/test_cases.go @@ -4,13 +4,14 @@ import ( "bufio" "bytes" "context" + "os" "os/exec" + "path/filepath" "regexp" "strings" "testing" "time" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "gopkg.in/ini.v1" ) @@ -58,19 +59,6 @@ func testSystemdUnits(t *testing.T) { //nolint: thelper, this is a test // Terminating to start systemd, and to ensure no services from previous tests are running terminateDistro(t) - distroNameToFailedUnits := map[string][]string{ - "Ubuntu-18.04": {"user@0.service", "atd.service"}, - "Ubuntu-20.04": {"user@0.service", "atd.service"}, - "Ubuntu-22.04": {"user@0.service"}, - "Ubuntu": {"user@0.service"}, - "Ubuntu-Preview": {"user@0.service"}, - } - - expectedFailure, ok := distroNameToFailedUnits[*distroName] - if !ok { // Development version - expectedFailure = distroNameToFailedUnits["Ubuntu-Preview"] - } - ctx, cancel := context.WithTimeout(context.Background(), systemdBootTimeout) defer cancel() @@ -81,18 +69,23 @@ func testSystemdUnits(t *testing.T) { //nolint: thelper, this is a test s := bufio.NewScanner(bytes.NewReader(out)) var failedUnits []string for s.Scan() { + text := s.Text() + if strings.HasPrefix(text, "Failed to start the systemd user session for 'root'") { + // Kinda expected, though we need to investigate it further. + continue + } data := strings.Fields(s.Text()) if len(data) == 0 { continue } unit := strings.TrimSpace(data[0]) + if unit == "user@0.service" { + continue // Ditto. + } failedUnits = append(failedUnits, unit) } require.NoError(t, s.Err(), "Error scanning output of systemctl") - - for _, u := range failedUnits { - assert.Contains(t, expectedFailure, u, "Unexpected failing unit") - } + require.Emptyf(t, failedUnits, "There are failed systemd units: %v\n. systemctl output was:\n%s", failedUnits, out) } // testCorrectUpgradePolicy ensures upgrade policy matches the one expected for the app. @@ -133,8 +126,11 @@ func testUpgradePolicyIdempotent(t *testing.T) { //nolint: thelper, this is a te ctx, cancel := context.WithTimeout(context.Background(), systemdBootTimeout) defer cancel() - wantsDate, err := launcherCommand(ctx, "run", "date", "-r", "/etc/update-manager/release-upgrades").CombinedOutput() - require.NoError(t, err, "Failed to execute date: %s", wantsDate) + path := filepath.Join(`\\wsl.localhost\`, *distroName, `etc\update-manager\release-upgrades`) + wantsInfo, err := os.Stat(path) + + require.NoError(t, err, "Failed to stat release-upgrades file: %s", err) + wantsDate := wantsInfo.ModTime() terminateDistro(t) @@ -143,10 +139,14 @@ func testUpgradePolicyIdempotent(t *testing.T) { //nolint: thelper, this is a te ctx, cancel = context.WithTimeout(context.Background(), systemdBootTimeout) defer cancel() - gotDate, err := launcherCommand(ctx, "run", "date", "-r", "/etc/update-manager/release-upgrades").CombinedOutput() - require.NoError(t, err, "Failed to execute date: %s", gotDate) + _, err = launcherCommand(ctx, "run", "exit", "0").CombinedOutput() + require.NoError(t, err, "Failed to execute the distro launcher: %s", err) + gotInfo, err := os.Stat(path) + + require.NoError(t, err, "Failed to stat release-upgrades file the second time: %s", err) + gotDate := gotInfo.ModTime() - require.Equal(t, string(wantsDate), string(gotDate), "Launcher is modifying release upgrade every boot") + require.Equal(t, wantsDate, gotDate, "Launcher is modifying release upgrade every boot") } // testInteropIsEnabled ensures interop works fine. @@ -195,9 +195,7 @@ func testHelpFlag(t *testing.T) { } func testFileExists(t *testing.T, linuxPath string) { - ctx, cancel := context.WithTimeout(context.Background(), systemdBootTimeout) - defer cancel() - - out, err := launcherCommand(ctx, "run", "test", "-e", linuxPath).CombinedOutput() - require.NoError(t, err, "Unexpected error checking file existence: %s", out) + stat, err := os.Stat(filepath.Join(`\\wsl.localhost\`, *distroName, linuxPath)) + require.NoError(t, err, "Unexpected error checking file existence: %s", err) + require.True(t, stat.Mode().IsRegular(), "Expected %s to be a regular file", linuxPath) } diff --git a/e2e/launchertester/test_utils.go b/e2e/launchertester/test_utils.go index 6657b1cd1..cb7aed4af 100644 --- a/e2e/launchertester/test_utils.go +++ b/e2e/launchertester/test_utils.go @@ -86,8 +86,8 @@ func distroState(t *testing.T) string { // We use $env:WSL_UTF8=1 to prevent this (Available from 0.64.0 onwards https://github.com/microsoft/WSL/releases/tag/0.64.0) out, err := exec.Command("powershell.exe", "-noninteractive", "-nologo", "-noprofile", "-command", "$env:WSL_UTF8=1 ; wsl -l -v").CombinedOutput() if err != nil { - // This error shows up when there is no distro installed - require.Containsf(t, string(out), "WSL_E_DEFAULT_DISTRO_NOT_FOUND", "Unexpected error calling 'wsl -l -v'. Error: %v\nOutput: %s", err, out) + // A hint for this command is shown when there is no distro instance registered. + require.Containsf(t, string(out), "wsl.exe --list --online", "Unexpected error calling 'wsl -l -v'. Error: %v\nOutput: %s", err, out) return distroNotFoundMsg } diff --git a/go.mod b/go.mod deleted file mode 100644 index fdde9bd4f..000000000 --- a/go.mod +++ /dev/null @@ -1,3 +0,0 @@ -module launchertester - -go 1.21.4 diff --git a/go.work b/go.work index 21b4ca3b1..eb9d3eae9 100644 --- a/go.work +++ b/go.work @@ -1,6 +1,7 @@ -go 1.21.4 +go 1.23.0 use ( + ./e2e ./wsl-builder/common ./wsl-builder/prepare-assets ./wsl-builder/prepare-build diff --git a/go.work.sum b/go.work.sum index d3edfb8e2..1de89af18 100644 --- a/go.work.sum +++ b/go.work.sum @@ -1,4 +1,5 @@ github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136 h1:A1gGSx58LAGVHUUsOf7IiR0u8Xb6W51gRwfDBhkdcaw= golang.org/x/mod v0.6.0/go.mod h1:4mET923SAdbXp2ki8ey+zGs1SLqsuM2Y0uvdZR/fUNI= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/wsl-builder/common/go.mod b/wsl-builder/common/go.mod index 265e44389..e8f894b18 100644 --- a/wsl-builder/common/go.mod +++ b/wsl-builder/common/go.mod @@ -3,6 +3,6 @@ module github.com/ubuntu/wsl/wsl-builder/common go 1.16 require ( - github.com/google/uuid v1.3.0 + github.com/google/uuid v1.6.0 golang.org/x/text v0.3.7 ) diff --git a/wsl-builder/common/go.sum b/wsl-builder/common/go.sum index 11563180e..d3c9aae8a 100644 --- a/wsl-builder/common/go.sum +++ b/wsl-builder/common/go.sum @@ -1,5 +1,5 @@ -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= diff --git a/wsl-builder/common/releasesinfo.go b/wsl-builder/common/releasesinfo.go index 50eeef2ef..275f52ca5 100644 --- a/wsl-builder/common/releasesinfo.go +++ b/wsl-builder/common/releasesinfo.go @@ -27,6 +27,7 @@ type WslReleaseInfo struct { LauncherName string // name of the executable WSL launcher. ShortVersion string // Ubuntu version without point release and LTS. For instance 20.04 -> 20.04. 20.04.5 -> 20.04 IconVersion string // If used in the assets, version to show in some icon without point release. 20.04 -> 20.04 LTS. 20.04.5 -> 20.04 LTS + PointRelease int // The point/minor release number. For instance, for 20.04.5, the point release is 5. ReleaseVersion string // Full version name, without the Application in front. For instance, 20.04.5 LTS. TerminalProfileGUID string // GUID for the Terminal profile used to update autogenerated profiles. ReservedNames []string // list of reserved names in the store ("Ubuntu 20.04 LTS" for instance. One should match the UWP package name) @@ -69,7 +70,7 @@ func buildWSLReleaseInfo(releases [][]string) (wslReleases []WslReleaseInfo, err // There is always a development release, LTS or not if isDevelopmentRelease { wsl, err := newWslReleaseInfo("Ubuntu-Preview", "UbuntuPreview", "Ubuntu (Preview)", buildVersion, "ubuntupreview", - release[0], release[0], "Preview", codeName, []string{"Ubuntu (Preview)"}, true) + release[0], release[0], minor, "Preview", codeName, []string{"Ubuntu (Preview)"}, true) if err != nil { return nil, err } @@ -117,7 +118,7 @@ func buildWSLReleaseInfo(releases [][]string) (wslReleases []WslReleaseInfo, err // Add per-release application wsl, err := newWslReleaseInfo(wslID, appID, fmt.Sprintf("Ubuntu %s LTS", version), buildVersion, launcherName, - release[0], fmt.Sprintf("%s LTS", release[0]), fmt.Sprintf("%s LTS", version), codeName, reservedNames, shouldBuild) + release[0], fmt.Sprintf("%s LTS", release[0]), minor, fmt.Sprintf("%s LTS", version), codeName, reservedNames, shouldBuild) if err != nil { return nil, err } @@ -190,7 +191,7 @@ func withinThreeWeeksOf(date time.Time) bool { } // newWslReleaseInfo creates a new WSL release info from parameters and computes the terminal profile GUID. -func newWslReleaseInfo(wslID, appID, fullName, buildVersion, launcherName, shortVersion, iconVersion, releaseVersion, codeName string, reservedNames []string, shouldBuild bool) (WslReleaseInfo, error) { +func newWslReleaseInfo(wslID, appID, fullName, buildVersion, launcherName, shortVersion, iconVersion string, minor int, releaseVersion, codeName string, reservedNames []string, shouldBuild bool) (WslReleaseInfo, error) { w := WslReleaseInfo{ WslID: wslID, AppID: appID, @@ -199,6 +200,7 @@ func newWslReleaseInfo(wslID, appID, fullName, buildVersion, launcherName, short LauncherName: launcherName, ShortVersion: shortVersion, IconVersion: iconVersion, + PointRelease: minor, ReleaseVersion: releaseVersion, ReservedNames: reservedNames, @@ -234,25 +236,27 @@ func (w *WslReleaseInfo) refreshedTerminalProfileID() error { } // RootfsURL returns the URL to the rootfs tarball for the given architecture. -// The base image name is in the format: -// ubuntu--wsl--.rootfs.tar.gz -// before 22.04, upgrade-type is always "wsl" -// otherwise: -// - ubuntu -> wsl (upgrade: lts) -// - ubuntupreview -> preview (upgrade: always) -// - ubuntu24.04lts -> ubuntu24.04lts (upgrade: never) +// The base image name is in the format: ubuntu--wsl-.wsl +// Supported releases are 20.04 and later available at per-architecture URLS: +// ARM64 releases are available at https://cdimage.ubuntu.com/releases//release/ubuntu--wsl-arm64.wsl +// AMD64 releases are available at https://releases.ubuntu.com//ubuntu--wsl-amd64.wsl +// No other architectures are supported. func (w *WslReleaseInfo) RootfsURL(arch string) string { - imageBaseName := fmt.Sprintf("ubuntu-%s-wsl-%s", w.CodeName, arch) - - suffix := "wsl" - // We have multiple versions with different upgrade policy management. Pick the one based on the app name. - if strings.Compare(w.BuildVersion, "2204") >= 0 { - suffix = strings.ToLower(w.AppID) - if suffix == "" { - suffix = "wsl" + // We want daily images instead of those already published. + if w.ShouldBuild { + if w.PointRelease > 0 { // Already released + return fmt.Sprintf("https://cdimages.ubuntu.com/ubuntu-wsl/%s/daily-live/current/%s-wsl-%s.wsl", w.CodeName, w.CodeName, arch) } + return fmt.Sprintf("https://cdimages.ubuntu.com/ubuntu-wsl/daily-live/current/ubuntu-wsl-%s-%s.wsl", w.CodeName, arch) + } + // Release version without the potential LTS suffix: + version := strings.TrimSuffix(w.ReleaseVersion, " LTS") + switch arch { + case "amd64", "x86_64": + return fmt.Sprintf("https://releases.ubuntu.com/%s/ubuntu-%s-wsl-amd64.wsl", w.CodeName, version) + case "arm64", "aarch64": + return fmt.Sprintf("https://cdimage.ubuntu.com/releases/%s/release/ubuntu-%s-wsl-arm64.wsl", w.CodeName, version) + default: + return "" } - imageName := fmt.Sprintf("%s-%s.rootfs.tar.gz", imageBaseName, suffix) - - return fmt.Sprintf("https://cloud-images.ubuntu.com/wsl/%s/current/%s", w.CodeName, imageName) } diff --git a/wsl-builder/prepare-assets/assets.go b/wsl-builder/prepare-assets/assets.go index 6217d9a52..084cc0e0c 100644 --- a/wsl-builder/prepare-assets/assets.go +++ b/wsl-builder/prepare-assets/assets.go @@ -7,7 +7,6 @@ import ( "image" _ "image/png" "io/fs" - "io/ioutil" "os" "os/exec" "path/filepath" @@ -17,7 +16,7 @@ import ( shutil "github.com/termie/go-shutil" "github.com/ubuntu/wsl/wsl-builder/common" - "gopkg.in/gographics/imagick.v2/imagick" + "gopkg.in/gographics/imagick.v3/imagick" ) const ( @@ -68,7 +67,7 @@ func updateAssets(csvPath string) error { generatedPath := filepath.Join(wslPath, common.GeneratedDir) // Cleanup previous generated directory - if err := os.RemoveAll(generatedPath); err != nil { + if err = os.RemoveAll(generatedPath); err != nil { return err } @@ -85,7 +84,7 @@ func updateAssets(csvPath string) error { } // And now, generate the application meta from xml template - if err := generateMetaForRelease(r, refFiles, rootPath, generatedPath); err != nil { + if err := generateMetaForRelease(r, refFiles, generatedPath); err != nil { return err } @@ -163,7 +162,7 @@ func listFilesForMeta(existing map[string]string, refPath string, blacklist []st } // generateMetaForRelease updates all templated non img files for a given release. -func generateMetaForRelease(r common.WslReleaseInfo, files map[string]string, rootPath, generatedPath string) (err error) { +func generateMetaForRelease(r common.WslReleaseInfo, files map[string]string, generatedPath string) (err error) { defer func() { if err != nil { err = fmt.Errorf("can't generate metadata file for %s: %v", r.AppID, err) @@ -187,7 +186,7 @@ func generateMetaForRelease(r common.WslReleaseInfo, files map[string]string, ro } dest := filepath.Join(generatedPath, relPath) - if err := os.MkdirAll(filepath.Dir(dest), 0755); err != nil { + if err = os.MkdirAll(filepath.Dir(dest), 0755); err != nil { return err } @@ -203,7 +202,7 @@ func generateMetaForRelease(r common.WslReleaseInfo, files map[string]string, ro // Not a template or file we will replace later: direct copy if !strings.Contains(templateData, textualStartTag) || filepath.Base(dest) == "ProductDescription.xml" { - if err := shutil.CopyFile(src, dest, false); err != nil { + if err = shutil.CopyFile(src, dest, false); err != nil { return err } continue @@ -215,7 +214,7 @@ func generateMetaForRelease(r common.WslReleaseInfo, files map[string]string, ro if err != nil { return nil } - defer f.Close() + defer func() { _ = f.Close() }() if err := t.Execute(f, r); err != nil { return err } @@ -254,7 +253,7 @@ func generateMetaForRelease(r common.WslReleaseInfo, files map[string]string, ro if err != nil { return nil } - defer f.Close() + defer func() { _ = f.Close() }() return t.Execute(f, rWithScreenshots) }) @@ -281,7 +280,7 @@ func listAndSortImagesIn(path string) ([]string, error) { } // generateImages creates .png and icons using templated svg. -func generateImages(r common.WslReleaseInfo, templates map[string]string, rootPath, generatedPath string) (err error) { +func generateImages(r common.WslReleaseInfo, templates map[string]string, rootPath, generatedPath string) error { // Iterates and generates over generated assets as a reference // A. Store and application images @@ -290,19 +289,19 @@ func generateImages(r common.WslReleaseInfo, templates map[string]string, rootPa return err } assetsRefPath := filepath.Join(rootPath, relDir) - images, err := ioutil.ReadDir(assetsRefPath) + images, err := os.ReadDir(assetsRefPath) if err != nil { return err } mwTemplates := make(map[string]*imagick.MagickWand) for _, f := range images { - // 1. Load size of the ressource image + // 1. Load size of the resource image refF, err := os.Open(filepath.Join(assetsRefPath, f.Name())) if err != nil { return err } - defer refF.Close() + defer func() { _ = refF.Close() }() ref, _, err := image.DecodeConfig(refF) if err != nil { @@ -333,7 +332,7 @@ func generateImages(r common.WslReleaseInfo, templates map[string]string, rootPa } t := template.Must(template.New("").Parse(string(templateData))) var templateBuf bytes.Buffer - if err := t.Execute(&templateBuf, r); err != nil { + if err = t.Execute(&templateBuf, r); err != nil { return err } @@ -345,10 +344,10 @@ func generateImages(r common.WslReleaseInfo, templates map[string]string, rootPa pw.SetColor("none") mw = imagick.NewMagickWand() defer mw.Destroy() - if err := mw.SetBackgroundColor(pw); err != nil { + if err = mw.SetBackgroundColor(pw); err != nil { return err } - if err := mw.ReadImageBlob(templateBuf.Bytes()); err != nil { + if err = mw.ReadImageBlob(templateBuf.Bytes()); err != nil { return err } mwTemplates[templateName] = mw @@ -357,27 +356,30 @@ func generateImages(r common.WslReleaseInfo, templates map[string]string, rootPa defer mw.Destroy() // There is a limitation of 200K to the image size uploaded to the store. All source images are 8 bits. - if err := mw.SetImageDepth(8); err != nil { + if err = mw.SetImageDepth(8); err != nil { return err } - if err := mw.SetImageFormat(strings.TrimPrefix(filepath.Ext(f.Name()), ".")); err != nil { + if err = mw.SetImageFormat(strings.TrimPrefix(filepath.Ext(f.Name()), ".")); err != nil { return err } - if err := mw.ResizeImage(uint(ref.Width), uint(ref.Height), imagick.FILTER_LANCZOS, 1); err != nil { + if err = mw.ResizeImage(uint(ref.Width), uint(ref.Height), imagick.FILTER_LANCZOS); err != nil { return err } - if err := mw.StripImage(); err != nil { + if err = mw.StripImage(); err != nil { return err } // Crush the image size for png files - var img = mw.GetImageBlob() + img, err := mw.GetImageBlob() + if err != nil { + return err + } if filepath.Ext(f.Name()) == ".png" { cmd := exec.Command("pngquant", "-") var out bytes.Buffer cmd.Stdin = bytes.NewBuffer(img) cmd.Stdout = &out - err := cmd.Run() + err = cmd.Run() if err != nil { return err } @@ -385,49 +387,49 @@ func generateImages(r common.WslReleaseInfo, templates map[string]string, rootPa } assetsDest := filepath.Join(generatedPath, relDir, f.Name()) - if err := os.MkdirAll(filepath.Dir(assetsDest), 0755); err != nil { + if err = os.MkdirAll(filepath.Dir(assetsDest), 0755); err != nil { return err } f, err := os.Create(assetsDest) if err != nil { return err } - defer f.Close() + defer func() { _ = f.Close() }() if _, err := f.Write(img); err != nil { return err } - f.Close() + _ = f.Close() } // B. Icon files iconRelPath := filepath.Join("DistroLauncher", "images", "icon.svg") - if err := os.MkdirAll(filepath.Join(generatedPath, filepath.Dir(iconRelPath)), 0755); err != nil { + if err = os.MkdirAll(filepath.Join(generatedPath, filepath.Dir(iconRelPath)), 0755); err != nil { return err } tmpDir, err := os.MkdirTemp("", "update-releases-*") if err != nil { return err } - defer os.RemoveAll(tmpDir) + defer func() { _ = os.RemoveAll(tmpDir) }() src := filepath.Join(tmpDir, "icon.svg") srcF, err := os.Create(src) if err != nil { return err } - defer srcF.Close() + defer func() { _ = srcF.Close() }() templateData, err := os.ReadFile(templates[iconRelPath]) if err != nil { return err } t := template.Must(template.New("").Parse(string(templateData))) - if err := t.Execute(srcF, r); err != nil { + if err = t.Execute(srcF, r); err != nil { return err } - srcF.Close() + _ = srcF.Close() dest := filepath.Join(generatedPath, strings.ReplaceAll(iconRelPath, ".svg", ".ico")) - if err := os.MkdirAll(filepath.Dir(dest), 0755); err != nil { + if err = os.MkdirAll(filepath.Dir(dest), 0755); err != nil { return err } diff --git a/wsl-builder/prepare-assets/go.mod b/wsl-builder/prepare-assets/go.mod index f5467840a..a36811979 100644 --- a/wsl-builder/prepare-assets/go.mod +++ b/wsl-builder/prepare-assets/go.mod @@ -1,16 +1,16 @@ module github.com/ubuntu/wsl/wsl-builder/prepare-assets -go 1.21.4 +go 1.22 require ( github.com/spf13/cobra v1.1.3 github.com/termie/go-shutil v0.0.0-20140729215957-bcacb06fecae github.com/ubuntu/wsl/wsl-builder/common v0.0.0-20220324102537-8d5048ba3748 - gopkg.in/gographics/imagick.v2 v2.6.0 + gopkg.in/gographics/imagick.v3 v3.7.3 ) require ( - github.com/google/uuid v1.3.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect github.com/spf13/pflag v1.0.5 // indirect golang.org/x/text v0.3.7 // indirect diff --git a/wsl-builder/prepare-assets/go.sum b/wsl-builder/prepare-assets/go.sum index b43944ae2..033f72b6d 100644 --- a/wsl-builder/prepare-assets/go.sum +++ b/wsl-builder/prepare-assets/go.sum @@ -61,8 +61,9 @@ github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXi github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= @@ -281,8 +282,8 @@ gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLks gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/gographics/imagick.v2 v2.6.0 h1:ewRsUQk3QkjGumERlndbFn/kTYRjyMaPY5gxwpuAhik= -gopkg.in/gographics/imagick.v2 v2.6.0/go.mod h1:/QVPLV/iKdNttRKthmDkeeGg+vdHurVEPc8zkU0XgBk= +gopkg.in/gographics/imagick.v3 v3.7.3 h1:Hy2MbJKLJ/9T3ZuV1zwBOy09O9prf2MCCVpM7bcZdpY= +gopkg.in/gographics/imagick.v3 v3.7.3/go.mod h1:7I4S9VWdwr88yzYi7g+ZL4H8oZuH9cmSQI7GsZCcYFM= gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= diff --git a/wsl-builder/prepare-build/go.mod b/wsl-builder/prepare-build/go.mod index 7b990f6cd..0e17bba49 100644 --- a/wsl-builder/prepare-build/go.mod +++ b/wsl-builder/prepare-build/go.mod @@ -8,3 +8,10 @@ require ( github.com/ubuntu/wsl/wsl-builder/common v0.0.0-20220324102537-8d5048ba3748 golang.org/x/sync v0.0.0-20210220032951-036812b2e83c ) + +require ( + github.com/google/uuid v1.6.0 // indirect + github.com/inconshreveable/mousetrap v1.0.0 // indirect + github.com/spf13/pflag v1.0.5 // indirect + golang.org/x/text v0.3.7 // indirect +) diff --git a/wsl-builder/prepare-build/go.sum b/wsl-builder/prepare-build/go.sum index 81b7d99f3..ba7a685c3 100644 --- a/wsl-builder/prepare-build/go.sum +++ b/wsl-builder/prepare-build/go.sum @@ -61,8 +61,9 @@ github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXi github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= diff --git a/wsl-builder/release-info/go.mod b/wsl-builder/release-info/go.mod index 4e2bfc52b..f18de5abc 100644 --- a/wsl-builder/release-info/go.mod +++ b/wsl-builder/release-info/go.mod @@ -10,7 +10,7 @@ require ( ) require ( - github.com/google/uuid v1.3.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect github.com/spf13/pflag v1.0.5 // indirect golang.org/x/text v0.3.7 // indirect diff --git a/wsl-builder/release-info/go.sum b/wsl-builder/release-info/go.sum index 4af82bdca..e67accac5 100644 --- a/wsl-builder/release-info/go.sum +++ b/wsl-builder/release-info/go.sum @@ -63,8 +63,9 @@ github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXi github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= diff --git a/wsl-builder/release-info/main.go b/wsl-builder/release-info/main.go index c938273ab..236e31a43 100644 --- a/wsl-builder/release-info/main.go +++ b/wsl-builder/release-info/main.go @@ -24,7 +24,7 @@ Fields are always in the same order, regardless of the order the flags are passe }, } - f.appId = rootCmd.Flags().Bool("app-id", false, "Display the App ID as shown in the store.") + f.appID = rootCmd.Flags().Bool("app-id", false, "Display the App ID as shown in the store.") f.fullName = rootCmd.Flags().Bool("full-name", false, "Display the App FullName as shown in your machine.") f.launcher = rootCmd.Flags().Bool("launcher", false, "Display the launcher executable name.") f.codeName = rootCmd.Flags().Bool("code-name", false, "Display the code name, i.e. the distro's adjective.") diff --git a/wsl-builder/release-info/release-info.go b/wsl-builder/release-info/release-info.go index f0539f7b2..fd2a14612 100644 --- a/wsl-builder/release-info/release-info.go +++ b/wsl-builder/release-info/release-info.go @@ -14,7 +14,7 @@ import ( type columns struct { rootfsArch *string - appId, fullName, launcher, codeName, short *bool + appID, fullName, launcher, codeName, short *bool } func writeReleaseInfo(csvPath string, distros []string, cols columns) error { @@ -51,7 +51,7 @@ func writeHeader(w io.Writer, f columns) error { text := []string{} text = append(text, "WslID") - if *f.appId { + if *f.appID { text = append(text, "AppID") } if *f.fullName { @@ -76,7 +76,7 @@ func writeHeader(w io.Writer, f columns) error { func writeRow(w io.Writer, r common.WslReleaseInfo, f columns) error { var text []string text = append(text, r.WslID) - if *f.appId { + if *f.appID { text = append(text, r.AppID) } if *f.fullName { @@ -123,7 +123,7 @@ func selectReleases(csvPath string, targets []string) (releases []common.WslRele } if end < len(targets) { - end := partition(targets, func(t string) bool { return len(t) != 0 }) + end = partition(targets, func(t string) bool { return len(t) != 0 }) return nil, fmt.Errorf("the following releases were not found: %s", strings.Join(targets[:end], ", ")) } return releases[:end], nil