Unverified Commit ea9298bd authored by Michael Daniels's avatar Michael Daniels Committed by GitHub
Browse files

megacmd: 1.7.0 -> 2.5.2 (#503260)

parents cc1bccf6 b9350f8d
Loading
Loading
Loading
Loading
+125 −0
Original line number Diff line number Diff line
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0daf084d..4ff0a86d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -88,6 +88,12 @@ endif()
 include(megacmd_options) #Load first MEGAcmd's options (that we have prevalescence over SDK (e.g libuv)
 include(sdklib_options) #load default sdk's
 
+if (WIN32 OR APPLE)
+    option(ENABLE_UPDATER "Enable updater" ON)
+else()
+    option(ENABLE_UPDATER "Enable updater" OFF)
+endif()
+
 if (EXISTS ${CMAKE_CURRENT_LIST_DIR}/sdk/include/mega/config.h)
     file(RENAME ${CMAKE_CURRENT_LIST_DIR}/sdk/include/mega/config.h ${CMAKE_CURRENT_LIST_DIR}/sdk/include/mega/config.h_non_cmake_bk)
 endif()
@@ -222,6 +228,10 @@ target_compile_definitions(LMegacmdServer
     $<$<BOOL:${USE_PCRE}>:USE_PCRE>
 )
 
+if (ENABLE_UPDATER)
+    target_compile_definitions(LMegacmdServer PUBLIC ENABLE_UPDATER)
+endif()
+
 if (NOT WIN32)
     if (ENABLE_ASAN)
         add_compile_options("-fsanitize=address" "-fno-omit-frame-pointer" "-fno-common")
@@ -419,7 +429,7 @@ load_megacmdserver_libraries()
 
 
 list(APPEND all_targets mega-exec mega-cmd mega-cmd-server)
-if (APPLE)
+if (APPLE AND ENABLE_UPDATER)
     list(APPEND all_targets mega-cmd-updater)
 endif()
 
diff --git a/src/megacmd.cpp b/src/megacmd.cpp
index 9110ae31..aeb3b1e1 100644
--- a/src/megacmd.cpp
+++ b/src/megacmd.cpp
@@ -830,7 +830,7 @@ void insertValidParamsPerCommand(set<string> *validParams, string thecommand, se
     {
         validParams->insert("only-shell");
     }
-#if defined(_WIN32) || defined(__APPLE__)
+#ifdef ENABLE_UPDATER
     else if ("update" == thecommand)
     {
         validOptValues->insert("auto");
@@ -4211,7 +4211,7 @@ static bool process_line(const std::string_view line)
                 break;
             }
 
-#if defined(_WIN32) || defined(__APPLE__)
+#ifdef ENABLE_UPDATER
             else if (isBareCommand(l, "update")) //if extra args are received, it'll be processed by executer
             {
                 string confirmationQuery("This might require restarting MEGAcmd. Are you sure to continue");
@@ -4684,7 +4684,7 @@ void megacmd()
 
                 std::string s;
 
-#if defined(_WIN32) || defined(__APPLE__)
+#ifdef ENABLE_UPDATER
                 ostringstream os;
                 auto updatMsgOpt = lookForAvailableNewerVersions(api);
                 //TODO: have this executed in worker thread instead (see MegaCmdExecuter::mayExecutePendingStuffInWorkerThread)
diff --git a/src/megacmdcommonutils.h b/src/megacmdcommonutils.h
index 039d7b81..977dbb67 100644
--- a/src/megacmdcommonutils.h
+++ b/src/megacmdcommonutils.h
@@ -120,7 +120,7 @@ static std::vector<std::string> loginInValidCommands { "log", "debug", "speedlim
 #elif defined(_WIN32)
                              , "unicode"
 #endif
-#if defined(_WIN32) || defined(__APPLE__)
+#ifdef ENABLE_UPDATER
                              , "update"
 #endif
                            };
@@ -144,7 +144,7 @@ static std::vector<std::string> allValidCommands { "login", "signup", "confirm",
 #else
                              , "permissions"
 #endif
-#if defined(_WIN32) || defined(__APPLE__)
+#ifdef ENABLE_UPDATER
                              , "update"
 #endif
 #ifdef WITH_FUSE
diff --git a/src/megacmdexecuter.cpp b/src/megacmdexecuter.cpp
index 19f4903b..7712d546 100644
--- a/src/megacmdexecuter.cpp
+++ b/src/megacmdexecuter.cpp
@@ -2696,7 +2696,7 @@ int MegaCmdExecuter::actUponLogin(SynchronousRequestListener *srl, int timeout)
         fetchNodes(api, clientID);
     }
 
-#if defined(_WIN32) || defined(__APPLE__)
+#ifdef ENABLE_UPDATER
 
     MegaCmdListener *megaCmdListener = new MegaCmdListener(NULL);
     srl->getApi()->getLastAvailableVersion("BdARkQSQ",megaCmdListener);
@@ -5829,7 +5829,7 @@ void MegaCmdExecuter::executecommand(vector<string> words, map<string, int> *clf
             }
         }
     }
-#if defined(_WIN32) || defined(__APPLE__)
+#ifdef ENABLE_UPDATER
     else if (words[0] == "update")
     {
         string sauto = getOption(cloptions, "auto", "");
diff --git a/src/megacmdshell/megacmdshell.cpp b/src/megacmdshell/megacmdshell.cpp
index 7723982e..2d077c7c 100644
--- a/src/megacmdshell/megacmdshell.cpp
+++ b/src/megacmdshell/megacmdshell.cpp
@@ -1289,7 +1289,7 @@ void process_line(const char * line)
                         doExit = true;
                     }
                 }
