diff --git a/api/logic/Env.cpp b/api/logic/Env.cpp index d7be4a28..59d4c4a8 100644 --- a/api/logic/Env.cpp +++ b/api/logic/Env.cpp @@ -3,11 +3,13 @@ #include "BaseVersion.h" #include "BaseVersionList.h" #include +#include #include #include #include #include "tasks/Task.h" #include "meta/Index.h" +#include "FileSystem.h" #include @@ -19,6 +21,7 @@ public: std::shared_ptr m_iconlist; QMap> m_versionLists; shared_qobject_ptr m_metadataIndex; + QString m_jarsPath; }; static Env * instance; @@ -190,4 +193,18 @@ void Env::updateProxySettings(QString proxyTypeStr, QString addr, int port, QStr qDebug() << proxyDesc; } +QString Env::getJarsPath() +{ + if(d->m_jarsPath.isEmpty()) + { + return FS::PathCombine(QCoreApplication::applicationDirPath(), "jars"); + } + return d->m_jarsPath; +} + +void Env::setJarsPath(const QString& path) +{ + d->m_jarsPath = path; +} + #include "Env.moc" diff --git a/api/logic/Env.h b/api/logic/Env.h index 75ebe4a0..08b1dd0d 100644 --- a/api/logic/Env.h +++ b/api/logic/Env.h @@ -59,6 +59,8 @@ public: shared_qobject_ptr metadataIndex(); + QString getJarsPath(); + void setJarsPath(const QString & path); protected: Private * d; }; diff --git a/api/logic/java/JavaChecker.cpp b/api/logic/java/JavaChecker.cpp index daf375ad..ebbd80be 100644 --- a/api/logic/java/JavaChecker.cpp +++ b/api/logic/java/JavaChecker.cpp @@ -7,13 +7,15 @@ #include #include +#include "Env.h" + JavaChecker::JavaChecker(QObject *parent) : QObject(parent) { } void JavaChecker::performCheck() { - QString checkerJar = FS::PathCombine(QCoreApplication::applicationDirPath(), "jars", "JavaCheck.jar"); + QString checkerJar = FS::PathCombine(ENV.getJarsPath(), "JavaCheck.jar"); QStringList args; diff --git a/api/logic/minecraft/launch/LauncherPartLaunch.cpp b/api/logic/minecraft/launch/LauncherPartLaunch.cpp index b69ae413..d9441e56 100644 --- a/api/logic/minecraft/launch/LauncherPartLaunch.cpp +++ b/api/logic/minecraft/launch/LauncherPartLaunch.cpp @@ -19,6 +19,7 @@ #include #include #include +#include "Env.h" LauncherPartLaunch::LauncherPartLaunch(LaunchTask *parent) : LaunchStep(parent) { @@ -43,7 +44,7 @@ void LauncherPartLaunch::executeTask() // make detachable - this will keep the process running even if the object is destroyed m_process.setDetachable(true); - args << "-jar" << FS::PathCombine(QCoreApplication::applicationDirPath(), "jars", "NewLaunch.jar"); + args << "-jar" << FS::PathCombine(ENV.getJarsPath(), "NewLaunch.jar"); QString wrapperCommand = instance->getWrapperCommand(); if(!wrapperCommand.isEmpty()) diff --git a/application/CMakeLists.txt b/application/CMakeLists.txt index 2ae8b1c5..9c1ca3cd 100644 --- a/application/CMakeLists.txt +++ b/application/CMakeLists.txt @@ -304,8 +304,8 @@ target_link_libraries(MultiMC MultiMC_gui ${QUAZIP_LIBRARIES} hoedown MultiMC_ra ######## Packaging/install paths setup ######## # How to install the build results -set(MultiMC_LAYOUT "auto" CACHE STRING "The layout for MultiMC installation (auto, win-bundle, lin-bundle, mac-bundle, lin-nodeps)") -set_property(CACHE MultiMC_LAYOUT PROPERTY STRINGS auto win-bundle lin-bundle mac-bundle lin-nodeps) +set(MultiMC_LAYOUT "auto" CACHE STRING "The layout for MultiMC installation (auto, win-bundle, lin-bundle, lin-nodeps, lin-system, mac-bundle)") +set_property(CACHE MultiMC_LAYOUT PROPERTY STRINGS auto win-bundle lin-bundle lin-nodeps lin-system mac-bundle) if(MultiMC_LAYOUT STREQUAL "auto") if(UNIX AND APPLE) @@ -326,6 +326,7 @@ if(MultiMC_LAYOUT_REAL STREQUAL "mac-bundle") set(LIBRARY_DEST_DIR "MultiMC.app/Contents/MacOS") set(PLUGIN_DEST_DIR "MultiMC.app/Contents/MacOS") set(RESOURCES_DEST_DIR "MultiMC.app/Contents/Resources") + set(JARS_DEST_DIR "MultiMC.app/Contents/MacOS") set(BUNDLE_DEST_DIR ".") @@ -346,7 +347,7 @@ if(MultiMC_LAYOUT_REAL STREQUAL "mac-bundle") set(DIRS ${QT_LIBS_DIR} ${QT_LIBEXECS_DIR} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) # install as bundle - set(INSTALL_BUNDLE TRUE) + set(INSTALL_BUNDLE "full") # Add the icon install(FILES resources/MultiMC.icns DESTINATION ${RESOURCES_DEST_DIR}) @@ -357,6 +358,7 @@ elseif(MultiMC_LAYOUT_REAL STREQUAL "lin-bundle") set(PLUGIN_DEST_DIR "plugins") set(BUNDLE_DEST_DIR ".") set(RESOURCES_DEST_DIR ".") + set(JARS_DEST_DIR "bin") # Apps to bundle set(APPS "\${CMAKE_INSTALL_PREFIX}/bin/MultiMC") @@ -365,7 +367,7 @@ elseif(MultiMC_LAYOUT_REAL STREQUAL "lin-bundle") set(DIRS ${QT_LIBS_DIR} ${QT_LIBEXECS_DIR} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) # install as bundle - set(INSTALL_BUNDLE TRUE) + set(INSTALL_BUNDLE "full") # Set RPATH SET_TARGET_PROPERTIES(MultiMC PROPERTIES INSTALL_RPATH "$ORIGIN/") @@ -379,9 +381,10 @@ elseif(MultiMC_LAYOUT_REAL STREQUAL "lin-nodeps") set(PLUGIN_DEST_DIR "plugins") set(BUNDLE_DEST_DIR ".") set(RESOURCES_DEST_DIR ".") + set(JARS_DEST_DIR "bin") - # do not install as bundle - set(INSTALL_BUNDLE FALSE) + # install as bundle with no dependencies included + set(INSTALL_BUNDLE "nodeps") # Set RPATH SET_TARGET_PROPERTIES(MultiMC PROPERTIES INSTALL_RPATH "$ORIGIN/") @@ -389,12 +392,30 @@ elseif(MultiMC_LAYOUT_REAL STREQUAL "lin-nodeps") # Install basic runner script install(PROGRAMS package/linux/MultiMC DESTINATION ${BUNDLE_DEST_DIR}) +elseif(MultiMC_LAYOUT_REAL STREQUAL "lin-system") + set(MultiMC_BINARY_DEST_DIR "usr/bin" CACHE STRING "Relative path from packaging root to the binary directory") + set(MultiMC_LIBRARY_DEST_DIR "usr/lib" CACHE STRING "Relative path from packaging root to the library directory") + set(MultiMC_SHARE_DEST_DIR "usr/share/multimc5" CACHE STRING "Relative path from packaging root to the shared data directory") + set(JARS_DEST_DIR "${MultiMC_SHARE_DEST_DIR}") + + set(BINARY_DEST_DIR ${MultiMC_BINARY_DEST_DIR}) + set(LIBRARY_DEST_DIR ${MultiMC_LIBRARY_DEST_DIR}) + + MESSAGE(STATUS "Compiling for linux system with ${MultiMC_SHARE_DEST_DIR} and MULTIMC_LINUX_DATADIR") + set_target_properties(MultiMC PROPERTIES OUTPUT_NAME "multimc5") + target_compile_definitions(MultiMC PRIVATE "-DMULTIMC_JARS_LOCATION=/${MultiMC_SHARE_DEST_DIR}/jars" "-DMULTIMC_LINUX_DATADIR" + ) + + # install as bundle with no dependencies included + set(INSTALL_BUNDLE "nodeps") + elseif(MultiMC_LAYOUT_REAL STREQUAL "win-bundle") set(BINARY_DEST_DIR ".") set(LIBRARY_DEST_DIR ".") set(PLUGIN_DEST_DIR ".") set(BUNDLE_DEST_DIR ".") set(RESOURCES_DEST_DIR ".") + set(JARS_DEST_DIR ".") # Apps to bundle set(APPS "\${CMAKE_INSTALL_PREFIX}/MultiMC.exe") @@ -403,7 +424,7 @@ elseif(MultiMC_LAYOUT_REAL STREQUAL "win-bundle") set(DIRS ${QT_LIBS_DIR} ${QT_LIBEXECS_DIR} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) # install as bundle - set(INSTALL_BUNDLE TRUE) + set(INSTALL_BUNDLE "full") else() message(FATAL_ERROR "No sensible install layout set.") endif() @@ -417,12 +438,11 @@ install(TARGETS MultiMC RUNTIME DESTINATION ${BINARY_DEST_DIR} COMPONENT Runtime ) -#### jars needed for testing java and launching Minecraft #### -install_jar(JavaCheck "${BINARY_DEST_DIR}/jars") -install_jar(NewLaunch "${BINARY_DEST_DIR}/jars") +install_jar(JavaCheck "${JARS_DEST_DIR}/jars") +install_jar(NewLaunch "${JARS_DEST_DIR}/jars") -#### Shared libraries and dependencies #### -if(NOT INSTALL_BUNDLE) +#### Dependency installations #### +if(INSTALL_BUNDLE STREQUAL "nodeps") # Just our own stuff # FIXME: this does not remove RPATH. install( @@ -437,7 +457,7 @@ if(NOT INSTALL_BUNDLE) DESTINATION ${LIBRARY_DEST_DIR} ) -else() +elseif(INSTALL_BUNDLE STREQUAL "full") # Add qt.conf - this makes Qt stop looking for things outside the bundle install( CODE "file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${RESOURCES_DEST_DIR}/qt.conf\" \" \")" @@ -450,7 +470,7 @@ else() DIRECTORY "${QT_PLUGINS_DIR}/imageformats" DESTINATION ${PLUGIN_DEST_DIR} COMPONENT Runtime - REGEX "tga|tiff|mng" EXCLUDE + REGEX "tga|tiff|mng|webp" EXCLUDE ) # Icon engines install( @@ -472,7 +492,7 @@ else() DIRECTORY "${QT_PLUGINS_DIR}/imageformats" DESTINATION ${PLUGIN_DEST_DIR} COMPONENT Runtime - REGEX "tga|tiff|mng" EXCLUDE + REGEX "tga|tiff|mng|webp" EXCLUDE REGEX "d\\." EXCLUDE REGEX "_debug\\." EXCLUDE REGEX "\\.dSYM" EXCLUDE diff --git a/application/MultiMC.cpp b/application/MultiMC.cpp index 52755e84..495b14a0 100644 --- a/application/MultiMC.cpp +++ b/application/MultiMC.cpp @@ -79,6 +79,9 @@ #include #endif +#define STRINGIFY(x) #x +#define TOSTRING(x) STRINGIFY(x) + static const QLatin1String liveCheckFile("live.check"); using namespace Commandline; @@ -138,7 +141,7 @@ MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv) parser.addShortOpt("version", 'V'); parser.addDocumentation("version", "display program version and exit."); // --dir - parser.addOption("dir", applicationDirPath()); + parser.addOption("dir"); parser.addShortOpt("dir", 'd'); parser.addDocumentation("dir", "use the supplied folder as MultiMC root instead of " "the binary location (use '.' for current)"); @@ -199,8 +202,19 @@ MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv) } else { +#ifdef MULTIMC_LINUX_DATADIR + QString xdgDataHome = QFile::decodeName(qgetenv("XDG_DATA_HOME")); + if (xdgDataHome.isEmpty()) + xdgDataHome = QDir::homePath() + QLatin1String("/.local/share"); + dataPath = xdgDataHome + "/multimc"; + printf("BLAH %s", xdgDataHome.toStdString().c_str()); + + adjustedBy += "XDG standard " + dataPath; + +#else dataPath = applicationDirPath(); adjustedBy += "Fallback to binary path " + dataPath; +#endif } if (!FS::ensureFolderPathExists(dataPath)) @@ -297,6 +311,9 @@ MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv) { qDebug() << "ID of instance to launch : " << m_instanceIdToLaunch; } +#ifdef MULTIMC_JARS_LOCATION + ENV.setJarsPath( TOSTRING(MULTIMC_JARS_LOCATION) ); +#endif do // once { diff --git a/application/package/linux/multimc.desktop b/application/package/linux/multimc.desktop new file mode 100755 index 00000000..ad18381e --- /dev/null +++ b/application/package/linux/multimc.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Version=1.0 +Encoding=UTF-8 +Name=MultiMC +GenericName=Minecraft launcher +Comment=Free, open source launcher and instance manager for Minecraft. +Type=Application +Terminal=false +Exec=multimc +Icon=multimc +Categories=Application;Game diff --git a/application/package/ubuntu/multimc/DEBIAN/control b/application/package/ubuntu/multimc/DEBIAN/control deleted file mode 100644 index a0300e99..00000000 --- a/application/package/ubuntu/multimc/DEBIAN/control +++ /dev/null @@ -1,11 +0,0 @@ -Package: multimc -Version: 1.1-2 -Architecture: all -Maintainer: Petr Mrázek -Section: games -Priority: optional -Installed-Size: 75 -Depends: zenity, default-jre -Homepage: http://multimc.org -Description: A local install wrapper for MultiMC - diff --git a/application/package/ubuntu/multimc/DEBIAN/postrm b/application/package/ubuntu/multimc/DEBIAN/postrm deleted file mode 100755 index f9bbc8a7..00000000 --- a/application/package/ubuntu/multimc/DEBIAN/postrm +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -set -e -update-desktop-database diff --git a/application/package/ubuntu/multimc/opt/multimc/icon.svg b/application/package/ubuntu/multimc/opt/multimc/icon.svg deleted file mode 100644 index 178509ac..00000000 --- a/application/package/ubuntu/multimc/opt/multimc/icon.svg +++ /dev/null @@ -1,1993 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/application/package/ubuntu/multimc/opt/multimc/run.sh b/application/package/ubuntu/multimc/opt/multimc/run.sh deleted file mode 100755 index f4f2fa42..00000000 --- a/application/package/ubuntu/multimc/opt/multimc/run.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -INSTDIR="${XDG_DATA_HOME-$HOME/.local/share}/multimc" - -if [ `getconf LONG_BIT` = "64" ] -then - PACKAGE="mmc-stable-lin64.tar.gz" -else - PACKAGE="mmc-stable-lin32.tar.gz" -fi - -deploy() { - mkdir -p $INSTDIR - cd ${INSTDIR} - - wget --progress=dot:force "https://files.multimc.org/downloads/${PACKAGE}" 2>&1 | sed -u 's/.* \([0-9]\+%\)\ \+\([0-9.]\+.\) \(.*\)/\1\n# Downloading at \2\/s, ETA \3/' | zenity --progress --auto-close --auto-kill --title="Downloading MultiMC..." - - tar -xzf ${PACKAGE} --transform='s,MultiMC/,,' - rm ${PACKAGE} - chmod +x MultiMC -} - -runmmc() { - cd ${INSTDIR} - ./MultiMC -} - -if [[ ! -f ${INSTDIR}/MultiMC ]]; then - deploy - runmmc -else - runmmc -fi diff --git a/application/package/ubuntu/multimc/usr/share/applications/multimc.desktop b/application/package/ubuntu/multimc/usr/share/applications/multimc.desktop deleted file mode 100755 index 6002e686..00000000 --- a/application/package/ubuntu/multimc/usr/share/applications/multimc.desktop +++ /dev/null @@ -1,16 +0,0 @@ -[Desktop Entry] -Categories=Game; -Exec=/opt/multimc/run.sh -Icon=/opt/multimc/icon.svg -Keywords=game; -MimeType= -Name=MultiMC 5 -Path= -StartupNotify=true -Terminal=false -TerminalOptions= -Type=Application -X-DBUS-ServiceName= -X-DBUS-StartupType= -X-KDE-SubstituteUID=false -X-KDE-Username= diff --git a/application/package/ubuntu/readme.md b/application/package/ubuntu/readme.md deleted file mode 100644 index 907fd649..00000000 --- a/application/package/ubuntu/readme.md +++ /dev/null @@ -1,12 +0,0 @@ -# What is this? -A simple ubuntu package for MultiMC that wraps the contains a script that downloads and installs real MultiMC on ubuntu based systems. - -It contains a `.dekstop` file, an icon, and a simple script that does the heavy lifting. - -# How to build this? -You need dpkg utils and then run: -``` -fakeroot dpkg-deb --build multimc_1.1-1 -``` - -Replace the version with whatever is appropriate.