diff --git a/docker-builder-data/build/script/common/manager.sh b/docker-builder-data/build/script/common/manager.sh index 48e3c0f..552b90b 100755 --- a/docker-builder-data/build/script/common/manager.sh +++ b/docker-builder-data/build/script/common/manager.sh @@ -195,6 +195,21 @@ copy() { fi } +foreachfile() { + local FILE=$1 + local COMMAND=$2 + if [ ! -x "$FILE" ]; then + return 1 + fi + if [ -d "$FILE" ]; then + ls -1 "$FILE" | while read SUBFILE; do + if ! $COMMAND "$FILE/$SUBFILE" ${@:3}; then + return 1 + fi + done + fi +} + readdir() { local FILE=$1 if [ -d "$FILE" ]; then diff --git a/docker-builder-data/build/script/packet/opentoonz-nsis.files/opentoonz.nsi b/docker-builder-data/build/script/packet/opentoonz-nsis.files/opentoonz.nsi new file mode 100644 index 0000000..7e08320 --- /dev/null +++ b/docker-builder-data/build/script/packet/opentoonz-nsis.files/opentoonz.nsi @@ -0,0 +1,176 @@ +;-------------------------------- +; Requires files: +; config.nsh +; files-install.nsh +; files-uninstall.nsh +; files-stuff-install.nsh +; files-stuff-uninstall.nsh + +; Defines which will set by 'config.nsh': +; PK_NAME - XxxxxXxxxx - name without spaces +; PK_NAME_FULL - Xxxxx Xxxxxxxxxx - full name, may be with spaces +; PK_ARCH - XX - architecture, 32 or 64 +; PK_VERSION - X.X - first two numbers of version +; PK_VERSION_FULL - X.X.X-xxxxx-xxxxx - full version, without spaces +; PK_EXECUTABLE - xxx\XxxxXxxx-xxx_xxx.exe - subpath to executable file + +!include "config.nsh" + +;-------------------------------- + +!include "MUI2.nsh" + +;second directory selection + +;-------------------------------- + +; The name of the installer +Name "${PK_NAME_FULL} ${PK_VERSION_FULL}" + +; The file to write +OutFile "${PK_NAME}-${PK_VERSION_FULL}.exe" + +; The default installation directory and registry +InstallDir "$PROGRAMFILES${PK_ARCH}\${PK_NAME}" +Var STUFFDIR + +; Request application privileges for Windows Vista +RequestExecutionLevel highest + +!insertmacro MUI_LANGUAGE "English" + +!define MUI_ABORTWARNING + +!define SHCNE_ASSOCCHANGED 0x8000000 +!define SHCNF_IDLIST 0 + +!define PRODUCT_REG_KEY "Software\${PK_NAME}" +!define PRODUCT_UNINSTALL_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PK_NAME}" +!define PRODUCT_UNINSTALL_KEY2 "Software\Microsoft\Windows\CurrentVersion\Uninstall\{D9A9B1A3-9370-4BE9-9C8F-7B52EEECB973}_is1" +!define PRODUCT_UNINSTALL_EXE "uninstall-${PK_NAME}.exe" + +;-------------------------------- + +; Pages + +!insertmacro MUI_PAGE_COMPONENTS + +!define MUI_PAGE_CUSTOMFUNCTION_LEAVE InstDirPageLeave +!insertmacro MUI_PAGE_DIRECTORY + +Function InstDirPageLeave + StrCpy $STUFFDIR "C:\${PK_NAME} ${PK_VERSION} stuff" +FunctionEnd + +!define MUI_DIRECTORYPAGE_VARIABLE $STUFFDIR +!define MUI_DIRECTORYPAGE_TEXT_TOP "Choose stuff directory for ${PK_NAME}..." +!define MUI_DIRECTORYPAGE_TEXT_DESTINATION "Stuff Directory:" +!insertmacro MUI_PAGE_DIRECTORY +!insertmacro MUI_PAGE_INSTFILES + +!insertmacro MUI_UNPAGE_CONFIRM +!insertmacro MUI_UNPAGE_INSTFILES + +;-------------------------------- +; Installer +;-------------------------------- + +Section "${PK_NAME_FULL} (required)" + SetRegView ${PK_ARCH} + + SectionIn RO + + SetOutPath "$INSTDIR" + !include "files-install.nsh" + + SetOutPath "$STUFFDIR" + !include "files-stuff-install.nsh" + + WriteRegStr HKLM "${PRODUCT_REG_KEY}" "Path" "$INSTDIR" + WriteRegStr HKLM "${PRODUCT_REG_KEY}" "Version" "${PK_VERSION_FULL}" + WriteRegStr HKLM "${PRODUCT_REG_KEY}\${PK_NAME}\${PK_VERSION}" "TOONZROOT" "$STUFFDIR" + + ; Write the uninstall keys for Windows + WriteRegStr HKLM "${PRODUCT_UNINSTALL_KEY}" "DisplayName" "${PK_NAME_FULL}" + WriteRegStr HKLM "${PRODUCT_UNINSTALL_KEY}" "DisplayVersion" "${PK_VERSION_FULL}" + WriteRegStr HKLM "${PRODUCT_UNINSTALL_KEY}" "UninstallString" '"$INSTDIR\${PRODUCT_UNINSTALL_EXE}"' + WriteRegDWORD HKLM "${PRODUCT_UNINSTALL_KEY}" "NoModify" 1 + WriteRegDWORD HKLM "${PRODUCT_UNINSTALL_KEY}" "NoRepair" 1 + + System::Call 'Shell32::SHChangeNotify(i ${SHCNE_ASSOCCHANGED}, i ${SHCNF_IDLIST}, i 0, i 0)' + + SetOutPath "$INSTDIR" + WriteUninstaller "${PRODUCT_UNINSTALL_EXE}" +SectionEnd + +; Optional section (can be disabled by the user) +Section "Start Menu Shortcuts" + SetRegView ${PK_ARCH} + + SetOutPath "$INSTDIR\bin" + + SetShellVarContext All + CreateDirectory "$SMPROGRAMS\${PK_NAME_FULL}" + CreateShortCut "$SMPROGRAMS\${PK_NAME_FULL}\Uninstall ${PK_NAME_FULL}.lnk" "$INSTDIR\uninstall-${PK_NAME}.exe" "" "$INSTDIR\uninstall-${PK_NAME}.exe" 0 + CreateShortCut "$SMPROGRAMS\${PK_NAME_FULL}\${PK_NAME_FULL}.lnk" "$INSTDIR\${PK_EXECUTABLE}" "" "$INSTDIR\${PK_EXECUTABLE}" 0 +SectionEnd + +;-------------------------------- +; Uninstaller +;-------------------------------- + +Section "Uninstall" + SetRegView ${PK_ARCH} + + ReadRegStr $STUFFDIR HKLM "${PRODUCT_REG_KEY}\${PK_NAME}\${PK_VERSION}" "TOONZROOT" + + ; Remove registry keys + DeleteRegKey HKLM "${PRODUCT_REG_KEY}" + DeleteRegKey HKLM "${PRODUCT_UNINSTALL_KEY}" + + ; Remove files and uninstaller + !include "files-stuff-uninstall.nsh" + !include "files-uninstall.nsh" + Delete "$INSTDIR\${PRODUCT_UNINSTALL_EXE}" + + ; Remove shortcuts, if any + SetShellVarContext All + Delete "$SMPROGRAMS\${PK_NAME_FULL}\${PK_NAME_FULL}.lnk" + Delete "$SMPROGRAMS\${PK_NAME_FULL}\Uninstall ${PK_NAME_FULL}.lnk" + + ; Remove directories used + RMDir "$SMPROGRAMS\${PK_NAME_FULL}" + RMDir "$STUFFDIR" + RMDir "$INSTDIR" + + System::Call 'Shell32::SHChangeNotify(i ${SHCNE_ASSOCCHANGED}, i ${SHCNF_IDLIST}, i 0, i 0)' +SectionEnd + +Function .onInit + SetRegView 32 + + ; Check previous installation + ReadRegStr $R0 HKLM "${PRODUCT_UNINSTALL_KEY}" "UninstallString" + StrCmp $R0 "" 0 oops + + ; Check previous installation 2 + ReadRegStr $R0 HKLM "${PRODUCT_UNINSTALL_KEY2}" "UninstallString" + StrCmp $R0 "" 0 oops + + SetRegView 64 + + ; Check previous installation + ReadRegStr $R0 HKLM "${PRODUCT_UNINSTALL_KEY}" "UninstallString" + StrCmp $R0 "" 0 oops + + ; Check previous installation 2 + ReadRegStr $R0 HKLM "${PRODUCT_UNINSTALL_KEY2}" "UninstallString" + StrCmp $R0 "" 0 oops + + BringToFront + Return + +oops: + MessageBox MB_OK|MB_ICONEXCLAMATION "Another version of ${PK_NAME_FULL} appears to be installed. Please, uninstall it first?" + Abort +FunctionEnd diff --git a/docker-builder-data/build/script/packet/opentoonz-nsis.sh b/docker-builder-data/build/script/packet/opentoonz-nsis.sh new file mode 100644 index 0000000..511110a --- /dev/null +++ b/docker-builder-data/build/script/packet/opentoonz-nsis.sh @@ -0,0 +1,70 @@ +DEPS="opentoonz-master" + +pkfunc_register_file() { + local FILE=$1 + local WIN_FILE=$(echo "$FILE" | sed "s|\/|\\\\|g") + ! [ -L "$FILE" ] || return 0 + + if [ "${FILE:0:8}" = "./files-" ]; then + true # skip + elif [ "${FILE:0:24}" = "./share/opentoonz/stuff/" ]; then + if [ -d "$FILE" ]; then + echo "CreateDirectory \"\$STUFFDIR\\${WIN_FILE:24}\"" >> "files-stuff-install.nsh" + foreachfile $FILE pkfunc_register_file + echo "RMDir \"\$STUFFDIR\\${WIN_FILE:24}\"" >> "files-stuff-uninstall.nsh" + else + echo "File \"/oname=${WIN_FILE:24}\" \"${WIN_FILE:2}\"" >> "files-stuff-install.nsh" + echo "Delete \"\$STUFFDIR\\${WIN_FILE:24}\"" >> "files-stuff-uninstall.nsh" + fi + elif [ "${FILE:0:2}" = "./" ]; then + if [ -d "$FILE" ]; then + echo "CreateDirectory \"\$INSTDIR\\${WIN_FILE:2}\"" >> "files-install.nsh" + foreachfile $FILE pkfunc_register_file + echo "RMDir \"\$INSTDIR\\${WIN_FILE:2}\"" >> "files-uninstall.nsh" + else + echo "File \"/oname=${WIN_FILE:2}\" \"${WIN_FILE:2}\"" >> "files-install.nsh" + echo "Delete \"\$INSTDIR\\${WIN_FILE:2}\"" >> "files-uninstall.nsh" + fi + else + foreachfile $FILE pkfunc_register_file + fi +} + +pkinstall_release() { + # create temporary dir + rm -rf "$INSTALL_RELEASE_PACKET_DIR/installer" + mkdir -p "$INSTALL_RELEASE_PACKET_DIR/installer" + cd "$INSTALL_RELEASE_PACKET_DIR/installer" || return 1 + + # copy files + copy "$ENVDEPS_RELEASE_PACKET_DIR" "./" || return 1 + + # get version + local LOCAL_VERSION=$(cat "$ENVDEPS_RELEASE_PACKET_DIR/version-opentoonz-master") + + # create file lists + echo "create file lists" + pkfunc_register_file . + echo "created" + + # copy NSIS configuration + cp "$FILES_PACKET_DIR/opentoonz.nsi" "./" || return 1 + + # create config.nsh (see opentoons.nsi) + cat > config.nsh << EOF +!define PK_NAME "OpenToonz" +!define PK_NAME_FULL "OpenToonz" +!define PK_ARCH "$ARCH" +!define PK_VERSION "${LOCAL_VERSION:0:3}" +!define PK_VERSION_FULL "${LOCAL_VERSION:0:11}" +!define PK_EXECUTABLE "bin\\\${PK_NAME}_\${PK_VERSION}.exe" +EOF + + # let's go + makensis opentoonz.nsi || return 1 + + # remove temporary dir + cd "$INSTALL_RELEASE_PACKET_DIR" || return 1 + mv installer/*.exe ./ || return 1 + rm -rf "installer" +} diff --git a/docker-builder-data/build/script/packet/qt-5.7.sh b/docker-builder-data/build/script/packet/qt-5.7.sh index 9e44672..e397a1a 100644 --- a/docker-builder-data/build/script/packet/qt-5.7.sh +++ b/docker-builder-data/build/script/packet/qt-5.7.sh @@ -59,3 +59,10 @@ EOF return 1 fi } + +pkhook_postinstall_release() { + cd "$INSTALL_RELEASE_PACKET_DIR" || return 1 + rm -rf "examples" || return 1 + rm -rf "mkspecs" || return 1 + rm -rf "doc" || return 1 +} \ No newline at end of file