perl: created a release script for native (mingw) perl-5.12.2
[msysgit.git] / src / perl / release.cmd
blob752bc368c08ff9963585f2c9ff0a6eba6c635fb7
1 @rem Build script for compiling Perl for msysGit
2 @rem
3 @rem Perl prefers to be built from a cmd prompt and requires 'dmake'
4 @rem when using gcc as the compiler.
5 @rem
6 @rem You need a copy of sed. Don't add msysGit/bin to the path though
7 @rem as that breaks the perl build. Grab another from somewhere or
8 @rem manually fixup the patch file and comment out the sed lines here.
9 @rem
10 @rem TODO:
11 @rem It would be nice if we could fix the install layout so that it
12 @rem matched the msys-perl layout. But this failed when I tried it.
13 @rem In the meantime - make a perl shell script that runs the perl
14 @rem from mingw/perl/bin/perl so that it gets used instead of /bin/perl
15 @rem then we need to fix git-am, git- and the tests that use perl
16 @rem File::Spec::Functions should be useful.
17 @rem
18 @setlocal
20 @for /F "delims=" %%I in ("%~dp0.") do @set BASE=%%~fI
21 @for /F "delims=" %%I in ("%~dp0..\..") do @set ROOT=%%~fI
22 @set PATH=%ROOT%\mingw\bin;%PATH%
23 @set ZIP=%ROOT%\share\7-zip\7za.exe >NUL
24 @set URL=http://www.cpan.org/src/5.0
25 @set VER=5.12.2
26 @set MD5=af2df531d46b77fdf0d97eecb03eddb2
27 @set DMAKE=dmake-4.12-20090907-SHAY.zip
28 @set DMAKEMD5=6a68a9d456df62808d798bd8710ce091
30 :DOWNLOADPERL
31 @if exist perl-%VER%.tar.gz @goto CHECKSUMPERL
32 @echo Downloading perl from %URL%
33 @curl -o perl-%VER%.tar.gz %URL%/perl-%VER%.tar.gz
35 :CHECKSUMPERL
36 @echo %MD5% *perl-%VER%.tar.gz | md5sum >NUL --check -
37 @if ERRORLEVEL 0 @goto DOWNLOADDMAKE
38 @echo error: incorrect checksum for perl file
39 @goto EXIT
41 :DOWNLOADDMAKE
42 @if exist %DMAKE% @goto CHECKSUMDMAKE
43 @echo Downloading dmake
44 @curl -o %DMAKE% http://search.cpan.org/CPAN/authors/id/S/SH/SHAY/%DMAKE%
46 :CHECKSUMDMAKE
47 @echo %DMAKEMD5% *%DMAKE% | md5sum >NUL --check -
48 @if ERRORLEVEL 0 @goto UNPACKDMAKE
49 @echo error: incorrect checksum for dmake file
50 @goto EXIT
52 :UNPACKDMAKE
53 @if exist dmake @goto UNPACK
54 @if not exist dmake %ZIP% x %DMAKE%
56 :UNPACK
57 @if exist perl-%VER% goto CLEAN
58 @if not exist perl-%VER%.tar %ZIP% x perl-%VER%.tar.gz
59 @if not exist perl-%VER% %ZIP% x perl-%VER%.tar
60 @if ERRORLEVEL 0 (
61 @pushd perl-%VER%
62 @cmd /c git init
63 @cmd /c git config core.autocrlf true
64 @cmd /c git add . 2>NUL
65 @cmd /c git commit -m "Imported perl-%VER%" 2>NUL
66 @cmd /c git rm -rf . >NUL
67 @cmd /c git reset --hard HEAD
69 @popd
71 :CLEAN
72 @pushd perl-%VER%
73 @cmd /c git reset --hard HEAD
74 @cmd /c git clean -fd
75 @popd
77 :PATCH
78 @sed -e "s/@ROOT@/%ROOT:\=\\%/" patches\makefile.patch > fixed.patch
79 @dos2unix fixed.patch
80 @pushd perl-%VER%
81 @cmd /c git apply ../fixed.patch
82 @popd
84 :COMPILE
85 @pushd perl-%VER%\win32
86 @%BASE%\dmake\dmake install
87 @popd
88 @del %ROOT%\bin\perl.exe
89 @echo #!/bin/sh > %ROOT%\bin\perl
90 @echo /mingw/perl/bin/perl "$@" >> %ROOT%\bin\perl
92 :EXIT