This repository was archived by the owner on Oct 26, 2023. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathscripts.ps1
More file actions
163 lines (133 loc) · 5.99 KB
/
Copy pathscripts.ps1
File metadata and controls
163 lines (133 loc) · 5.99 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
### Global variables
$RTOOLS_ARCH = ${env:RTOOLS_ARCH}
$RTOOLS_ZIP = "rtools40-${RTOOLS_ARCH}.7z"
$RTOOLS_EXE = "rtools40-${RTOOLS_ARCH}.exe"
### Use for bootstrapping installation
$RTOOLS_MIRROR = "https://ftp.opencpu.org/rtools/installer/"
# $RTOOLS_MIRROR = "https://cloud.r-project.org/bin/windows/Rtools/"
# $RTOOLS_MIRROR = "https://ftp.opencpu.org/archive/rtools/4.0/"
### InnoSetup Mirror
# $INNO_MIRROR = "http://www.jrsoftware.org/download.php/is.exe?site=2"
### Latest InnoSetup does not support Vista anymore
$INNO_MIRROR = "http://files.jrsoftware.org/is/6/innosetup-6.0.4.exe"
### MikTex Mirror
$MIKTEX_MIRROR = "https://miktex.org/download/win/basic-miktex-x64.exe"
#$MIKTEX_MIRROR = "https://cloud.r-project.org/bin/windows/Rtools/basic-miktex-2.9.7152-x64.exe"
function CheckExitCode($msg) {
if ($LastExitCode -ne 0) {
Throw $msg
}
}
# Unzip and Initiate Rtools dump
Function InstallRtoolsZip {
Write-Host "Installing ${RTOOLS_ZIP}..." -ForegroundColor Cyan
$tmp = "$($env:USERPROFILE)\${RTOOLS_ZIP}"
(New-Object Net.WebClient).DownloadFile($RTOOLS_MIRROR + $RTOOLS_ZIP, $tmp)
7z x $tmp -y -oC:\ | Out-Null
CheckExitCode "Failed to extract ${RTOOLS_ZIP}"
C:\rtools40\usr\bin\bash.exe --login -c exit 2>$null
Write-Host "Installation of ${RTOOLS_ZIP} done!" -ForegroundColor Green
}
# Don't use installer when: (1) architecture doesn't match host (2) Dir C:/rtools40 already exists
Function InstallRtoolsExe {
Write-Host "Installing ${RTOOLS_EXE}..." -ForegroundColor Cyan
$tmp = "$($env:USERPROFILE)\${RTOOLS_EXE}"
(New-Object Net.WebClient).DownloadFile($RTOOLS_MIRROR + $RTOOLS_EXE, $tmp)
Start-Process -FilePath $tmp -ArgumentList /VERYSILENT -NoNewWindow -Wait
Write-Host "Installation of ${RTOOLS_EXE} done!" -ForegroundColor Green
}
function bash($command) {
Write-Host $command -NoNewline
cmd /c start /wait C:\rtools40\usr\bin\sh.exe --login -c $command
Write-Host " - OK" -ForegroundColor Green
}
function InstallRtools {
InstallRtoolsZip
bash 'pacman -Sy --noconfirm pacman pacman-mirrors'
bash 'pacman -Syyu --noconfirm --ask 20'
}
Function InstallInno {
Write-Host "Downloading InnoSetup from: " + $INNO_MIRROR
& "C:\Program Files\Git\mingw64\bin\curl.exe" -s -o ../innosetup.exe -L $INNO_MIRROR
CheckExitCode "Failed to download $INNO_MIRROR"
Write-Host "Installig InnoSetup..."
Start-Process -FilePath ..\innosetup.exe -ArgumentList "/ALLUSERS /SILENT" -NoNewWindow -Wait
CheckExitCode "Failed to install InnoSetup"
Write-Host "InnoSetup installation: Done" -ForegroundColor Green
Get-ItemProperty "C:\Program Files (x86)\Inno Setup 6\ISCC.exe"
}
function InnoBuild($iss){
Write-Host "Creating installer..." -NoNewline
& "C:\Program Files (x86)\Inno Setup 5\iscc.exe" "${env:RTOOLS_NAME}.iss" | Out-File output.log
Write-Host "OK!" -ForegroundColor Green
}
function SignFiles($files) {
(New-Object Net.WebClient).DownloadFile(${env:PfxUri}, 'C:\jeroen.pfx')
& $env:SignTool sign /f C:\jeroen.pfx /p "$env:CertPassword" /tr http://sha256timestamp.ws.symantec.com/sha256/timestamp /td sha256 /fd sha256 $files
CheckExitCode "Failed to sign files."
Remove-Item 'C:\jeroen.pfx'
}
Function InstallMiktex {
$miktexinstall = "--unattended --auto-install=yes --shared --package-set=basic"
Write-Host "Downloading " + $MIKTEX_MIRROR
& "C:\Program Files\Git\mingw64\bin\curl.exe" -s -o ../basic-miktex-x64.exe -L $MIKTEX_MIRROR
Write-Host "Installing MiKTeX: " + $miktexinstall
Start-Process -FilePath ..\basic-miktex-x64.exe -ArgumentList $miktexinstall -NoNewWindow -Wait
Write-Host "Setting PATH variable for current process"
$env:PATH = 'C:\Program Files\MiKTeX\miktex\bin\x64;' + $env:PATH
Write-Host "Installing CTAN packages"
mpm --admin --set-repository=https://ctan.math.illinois.edu/systems/win32/miktex/tm/packages/
mpm --admin --verbose --update-db
mpm --admin --verbose --update
mpm --admin --install=inconsolata
# Enable auto-install, just in case
initexmf --admin --enable-installer
initexmf --admin --set-config-value "[MPM]AutoInstall=1"
# See https://tex.stackexchange.com/a/129523/12890
$conffile = "C:\Program Files\MiKTeX\miktex\config\updmap.cfg"
Write-Host "Adding zi4.map"
initexmf --admin --update-fndb
Add-Content $conffile "`nMap zi4.map`n"
initexmf --admin --mkmaps
# First time running 'pdflatex' always fails with some inite
Write-Host "Trying pdflatex..."
# pdflatex.exe --version
Write-Host "MiKTeX installation: Done" -ForegroundColor Green
}
########### OLD CODE ###########
Function InstallMSYS32 {
Write-Host "Installing MSYS2 32-bit..." -ForegroundColor Cyan
# download installer
$zipPath = "$($env:USERPROFILE)\msys2-i686-latest.tar.xz"
$tarPath = "$($env:USERPROFILE)\msys2-i686-latest.tar"
Write-Host "Downloading MSYS installation package..."
(New-Object Net.WebClient).DownloadFile('http://repo.msys2.org/distrib/msys2-i686-latest.tar.xz', $zipPath)
Write-Host "Untaring installation package..."
7z x $zipPath -y -o"$env:USERPROFILE" | Out-Null
Write-Host "Unzipping installation package..."
7z x $tarPath -y -oC:\ | Out-Null
del $zipPath
del $tarPath
}
function rtools_bootstrap {
# AppVeyor only has msys64 preinstalled
if($env:MSYS_VERSION -eq 'msys32') {
InstallMSYS32
bash 'pacman -Sy --noconfirm pacman pacman-mirrors'
# May upgrade runtime, need to exit afterwards
bash 'pacman -Syyuu --noconfirm --ask 20'
}
bash 'pacman --version'
bash 'pacman --noconfirm -Rcsu mingw-w64-x86_64-toolchain mingw-w64-i686-toolchain'
bash 'repman add rtools "https://dl.bintray.com/rtools/${MSYSTEM_CARCH}"'
bash 'pacman --noconfirm --sync rtools/pacman-mirrors rtools/pacman rtools/tar'
bash 'mv /etc/pacman.conf /etc/pacman.conf.old'
bash 'mv /etc/pacman.conf.pacnew /etc/pacman.conf'
bash 'pacman --noconfirm -Scc'
bash 'pacman --noconfirm --ask 20 -Syyu'
}
Function SetTimezone {
tzutil /g
tzutil /s "GMT Standard Time"
tzutil /g
}