GetMingwBatch

@echo off

cls
echo This is a batch file that automatically installs MinGW, MSYS and ActivePerl,
echo and prepares MSYS for automatically getting and compiling The Gimp 
echo by a shell-script. You should run it as Administrator or with Administrator
echo rights.
echo.
echo Written by Ted Shaneyfelt and Anton Verburg (anton.verburg AT otb.nl)
echo Thanks to Ted Shaneyfelt for the original idea and batch file that did all
echo this and built from source.  Comments and output added.
echo.

REM Updated by Carlo Baldassi:
REM - Made it easier to update it by using environment variables
REM - Tries to re-use already downloaded packages if present

REM Pausing so user can read the above text
pause

set SOURCEFORGE_MIRROR=freefr.dl
set MINGW=MinGW-5.1.4.exe
rem --- set MSYS=MSYS-1.0.11-2004.04.30-1.exe
set MSYS=MSYS-1.0.10.exe
set ACTIVEPERL_VERSION=5.10
set ACTIVEPERL=ActivePerl-5.10.0.1004-MSWin32-x86-287188.msi
set WGET_VERSION=1.11.4-1
set WGETBIN=wget-%WGET_VERSION%-bin.zip
set WGETDEP=wget-%WGET_VERSION%-dep.zip
set UNZIP_VERSION=5.51-1
set UNZIPBIN=unzip-%UNZIP_VERSION%-bin.zip

rem --- Delete any previous TmpInstall directory
rem IF EXIST TmpInstall (
rem    rmdir /S /Q TmpInstall
rem )

rem --- Create the TmpInstall directory and change into it
mkdir TmpInstall
cd TmpInstall

echo ----------------------------------------------------------------------
echo Downloading unzip
echo ----------------------------------------------------------------------
if NOT EXIST unz552xN.exe (
        echo> getunzip.tmp open ftp.info-zip.org
        echo>>getunzip.tmp binary
        echo>>getunzip.tmp get /pub/infozip/win32/unz552xn.exe
        echo>>getunzip.tmp close
        echo>>getunzip.tmp quit
        ftp -s:getunzip.tmp -A
        del getunzip.tmp
)
echo.
IF NOT EXIST unz552xN.exe (
   echo !!! Failed to download file: unz552xN.exe
   goto ERR
)

echo ----------------------------------------------------------------------
echo Extracting unzip
echo ----------------------------------------------------------------------
unz552xN.exe
echo.
IF errorlevel 1 GOTO ERR

echo ----------------------------------------------------------------------
echo Downloading wget
echo ----------------------------------------------------------------------
if NOT EXIST wget-complete-stable.zip (
        echo> getwget.tmp open sunsite.dk
        echo>>getwget.tmp binary
        echo>>getwget.tmp get /pub/projects/wget/windows/wget-complete-stable.zip
        echo>>getwget.tmp close
        echo>>getwget.tmp quit
        ftp -s:getwget.tmp -A
        del getwget.tmp
)
echo.
IF NOT EXIST wget-complete-stable.zip (
   echo !!! Failed to download file: wget-complete-stable.zip
   goto ERR
)

echo ----------------------------------------------------------------------
echo Extracting wget
echo ----------------------------------------------------------------------
unzip -o wget-complete-stable.zip
echo.
IF errorlevel 1 GOTO ERR

echo ----------------------------------------------------------------------
echo Downloading MinGW
echo ----------------------------------------------------------------------
if NOT EXIST %MINGW% (
        wget http://%SOURCEFORGE_MIRROR%.sourceforge.net/sourceforge/mingw/%MINGW%
)
echo.
IF NOT EXIST %MINGW% (
   echo !!! Failed to download file: %MINGW%
   goto ERR
)

echo ----------------------------------------------------------------------
echo Downloading MSYS
echo ----------------------------------------------------------------------
if NOT EXIST %MSYS% (
        wget http://%SOURCEFORGE_MIRROR%.sourceforge.net/sourceforge/mingw/%MSYS%
)
echo.
IF NOT EXIST %MSYS% (
   echo !!! Failed to download file: %MSYS%
   goto ERR
)

echo ----------------------------------------------------------------------
echo Downloading ActivePerl
echo ----------------------------------------------------------------------
if NOT EXIST %ACTIVEPERL% (
        wget http://downloads.activestate.com/ActivePerl/Windows/%ACTIVEPERL_VERSION%/%ACTIVEPERL%
)
echo.
IF NOT EXIST %ACTIVEPERL% (
   echo !!! Failed to download file: %ACTIVEPERL%
   goto ERR
)

echo ----------------------------------------------------------------------
echo Starting MinGW installation
echo ----------------------------------------------------------------------
%MINGW%
IF errorlevel 1 GOTO ERR
echo.

echo ----------------------------------------------------------------------
echo Starting MSYS installation
echo   - In graphical installer, accept default options
echo   - In terminal window, answer "y" twice, then answer "c:/MinGW"
echo ----------------------------------------------------------------------
%MSYS%
IF errorlevel 1 GOTO ERR
echo.

echo ----------------------------------------------------------------------
echo Starting ActivePerl installation
echo ----------------------------------------------------------------------
%ACTIVEPERL%
IF errorlevel 1 GOTO ERR
echo.

echo ----------------------------------------------------------------------
echo Downloading wget for MinGW
echo ----------------------------------------------------------------------
if NOT EXIST %WGETBIN% (
        wget http://%SOURCEFORGE_MIRROR%.sourceforge.net/sourceforge/gnuwin32/%WGETBIN%
)
echo.
IF NOT EXIST %WGETBIN% (
   echo !!! Failed to download file: %WGETBIN%
   goto ERR
)

if NOT EXIST %WGETDEP% (
        wget http://%SOURCEFORGE_MIRROR%.sourceforge.net/sourceforge/gnuwin32/%WGETDEP%
)
echo.
IF NOT EXIST %WGETDEP% (
   echo !!! Failed to download file: %WGETDEP%
   goto ERR
)

echo ----------------------------------------------------------------------
echo Extracting wget for MinGW
echo ----------------------------------------------------------------------
unzip -o %WGETBIN% -d c:\MinGW\
echo.
IF errorlevel 1 GOTO ERR
unzip -o %WGETDEP% -d c:\MinGW\
echo.
IF errorlevel 1 GOTO ERR

echo ----------------------------------------------------------------------
echo Downloading unzip for MinGW
echo ----------------------------------------------------------------------
REM The below REM'd unzip downloads didn't work.  Added the EasyNews mirror --MrKrrtft
REM #wget http://internap.dl.sourceforge.net/sourceforge/gnuwin32/unzip-5.51-bin.zip - doesn´t work
REM #wget http://internap.dl.sourceforge.net/sourceforge/gnuwin32/unzip-5.51-1-bin.zip - Doesn't Work --MrKrrtft
if NOT EXIST %UNZIPBIN% (
        wget http://%SOURCEFORGE_MIRROR%.sourceforge.net/sourceforge/gnuwin32/%UNZIPBIN%
)
echo.
IF NOT EXIST %UNZIPBIN% (
   echo !!! Failed to download file: %UNZIPBIN%
   goto ERR
)

echo ----------------------------------------------------------------------
echo Extracting unzip for MinGW
echo ----------------------------------------------------------------------
unzip -o %UNZIPBIN% -d c:\MinGW\
echo.
IF errorlevel 1 GOTO ERR

echo ----------------------------------------------------------------------
echo Cleaning up temporary files
echo ----------------------------------------------------------------------
cd ..
rmdir /S /Q TmpInstall
echo.
IF errorlevel 1 GOTO ERR

echo MinGW successfully installed.
goto END

:ERR
echo !!! An error has occurred.  The script did not complete successfully.
cd ..

:END
pause

last edited 2009-06-30 18:34:18 by gramound