diff --git a/binary/mysql/mysql.py b/binary/mysql/mysql.py --- a/binary/mysql/mysql.py +++ b/binary/mysql/mysql.py @@ -54,22 +54,30 @@ self.subinfo.options.package.packSources = False def install(self): - libname = "mariadb" if self.subinfo.options.dynamic.useMariaDB else "mysql" shutil.copytree(os.path.join(self.sourceDir(), "bin"), os.path.join(self.installDir(), "bin"), - ignore=shutil.ignore_patterns('*.pdb', '*.map', '*test*', 'mysqld-debug.exe', '*.pl', 'debug*')) - utils.copyFile(os.path.join(self.sourceDir(), "lib", f"lib{libname}.dll"), os.path.join(self.installDir(), "bin")) - if not self.subinfo.options.dynamic.useMariaDB: - utils.copyFile(os.path.join(self.sourceDir(), "lib", f"lib{libname}d.dll"), os.path.join(self.installDir(), "bin")) - shutil.copytree(os.path.join(self.sourceDir(), "lib"), os.path.join(self.installDir(), "lib"), - ignore=shutil.ignore_patterns('*.pdb', '*.map', 'debug*', f'lib{libname}.dll', - f'lib{libname}.dll', f'{libname}*')) - if CraftCore.compiler.isMinGW(): - utils.createImportLibs(f"lib{libname}d", self.installDir()) - utils.createImportLibs(f"lib{libname}", self.installDir()) + ignore=shutil.ignore_patterns('*.pdb', '*.map', '*test*', 'mysqld-debug.exe', 'echo.exe', '*.pl', 'debug*')) + shutil.copytree(os.path.join(self.sourceDir(), "lib", "plugin"), os.path.join(self.installDir(), "lib", "plugin"), + ignore=shutil.ignore_patterns('*.pdb', '*.map', 'debug*')) shutil.copytree(os.path.join(self.sourceDir(), "include"), os.path.join(self.installDir(), "include"), ignore=shutil.ignore_patterns('*.def')) shutil.copytree(os.path.join(self.sourceDir(), "share"), os.path.join(self.installDir(), "share"), ignore=shutil.ignore_patterns('Makefile*')) + + if self.subinfo.options.dynamic.useMariaDB: + utils.copyFile(os.path.join(self.sourceDir(), "lib", f"mariadbclient.lib"), os.path.join(self.installDir(), "lib")) + utils.copyFile(os.path.join(self.sourceDir(), "lib", f"libmariadb.lib"), os.path.join(self.installDir(), "lib")) + utils.copyFile(os.path.join(self.sourceDir(), "lib", f"libmariadb.dll"), os.path.join(self.installDir(), "bin")) + if CraftCore.compiler.isMinGW(): + utils.createImportLibs(f"libmariadb", self.installDir()) + else: + utils.copyFile(os.path.join(self.sourceDir(), "lib", f"mysqlclient.lib"), os.path.join(self.installDir(), "lib")) + utils.copyFile(os.path.join(self.sourceDir(), "lib", f"libmysql.lib"), os.path.join(self.installDir(), "lib")) + utils.copyFile(os.path.join(self.sourceDir(), "lib", f"libmysqld.lib"), os.path.join(self.installDir(), "lib")) + utils.copyFile(os.path.join(self.sourceDir(), "lib", f"libmysqld.dll"), os.path.join(self.installDir(), "bin")) + utils.copyFile(os.path.join(self.sourceDir(), "lib", f"libmysql.dll"), os.path.join(self.installDir(), "bin")) + if CraftCore.compiler.isMinGW(): + utils.createImportLibs(f"libmysqld", self.installDir()) + utils.createImportLibs(f"libmysql", self.installDir()) return True def qmerge(self): diff --git a/extragear/kexi/FileAssociation.nsh b/extragear/kexi/FileAssociation.nsh new file mode 100644 --- /dev/null +++ b/extragear/kexi/FileAssociation.nsh @@ -0,0 +1,190 @@ +/* +_____________________________________________________________________________ + + File Association +_____________________________________________________________________________ + + Based on code taken from http://nsis.sourceforge.net/File_Association + + Usage in script: + 1. !include "FileAssociation.nsh" + 2. [Section|Function] + ${FileAssociationFunction} "Param1" "Param2" "..." $var + [SectionEnd|FunctionEnd] + + FileAssociationFunction=[RegisterExtension|UnRegisterExtension] + +_____________________________________________________________________________ + + ${RegisterExtension} "[executable]" "[extension]" "[description]" + +"[executable]" ; executable which opens the file format + ; +"[extension]" ; extension, which represents the file format to open + ; +"[description]" ; description for the extension. This will be display in Windows Explorer. + ; + + + ${UnRegisterExtension} "[extension]" "[description]" + +"[extension]" ; extension, which represents the file format to open + ; +"[description]" ; description for the extension. This will be display in Windows Explorer. + ; + +_____________________________________________________________________________ + + Macros +_____________________________________________________________________________ + + Change log window verbosity (default: 3=no script) + + Example: + !include "FileAssociation.nsh" + !insertmacro RegisterExtension + ${FileAssociation_VERBOSE} 4 # all verbosity + !insertmacro UnRegisterExtension + ${FileAssociation_VERBOSE} 3 # no script +*/ + + +!ifndef FileAssociation_INCLUDED +!define FileAssociation_INCLUDED + +!include Util.nsh + +!verbose push +!verbose 3 +!ifndef _FileAssociation_VERBOSE + !define _FileAssociation_VERBOSE 3 +!endif +!verbose ${_FileAssociation_VERBOSE} +!define FileAssociation_VERBOSE `!insertmacro FileAssociation_VERBOSE` +!verbose pop + +!macro FileAssociation_VERBOSE _VERBOSE + !verbose push + !verbose 3 + !undef _FileAssociation_VERBOSE + !define _FileAssociation_VERBOSE ${_VERBOSE} + !verbose pop +!macroend + + + +!macro RegisterExtensionCall _EXECUTABLE _EXTENSION _DESCRIPTION + !verbose push + !verbose ${_FileAssociation_VERBOSE} + Push `${_DESCRIPTION}` + Push `${_EXTENSION}` + Push `${_EXECUTABLE}` + ${CallArtificialFunction} RegisterExtension_ + !verbose pop +!macroend + +!macro UnRegisterExtensionCall _EXTENSION _DESCRIPTION + !verbose push + !verbose ${_FileAssociation_VERBOSE} + Push `${_EXTENSION}` + Push `${_DESCRIPTION}` + ${CallArtificialFunction} UnRegisterExtension_ + !verbose pop +!macroend + + + +!define RegisterExtension `!insertmacro RegisterExtensionCall` +!define un.RegisterExtension `!insertmacro RegisterExtensionCall` + +!macro RegisterExtension +!macroend + +!macro un.RegisterExtension +!macroend + +!macro RegisterExtension_ + !verbose push + !verbose ${_FileAssociation_VERBOSE} + + Exch $R2 ;exe + Exch + Exch $R1 ;ext + Exch + Exch 2 + Exch $R0 ;desc + Exch 2 + Push $0 + Push $1 + + ReadRegStr $1 HKCR $R1 "" ; read current file association + StrCmp "$1" "" NoBackup ; is it empty + StrCmp "$1" "$R0" NoBackup ; is it our own + WriteRegStr HKCR $R1 "backup_val" "$1" ; backup current value +NoBackup: + WriteRegStr HKCR $R1 "" "$R0" ; set our file association + + ReadRegStr $0 HKCR $R0 "" + StrCmp $0 "" 0 Skip + WriteRegStr HKCR "$R0" "" "$R0" + WriteRegStr HKCR "$R0\shell" "" "open" + WriteRegStr HKCR "$R0\DefaultIcon" "" "$R2,0" +Skip: + WriteRegStr HKCR "$R0\shell\open\command" "" '"$R2" "%1"' + WriteRegStr HKCR "$R0\shell\edit" "" "Edit $R0" + WriteRegStr HKCR "$R0\shell\edit\command" "" '"$R2" "%1"' + + Pop $1 + Pop $0 + Pop $R2 + Pop $R1 + Pop $R0 + + !verbose pop +!macroend + + + +!define UnRegisterExtension `!insertmacro UnRegisterExtensionCall` +!define un.UnRegisterExtension `!insertmacro UnRegisterExtensionCall` + +!macro UnRegisterExtension +!macroend + +!macro un.UnRegisterExtension +!macroend + +!macro UnRegisterExtension_ + !verbose push + !verbose ${_FileAssociation_VERBOSE} + + Exch $R1 ;desc + Exch + Exch $R0 ;ext + Exch + Push $0 + Push $1 + + ReadRegStr $1 HKCR $R0 "" + StrCmp $1 $R1 0 NoOwn ; only do this if we own it + ReadRegStr $1 HKCR $R0 "backup_val" + StrCmp $1 "" 0 Restore ; if backup="" then delete the whole key + DeleteRegKey HKCR $R0 + Goto NoOwn + +Restore: + WriteRegStr HKCR $R0 "" $1 + DeleteRegValue HKCR $R0 "backup_val" + DeleteRegKey HKCR $R1 ;Delete key with association name settings + +NoOwn: + + Pop $1 + Pop $0 + Pop $R1 + Pop $R0 + + !verbose pop +!macroend + +!endif # !FileAssociation_INCLUDED diff --git a/extragear/kexi/NullsoftInstaller.nsi b/extragear/kexi/NullsoftInstaller.nsi new file mode 100644 --- /dev/null +++ b/extragear/kexi/NullsoftInstaller.nsi @@ -0,0 +1,168 @@ +; KEXI script for NullsoftInstallerPackager +; +; Copyright 2010 Patrick Spendrin +; Copyright 2016 Kevin Funk +; Copyright 2018 Jarosław Staniek + +; registry stuff +!define regkey "Software\@{company}\@{productname}\@{version}" +!define uninstkey "Software\Microsoft\Windows\CurrentVersion\Uninstall\@{productname} @{version}" + +!define startmenu "$SMPROGRAMS\@{productname}\@{productname} @{version}" +!define uninstall_string "Uninstall @{productname} @{version}" +!define uninstaller "${uninstall_string}.exe" + +BrandingText "Generated by Craft https://community.kde.org/Craft" + +;-------------------------------- + +XPStyle on +ShowInstDetails hide +ShowUninstDetails hide + +SetCompressor /SOLID lzma + +Name "@{productname} @{version}" +Caption "@{productname} @{version}" + +OutFile "@{setupname}" +!include "MUI2.nsh" +!include "LogicLib.nsh" +!include "x64.nsh" +!include "FileAssociation.nsh" + +;!define MUI_ICON +@{icon} +;!define MUI_ICON + +!insertmacro MUI_PAGE_WELCOME + +;!insertmacro MUI_PAGE_LICENSE +@{license} +;!insertmacro MUI_PAGE_LICENSE + +!insertmacro MUI_PAGE_DIRECTORY +!insertmacro MUI_PAGE_INSTFILES +!insertmacro MUI_UNPAGE_CONFIRM +!insertmacro MUI_UNPAGE_INSTFILES + +!define MUI_FINISHPAGE_NOAUTOCLOSE +!define MUI_FINISHPAGE_RUN +!define MUI_FINISHPAGE_RUN_TEXT "Run @{productname}" +!define MUI_FINISHPAGE_RUN_FUNCTION "LaunchLink" +!define MUI_FINISHPAGE_LINK "Visit @{productname} home page" +!define MUI_FINISHPAGE_LINK_LOCATION "@{webpage}" +!insertmacro MUI_PAGE_FINISH + +!insertmacro MUI_LANGUAGE "English" + +SetDateSave on +SetDatablockOptimize on +CRCCheck on +SilentInstall normal + +InstallDir "@{defaultinstdir}\@{productname}\@{version}" +InstallDirRegKey HKLM "${regkey}" "Install_Dir" + +Var /global ExistingInstallation + +Function .onInit +!if @{architecture} == "x64" + ${IfNot} ${RunningX64} + MessageBox MB_OK|MB_ICONEXCLAMATION "This installer can only be run on 64-bit Windows." + Abort + ${EndIf} +!endif +ReadRegStr $R0 HKLM "${regkey}" "Install_Dir" +${IfNot} $R0 == "" + StrCpy $ExistingInstallation $R0 +${EndIf} +FunctionEnd + +Function LaunchLink + ExecShell "" "${startmenu}\@{productname} @{version}.lnk" +FunctionEnd + +;-------------------------------- + +AutoCloseWindow false + + +; beginning (invisible) section +Section +${IfNot} $ExistingInstallation == "" + ExecWait '"$ExistingInstallation\${uninstaller}" /S _?=$ExistingInstallation' +${EndIf} + WriteRegStr HKLM "${regkey}" "Install_Dir" "$INSTDIR" + ; write uninstall strings + WriteRegStr HKLM "${uninstkey}" "DisplayName" "@{productname} @{version}" + WriteRegStr HKLM "${uninstkey}" "UninstallString" '"$INSTDIR\${uninstaller}"' + WriteRegStr HKLM "${uninstkey}" "DisplayIcon" "$INSTDIR\@{executable}" + WriteRegStr HKLM "${uninstkey}" "URLInfoAbout" "@{webpage}" + WriteRegStr HKLM "${uninstkey}" "Publisher" "@{company}" + WriteRegStr HKLM "${uninstkey}" "DisplayVersion" "@{version}" + + ; TODO: find a way to extend the default script + ; TODO? WriteRegStr HKCR "*\shell\OpenWith@{productname}\@{version}" "" "Edit with @{productname} @{version}" + ; TODO? WriteRegStr HKCR "*\shell\OpenWith@{productname}\@{version}\command" "" '"$INSTDIR\@{executable}" "%V"' + + !define kexi_file_desc "KEXI project file" + !define kexi_file_ext ".kexi" + ${registerExtension} "$INSTDIR\@{executable}" "${kexi_file_ext}" "${kexi_file_desc}" + + SetOutPath $INSTDIR + + +; package all files, recursively, preserving attributes +; assume files are in the correct places + +File /a /r /x "*.nsi" /x "@{setupname}" "@{srcdir}\*.*" + +WriteUninstaller "${uninstaller}" + +SectionEnd + +; create shortcuts +Section +SetShellVarContext all +CreateDirectory "${startmenu}" +SetOutPath $INSTDIR ; for working directory +CreateShortCut "${startmenu}\@{productname} @{version}.lnk" "$INSTDIR\@{executable}" +CreateShortCut "${startmenu}\${uninstall_string}.lnk" "$INSTDIR\${uninstaller}" +@{extrashortcuts} +SectionEnd + +;post install +Section +SetOutPath "$INSTDIR" +!if "@{vcredist}" != "none" + File /a /oname=vcredist.exe "@{vcredist}" + ExecWait '"$INSTDIR\vcredist.exe" /passive /norestart' +!endif +ExecWait '"$INSTDIR\bin\update-mime-database.exe" "$INSTDIR\share\mime"' +ExecWait '"$INSTDIR\bin\kbuildsycoca5.exe" "--noincremental"' +Delete "$INSTDIR\vcredist.exe" +SectionEnd + +; Uninstaller +; All section names prefixed by "Un" will be in the uninstaller + +UninstallText "This will uninstall @{productname} @{version}." + +Section "Uninstall" +SetShellVarContext all +ExecWait '"$INSTDIR\bin\kdeinit5.exe" "--shutdown"' +ExecWait '"taskkill" "/F" "/IM" "dbus-daemon.exe"' + +DeleteRegKey HKLM "${uninstkey}" +DeleteRegKey HKLM "${regkey}" + +Delete "${startmenu}\@{productname} @{version}.lnk" +Delete "${startmenu}\${uninstall_string}.lnk" + +RMDir /r "${startmenu}" +RMDir /r "$INSTDIR" + +${unregisterExtension} "${kexi_file_ext}" "${kexi_file_desc}" + +SectionEnd diff --git a/extragear/kexi/blacklist.txt b/extragear/kexi/blacklist.txt new file mode 100644 --- /dev/null +++ b/extragear/kexi/blacklist.txt @@ -0,0 +1,44 @@ +# blacklist for KEXI + +# common app stuff +lib/.* +share/.* + +# Unused Qt modules +qml/.* + +# unneeded LLVM artifacts +tools/msbuild/.* + +# unrelated +dev-utils/.* + +# other files +bin/dbus-env\.bat +bin/libGLESv2.dll +bin/qmltooling/.* +bin/data/(?!(applications|color-schemes|dbus-1|kexi|kf5/kcharselect|kf5/licenses|kf5/sonnet|kservices5|kservicetypes5|kstyle|locale|metainfo|mime|xdg))/.* +bin/data/(aspell|kdevappwizard|wallpapers)/.* +bin/data/icons/(breeze_cursors|breeze-dark|Breeze_Snow|hicolor|)/.* + +# strip most executables +bin/(?!(kexi|kbuildsycoca5|update-mime-database|kioslave|QtWebProcess)).*\.exe +bin/Qt5Designer.*\.dll +bin/Qt5Test\.dll +bin/Qt5QuickTest\.dll +bin/testplug.dll +plugins/org.kde.kdecoration2/.* +plugins/plasma/.* +plugins/platforms/qdirect2d\.dll +plugins/platforms/qminimal\.dll +plugins/platforms/qoffscreen\.dll +plugins/playlistformats/.* +plugins/qmltooling/.* +plugins/scenegraph/.* +plugins/sensors/.* +plugins/sensorgestures/.* +plugins/bearer/.* +plugins/generic/.* +plugins/sqldrivers/(?!(qsqlite))\.dll +plugins/texttospeech/.* +# no, needed by Qt5WebKit: bin/Qt5Sql\.dll diff --git a/extragear/kexi/kexi.py b/extragear/kexi/kexi.py --- a/extragear/kexi/kexi.py +++ b/extragear/kexi/kexi.py @@ -1,16 +1,34 @@ import info from CraftOS.osutils import OsUtils +import datetime +import os +import subprocess class subinfo(info.infoclass): def setTargets(self): - versions = ['3.1', 'master'] - for ver in versions: - self.svnTargets[ver] = f"git://anongit.kde.org/kexi|{ver}" + self.versionStrings = {} + self.versionSemantic = {} + + ver = '3.1' # default version, TODO update on release + self.svnTargets[ver] = f"git://anongit.kde.org/kexi|{ver}" + self.versionStrings[ver] = '3.1.0 Preview' # TODO update on release + self.versionSemantic[ver] = '3.1.0' # TODO update on release + + ver = 'master' + self.svnTargets[ver] = f"git://anongit.kde.org/kexi|master" + self.versionStrings[ver] = '3.2 Alpha' # TODO update on release + self.versionSemantic[ver] = '3.1.90' # TODO update on release + + versions = [*self.svnTargets] self.defaultTarget = versions[0] self.description = "A visual database applications builder" + self.webpage = "http://kexi-project.org" self.options.configure.args = " -DBUILD_EXAMPLES=ON" + def registerOptions(self): + self.options.dynamic.registerOption("desktop", True) + def setDependencies(self): self.runtimeDependencies["virtual/base"] = "default" self.buildDependencies["frameworks/extra-cmake-modules"] = "default" @@ -34,13 +52,16 @@ self.runtimeDependencies["extragear/kdb"] = "default" self.runtimeDependencies["extragear/kproperty"] = "default" self.runtimeDependencies["extragear/kreport"] = "default" - # Desktop only: - self.runtimeDependencies["frameworks/tier2/kcompletion"] = "default" - self.runtimeDependencies["frameworks/tier3/kio"] = "default" - self.runtimeDependencies["frameworks/tier3/ktexteditor"] = "default" - self.runtimeDependencies["frameworks/tier3/ktextwidgets"] = "default" - if OsUtils.isLinux(): - self.runtimeDependencies["frameworks/tier1/kcrash"] = "default" + if self.options.dynamic.desktop: + # Desktop only: + self.runtimeDependencies["frameworks/tier1/breeze-icons"] = "default" # hard dependency for now + self.runtimeDependencies["frameworks/tier2/kcompletion"] = "default" + self.runtimeDependencies["frameworks/tier3/kio"] = "default" + self.runtimeDependencies["frameworks/tier3/ktexteditor"] = "default" + self.runtimeDependencies["frameworks/tier3/ktextwidgets"] = "default" + self.runtimeDependencies["kde/plasma/breeze"] = "default" # hard dependency for now + if OsUtils.isLinux(): + self.runtimeDependencies["frameworks/tier1/kcrash"] = "default" from Package.CMakePackageBase import * @@ -50,14 +71,66 @@ def __init__(self): CMakePackageBase.__init__(self) + def stableVersion(self): + """ Returns stable version for self.subinfo.versionSemantic[self.subinfo.buildTarget], + that is x.y for stable releases and x.y+1 for unsable releases + """ + buildTarget = self.subinfo.versionSemantic[self.subinfo.buildTarget].split('.') + if int(buildTarget[2]) >= 90: + return f"{buildTarget[0]}.{int(buildTarget[1]) + 1}" + else: + return f"{buildTarget[0]}.{buildTarget[1]}" + def createPackage(self): - # TODO - #self.blacklist_file.append(os.path.join(self.packageDir(), 'blacklist.txt')) + self.defines["version_semantic"] = self.subinfo.versionSemantic[self.subinfo.buildTarget] + ver = self.subinfo.versionStrings[self.subinfo.buildTarget] + isAlpha = ver.endswith("Alpha") + isPreview = "Preview" in ver + if isAlpha or isPreview: # add git hash and date for Alphas/Previews + gitHash = subprocess.check_output( + ["git", "rev-parse", "--short", self.subinfo.buildTarget], + cwd=self.sourceDir(), universal_newlines=True).strip() + if isAlpha: + date = subprocess.check_output( + ["git", "show", "--no-patch", "--format=%ci", self.subinfo.buildTarget], + cwd=self.sourceDir(), universal_newlines=True).strip().split(" ")[0] + elif isPreview: + date = str(datetime.date.today()) + ver = f"{ver} {date} ({gitHash})" + self.defines["version"] = ver self.defines["productname"] = "KEXI" - self.defines["executable"] = "bin\\kexi.exe" - #self.defines["icon"] = os.path.join(self.packageDir(), "kexi.ico") + #default: self.defines["company"] = "KDE" + self.defines["webpage"] = self.subinfo.webpage + self.defines["executable"] = f"bin\\kexi-{self.stableVersion()}.exe" + self.defines["icon"] = os.path.join(self.buildDir(), "src", "_source_var.ico") + self.defines["license"] = os.path.join(self.sourceDir(), "COPYING.LIB") + # user-friendly filename + arch = '32' if CraftCore.compiler.isX86() else '64' + filename = f"{self.defines['productname']}_{self.defines['version']}_Win{arch}.exe".replace(' ', '_') + self.defines["setupname"] = os.path.join(self.packageDestinationDir(), filename) + + self.blacklist_file.append(os.path.join(self.packageDir(), 'blacklist.txt')) + + self.ignoredPackages.append("libs/d3dcompiler") + self.ignoredPackages.append("libs/qt5/qttools") + self.ignoredPackages.append("libs/qt5/qtscript") + # no, needed by Qt5WebKit: self.ignoredPackages.append("libs/qt5/qtmultimedia") + # no, needed by Qt5WebKit: self.ignoredPackages.append("libs/qt5/qtwebchannel") + # no, needed by Qt5WebKit: self.ignoredPackages.append("qt-libs/phonon") + + self.ignoredPackages.append("frameworks/tier2/kpackage") + self.ignoredPackages.append("frameworks/tier3/kdeclarative") + self.ignoredPackages.append("frameworks/tier3/knewstuff") + self.ignoredPackages.append("frameworks/tier3/kwallet") # pulled in by kio + self.ignoredPackages.append("frameworks/tier3/plasma-framework") + # TODO: find a way to extend the default script - #self.scriptname = os.path.join(self.packageDir(), "NullsoftInstaller.nsi") - #self.ignoredPackages.append("binary/mysql") + self.scriptname = os.path.join(self.packageDir(), "NullsoftInstaller.nsi") + utils.copyFile(os.path.join(self.packageDir(), "FileAssociation.nsh"), + self.workDir(), False) # needed in workdir + + for file in ["COPYING.DOC", "COPYING.LIB", "COPYING", "AUTHORS", "README.md", "README.PACKAGERS.md"]: + utils.copyFile(os.path.join(self.sourceDir(), file), + os.path.join(self.installDir(), file), False) return TypePackager.createPackage(self)