| 1 | **Installing MacPorts on Ubuntu Linux** |
| 2 | |
| 3 | ---- |
| 4 | |
| 5 | 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. |
| 6 | |
| 7 | First, some quick notes for those familiar with Darwin; on Ubuntu: |
| 8 | |
| 9 | apt 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 | |
| 18 | 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: |
| 19 | {{{ |
| 20 | sudo apt install clang-9 |
| 21 | sudo apt install clang |
| 22 | sudo apt install mtree-netbsd |
| 23 | sudo apt install tcl8.6 |
| 24 | sudo apt install curl |
| 25 | sudo apt install sqlite3 |
| 26 | sudo apt install gnustep |
| 27 | sudo apt install libcurl4-gnutls-dev |
| 28 | sudo apt install libsqlite3-dev |
| 29 | sudo apt install libssl-dev |
| 30 | }}} |
| 31 | or, all at once: |
| 32 | {{{ |
| 33 | sudo apt install clang-9 clang mtree-netbsd tcl8.6 curl sqlite3 gnustep libcurl4-gnutls-dev libsqlite3-dev libssl-dev |
| 34 | }}} |
| 35 | |
| 36 | Then 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 | |
| 38 | 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: |
| 39 | {{{ |
| 40 | ./configure --without-startupitems |
| 41 | }}} |
| 42 | and then |
| 43 | {{{ |
| 44 | make && sudo make install |
| 45 | }}} |
| 46 | |
| 47 | Then add the "macports" user, in the Ubuntu way: |
| 48 | {{{ |
| 49 | sudo adduser --system --group --home /opt/local/var/macports/home --disabled-password macports |
| 50 | sudo chown -R macports:macports /opt/local/var/macports/home |
| 51 | }}} |
| 52 | |
| 53 | Add the macports directory to your PATH as usual, but on Ubuntu, by editing ".bashrc", for example with {{{nano}}}, adding a line like this: |
| 54 | {{{ |
| 55 | export PATH=/opt/local/bin:/opt/local/sbin:$PATH |
| 56 | }}} |
| 57 | |
| 58 | Also add that PATH to the sudo command's path, like this: |
| 59 | {{{ |
| 60 | sudo visudo |
| 61 | }}} |
| 62 | and add it to the secure_path |
| 63 | {{{ |
| 64 | Defaults secure_path="/opt/local/bin:/opt/local/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin" |
| 65 | }}} |
| 66 | 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: |
| 67 | |
| 68 | {{{ |
| 69 | sudo gedit /opt/local/etc/macports/macports.conf |
| 70 | }}} |
| 71 | and add: |
| 72 | {{{ |
| 73 | buildmakejobs 2 # or a more appropriate number for your processor count |
| 74 | default_compilers clang # compiler selection is not yet working on Ubuntu, this chooses /usr/bin/clang which works best with macport's portfiles |
| 75 | cxx_stdlib libstdc++ # configure.cxx_stdlib is not yet working on Ubuntu, this fills in appropriate default |
| 76 | build_arch x86_64 |
| 77 | }}} |
| 78 | |
| 79 | 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: |
| 80 | {{{ |
| 81 | sudo ln -s /bin/sed /usr/bin/sed |
| 82 | }}} |
| 83 | |
| 84 | And at that point, you should be able to run normal MacPorts commands. |
| 85 | {{{ |
| 86 | sudo port -v selfupdate |
| 87 | }}} |
| 88 | will update your ports tree to the current status. |
| 89 | |
| 90 | And then try to install a typical port, like this: |
| 91 | {{{ |
| 92 | sudo port -v install libffi |
| 93 | }}} |
| 94 | |
| 95 | And presto: |
| 96 | {{{ |
| 97 | $ port -v installed |
| 98 | The 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 | |
| 102 | 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. |
| 103 | |
| 104 | |
| 105 | |