Last active
February 11, 2024 15:20
Star
You must be signed in to star a gist
batch to install Opam/OCaml/ocamlfind/Camlp5 for GeneWeb under Windows
This file contains 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
@echo off | |
REM Quick test for Windows generation: UAC aware or not ; all OS before NT4 ignored for simplicity | |
SET NewOSWith_UAC=YES | |
VER | FINDSTR /IL "5." > NUL | |
IF %ERRORLEVEL% == 0 SET NewOSWith_UAC=NO | |
VER | FINDSTR /IL "4." > NUL | |
IF %ERRORLEVEL% == 0 SET NewOSWith_UAC=NO | |
REM Test if Admin | |
CALL fltmc >nul 2>&1 | |
IF NOT %ERRORLEVEL% == 0 ( | |
if /i "%NewOSWith_UAC%"=="YES" ( | |
rem Start batch again with UAC | |
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs" | |
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs" | |
"%temp%\getadmin.vbs" | |
del "%temp%\getadmin.vbs" | |
exit /B | |
) | |
rem You need administrator's right on Command Prompt to launch this script. | |
rem Program will now start again automatically with admin rights! | |
rem pause | |
goto :EOF | |
) | |
:INSTALL | |
REM DROPBOX LINKS FOR OPAM32/64.TAR.GZ COME FROM https://github.com/fdopen/opam-repository-mingw RELEASES NOT DROPBOX | |
REM SEE https://github.com/fdopen/opam-repository-mingw/issues/26 | |
IF EXIST "%PROGRAMFILES(X86)%" (set CYG_ROOT=c:\cygwin64) ELSE (set CYG_ROOT=c:\cygwin) | |
set /p CYG_ROOT="Enter directory for installation (if left empty default directory will be %CYG_ROOT%): " | |
set CYG_BASH=%CYG_ROOT%\bin\bash -lc | |
mkdir %CYG_ROOT% | |
IF EXIST "%PROGRAMFILES(X86)%" (GOTO 64BIT) ELSE (GOTO 32BIT) | |
:64BIT | |
IF NOT EXIST setup-x86_64.exe GOTO PS64 | |
echo Installing Cygwin/Opam/Camlp5/Dune for a 64 bit operating system into %CYG_ROOT% | |
setup-x86_64.exe -qnNdO -R %CYG_ROOT% -s http://cygwin.mirror.constant.com -l %CYG_ROOT%/var/cache/setup -P rsync -P patch -P diffutils -P curl -P make -P unzip -P git -P m4 -P perl -P perl-IPC-System-Simple -P mingw64-x86_64-gcc-core -P mingw64-x86_64-gmp | |
%CYG_BASH% "curl -fsSL -o opam64.tar.xz https://github.com/fdopen/opam-repository-mingw/releases/download/0.0.0.2t/opam64.tar.xz" | |
%CYG_BASH% "tar -xf opam64.tar.xz" | |
%CYG_BASH% "opam64/install.sh" | |
%CYG_BASH% "opam init -a mingw https://github.com/ocaml-opam/opam-repository-mingw.git#sunset -c 4.14.1+mingw64c --disable-sandboxing" | |
::set PATH=%PATH%;%CYG_ROOT%\home\%USERNAME%\.opam\4.14.1+mingw64c\bin | |
GOTO END | |
:32BIT | |
IF NOT EXIST setup-x86.exe GOTO PS32 | |
echo Installing Cygwin/Opam/ocamlfind/Camlp5 for a 32 bit operating system into %CYG_ROOT% | |
setup-x86.exe -qnNdO -R %CYG_ROOT% -s http://cygwin.mirror.constant.com -l %CYG_ROOT%/var/cache/setup -P rsync -P patch -P diffutils -P curl -P make -P unzip -P git -P m4 -P perl -P perl-IPC-System-Simple -P mingw64-i686-gcc-core -P mingw64-i686-gmp | |
%CYG_BASH% "curl -fsSL -o opam32.tar.xz https://github.com/fdopen/opam-repository-mingw/releases/download/0.0.0.2t/opam32.tar.xz" | |
%CYG_BASH% "tar -xf opam32.tar.xz" | |
%CYG_BASH% "opam32/install.sh" | |
%CYG_BASH% "opam init -a mingw https://github.com/ocaml-opam/opam-repository-mingw.git#sunset -c 4.14.1+mingw32c --disable-sandboxing" | |
::set PATH=%PATH%;%CYG_ROOT%\home\%USERNAME%\.opam\4.14.1+mingw32c\bin | |
GOTO END | |
:END | |
set PATH=%PATH%;%CYG_ROOT%\usr\x86_64-w64-mingw32\sys-root\mingw\bin;%CYG_ROOT%\bin | |
%CYG_BASH% "opam install -y calendars camlp5.8.00.03 camlp-streams cppo dune jingoo markup ppx_blob ppx_deriving ppx_import stdlib-shims syslog unidecode.0.2.0 uri uucp uutf uunf" | |
%CYG_BASH% "eval $(ocaml-env cygwin)" | |
set GITCLONE=y | |
set /p GITCLONE="Compile GeneWeb master in Cygwin home directory [y/n]? " | |
IF NOT "%GITCLONE%"=="y" GOTO :EOF | |
%CYG_BASH% "git clone https://github.com/geneweb/geneweb" | |
%CYG_BASH% "cd ~/geneweb && ocaml ./configure.ml --sosa-legacy --gwdb-legacy --release" | |
%CYG_BASH% "cd ~/geneweb && make distrib && ./distribution/gw/gwd -cgi" | |
cd %CYG_ROOT%/home/%USERNAME%/geneweb/distribution | |
echo If you see copyright footer from gwd in last lines, GeneWeb should be working, launch it with gwd.bat! | |
%CYG_BASH% "echo GeneWeb is in ~/geneweb/distribution/" | |
GOTO EOF | |
:PS64 | |
IF EXIST "%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe" GOTO PS64B ELSE ( | |
echo You need to download Cygwin x64 setup from https://www.cygwin.com/setup-x86_64.exe before launching script. | |
GOTO EOF) | |
:PS64B | |
powershell.exe -Command (new-object System.Net.WebClient).DownloadFile('https://www.cygwin.com/setup-x86_64.exe','setup-x86_64.exe') | |
GOTO 64BIT | |
:PS32 | |
IF EXIST "%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe" GOTO PS32B ELSE ( | |
echo You need to download Cygwin x86 setup from https://www.cygwin.com/setup-x86.exe before launching script. | |
GOTO EOF) | |
:PS32B | |
powershell.exe -Command (new-object System.Net.WebClient).DownloadFile('https://www.cygwin.com/setup-x86.exe','setup-x86.exe') | |
GOTO 32BIT | |
:EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment