Last active
November 29, 2016 13:50
-
-
Save Prince-Mandor/50bb3678b4ced9af17637dca51c1290c to your computer and use it in GitHub Desktop.
batch for fresh cygwin install
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
: <<TRAMPOLINE | |
@echo off | |
setlocal enableDelayedExpansion | |
set "options=-drive:c:" | |
for %%O in (%options%) do for /f "tokens=1,* delims=:" %%A in ("%%O") do set "%%A=%%~B" | |
for /f "tokens=3" %%a in ('reg query "HKLM\Software\Cygwin\setup" /v "rootdir" ^|findstr /ri "REG_SZ"') do set -drive=%%~da | |
:loop | |
if not "%~1"=="" ( | |
set "test=!options:*%~1:=! " | |
if "!test!"=="!options! " ( | |
echo Error: Invalid option %~1 | |
) else if "!test:~0,1!"==" " ( | |
set "%~1=1" | |
) else ( | |
setlocal disableDelayedExpansion | |
set "val=%~2" | |
call :escapeVal | |
setlocal enableDelayedExpansion | |
for /f delims^=^ eol^= %%A in ("!val!") do endlocal&endlocal&set "%~1=%%A" ! | |
shift /1 | |
) | |
shift /1 | |
goto :loop | |
) | |
goto :endArgs | |
:escapeVal | |
set "val=%val:^=^^%" | |
set "val=%val:!=^!%" | |
exit /b | |
:endArgs | |
set cygwin-root-path=!-drive!\cygwin\ | |
set cygwin-bin-path=!-drive!\cygwin\bin\ | |
set cygwin-install-path=!-drive!\cygwin\.install\ | |
if /i "%~dp0" == "!cygwin-install-path!" goto :skiprestart | |
md !cygwin-install-path! | |
xcopy %0 !cygwin-install-path! /Y | |
cd /d !cygwin-install-path! | |
%~nx0 -drive %-drive% | |
goto :eof | |
:skiprestart | |
if exist setup-x86_64.exe (echo Skiping download & goto :skipdownload) | |
set downloader=Not Found :( | |
for %%I in (wget.exe, BITSAdmin.exe) do (if not ""=="%%~$PATH:I" (set downloader=%%I & goto :found_dl)) | |
:found_dl | |
rem set downloader=%%~$PATH:I | |
rem bitsadmin /transfer myDownloadJob /download /priority normal http://downloadsrv/10mb.zip c:\10mb.zip | |
if "%downloader%"=="wget.exe" ( | |
wget --directory-prefix=!cygwin-install-path! https://www.cygwin.com/setup-x86_64.exe | |
) | |
if "%downloader%"=="BITSAdmin.exe" ( | |
bitsadmin /transfer "Download CygWin Setup" /download /priority normal https://www.cygwin.com/setup-x86_64.exe !cygwin-install-path!setup-x86_64.exe | |
) | |
:skipdownload | |
setup-x86_64.exe --root !cygwin-root-path! --local-package-dir !cygwin-install-path! --packages lynx --site http://cygwin.mbwarez.dk/ --wait --upgrade-also --quiet-mode | |
echo %PATH%|find /i "%cygwin-bin-path%">nul || set PATH=%PATH%;%cygwin-bin-path%; | |
set PATH=%PATH:;;=;% | |
rem setx PATH "%PATH%" | |
bash --login -i %0 | |
goto :eof | |
TRAMPOLINE | |
#################################################################################### | |
#!/bin/bash | |
lynx -source rawgit.com/transcode-open/apt-cyg/master/apt-cyg > apt-cyg | |
install apt-cyg /bin | |
rm apt-cyg | |
apt-cyg update | |
apt-cyg install wget python python3 openssh git mc | |
mc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment