Changes between Initial Version and Version 1 of InstallingMacPortsOnUbuntuLinux


Ignore:
Timestamp:
May 3, 2020, 6:28:21 AM (4 years ago)
Author:
kencu (Ken)
Comment:

Initial submission - to be further tweaked before being made public.

Legend:

Unmodified
Added
Removed
Modified
  • InstallingMacPortsOnUbuntuLinux

    v1 v1  
     1**Installing MacPorts on Ubuntu Linux**
     2
     3----
     4
     5MacPorts 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.
     6
     7First, some quick notes for those familiar with Darwin;   on Ubuntu:
     8
     9apt is the built-in package manager, similar to "port".
     10
     11"sudo apt install" is similar to "sudo port install".
     12
     13"apt info" is similar to "port info"
     14
     15"apt-file show" does something similar to "port contents", but the software does not have to be installed.
     16
     17
     18To 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:
     19{{{
     20sudo apt install clang-9
     21sudo apt install clang
     22sudo apt install mtree-netbsd
     23sudo apt install tcl8.6
     24sudo apt install curl
     25sudo apt install sqlite3
     26sudo apt install gnustep
     27sudo apt install libcurl4-gnutls-dev
     28sudo apt install libsqlite3-dev
     29sudo apt install libssl-dev
     30}}}
     31or, all at once:
     32{{{
     33sudo apt install clang-9 clang mtree-netbsd tcl8.6 curl sqlite3 gnustep libcurl4-gnutls-dev libsqlite3-dev libssl-dev
     34}}}
     35
     36Then download the macports tarball using a web browser 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>.
     37
     38I 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:
     39{{{
     40./configure --without-startupitems
     41}}}
     42and then
     43{{{
     44make && sudo make install
     45}}}
     46
     47Then add the "macports" user, in the Ubuntu way:
     48{{{
     49sudo adduser --system --group --home /opt/local/var/macports/home  --disabled-password macports
     50sudo chown -R macports:macports /opt/local/var/macports/home
     51}}}
     52
     53Add the macports directory to your PATH as usual, but on Ubuntu, by editing ".bashrc", for example with {{{nano}}}, adding a line like this:
     54{{{
     55export PATH=/opt/local/bin:/opt/local/sbin:$PATH
     56}}}
     57
     58Also add that PATH to the sudo command's path, like this:
     59{{{
     60sudo visudo
     61}}}
     62and add it to the secure_path
     63{{{
     64Defaults  secure_path="/opt/local/bin:/opt/local/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
     65}}}
     66There 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:
     67
     68{{{
     69sudo gedit /opt/local/etc/macports/macports.conf
     70}}}
     71and add:
     72{{{
     73buildmakejobs          2                # or a more appropriate number for your processor count
     74default_compilers      clang            # compiler selection is not yet working on Ubuntu, this chooses /usr/bin/clang which works best with macport's portfiles
     75cxx_stdlib             libstdc++        # configure.cxx_stdlib is not yet working on Ubuntu, this fills in appropriate default
     76build_arch             x86_64
     77}}}
     78
     79Darwin and Ubuntu supply 'sed' in different locations, so rather than edit many Portfiles that expect it in the Darwin location, you can do this:
     80{{{
     81sudo ln -s /bin/sed /usr/bin/sed
     82}}}
     83
     84And at that point, you should be able to run normal MacPorts commands.
     85{{{
     86sudo port -v selfupdate
     87}}}
     88will update your ports tree to the current status.
     89
     90And then try to install a typical port, like this:
     91{{{
     92sudo port -v install libffi
     93}}}
     94
     95And presto:
     96{{{
     97$ port -v installed
     98The following ports are currently installed:
     99  libffi @3.2.1_0 (active) platform='linux 5' archs='x86_64' date='2020-05-02T23:25:44-0700
     100}}}
     101
     102You 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.
     103
     104
     105