Skip to content

Commit

Permalink
Add support for the Cygwin Time Machine
Browse files Browse the repository at this point in the history
Using the Cygwin Time Machine requires (a) being able to specify the
mirror that's used for installing Cygwin, and (b) being able to disable
the signature checks the installer performs.  Add options that allow
that, tests to check it works as expected, and documentation for the new
options.
  • Loading branch information
me-and authored and jon-turney committed Mar 14, 2022
1 parent ad81540 commit cf17b9c
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 6 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,54 @@ jobs:
shell: bash
env:
SHELLOPTS: igncr

time-machine:
runs-on: windows-latest
strategy:
fail-fast: false

name: 'Test time machine signature'

steps:
- run: git config --global core.autocrlf input

- uses: actions/checkout@v2

- name: Install Cygwin
uses: ./
with:
site: http://ctm.crouchingtigerhiddenfruitbat.org/pub/cygwin/circa/64bit/2021/01/22/181752
check-sig: false

- name: Check cygwin version
run: |
cygcheck -cd cygwin | grep -qF 3.1.7-1
shell: C:\cygwin\bin\bash.exe --noprofile --norc -o igncr -eo pipefail '{0}'

bad-sig:
runs-on: windows-latest
strategy:
fail-fast: false

name: 'Test failure of time machine signature'

steps:
- run: git config --global core.autocrlf input

- uses: actions/checkout@v2

- name: Fail to install Cygwin
uses: ./
with:
site: http://ctm.crouchingtigerhiddenfruitbat.org/pub/cygwin/circa/64bit/2021/01/22/181752
continue-on-error: true

- name: Check Cygwin isn't installed
run: |
if [[ "${OSTYPE}" = "cygwin" ]]; then
echo "Unexpectedly running Cygwin"
exit 1
fi
shell: bash
env:
SHELLOPTS: igncr
21 changes: 16 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ Please fix my terrible cargo-cult PowerShell.
Parameters
----------

| Input | Default | Description
| ----------- | --------- | -----------
| 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
| Input | Default | Description
| ----------- | -------------------------------------------- | -----------
| 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
| check-sig | true | Whether to check the setup.ini signature

Line endings
------------
Expand Down Expand Up @@ -77,6 +79,15 @@ symlinks. Since CMD and PowerShell don't understand those symlinks, you cannot
run those executables directly in a `run:` in your workflow. Execute them via
`bash` or `env` instead.

Mirrors and signatures
----------------------

You probably don't need to change the setting for `site`, and you shouldn't
change `check-sig` unless you're very confident it's appropriate and necessary.
These options are very unlikely to be useful except in some very isolated
circumstances, such as using the [Cygwin Time
Machine](http://www.crouchingtigerhiddenfruitbat.org/Cygwin/timemachine.html).

[1] The
[Workflow documentation](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference)
suggests you should also use bash options `-eo pipefail`, omitted here for clarity
14 changes: 13 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ inputs:
description: Installation directory
required: false
default: C:\cygwin
check-sig:
description: Should the setup.ini file signature be checked?
required: false
default: true
site:
description: Download site URL
required: false
default: http://mirrors.kernel.org/sourceware/cygwin/

runs:
using: "composite"
Expand All @@ -39,7 +47,7 @@ runs:
$args = @(
'-qgnO',
'-s', 'http://mirrors.kernel.org/sourceware/cygwin/',
'-s', '${{ inputs.site }}',
'-l', 'C:\cygwin-packages',
'-R', '${{ inputs.install-dir }}'
)
Expand All @@ -49,6 +57,10 @@ runs:
$args += $pkg_list -Join(',')
}
if ('${{ inputs.check-sig }}' -eq $false) {
$args += '-X'
}
# because setup is a Windows GUI app, make it part of a pipeline to make
# PowerShell wait for it to exit
& C:\setup.exe $args | Out-Default
Expand Down

0 comments on commit cf17b9c

Please sign in to comment.