diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1116f90..27e3ec7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,6 +31,7 @@ jobs: with: platform: ${{ matrix.platform }} packages: ${{ matrix.packages }} + add-to-path: false - name: Explicitly running shell run: C:\cygwin\bin\bash -lc "echo 'Explicitly run shell'" @@ -52,6 +53,21 @@ jobs: run: C:\cygwin\bin\sponge.exe tmp if: contains(matrix.packages, 'moreutils') + - name: Check PATH hasn't changed + run: | + if [[ "${OSTYPE}" = "cygwin" ]]; then + echo "unexpectedly using Cygwin Bash" + exit 1 + fi + + if [[ "$(cygpath -aw "$(which cygpath)")" = 'C:\cygwin\'* ]]; then + echo "unexpectedly using Cygwin cygpath" + exit 1 + fi + shell: bash # If Cygwin is not in PATH -- as expected -- this will be Git Bash + env: + SHELLOPTS: igncr + complex-test: runs-on: windows-latest name: 'Complex Test' @@ -212,3 +228,32 @@ jobs: shell: bash env: SHELLOPTS: igncr + + multiple-sites-and-pubkeys: + runs-on: windows-latest + strategy: + fail-fast: false + + name: 'Test multiple sites and extra pubkeys' + + steps: + - run: git config --global core.autocrlf input + + - uses: actions/checkout@v2 + + - name: Run repo HTTP server + uses: Eun/http-server-action@v1.0.6 + with: + directory: ${{ github.workspace }}\tests\repo + + - name: Install Cygwin + uses: ./ + with: + site: | + http://localhost:8080 + http://mirrors.kernel.org/sourceware/cygwin/ + packages: cygwin-install-action-test + pubkeys: ${{ github.workspace }}\tests\repo\key.pub + + - name: Run test shell script + run: C:\cygwin\bin\bash.exe /cygwin-install-action-test.sh diff --git a/README.md b/README.md index 2a9a8d8..1ef161c 100644 --- a/README.md +++ b/README.md @@ -23,8 +23,10 @@ Parameters | platform | x86_64 | Install the x86 or x86\_64 version of Cygwin. | packages | *none* | List of additional packages to install. | install-dir | C:\cygwin | Installation directory -| site | http://mirrors.kernel.org/sourceware/cygwin/ | Mirror site to install from +| site | http://mirrors.kernel.org/sourceware/cygwin/ | Mirror sites to install from, separated by whitespace +| pubkeys | *none* | Absolute paths of extra public key files (RFC4880 format), separated by whitespace | check-sig | true | Whether to check the setup.ini signature +| add-to-path | true | Whether to add Cygwin's `/bin` directory to the system `PATH` Line endings ------------ @@ -52,7 +54,7 @@ Alternatively, you can also use: PATH ---- -This action prepends Cygwin's /usr/bin directory to the PATH. +By default, this action prepends Cygwin's /usr/bin directory to the PATH. However, if you want to ensure that PATH only contains Cygwin executables, and other stuff installed in the VM image isn't going to get picked up: @@ -69,6 +71,8 @@ or, * prevent the profile script from changing directory by putting `CHERE_INVOKING` into the environment +If you want the opposite – the system PATH to remain unchanged by this action – add `add-to-path: false` to the action settings. + Symlinks -------- diff --git a/action.yml b/action.yml index c039af1..463d273 100644 --- a/action.yml +++ b/action.yml @@ -19,9 +19,16 @@ inputs: description: Should the setup.ini file signature be checked? required: false default: true + pubkeys: + description: Absolute paths of extra public key files (RFC4880 format), separated by whitespace + required: false site: - description: Download site URL + description: Download site URLs separated by whitespace + required: false + add-to-path: + description: Should Cygwin's bin directory be added to the system PATH? required: false + default: true runs: using: "composite" @@ -42,24 +49,27 @@ runs: $pkg_list = $pkg_list | % { $_.Trim() } $pkg_list = $pkg_list | % { $_.Trim(',') } - # default site if not specified - if (! '${{ inputs.site }}' ) { - if ($platform -eq 'x86') { - $site = 'http://mirrors.kernel.org/sourceware/cygwin-archive/20221123' - } else { - $site = 'http://mirrors.kernel.org/sourceware/cygwin/' - } - } else { - $site = '${{ inputs.site }}' - } - $args = @( '-qgnO', - '-s', $site, '-l', 'C:\cygwin-packages', '-R', '${{ inputs.install-dir }}' ) + # default site if not specified + if ( '${{ inputs.site }}' ) { + $sites = '${{ inputs.site }}' + } elseif ($platform -eq 'x86') { + $sites = 'http://mirrors.kernel.org/sourceware/cygwin-archive/20221123' + } else { + $sites = 'http://mirrors.kernel.org/sourceware/cygwin/' + } + $site_list = $sites.Split('', [System.StringSplitOptions]::RemoveEmptyEntries) + $site_list = $site_list | % { $_.Trim() } + foreach ($site in $site_list) { + $args += '-s' + $args += $site + } + if ($pkg_list.Count -gt 0) { $args += '-P' $args += $pkg_list -Join(',') @@ -69,6 +79,16 @@ runs: $args += '-X' } + if ( '${{ inputs.pubkeys }}' ) { + $pubkeys = '${{ inputs.pubkeys }}' + $pubkey_list = $pubkeys.Split('', [System.StringSplitOptions]::RemoveEmptyEntries) + $pubkey_list = $pubkey_list | % { $_.Trim() } + foreach ($pubkey in $pubkey_list) { + $args += '-K' + $args += $pubkey + } + } + if ($platform -eq 'x86') { $args += '--allow-unsupported-windows' } @@ -78,8 +98,11 @@ runs: & C:\setup.exe $args | Out-Default shell: powershell + - if: ${{ inputs.add-to-path == 'true' }} + run: echo "${{ inputs.install-dir }}\bin" >> $env:GITHUB_PATH + shell: powershell + - run: | - echo "${{ inputs.install-dir }}\bin" >> $env:GITHUB_PATH # run login shell to copy skeleton profile files ${{ inputs.install-dir }}\bin\bash.exe --login shell: powershell diff --git a/tests/repo/key.priv b/tests/repo/key.priv new file mode 100644 index 0000000..1d75611 Binary files /dev/null and b/tests/repo/key.priv differ diff --git a/tests/repo/key.pub b/tests/repo/key.pub new file mode 100644 index 0000000..e06732c Binary files /dev/null and b/tests/repo/key.pub differ diff --git a/tests/repo/x86_64/release/cygwin-install-action-test/cygwin-install-action-test-1.0.0-1-src.hint b/tests/repo/x86_64/release/cygwin-install-action-test/cygwin-install-action-test-1.0.0-1-src.hint new file mode 100644 index 0000000..4a5881d --- /dev/null +++ b/tests/repo/x86_64/release/cygwin-install-action-test/cygwin-install-action-test-1.0.0-1-src.hint @@ -0,0 +1,4 @@ +category: Debug +build-depends: cygport +sdesc: "test" +ldesc: "test" diff --git a/tests/repo/x86_64/release/cygwin-install-action-test/cygwin-install-action-test-1.0.0-1-src.tar.xz b/tests/repo/x86_64/release/cygwin-install-action-test/cygwin-install-action-test-1.0.0-1-src.tar.xz new file mode 100644 index 0000000..6e658e0 Binary files /dev/null and b/tests/repo/x86_64/release/cygwin-install-action-test/cygwin-install-action-test-1.0.0-1-src.tar.xz differ diff --git a/tests/repo/x86_64/release/cygwin-install-action-test/cygwin-install-action-test-1.0.0-1.hint b/tests/repo/x86_64/release/cygwin-install-action-test/cygwin-install-action-test-1.0.0-1.hint new file mode 100644 index 0000000..1f6b77b --- /dev/null +++ b/tests/repo/x86_64/release/cygwin-install-action-test/cygwin-install-action-test-1.0.0-1.hint @@ -0,0 +1,4 @@ +category: Debug +requires: cygwin +sdesc: "test" +ldesc: "test" diff --git a/tests/repo/x86_64/release/cygwin-install-action-test/cygwin-install-action-test-1.0.0-1.tar.xz b/tests/repo/x86_64/release/cygwin-install-action-test/cygwin-install-action-test-1.0.0-1.tar.xz new file mode 100644 index 0000000..6e658e0 Binary files /dev/null and b/tests/repo/x86_64/release/cygwin-install-action-test/cygwin-install-action-test-1.0.0-1.tar.xz differ diff --git a/tests/repo/x86_64/setup.ini b/tests/repo/x86_64/setup.ini new file mode 100644 index 0000000..bc8c38d --- /dev/null +++ b/tests/repo/x86_64/setup.ini @@ -0,0 +1,20 @@ +# This file was automatically generated at 2023-04-06 23:08:13 CEST. +# +# If you edit it, your edits will be discarded next time the file is +# generated. +# +# See https://sourceware.org/cygwin-apps/setup.ini.html for a description +# of the format. +release: cygwin +arch: x86_64 +setup-timestamp: 1680815293 + +@ cygwin-install-action-test +sdesc: "test" +ldesc: "test" +category: Debug +version: 1.0.0-1 +install: x86_64/release/cygwin-install-action-test/cygwin-install-action-test-1.0.0-1.tar.xz 232 87295610f57d118b9c7f80949c220a71578d1e89ef4cf8d63ff785d0e1ba98b285fbc16ede73a66712aaa5f5ab3729bbbd1968247ee1e8bfb19f3fcbc3c8a576 +source: x86_64/release/cygwin-install-action-test/cygwin-install-action-test-1.0.0-1-src.tar.xz 232 87295610f57d118b9c7f80949c220a71578d1e89ef4cf8d63ff785d0e1ba98b285fbc16ede73a66712aaa5f5ab3729bbbd1968247ee1e8bfb19f3fcbc3c8a576 +depends2: cygwin +build-depends: cygport diff --git a/tests/repo/x86_64/setup.ini.sig b/tests/repo/x86_64/setup.ini.sig new file mode 100644 index 0000000..9aa1b87 Binary files /dev/null and b/tests/repo/x86_64/setup.ini.sig differ