Skip to content
This repository has been archived by the owner on Nov 18, 2022. It is now read-only.

Add native support for Apple Silicon Macs #786

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

nehalvpatel
Copy link

@nehalvpatel nehalvpatel commented Oct 2, 2021

Building the daemon

You don't need to make any changes to compile the daemon for Apple Silicon. If your openssl is installed using Homebrew, you might need to export some variables before running ./configure and make.

Universal

Build or obtain both an x86_64 (Intel) and an arm64 (Apple Silicon) variant of the nzbget daemon. Use lipo to combine both binaries into a FAT binary.

xbuild


Building the tools

Thankfully, both 7za and unrar are ready to build for Apple Silicon as well.

You could grab 7za from Homebrew by installing the cask and extracting the binary:

carbon

You'll probably have to build unrar yourself.

Universal

Perform the same steps found above in the daemon's Universal section.


Building the wrapper

This is a little tricky. I believe the maintainers use a wrapper build script that's not in this repo. They'll have to make sure that the daemon and tools binaries they include are universal binaries (as shown above).

If you want to build it yourself:

  • Make a tools folder under osx/Resources.
  • In tools, paste in the Apple Silicon / universal binary of 7za.
  • In tools, paste in cacert.pem. (Can be found in an existing release of NZBGet.app)
  • In tools, paste in the Apple Silicon / universal binary of unrar.
  • Make a daemon folder under osx/Resources.
  • Make a usr folder under osx/Resources/daemon.
  • Make a local folder under osx/Resources/daemon/usr.
  • Make a bin folder under osx/Resources/daemon/usr/local.
  • In bin, create a symbolic link called 7za to ../../../../tools/7za.
  • In bin, create a symbolic link called 7zr to ../../../../tools/7za.
  • In bin, create a symbolic link called cacert.pem to ../../../../tools/cacert.pem.
  • In bin, create a symbolic link called unrar to ../../../../tools/unrar.
  • In bin , paste in the Apple Silicon / universal binary of the nzbget daemon.
  • Make a share folder under osx/Resources/daemon/usr/local.
  • Make a nzbget folder under osx/Resources/daemon/usr/local/share.
  • In share, paste in scripts. (Can be found in the root of the repo)
  • In share, paste in webui. (Can be found in the root of the repo)
  • In share, paste in nzbget.conf or your own. (Can be found in the root of the repo)
  • Open NZBGet.xcodeproj in osx/ with Xcode.
  • In Xcode, create a Release build.
  • In Xcode, use the ProductShow Build Folder in Finder menubar command.
  • In Finder, locate the NZBGet.app you just built and place it in your Applications folder.
  • In Terminal, run this command to code-sign the wrapper: sudo codesign --force --deep --sign - /Applications/NZBGet.app

Universal wrapper binary built with Xcode:

lipo

Native daemon and wrapper app running on an M1 Mac:

Screen Shot 2021-10-02 at 5 16 44 PM

Note from Apple's Building a Universal macOS Binary article:

Screen Shot 2021-10-02 at 17 14 35

@rtargosz
Copy link

rtargosz commented Dec 21, 2021

Hey @nehalvpatel thanks for this excellent write-up! I received my new M1 MacBook Pro yesterday and followed this to get NZBGet building as a Universal application. A couple of extra notes:

  • OpenSSL v3 changes FIPS integration so I added a check in daemon/connect/TlsSocket.cpp at line 191 for "#if OPENSSL_VERSION_MAJOR < 0x3" to avoid calling FIPS_mode_set(0) which is depreciated. Not sure if OpenSSL v2 works on OSX 12.1 and later, but this is a two line change (with the #endif) to get v3 working, so easy enough.
  • Also in daemon/connect/TlsSocket.cpp, the 5-6 instances of PrintError that use the BString give an error about no conversion available to const char *. There are some easy fixes to this, but I just commented them out for now.
  • RarLab now has an Apple Silicon version (6.10 or later) of the CLI tools available here, so you no longer need to build unrar from source.

Here are the steps I used on MacOS 12.1 on Apple Silicon for anybody who wants them:
Install Xcode 13.2, register as developer toolchain, enable command line tools.
Install homebrew and then these packages:

  • brew install libxml2
  • brew install openssl
  • brew install zsh
  • brew install sevenzip

Make changes indicated above to daemon/connect/TlsSocket.cpp and NZBGet.xcodeproj/project.pbxproj

./configure --with-libxml2-includes=/opt/homebrew/opt/libxml2/include/ --with-libxml2-libraries=/opt/homebrew/opt/libxml2/lib/ --with-libcurses-includes=/opt/homebrew/opt/ncurses/include/ --with-libcurses-libraries=/opt/homebrew/opt/ncurses/lib/ --with-openssl-includes="/opt/homebrew/opt/openssl@3/include/" --with-openssl-libraries="/opt/homebrew/opt/openssl@3/lib/" --with-zlib-includes=/opt/homebrew/opt/zlib/include/ --with-zlib-libraries=/opt/homebrew/opt/zlib/lib/

Run the make command then follow the "Building the wrapper" instructions above.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants