Version 3 (modified by kencu (Ken), 4 years ago) (diff) |
---|
Installing MacPorts on Ubuntu Linux
MacPorts has been designed to be multi-platform, and it does install on Ubuntu Linux with modest modifications. Please note that at this point in time, this is a highly experimental process, and issues are expected to arise.
First, some quick notes for those familiar with Darwin; on Ubuntu:
apt is the built-in package manager, similar to "port".
"sudo apt install" is similar to "sudo port install".
"apt info" is similar to "port info"
"apt-file show" does something similar to "port contents", but the software does not have to be installed.
To install MacPorts on Ubuntu Linux, you must first install the necessary prerequisites that are typically found on Darwin systems. At the time of writing, this was:
sudo apt install clang-9 sudo apt install clang sudo apt install mtree-netbsd sudo apt install tcl8.6 sudo apt install curl sudo apt install sqlite3 sudo apt install gnustep sudo apt install libcurl4-gnutls-dev sudo apt install libsqlite3-dev sudo apt install libssl-dev
or, all at once:
sudo apt install clang-9 clang mtree-netbsd tcl8.6 curl sqlite3 gnustep libcurl4-gnutls-dev libsqlite3-dev libssl-dev
Note: there has been a conflict noted with libmd-dev
when installing base; just disable that temporarily to install MacPorts. There could easily be other such conflicts not yet discovered.
Then download the macports tarball from macports.org, perhaps using the included FireFox browser, and decompress it, as per the usual Darwin instructions <https://www.macports.org/install.php#source>.
I suggest that you don't install startup items at this point in time, as this functionality is different on Ubuntu, so configure your build like this:
./configure --without-startupitems
and then
make && sudo make install
Then add the "macports" user, in the Ubuntu way:
sudo adduser --system --group --home /opt/local/var/macports/home --disabled-password macports sudo chown -R macports:macports /opt/local/var/macports/home
Add the macports directory to your PATH as usual, but on Ubuntu, by editing ".bashrc", for example with nano
, adding a line like this:
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
Also add that PATH to the sudo command's path, like this:
sudo visudo
and add it to the secure_path
Defaults secure_path="/opt/local/bin:/opt/local/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
There are some differences between Darwin and Ubuntu, and to work around some of these that are not already compensated for by MacPorts base, set some defaults in macports.conf
like this:
sudo gedit /opt/local/etc/macports/macports.conf
and add:
buildmakejobs 2 # or a more appropriate number for your processor count default_compilers clang # compiler selection is not yet working on Ubuntu, this chooses /usr/bin/clang which works best with macport's portfiles cxx_stdlib libstdc++ # configure.cxx_stdlib is not yet working on Ubuntu, this fills in appropriate default build_arch x86_64
Darwin and Ubuntu supply 'sed' in different locations, so rather than edit many Portfiles that expect it in the Darwin location, you can do this:
sudo ln -s /bin/sed /usr/bin/sed
And at that point, you should be able to run normal MacPorts commands.
sudo port -v selfupdate
will update your ports tree to the current status.
And then try to install a typical port, like this:
sudo port -v install libffi
And presto:
$ port -v installed The following ports are currently installed: libffi @3.2.1_0 (active) platform='linux 5' archs='x86_64' date='2020-05-02T23:25:44-0700
You can certainly expect to come across issues; MacPorts' PortFiles have largely been written to assume they are installing on Darwin, but with minor modifications to some ports, seem happy with Linux as well.