-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstallPreRequisites.ps1
More file actions
154 lines (126 loc) · 5.36 KB
/
InstallPreRequisites.ps1
File metadata and controls
154 lines (126 loc) · 5.36 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
[CmdletBinding()]
param (
[Parameter()]
[string]
$PythonVersion = "3.12.2",
[Parameter()]
[string]
$MiktexVersion = "24.1",
[Parameter()]
[string]
$PanDocVersion = "3.1.12",
[Parameter()]
[string]
$EisVogelVersion = "2.4.2",
[Parameter(Mandatory = $false)]
[Switch]
$KeepArtifacts = $false
)
<#
.Install-Python
Downloads and installs Python into $env:LocalAppData\Programs\Python\$PythonVersion
#>
function Install-Python {
[CmdletBinding()]
param (
[Parameter()]
[string]
$DownloadDir,
[Parameter()]
[string]
$Version = "3.12.2"
)
$PythonInstaller = "python-$Version-amd64.exe"
$PythonInstallDir = "$env:LocalAppData\Programs\Python\$Version"
Start-BitsTransfer -Source "https://www.python.org/ftp/python/$Version/$PythonInstaller" -Destination "$DownloadDir\$PythonInstaller"
Start-Process -FilePath "$DownloadDir\$PythonInstaller" -ArgumentList @(
"/passive",
"InstallAllUsers=0",
"DefaultJustForMeTargetDir=`"$PythonInstallDir`"",
"AssociateFiles=0",
"Shortcuts=0",
"Include_doc=0"
"Include_dev=0",
"PrependPath=1",
"Include_launcher=0",
"Include_tcltk=0",
"Include_test=0"
) -Wait
[System.Environment]::SetEnvironmentVariable("PYTHON_HOME", "$PythonInstallDir", [System.EnvironmentVariableTarget]::User)
Start-Process -FilePath "$PythonInstallDir\python.exe" -ArgumentList @("-m", "pip", "install", "--upgrade", "pip") -Wait
Start-Process -FilePath "$PythonInstallDir\python.exe" -ArgumentList @("-m", "pip", "install", "mkdocs") -Wait
}
<#
.Install-MiKTeX
Downloads and installs MiKTeX into $env:LocalAppData\Programs\MiKTeX
#>
function Install-MiKTeX {
[CmdletBinding()]
param (
[Parameter()]
[string]
$DownloadDir,
[Parameter()]
[string]
$Version = "24.1"
)
$MiKTeXInstaller = "basic-miktex-$Version-x64.exe"
$MiKTeXInstallDir = "$env:LocalAppData\Programs\MiKTeX"
Start-BitsTransfer -Source "https://miktex.org/download/ctan/systems/win32/miktex/setup/windows-x64/$MiKTeXInstaller" -Destination "$DownloadDir\$MiKTeXInstaller"
Start-Process -FilePath "$DownloadDir\$MiKTeXInstaller" -ArgumentList @("--install", "--unattended", "--user-install=`"$MiKTeXInstallDir`"") -Wait
Start-Process -FilePath "$MiKTeXInstallDir\miktex\bin\x64\miktex.exe" -ArgumentList @("packages", "update") -Wait -NoNewWindow
$Packages = @("adjustbox", "auxhook", "bigintcalc", "bitset", "bookmark", "caption", "collectbox", "colortbl", "csquotes", "etexcmds", "fancyhdr", "float", "footmisc", "footnotebackref", "geometry", "gettitlestring", "hycolor", "ifoddpage", "infwarerr", "intcalc", "koma-script", "kvdefinekeys", "kvoptions", "kvsetkeys", "latex-graphics-dev", "letltxmacro", "ltxcmds", "ly1", "mdframed", "microtype", "mweights", "needspace", "pagecolor", "pdfescape", "refcount", "rerunfilecheck", "setspace", "sourcecodepro", "sourcesanspro", "titling", "uniquecounter", "upquote", "varwidth", "xurl", "zref", "beautybook", "babel-german", "parskip", "booktabs", "footnotehyper")
foreach ($Package in $Packages) {
Start-Process -FilePath "$MiKTeXInstallDir\miktex\bin\x64\miktex.exe" -ArgumentList @("packages", "install", "$Package") -Wait -NoNewWindow
}
}
<#
.Install-Pandoc
Downloads and installs Pandoc into $env:LocalAppData\Programs\Pandoc
#>
function Install-Pandoc {
[CmdletBinding()]
param (
[Parameter()]
[string]
$DownloadDir,
[Parameter()]
[string]
$Version = "3.1.12"
)
$PandocMsi = "pandoc-$Version-windows-x86_64.msi"
Start-BitsTransfer -Source "https://github.com/jgm/pandoc/releases/download/$Version/$PandocMsi" -Destination "$DownloadDir\$PandocMsi"
Start-Process -FilePath "msiexec" -ArgumentList @("/i", "$DownloadDir\$PandocMsi", "/qn", "APPLICATIONFOLDER=`"$env:LocalAppData\Programs\Pandoc`"", "ADDLOCAL=MainProgram,Complete,Manual,Citation") -Wait
}
<#
.Install-Template
Downloads and extracts the "EisVogel" template.
#>
function Install-Template {
[CmdletBinding()]
param (
[Parameter()]
[string]
$DownloadDir,
[Parameter()]
[string]
$Version = "2.4.2"
)
$EisvogelZip = "Eisvogel-$Version.zip"
Start-BitsTransfer -Source "https://github.com/Wandmalfarbe/pandoc-latex-template/releases/download/$Version/$EisvogelZip" -Destination "$DownloadDir\$EisvogelZip"
Expand-Archive -Path "$DownloadDir\$EisvogelZip" -DestinationPath "$env:AppData\pandoc\templates\"
}
# Create the download directory for the binaries
$UUID = (New-Guid)
$DownloadDir = "$env:TEMP\$UUID"
New-Item -ItemType "Directory" -Path "$DownloadDir"
Install-Python -DownloadDir "$DownloadDir" -Version "$PythonVersion"
Install-MiKTeX -DownloadDir "$DownloadDir" -Version "$MiktexVersion"
Install-Pandoc -DownloadDir "$DownloadDir" -Version "$PanDocVersion"
Install-Template -DownloadDir "$DownloadDir" -Version "$EisVogelVersion"
if ($KeepArtifacts -eq $false)
{
Write-Host -Object "Deleting downloaded artifacts"
Remove-Item -Recurse -Force -Path "$DownloadDir"
Write-Host -Object "Downloaded artifacts deleted"
}