Skip to content

Instantly share code, notes, and snippets.

@PandaEox
Created February 11, 2015 06:23
Show Gist options
  • Save PandaEox/e1c322631d97f648a8f2 to your computer and use it in GitHub Desktop.
Save PandaEox/e1c322631d97f648a8f2 to your computer and use it in GitHub Desktop.
Building RPMs on Windows machines
SETLOCAL
PUSHD .
REM Update buildroot path
FOR /F "tokens=*" %%i in ('cygpath %3') do SET NEW_BUILDROOT=%%i
REM Update topdir path
SET TOPDIR=%5
SET TOPDIR=%TOPDIR:~9,-1%
FOR /F "tokens=*" %%i in ('cygpath "%TOPDIR%"') do SET NEW_TOPDIR=%%i
REM Replace path in spec-file
SET OLD_PATH=%TOPDIR:\=\\%
SET NEW_PATH=%NEW_TOPDIR:/=\/%
REM Original sed command REM
sed -s -i -e s/%OLD_PATH%\\/%NEW_PATH%\//g %8
REM replace \ with / i.e. escape \\ replace with escape \/
sed -s -i -e s/\\/\//g %8
REM Execute rpmbuild
bash -c "rpmbuild %1 %2 %NEW_BUILDROOT% %4 ""_topdir %NEW_TOPDIR%"" %6 "%7" --define ""_build_name_fmt %%{ARCH}/%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm"" %8"
POPD
ENDLOCAL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment