forked from rtwolf/cygwin-auto-install
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.bat
82 lines (68 loc) · 2.38 KB
/
install.bat
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
@ECHO OFF
REM -- Automates Cygwin installation
REM -- See README.md file for history and details
SETLOCAL EnableDelayedExpansion
REM -- Change to the directory of the executing batch file
CD /D %~dp0
REM -- Configure our paths
SET SITE=https://mirror.csclub.uwaterloo.ca/cygwin/
SET ROOTDIR=C:\cygwin
SET LOCALDIR=%ROOTDIR%\dist
IF NOT EXIST "%ROOTDIR%" (
MKDIR "%ROOTDIR%"
)
SET SETUP_PATH=%ROOTDIR%\setup-x86_64.exe
IF NOT EXIST "%SETUP_PATH%" (
ECHO *** Downloading Cygwin installer...
bitsadmin /transfer cygwinDownloadJob /download /priority foreground https://cygwin.com/setup-x86_64.exe "%SETUP_PATH%"
ECHO *** Cygwin installer downloaded.
)
SET PACKAGES=cygwin
Call :LoadPackages "%~dp0packages.txt"
IF "%~1" NEQ "" (
IF EXIST "%~1" (
Call :LoadPackages "%~1"
) ELSE (
ECHO *** Adding the following packages %~1...
SET PACKAGES=!PACKAGES!,%~1
ECHO *** Packages %~1 added.
)
)
REM -- These are necessary for apt-cyg install, do not change. Any duplicates will be ignored.
SET PACKAGES=%PACKAGES%,wget,tar,gawk,bzip2
REM -- More info on command line options at: https://cygwin.com/faq/faq.html#faq.setup.cli
ECHO *** Installing Cygwin and packages...
"%SETUP_PATH%" --quiet-mode --upgrade-also --no-desktop --download --local-install --site %SITE% --local-package-dir "%LOCALDIR%" --root "%ROOTDIR%" --packages %PACKAGES%
ECHO.
ECHO.
ECHO *** Cygwin and packages installed.
ECHO *** Packages: %PACKAGES%
ECHO.
REM TODO: Fetch and decode PROFILES_DIR.
REM `"%ROOTDIR%/bin/regtool" get "/HKLM/Software/Microsoft/Windows NT/CurrentVersion/ProfileList/ProfilesDirectory"`
REM ...might give us something like "%SystemDrive%\Users" which would have to be expanded
SET PROFILES_DIR=C:\Users
IF NOT EXIST "%ROOTDIR%\home.old" (
ECHO *** Creating junction /home -^> %PROFILES_DIR%...
MOVE "%ROOTDIR%\home" "%ROOTDIR%\home.old"
MKLINK /J "%ROOTDIR%\home" "%PROFILES_DIR%"
ECHO *** Junction /home -^> %PROFILES_DIR% created.
)
IF NOT EXIST "%ROOTDIR%\bin\apt-cyg" (
ECHO *** Installing apt-cyg...
"%ROOTDIR%/bin/wget" https://raw.githubusercontent.com/transcode-open/apt-cyg/master/apt-cyg --output-document=/bin/apt-cyg
"%ROOTDIR%/bin/chmod" +x /bin/apt-cyg
ECHO *** apt-cyg installed.
)
ENDLOCAL
EXIT /B 0
:LoadPackages
IF EXIST "%~1" (
ECHO *** Loading packages from %~1...
FOR /F "eol=#" %%i in (%~1) do (
SET PACKAGES=!PACKAGES!,%%i
)
ECHO *** Packages from %~1 loaded.
EXIT /B 0
)
EXIT /B 1