setup-cygwin64.bat 2.14 KB
Newer Older
Benguria Elguezabal, Gorka's avatar
Benguria Elguezabal, Gorka committed
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
@echo off

rem we check de powershell version if lower that 3 exit
for /f %%i in ('powershell -Command "$PSVersionTable.PSVersion.Major"') do set powershellVersion=%%i
echo powershellVersion=%powershellVersion%

if %powershellVersion% LSS 3 (
  echo Only works with powershell greater or equal to 3 
  goto end
)

rem we download the setup package
set downloadUrl=https://cygwin.com/setup-x86_64.exe

mkdir downloads 2> nul

for /f %%i in ('powershell -Command "$(split-path -path "%downloadUrl%" -leaf)"') do set appFileName=%%i
echo appFileName=%appFileName%

rem The CMD shell does not use any great intelligence when evaluating parenthesis, and we have parenthesis in the inner command
if Not exist "downloads\%appFileName%" (
    rem file exists
	echo downloading %downloadUrl% to downloads
	rem we escape because we are inside if
	powershell -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest %downloadUrl% -OutFile downloads\%appFileName%"
)

rem we install cygwin
set CYGWIN_HOME_REL_PATH=cygwin64
mkdir %CYGWIN_HOME_REL_PATH% 2> nul

echo installing cygwin
33
set packages=rsync,zip,unzip,wget,curl,openssh,openssl,xmlstarlet,jq,bind-utils,inetutils,git,mysql,python,python-pip,python3,python3-pip
Benguria Elguezabal, Gorka's avatar
Benguria Elguezabal, Gorka committed
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
rem rsync,zip,unzip,wget,curl,openssh,openssl,xmlstarlet,jq,bind-utils,inetutils,git …
downloads\setup-x86_64.exe --no-admin --quiet-mode --no-startmenu --no-desktop --no-shortcuts --force-current --local-package-dir "%CD%\downloads" --root "%CD%\%CYGWIN_HOME_REL_PATH%" --site "http://cygwin.mirror.constant.com/" --packages %packages%

rem we fix the fstab
cygwin64\bin\sed -i "s\,user \,user,noacl \g" cygwin64\etc\fstab

rem we setup PATH
set CYGWIN_HOME=%CD%\%CYGWIN_HOME_REL_PATH%
set CYGWIN_PATH=%CYGWIN_HOME%\bin

echo The Current Dir is equal to %CD%
echo The CYGWIN_HOME is equal to %CYGWIN_HOME%
echo The CYGWIN_HOME_REL_PATH is equal to %CYGWIN_HOME_REL_PATH%

echo %PATH% | %WINDIR%\System32\find.exe "%CYGWIN_PATH%" /C >NUL
IF NOT ERRORLEVEL 1 GOTO pathDuplicate
SET PATH=%CYGWIN_PATH%;%PATH%
echo PATH has been updated PATH = %PATH%
:pathDuplicate

:end