From: Neil Date: Sun, 11 Sep 2016 12:30:40 +0000 (+0200) Subject: The usual windows packaging stuff X-Git-Tag: tabakrolletjie-v1.0.0~7 X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=980e10ce19a73a84d7d3d3ac10e11462a0a7bfb1;p=tabakrolletjie.git The usual windows packaging stuff --- diff --git a/packaging/makensis b/packaging/makensis new file mode 100755 index 0000000..26f388c --- /dev/null +++ b/packaging/makensis @@ -0,0 +1,31 @@ +#!/bin/sh +# Usage: makensis + +NSI_FILE="`dirname $0`/tabakrolletjie.nsi" +WS_VERSION=`sed -nre 's/( *)version="(.*)",/\2/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.7, +# so I haven't tested it. Thiis version works for me +# This is all for the 32 bit version +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 WS_VERSION\\).*#\\1 \"$WS_VERSION\"#" "$TMP_NSI" +makensis "$TMP_NSI" +rm "$TMP_NSI" diff --git a/packaging/tabakrolletjie.nsi b/packaging/tabakrolletjie.nsi new file mode 100644 index 0000000..2d2eb50 --- /dev/null +++ b/packaging/tabakrolletjie.nsi @@ -0,0 +1,143 @@ +; Compile with ./scripts/makensis ./scripts/tabakrolletjie.nsi . +; You'll need to have previously run wine-py2exe + + !include "MUI.nsh" + +; Application Details + + !define WS_VERSION "0.0.0" ; set by makensis scripts + !define WS_UNPACK "tabakrolletjie-${WS_VERSION}" + !define DIST_FOLDER "../dist" + + Name "Attack of the Giant Space Mould" + OutFile "${DIST_FOLDER}\tabakrolletjie-${WS_VERSION}.exe" + InstallDir "$PROGRAMFILES\Attack_of_the_Giant_Space_Mould-${WS_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 WS_PY2EXE_ZIP "tabakrolletjie-${WS_VERSION}.zip" + !define WS_ICON "../data/images/icons/tabakrolletjie_icon.ico" + !define WS_WINDOWS_ICON "data\images\icons\tabakrolletjie_icon.ico" + !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 "${WS_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 "Attack of the Giant Space Mould" + SetOutPath "$INSTDIR" + + WriteUninstaller "$INSTDIR\${UNINSTALLER}" + + File "${DIST_FOLDER}\${WS_PY2EXE_ZIP}" + File "${WS_ICON}" + + ZipDLL::extractall "$INSTDIR\${WS_PY2EXE_ZIP}" "$INSTDIR" + Delete "$INSTDIR\${WS_PY2EXE_ZIP}" + + CreateDirectory "$SMPROGRAMS\Attack of the Giant Space Mould" + + # link.lnk target.exe + # parameters icon.file icon_index_number start_options + # keyboard_shortcut description + + CreateShortCut "$SMPROGRAMS\Attack of the Giant Space Mould\Attack of the Giant Space Mould ${WS_VERSION}.lnk" "$INSTDIR\${WS_UNPACK}\tabakrolletjie.exe" \ + "" "$INSTDIR\${WS_UNPACK}\${WS_WINDOWS_ICON}" "" SW_SHOWNORMAL \ + "" "Attack of the Giant Space Mould" + + CreateShortCut "$SMPROGRAMS\Attack of the Giant Space Mould\Uninstall Attack of the Giant Space Mould ${WS_VERSION}.lnk" "$INSTDIR\${UNINSTALLER}" \ + "" "" "" SW_SHOWNORMAL \ + "" "Uninstall Attack of the Giant Space Mould" + +SectionEnd + +UninstallText "This will uninstall Attack of the Giant Space Mould ${WS_VERSION}." +UninstallIcon "${WS_ICON}" + +Section "Uninstall" + ; Delete files not deleted during install + + Delete "$INSTDIR\${WS_ICON}" + + ; Remove py2exe folder + RMDir /r /REBOOTOK "$INSTDIR\${WS_UNPACK}" + + ; Remove shortcut links + Delete "$SMPROGRAMS\Attack of the Giant Space Mould\Attack of the Giant Space Mould ${WS_VERSION}.lnk" + Delete "$SMPROGRAMS\Attack of the Giant Space Mould\Uninstall Attack of the Giant Space Mould ${WS_VERSION}.lnk" + + ; Remove shortcut folder if no links left + IfFileExists "$SMPROGRAMS\Attack of the Giant Space Mould\*.lnk" shortcuts_exist 0 + RMDir /REBOOTOK "$SMPROGRAMS\Attack of the Giant Space Mould" + 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 --git a/packaging/wine-py2exe b/packaging/wine-py2exe new file mode 100755 index 0000000..d87ba4c --- /dev/null +++ b/packaging/wine-py2exe @@ -0,0 +1,73 @@ +#!/bin/sh +# wine-py2exe +# +# Usage: wine-py2exe + +WS_VERSION=`sed -nre 's/( *)version="(.*)",/\2/p' setup.py` +BUILD_FOLDER="tabakrolletjie-${WS_VERSION}" +ZIP_NAME="${BUILD_FOLDER}.zip" +PY2EXE_LOG="py2exe.log" + +WINE_PYTHON=`winepath "C:/Python27"` +WINE_SYS32=`winepath "C:/windows/system32"` + +# +# Run py2exe build under wine +# + +echo "=== Running wine python setup.py ===" +echo "" +echo " Attack of the Giant Space Mould version: ${WS_VERSION}" +echo " Writing log to ${PY2EXE_LOG}." +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}" + +cp -v "${WINE_SYS32}/python27.dll" "${DEST}" + +echo "'data' -> '${DEST}/data'" +cp -R data ${DEST}/data + +echo "'${WINE_PYTHON}/Lib/site-packages/pygame' -> '${DEST}'" +rm -rf "${DEST}/pygame" +cp -R "${WINE_PYTHON}/Lib/site-packages/pygame" "${DEST}" +echo "'${WINE_PYTHON}/Lib/site-packages/pymunk' -> '${DEST}'" +rm -rf "${DEST}/pymunk" +cp -R "${WINE_PYTHON}/Lib/site-packages/pymunk" "${DEST}" +# Needed so we'll find it when running +cp -R "${WINE_PYTHON}/Lib/site-packages/pymunk/chipmunk.dll" "${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 ""