# HG changeset patch # User Neil Muller # Date 1336772305 -7200 # Node ID a82cab951ce29af567b046fd3e8564794e6edddf # Parent a5b8d33752a41efb16565388d2f2b395b9ccced0 windows packaging stuff diff -r a5b8d33752a4 -r a82cab951ce2 scripts/makensis --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/makensis Fri May 11 23:38:25 2012 +0200 @@ -0,0 +1,32 @@ +#!/bin/sh +# Usage: makensis + +NSI_FILE="`dirname $0`/sypikslang.nsi" +SY_VERSION=`sed -ne 's/VERSION_STR = "\(.*\)"/\1/p' setup.py` +TMP_NSI="$NSI_FILE.tmp" + +# We include the pre-SP1 version of the MS redistibutable package - there are +# contradictory reports of whether the SP1 release will work with python 2.6, +# so I haven't tested it. Thiis version works for me +# This is all for the 32 bit version - things will need to be redone for +# 64 bit support. +if [ ! -f "dist/vcredist_x86.exe" ]; then + echo "Please copy the required vcredist_x86.exe version into dist/" + echo "(version downloaded from http://www.microsoft.com/downloads/en/details.aspx?FamilyID=9b2da534-3e03-4391-8a4d-074b9f2bc1b)" + exit +else + # md5sum from 2011-06-25 - MS haven't changed this package in some + # time, so hopefully this will stay valid + EXPECTED="b936f0f378b9a35489353e878154e899" + MD5=`md5sum dist/vcredist_x86.exe | cut -d " " -f 1` + if [ "$MD5" != "$EXPECTED" ]; then + echo "Unexpected md5sum for vcredist_x86.exe" + echo "expected $EXPECTED, got $MD5" + exit + fi +fi + +cp "$NSI_FILE" "$TMP_NSI" +sed -i -e "s#\\(\\s*!define SY_VERSION\\).*#\\1 \"$SY_VERSION\"#" "$TMP_NSI" +makensis "$TMP_NSI" +rm "$TMP_NSI" diff -r a5b8d33752a4 -r a82cab951ce2 scripts/sypikslang.nsi --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/sypikslang.nsi Fri May 11 23:38:25 2012 +0200 @@ -0,0 +1,142 @@ +; Compile with ./scripts/makensis ./scripts/sypikslang.nsi . +; You'll need to have previously run wine-py2exe + + !include "MUI.nsh" + +; Application Details + + !define SY_VERSION "0.0.0" ; set by makensis scripts + !define SY_UNPACK "sypikslang-${SY_VERSION}" + !define DIST_FOLDER "../dist" + + Name "Sypikslang" + OutFile "${DIST_FOLDER}\sypikslang-${SY_VERSION}.exe" + InstallDir "$PROGRAMFILES\Sypikslang-${SY_VERSION}" + +; Interface Settings + + !define MUI_ABORTWARNING + + !define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\arrow-install.ico" + !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\arrow-uninstall.ico" + + !define MUI_HEADERIMAGE + !define MUI_HEADERIMAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Header\orange.bmp" + !define MUI_HEADERIMAGE_UNBITMAP "${NSISDIR}\Contrib\Graphics\Header\orange-uninstall.bmp" + +; Dependencies + + !define COMBINED_LICENSE "../LICENSE.txt" + !define SY_ICON "../data/icons/icon.ico" + !define SY_WINDOWS_ICON "data\icons\icon.ico" + !define SY_PY2EXE_ZIP "sypikslang-${SY_VERSION}.zip" + !define VCREDIST "vcredist_x86.exe" + !define VCREDIST_KEY "{FF66E9F6-83E7-3A3E-AF14-8DE9A809A6A4}" + !define UNINSTALLER "Uninstaller.exe" + +; Pages + + !insertmacro MUI_PAGE_LICENSE "${COMBINED_LICENSE}" + !insertmacro MUI_PAGE_DIRECTORY + !insertmacro MUI_PAGE_INSTFILES + + !insertmacro MUI_UNPAGE_CONFIRM + !insertmacro MUI_UNPAGE_INSTFILES + +; Languages + + !insertmacro MUI_LANGUAGE "English" + +; Other Stuff + + Icon "${SY_ICON}" + SetCompress off ; all the big stuff is already compressed + +; Installer Sections + +Section "vcredist" + + SetOutPath "$INSTDIR" + File "${DIST_FOLDER}\${VCREDIST}" + ; Check if it's already installed by checking for the uninstall key + ; Idea and key value to check taken post and comments at: + ; http://blogs.msdn.com/b/astebner/archive/2009/01/29/9384143.aspx + + ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${VCREDIST_KEY}" UninstallString + ; NSIS docs say if the key doesn't exist, we get an error and an empty string + IfErrors install done + +install: + ; Runs install with progress bar and no cancel button + ; Details taken from + ; http://blogs.msdn.com/b/astebner/archive/2010/10/18/9513328.aspx + + DetailPrint "Installing required MS runtime libraries" + ExecWait "$INSTDIR/${VCREDIST} /qb!" + +done: + + DetailPrint "MS runtime libraries already installed, skipping" + +SectionEnd + +Section "Sypikslang" + SetOutPath "$INSTDIR" + + WriteUninstaller "$INSTDIR\${UNINSTALLER}" + + File "${DIST_FOLDER}\${SY_PY2EXE_ZIP}" + File "${SY_ICON}" + + ZipDLL::extractall "$INSTDIR\${SY_PY2EXE_ZIP}" "$INSTDIR" + Delete "$INSTDIR\${SY_PY2EXE_ZIP}" + + CreateDirectory "$SMPROGRAMS\Sypikslang" + + # link.lnk target.exe + # parameters icon.file icon_index_number start_options + # keyboard_shortcut description + + CreateShortCut "$SMPROGRAMS\Sypikslang\Sypikslang ${SY_VERSION}.lnk" "$INSTDIR\${SY_UNPACK}\sypikslang.exe" \ + "" "$INSTDIR\${SY_UNPACK}\${SY_WINDOWS_ICON}" "" SW_SHOWNORMAL \ + "" "Sypikslang" + + CreateShortCut "$SMPROGRAMS\Sypikslang\Uninstall Sypikslang ${SY_VERSION}.lnk" "$INSTDIR\${UNINSTALLER}" \ + "" "" "" SW_SHOWNORMAL \ + "" "Uninstall Sypikslang" + +SectionEnd + +UninstallText "This will uninstall Sypikslang ${SY_VERSION}." +UninstallIcon "${SY_ICON}" + +Section "Uninstall" + ; Delete files not deleted during install + Delete "$INSTDIR\${SY_ICON}" + + ; Remove py2exe folder + RMDir /r /REBOOTOK "$INSTDIR\${SY_UNPACK}" + + ; Remove shortcut links + Delete "$SMPROGRAMS\Sypikslang\Sypikslang ${SY_VERSION}.lnk" + Delete "$SMPROGRAMS\Sypikslang\Uninstall Sypikslang ${SY_VERSION}.lnk" + + ; Remove shortcut folder if no links left + IfFileExists "$SMPROGRAMS\Sypikslang\*.lnk" shortcuts_exist 0 + RMDir /REBOOTOK "$SMPROGRAMS\Sypikslang" + shortcuts_exist: + + ; Final Clean up (no point doing this while the uninstall is incomplete) + RMDir /r /REBOOTOK $INSTDIR + + ; Offer to reboot if needed + IfRebootFlag 0 noreboot + MessageBox MB_YESNO "A reboot is required to finish the uninstallation. Do you wish to reboot now?" IDNO noreboot + Reboot + noreboot: + + ; TODO: We don't touch the vcredist stuff, since we can't tell a) if we were + ; the ones who installed it and b) if anything else needs it. This may cause + ; cruft on the users system, so should we tell the user? + +SectionEnd diff -r a5b8d33752a4 -r a82cab951ce2 scripts/wine-py2exe --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/wine-py2exe Fri May 11 23:38:25 2012 +0200 @@ -0,0 +1,82 @@ +#!/bin/sh +# wine-py2exe +# +# Usage: wine-py2exe + +MM_VERSION=`sed -nre 's/VERSION_STR = "(.*)"/\1/p' setup.py` +BUILD_FOLDER="sypikslang-${MM_VERSION}" +ZIP_NAME="${BUILD_FOLDER}.zip" +PY2EXE_LOG="py2exe.log" + +WINE_PYTHON=`winepath "C:/Python26"` +WINE_SYS32=`winepath "C:/windows/system32"` + +# +# Run py2exe build under wine +# + +echo "=== Running wine python setup.py ===" +echo "" +echo " Sypikslang version: ${MM_VERSION}" +echo " Writing log to ${PY2EXE_LOG}." +echo "" +echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" +echo " WARNING: After running please fix the sypikslang.exe" +echo " checksum and executable size using PETools!" +echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" +echo "" + +rm -rf "dist/${BUILD_FOLDER}" +mkdir -p "dist/${BUILD_FOLDER}" +rm -rf "dist/${ZIP_NAME}" + +wine python setup.py py2exe >${PY2EXE_LOG} 2>&1 + +# +# Copy dependencies py2exe missed +# + +echo "=== Copying dependencies that py2exe missed ===" +echo "" + +DEST="dist/${BUILD_FOLDER}" + +if [ -f "${WINE_SYS32}/python26.dll" ]; then + cp -v "${WINE_SYS32}/python26.dll" "${DEST}" +else + # Try the python installation + cp -v "${WINE_PYTHON}//python26.dll" "${DEST}" +fi +# TODO: the line below copies in the Wine placeholder DLL (oddly this +# doesn't appear to break anything) +# Decide whether to keep this or not. +# cp -v "${WINE_SYS32}/msvcr80.dll" "${DEST}" + +echo "'data' -> '${DEST}/data'" +hg archive -I "path:data/" "${DEST}" + +echo "'${WINE_PYTHON}/Lib/site-packages/pygame' -> '${DEST}'" +rm -rf "${DEST}/pygame" +cp -R "${WINE_PYTHON}/Lib/site-packages/pygame" "${DEST}" +rm -rf "${DEST}/pygame/examples" "${DEST}/pygame/tests" "${DEST}/pygame/docs" + +# +# create zip file +# + +echo "=== Creating zip of patched py2exe dist folder ===" +echo "" +echo " Zip file: dist/${ZIP_NAME}" +echo " Build folder: dist/${BUILD_FOLDER}" +echo "" + +cd dist +rm -f "$ZIP_NAME" +zip -r -q "$ZIP_NAME" "$BUILD_FOLDER" +cd .. + +echo "=== Done ===" +echo "" +echo -n " "; du -sh dist/${ZIP_NAME} +echo -n " "; du -sh dist/${BUILD_FOLDER} +echo ""