-#if defined(_WIN32) || defined(__APPLE__)
+#ifdef ENABLE_UPDATER
                 else if (words[0] == "update")
                 {
                     comms->markServerIsUpdating();
+26 −45
Original line number Diff line number Diff line
--- a/Makefile.am
+++ b/Makefile.am
@@ -25,6 +25,11 @@ AM_CPPFLAGS = \
 
 AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/sdk/include
 
+if DARWIN
+AM_LIBTOOLFLAGS="--tag=CXX"
+AM_CPPFLAGS+=-I$(top_srcdir)/include/mega/osx -I$(top_srcdir)/sdk/include/mega/osx
+endif
+
 if WIN32
 AM_CPPFLAGS+=-I$(top_srcdir)/sdk/include/mega/win32
 else
diff --git a/src/megacmdshell/megacmdshellcommunications.cpp b/src/megacmdshell/megacmdshellcommunications.cpp
index bdd683b2..266e17ee 100644
--- a/src/megacmdshell/megacmdshellcommunications.cpp
+++ b/src/megacmdshell/megacmdshellcommunications.cpp
@@ -306,10 +306,6 @@ SOCKET MegaCmdShellCommunications::createSocket(int number, bool initializeserve
         #endif
                     const char executable2[] = "./mega-cmd-server";
@@ -153,12 +153,9 @@ SOCKET MegaCmdShellCommunicationsPosix::createSocket(int number, bool initialize
 #ifndef NDEBUG
                 const char executable[] = "./mega-cmd-server";
 #else
-    #ifdef __MACH__
-                const char executable[] = "/Applications/MEGAcmd.app/Contents/MacOS/mega-cmd";
-                const char executable2[] = "./mega-cmd";
-    #else
                 const char executable[] = "mega-cmd-server";
             #ifdef __linux__
                 char executable2[PATH_MAX];
@@ -317,7 +313,6 @@ SOCKET MegaCmdShellCommunications::createSocket(int number, bool initializeserve
             #else
                     const char executable2[] = "./mega-cmd-server";
+    #ifdef __linux__
                 sprintf(executable2, "%s/mega-cmd-server", getCurrentExecPath().c_str());
     #endif
-        #endif
 #endif
@@ -217,11 +214,7 @@ SOCKET MegaCmdShellCommunicationsPosix::createSocket(int number, bool initialize
             {
 
                     std::vector<char*> argsVector{
--- a/sdk/Makefile.am
+++ b/sdk/Makefile.am
@@ -27,6 +27,11 @@ AM_CPPFLAGS = \
 
 include m4/aminclude.am
 
+if DARWIN
+AM_LIBTOOLFLAGS="--tag=CXX"
+AM_CPPFLAGS+=-I$(top_srcdir)/include/mega/osx
+endif
+
 if WIN32
 AM_CPPFLAGS+=-I$(top_srcdir)/include/mega/win32
                 cerr << "Unable to connect to " << (number?("response socket N "+std::to_string(number)):"service") << ": error=" << ERRNO << endl;
-#ifdef __linux__
                 cerr << "Please ensure mega-cmd-server is running" << endl;
-#else
-                cerr << "Please ensure MEGAcmdServer is running" << endl;
-#endif
                 return INVALID_SOCKET;
             }
             else
+0 −29
Original line number Diff line number Diff line
--- a/sdk/src/gfx/freeimage.cpp
+++ b/sdk/src/gfx/freeimage.cpp
@@ -216,11 +216,13 @@ bool GfxProviderFreeImage::readbitmapFreeimage(const LocalPath& imagePath, int s
 
 #ifdef HAVE_FFMPEG
 
+#if LIBAVCODEC_VERSION_MAJOR < 60
 #ifdef AV_CODEC_CAP_TRUNCATED
 #define CAP_TRUNCATED AV_CODEC_CAP_TRUNCATED
 #else
 #define CAP_TRUNCATED CODEC_CAP_TRUNCATED
 #endif
+#endif
 
 const char *GfxProviderFreeImage::supportedformatsFfmpeg()
 {
@@ -323,10 +325,12 @@ bool GfxProviderFreeImage::readbitmapFfmpeg(const LocalPath& imagePath, int size
 
     // Force seeking to key frames
     formatContext->seek2any = false;
+#if LIBAVCODEC_VERSION_MAJOR < 60
     if (decoder->capabilities & CAP_TRUNCATED)
     {
         codecContext->flags |= CAP_TRUNCATED;
     }
+#endif
 
     AVPixelFormat sourcePixelFormat = static_cast<AVPixelFormat>(codecParm->format);
     AVPixelFormat targetPixelFormat = AV_PIX_FMT_BGR24; //raw data expected by freeimage is in this format
+21 −0
Original line number Diff line number Diff line
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -135,7 +135,6 @@ if(UNIX AND NOT APPLE)
     # Note: using cmake --install --prefix /some/prefix will not set rpath relative to that prefix
     # The above can be used for building packages: in which install dir is a path construction folder that will not be there in packages
     set(CMAKE_INSTALL_LIBDIR "opt/megacmd/lib")
-    set(CMAKE_INSTALL_BINDIR "usr/bin") #override default "bin"
 
     if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
         message(STATUS "Overriding default CMAKE_INSTALL_PREFIX to /")
@@ -430,9 +429,9 @@ endif()
 if (APPLE)
     install(TARGETS ${all_targets}
         BUNDLE
-        DESTINATION "./"
+        DESTINATION "Applications/"
     )
 elseif(NOT WIN32)
     set(PERMISSIONS755
          OWNER_READ
          OWNER_WRITE
+40 −0
Original line number Diff line number Diff line
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bb161de8..5fa97e79 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -39,7 +39,7 @@ execute_process(
 )
 endif()
 
-if((NOT WIN32 OR BASH_VERSION_RESULT EQUAL 0) AND NOT EXISTS ${VCPKG_ROOT})
+if(VCPKG_ROOT AND (NOT WIN32 OR BASH_VERSION_RESULT EQUAL 0) AND NOT EXISTS ${VCPKG_ROOT})
     message(STATUS "vcpkg will be cloned into ${VCPKG_ROOT}")
     execute_process(
         #TODO: have the same for windows ... or at least check if bash is available
@@ -468,17 +468,19 @@ elseif(NOT WIN32)
         DESTINATION "etc/sysctl.d"
         )
 
-    #Install vcpkg dynamic libraries in locations defined by GNUInstallDirs.
-    if(CMAKE_BUILD_TYPE STREQUAL "Debug")
-        SET(vcpkg_lib_folder "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/lib/")
-    else()
-        SET(vcpkg_lib_folder "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/")
-    endif()
-    install(DIRECTORY "${vcpkg_lib_folder}"
+    if(VCPKG_ROOT)
+        #Install vcpkg dynamic libraries in locations defined by GNUInstallDirs.
+        if(CMAKE_BUILD_TYPE STREQUAL "Debug")
+            SET(vcpkg_lib_folder "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/lib/")
+        else()
+            SET(vcpkg_lib_folder "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/")
+        endif()
+        install(DIRECTORY "${vcpkg_lib_folder}"
             DESTINATION ${CMAKE_INSTALL_LIBDIR}
             FILES_MATCHING
             PATTERN "lib*.so*"
             PATTERN "*dylib*" #macOS
             PATTERN "manual-link" EXCLUDE
             PATTERN "pkgconfig" EXCLUDE)
+    endif()
 endif() #not WIN32
Loading