megacmd: 1.7.0 -> 2.5.2 (#503260)
This commit is contained in:
@@ -0,0 +1,125 @@
|
||||
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();
|
||||
@@ -1,49 +1,30 @@
|
||||
--- 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";
|
||||
#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";
|
||||
#endif
|
||||
- #endif
|
||||
@@ -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";
|
||||
char executable2[PATH_MAX];
|
||||
+ #ifdef __linux__
|
||||
sprintf(executable2, "%s/mega-cmd-server", getCurrentExecPath().c_str());
|
||||
#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
|
||||
else
|
||||
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
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
--- 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
|
||||
@@ -0,0 +1,21 @@
|
||||
--- 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
|
||||
@@ -0,0 +1,40 @@
|
||||
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
|
||||
@@ -1,106 +1,170 @@
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
autoreconfHook,
|
||||
c-ares,
|
||||
cmake,
|
||||
cryptopp,
|
||||
curl,
|
||||
fetchFromGitHub,
|
||||
file,
|
||||
ffmpeg,
|
||||
gcc-unwrapped,
|
||||
fuse,
|
||||
icu,
|
||||
libmediainfo,
|
||||
libraw,
|
||||
libsodium,
|
||||
libuv,
|
||||
libzen,
|
||||
pcre-cpp,
|
||||
makeWrapper,
|
||||
nix-update-script,
|
||||
pdfium-binaries,
|
||||
pkg-config,
|
||||
readline,
|
||||
sqlite,
|
||||
versionCheckHook,
|
||||
writeShellScriptBin,
|
||||
}:
|
||||
|
||||
let
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "megacmd";
|
||||
version = "1.7.0";
|
||||
srcOptions =
|
||||
if stdenv.hostPlatform.isLinux then
|
||||
{
|
||||
tag = "${version}_Linux";
|
||||
hash = "sha256-UlSqwM8GQKeG8/K0t5DbM034NQOeBg+ujNi/MMsVCuM=";
|
||||
}
|
||||
else
|
||||
{
|
||||
tag = "${version}_macOS";
|
||||
hash = "sha256-UlSqwM8GQKeG8/K0t5DbM034NQOeBg+ujNi/MMsVCuM=";
|
||||
};
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
inherit pname version;
|
||||
version = "2.5.2";
|
||||
|
||||
src = fetchFromGitHub (
|
||||
srcOptions
|
||||
// {
|
||||
owner = "meganz";
|
||||
repo = "MEGAcmd";
|
||||
fetchSubmodules = true;
|
||||
}
|
||||
);
|
||||
src = fetchFromGitHub {
|
||||
owner = "meganz";
|
||||
repo = "MEGAcmd";
|
||||
# The upstream makes a tag for each platform getting a release,
|
||||
# but the tags all point to the same commit,
|
||||
# so we just stick to the Linux tag to make the update script easy.
|
||||
tag = "${finalAttrs.version}_Linux";
|
||||
fetchSubmodules = true;
|
||||
postCheckout = "git -C $out/sdk rev-parse --short HEAD > $out/sdk/.gitrev";
|
||||
hash = "sha256-RE4n4igAXhYNshnjjyeb2McmBKt5HY0oZ+U5SMMtQ2I=";
|
||||
};
|
||||
|
||||
enableParallelBuilding = true;
|
||||
nativeBuildInputs = [
|
||||
autoreconfHook
|
||||
pkg-config
|
||||
];
|
||||
|
||||
buildInputs =
|
||||
lib.optionals stdenv.hostPlatform.isLinux [ gcc-unwrapped ] # fix: ld: cannot find lib64/libstdc++fs.a
|
||||
++ [
|
||||
c-ares
|
||||
cryptopp
|
||||
curl
|
||||
ffmpeg
|
||||
icu
|
||||
libmediainfo
|
||||
libraw
|
||||
libsodium
|
||||
libuv
|
||||
libzen
|
||||
pcre-cpp
|
||||
readline
|
||||
sqlite
|
||||
];
|
||||
|
||||
configureFlags = [
|
||||
"--disable-examples"
|
||||
"--with-cares"
|
||||
"--with-cryptopp"
|
||||
"--with-curl"
|
||||
"--with-ffmpeg"
|
||||
"--with-icu"
|
||||
"--with-libmediainfo"
|
||||
"--with-libuv"
|
||||
"--with-libzen"
|
||||
"--with-pcre"
|
||||
"--with-readline"
|
||||
"--with-sodium"
|
||||
"--with-termcap"
|
||||
"--without-freeimage"
|
||||
];
|
||||
|
||||
# On darwin, some macros defined in AssertMacros.h (from apple-sdk) are conflicting.
|
||||
postConfigure = ''
|
||||
echo '#define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0' >> sdk/include/mega/config.h
|
||||
'';
|
||||
__structuredAttrs = true;
|
||||
|
||||
patches = [
|
||||
./fix-ffmpeg.patch # https://github.com/meganz/sdk/issues/2635#issuecomment-1495405085
|
||||
./fix-darwin.patch # fix: libtool tag not found; MacFileSystemAccess not declared; server cannot init
|
||||
# use pkg-config instead of vcpkg
|
||||
# https://github.com/meganz/MEGAcmd/pull/1067
|
||||
./no-vcpkg.patch
|
||||
|
||||
# use cmake option to enable the updater instead of depending on os
|
||||
# https://github.com/meganz/MEGAcmd/pull/1117
|
||||
./disable-updater.patch
|
||||
|
||||
# fix install paths (/usr/bin -> /bin on linux, and / -> /Applications on darwin)
|
||||
./install-path.patch
|
||||
|
||||
# do not look for the mega-cmd-server executable in /Applications on darwin
|
||||
# but use the same strategy as on linux
|
||||
./fix-darwin.patch
|
||||
];
|
||||
|
||||
postPatch = ''
|
||||
# interesting typo (https://github.com/meganz/MEGAcmd/pull/1118, https://github.com/meganz/sdk/pull/2770)
|
||||
substituteInPlace build/cmake/modules/megacmd_configuration.cmake sdk/cmake/modules/configuration.cmake \
|
||||
--replace-fail "check_function_exists(aio_write, HAVE_AIO_RT)" "check_function_exists(aio_write HAVE_AIO_RT)"
|
||||
|
||||
# cryptopp on nixpkgs has libcryptopp.pc, not libcrypto++.pc
|
||||
# pdfium-binaries{,-v8} in nixpkgs does not provide a pc file but only a cmake file
|
||||
# libicui18n is needed (https://github.com/meganz/sdk/pull/2769)
|
||||
substituteInPlace sdk/cmake/modules/sdklib_libraries.cmake \
|
||||
--replace-fail "pkg_check_modules(cryptopp REQUIRED IMPORTED_TARGET libcrypto++)" "pkg_check_modules(cryptopp REQUIRED IMPORTED_TARGET libcryptopp)" \
|
||||
--replace-fail "pkg_check_modules(pdfium REQUIRED IMPORTED_TARGET pdfium)" "find_package(PDFium)" \
|
||||
--replace-fail "target_link_libraries(SDKlib PRIVATE PkgConfig::pdfium)" "target_link_libraries(SDKlib PRIVATE pdfium)" \
|
||||
--replace-fail "find_package(ICU COMPONENTS uc data REQUIRED)" "find_package(ICU COMPONENTS i18n uc data REQUIRED)" \
|
||||
--replace-fail "target_link_libraries(SDKlib PRIVATE ICU::uc ICU::data)" "target_link_libraries(SDKlib PRIVATE ICU::i18n ICU::uc ICU::data)"
|
||||
'';
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
nativeBuildInputs = [
|
||||
cmake
|
||||
pkg-config
|
||||
file
|
||||
makeWrapper
|
||||
|
||||
# https://github.com/meganz/MEGAcmd/blob/2.5.0_Linux/CMakeLists.txt#L4-L10
|
||||
(writeShellScriptBin "git" ''
|
||||
dir="$(pwd)"
|
||||
while [[ ! -f "$dir/.gitrev" ]]; do
|
||||
if [[ "$dir" == "/" ]]; then
|
||||
echo "fatal: not a git repository (or any of the parent directories): .git" >&2
|
||||
exit 128
|
||||
fi
|
||||
dir="$(dirname "$dir")"
|
||||
done
|
||||
cat "$dir/.gitrev"
|
||||
'')
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
cryptopp
|
||||
curl
|
||||
ffmpeg
|
||||
fuse
|
||||
icu
|
||||
libmediainfo
|
||||
libsodium
|
||||
libuv
|
||||
libzen
|
||||
pdfium-binaries
|
||||
readline
|
||||
sqlite
|
||||
];
|
||||
|
||||
cmakeFlags = [
|
||||
(lib.cmakeFeature "VCPKG_ROOT" "") # fallback to pkg-config instead of vcpkg
|
||||
(lib.cmakeBool "ENABLE_UPDATER" false)
|
||||
(lib.cmakeBool "USE_FREEIMAGE" false) # freeimage was removed from nixpkgs
|
||||
(lib.cmakeBool "USE_PCRE" false) # causes link errors and is not needed anyway (use std::regex instead)
|
||||
];
|
||||
|
||||
postInstall = lib.optionalString stdenv.hostPlatform.isDarwin ''
|
||||
mkdir -p $out/bin
|
||||
for bundle in $out/Applications/*.app; do
|
||||
ln -s "$bundle/Contents/MacOS"/* -t $out/bin
|
||||
done
|
||||
|
||||
# this command has different names (linux: mega-cmd-server; macos: MEGAcmd; windows: MEGAcmdServer)
|
||||
# NOTE: official documentation (https://help.mega.io/desktop-app/mega-cmd/cmd) is outdated about this
|
||||
ln -s $out/bin/MEGAcmd $out/bin/mega-cmd-server
|
||||
|
||||
# these commands are installed on linux but not on macos
|
||||
install -Dm755 ../src/client/mega-* -t $out/bin
|
||||
'';
|
||||
|
||||
preFixup = ''
|
||||
# use mega-exec from the same package instead of the one from PATH to avoid version mismatch
|
||||
for f in $out/bin/*; do
|
||||
if [[ "$(file -b --mime-type "$f")" == text/* ]]; then # shell script
|
||||
substituteInPlace "$f" --replace-fail mega-exec "exec $out/bin/mega-exec"
|
||||
elif [[ -f "$f" ]]; then # binary executable and not symlink
|
||||
wrapProgram "$f" --prefix PATH : $out/bin${
|
||||
# there are some rpath problems on darwin that causes the binaries unable to find shared libraries
|
||||
# there is probably a better way to fix this, but I cannot find it out
|
||||
# everything in buildInputs is needed
|
||||
lib.optionalString stdenv.hostPlatform.isDarwin
|
||||
" --prefix DYLD_LIBRARY_PATH : ${lib.makeLibraryPath finalAttrs.buildInputs}"
|
||||
}
|
||||
fi
|
||||
done
|
||||
'';
|
||||
|
||||
# mega-exec wants to connect to megacmd server
|
||||
__darwinAllowLocalNetworking = finalAttrs.doInstallCheck;
|
||||
|
||||
doInstallCheck = true;
|
||||
nativeInstallCheckInputs = [ versionCheckHook ];
|
||||
versionCheckProgram = "${placeholder "out"}/bin/mega-version";
|
||||
versionCheckProgramArg = "-l";
|
||||
|
||||
passthru.updateScript = nix-update-script {
|
||||
extraArgs = [ "--version-regex=(\\d+\\.\\d+\\.\\d+)_Linux" ];
|
||||
};
|
||||
|
||||
meta = {
|
||||
description = "MEGA Command Line Interactive and Scriptable Application";
|
||||
homepage = "https://mega.io/cmd";
|
||||
changelog = "https://github.com/meganz/MEGAcmd/blob/${finalAttrs.src.tag}/build/megacmd/megacmd.changes";
|
||||
license = with lib.licenses; [
|
||||
bsd2
|
||||
gpl3Only
|
||||
@@ -110,5 +174,6 @@ stdenv.mkDerivation {
|
||||
lunik1
|
||||
ulysseszhan
|
||||
];
|
||||
mainProgram = "mega-cmd";
|
||||
};
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user