This repository has been archived by the owner on Aug 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
setup_cygwin.ps1
executable file
·57 lines (49 loc) · 1.83 KB
/
setup_cygwin.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Helper functions
################################################################################
Function DownloadFileIfNecessary($source, $targetDir, $targetName) {
$target = $targetDir + '\' + $targetName;
if (!(Test-Path $target)) {
$webclient = New-Object System.Net.WebClient;
if (!(Test-Path $targetDir)) {
New-Item $targetDir -type directory -Force;
}
Write-Host " downloading $source into $target...";
$webclient.DownloadFile($source, $target);
}
EnsureFileDownloaded $source $target;
return $target;
}
Function EnsureFileDownloaded($source, $target) {
if (!(Test-Path $target)) {
Write-Host " failed to download $source";
exit 1;
} else {
Write-Host " $source downloaded successfully";
}
}
# Config
################################################################################
$CurrentDir = split-path -parent $MyInvocation.MyCommand.Definition
$Tmp = $CurrentDir + '\tmp'
$CmderDir = $CurrentDir + '\cmder'
$CygwinDir = $CmderDir + '\cygwin'
# Run cygwin setup if needed
################################################################################
Function SetupCygwin() {
$cygwinURL = 'https://cygwin.com/setup-x86_64.exe';
$cygwinEXE = DownloadFileIfNecessary $cygwinURL $Tmp 'setup-x86_64.exe';
$cygwinArgs = @(
'--no-admin', '--upgrade-also', '--package-manager',
'--no-desktop', '--no-startmenu', '--no-shortcuts',
# Directories `
'--root', $CygwinDir,
'--local-package-dir', $Tmp,
# Sources `
'--site', 'ftp://mirrors.kernel.org/sourceware/cygwin',
'--site', 'ftp://ftp.cygwinports.org/pub/cygwinports',
'--pubkey', 'http://cygwinports.org/ports.gpg')
Start-Process -FilePath $cygwinEXE -ArgumentList $cygwinArgs -NoNewWindow -Wait
}
# Run script
################################################################################
SetupCygwin;