Skip to content

Commit

Permalink
megacmd: add darwin support
Browse files Browse the repository at this point in the history
  • Loading branch information
UlyssesZh committed Dec 13, 2024
1 parent 4211063 commit 7c87ea1
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 28 deletions.
49 changes: 49 additions & 0 deletions pkgs/by-name/me/megacmd/fix-darwin.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
--- 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
--- 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
#endif

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
72 changes: 44 additions & 28 deletions pkgs/by-name/me/megacmd/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,43 +25,56 @@
let
pname = "megacmd";
version = "1.7.0";
srcOptions =
if stdenv.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;

src = fetchFromGitHub {
owner = "meganz";
repo = "MEGAcmd";
rev = "${version}_Linux";
hash = "sha256-UlSqwM8GQKeG8/K0t5DbM034NQOeBg+ujNi/MMsVCuM=";
fetchSubmodules = true;
};
src = fetchFromGitHub (
srcOptions
// {
owner = "meganz";
repo = "MEGAcmd";
fetchSubmodules = true;
}
);

enableParallelBuilding = true;
nativeBuildInputs = [
autoreconfHook
pkg-config
];

buildInputs = [
c-ares
cryptopp
curl
ffmpeg
icu
gcc-unwrapped
libmediainfo
libraw
libsodium
libuv
libzen
pcre-cpp
readline
sqlite
] ++ lib.optionals withFreeImage [ freeimage ];
buildInputs =
lib.optionals stdenv.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
]
++ lib.optionals withFreeImage [ freeimage ];

configureFlags = [
"--disable-curl-checks"
"--disable-examples"
"--with-cares"
"--with-cryptopp"
Expand All @@ -77,8 +90,14 @@ stdenv.mkDerivation {
"--with-termcap"
] ++ (if withFreeImage then [ "--with-freeimage" ] else [ "--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
'';

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
];

meta = {
Expand All @@ -88,10 +107,7 @@ stdenv.mkDerivation {
bsd2
gpl3Only
];
platforms = [
"i686-linux"
"x86_64-linux"
];
platforms = lib.platforms.linux ++ lib.platforms.darwin;
maintainers = with lib.maintainers; [
lunik1
ulysseszhan
Expand Down

0 comments on commit 7c87ea1

Please sign in to comment.