Skip to content

Commit 77d93c5

Browse files
committed
work-vol option to target different setup volume
Volume on which to store \setup.exe and \cygwin-packages Volume on which to store \cygwin if install-dir param not specified ref: cygwin#24 Signed-off-by: Glenn Strauss <[email protected]>
1 parent fb05f1a commit 77d93c5

File tree

2 files changed

+31
-11
lines changed

2 files changed

+31
-11
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@ Parameters
2222
| ------------------- | -------------------------------------------- | -----------
2323
| platform | x86_64 | Install the x86 or x86\_64 version of Cygwin.
2424
| packages | *none* | List of additional packages to install.
25-
| install-dir | C:\cygwin | Installation directory
25+
| install-dir | C:\cygwin | Installation directory (path overrides work-vol for install-dir)
2626
| site | http://mirrors.kernel.org/sourceware/cygwin/ | Mirror sites to install from, separated by whitespace
2727
| pubkeys | *none* | Absolute paths of extra public key files (RFC4880 format), separated by whitespace
2828
| check-sig | true | Whether to check the setup.ini signature
2929
| add-to-path | true | Whether to add Cygwin's `/bin` directory to the system `PATH`
3030
| allow-test-packages | false | Consider package versions marked test for installation
3131
| check-hash | true | Whether to check the hash of the downloaded Cygwin installer.
32+
| work-vol | C: | Volume on which to store \setup.exe, \cygwin-packages, \cygwin.
3233

3334
Line endings
3435
------------

action.yml

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ inputs:
1212
install-dir:
1313
# by default, install to C:\cygwin rather than the platform dependent
1414
# default to make everything simpler
15-
description: Installation directory
15+
description: Installation directory (path overrides work-vol for install-dir)
1616
required: false
17-
default: C:\cygwin
17+
default: ''
1818
check-sig:
1919
description: Should the setup.ini file signature be checked?
2020
required: false
@@ -37,6 +37,10 @@ inputs:
3737
description: Check the hash of the installer
3838
required: false
3939
default: 'true'
40+
work-vol:
41+
description: Volume on which to store \setup.exe, \cygwin-packages, \cygwin
42+
required: false
43+
default: 'C:'
4044

4145
runs:
4246
using: "composite"
@@ -51,9 +55,11 @@ runs:
5155
echo "unknown platform $platform"
5256
exit 1
5357
}
58+
$vol = '${{ inputs.work-vol }}'
59+
$setupExe = "$vol\setup.exe"
5460
$setupFileName = "setup-$platform.exe"
55-
Invoke-WebRequest "https://cygwin.com/$setupFileName" -OutFile C:\setup.exe
56-
if ((Get-Item -LiteralPath 'C:\setup.exe').Length -eq 0) {
61+
Invoke-WebRequest "https://cygwin.com/$setupFileName" -OutFile $setupExe
62+
if ((Get-Item -LiteralPath $setupExe).Length -eq 0) {
5763
throw "The downloaded setup has a zero length!"
5864
}
5965
@@ -69,7 +75,7 @@ runs:
6975
if ($expectedHash -eq '') {
7076
Write-Output -InputObject "::warning::Unable to find the hash for the file $setupFileName in https://cygwin.com/sha512.sum"
7177
} else {
72-
$actualHash = $(Get-FileHash -LiteralPath C:\setup.exe -Algorithm SHA512).Hash
78+
$actualHash = $(Get-FileHash -LiteralPath $setupExe -Algorithm SHA512).Hash
7379
if ($actualHash -ine $expectedHash) {
7480
throw "Invalid hash of the downloaded setup!`nExpected: $expectedHash`nActual : $actualHash"
7581
} else {
@@ -83,10 +89,14 @@ runs:
8389
$pkg_list = $pkg_list | % { $_.Trim() }
8490
$pkg_list = $pkg_list | % { $_.Trim(',') }
8591
92+
$installDir = '${{ inputs.install-dir }}'
93+
if ($installDir -eq '') {
94+
$installDir = "$vol\cygwin"
95+
}
8696
$args = @(
8797
'-qnO',
88-
'-l', 'C:\cygwin-packages',
89-
'-R', '${{ inputs.install-dir }}'
98+
'-l', "$vol\cygwin-packages",
99+
'-R', "$installDir"
90100
)
91101
92102
if ( '${{ inputs.allow-test-packages }}' -eq 'true' ) {
@@ -133,16 +143,25 @@ runs:
133143
134144
# because setup is a Windows GUI app, make it part of a pipeline to make
135145
# PowerShell wait for it to exit
136-
& C:\setup.exe $args | Out-Default
146+
& $setupExe $args | Out-Default
137147
shell: powershell
138148
139149
- if: ${{ inputs.add-to-path == 'true' }}
140-
run: echo "${{ inputs.install-dir }}\bin" >> $env:GITHUB_PATH
150+
run: |
151+
$installDir = '${{ inputs.install-dir }}'
152+
if ($installDir -eq '') {
153+
$installDir = '${{ inputs.work-vol }}\cygwin'
154+
}
155+
echo "$installDir\bin" >> $env:GITHUB_PATH
141156
shell: pwsh
142157

143158
- run: |
144159
# run login shell to copy skeleton profile files
145-
${{ inputs.install-dir }}\bin\bash.exe --login
160+
$installDir = '${{ inputs.install-dir }}'
161+
if ($installDir -eq '') {
162+
$installDir = '${{ inputs.work-vol }}\cygwin'
163+
}
164+
& "$installDir\bin\bash.exe" --login
146165
shell: pwsh
147166
148167
branding:

0 commit comments

Comments
 (0)