Unports

Unports is a humble attempt to provide an easy to use personal package management system. It is strongly inspired by the FreeBSD Ports and aims to recreate their simplicity and general structure. It was also influenced by Portage used in Gentoo Linux.

FEATURES

DEPENDENCIES

OK, BUT WHAT DOES IT DO?

At its core, Unports installs each program it manages into ~/pkgs/SOME_NAME and then merges all the ~/pkgs/* directory trees into ~/local with GNU Stow which creates a directory similar to /usr or /usr/local. The package format is meant to be as simple as possible and to automatically guess as much as it sanely can (for example automatic basic Autotools and CMake support).

To install Unports, run ./install.sh and answer the questions it will ask. It will explain each action it is about to make and let you abort at any point.

EXAMPLES

To see what Unports means by “extremely simple” consider these packages:

PKG = ncdu
VER = 1.13
URL = https://dev.yorhel.nl/download/$(ARCHIVE)

include ../unports.mk
PKG = emacs
VER = git
URL = https://git.savannah.gnu.org/git/$P.git --depth 1

MAKEOPTS = -j5

include ../unports.mk
PKG = emacs
VER = git
URL = https://git.savannah.gnu.org/git/$P.git -b $(BRANCH) --depth 1

BRANCH = emacs-26.1
MAKEOPTS = -j5

include ../unports.mk

Installation

To start using Unports, simply copy the unports directory into ~/ports (other directories will work too but it’s the default used by the installer) and start filling it with your packages/ports (one directory = one port). Try copying there some of the examples first to see how it works. So your first package would be placed in ~/ports/my-package and contain at minimum the file ~/ports/my-package/Makefile.

You can also run ./install.sh which does more or less the same thing.

Syntax

Usually an unport consists of only a Makefile with these 4 lines:

PKG = some-name
VER = version
URL = https://example.com
include ../unports.mk

Variables:

Additionally the variable P is a shorthand for PKG, V for VER and PV is the same as $(P)-$(V), like in the Portage ebuilds.

Optional variables:

Optional variables for Git-based packages:

Optional variables for archive-based packages:

In both cases $(PKGNAME) will also be used as the directory name in ~/pkgs.

Targets

The installation process in Unports consists of these targets:

Each of these targets may be invoked separately and each one will first run all the previous ones if needed. For example make extract will download and unpack the sources.

FETCH

If VER is set to git, fetch clone the URL repository with the --bare flag.

If VER isn’t set to git, it download the file pointed with URL. This file’s name should be stored in ARCHIVE (defaults to $(PV).tar.gz).

EXTRACT

If VER is set to git, clone locally the previously fetched bare repository into a normal repository with a regular working tree.

If VER isn’t set to git, use tar to unpack the previously downloaded archive.

PATCH

Symlink the patches directory from the package directory to the project source tree unpacked in the previous step. Afterwards apply all the patches in the Quilt series with quilt push -a.

If the patches directory doesn’t exist, do nothing.

CONFIGURE

Run ./configure --prefix=$(PREFIX) in the project source tree if configure exists. Calls ./autogen.sh beforehand too if it exists. If neither of these files exists, this step effectively does nothing.

Can be overriden with a script called script/configure. The script is started in the project source tree.

BUILD

Run make $(MAKEOPTS) in the project source tree.

Can be overriden with a script called script/build. The script is started in the project source tree.

INSTALL

Run make PREFIX=$(PREFIX) install in the project source tree to install it into $(PREFIX), by default ~/pkgs/$(PV).

Can be overriden with a script called script/install. The script is started in the project source tree.

MERGE

Run stow -v -t ~/local -S $(PREFIX) to merge the new package into ~/local. ~/local may be actually overriden with the STOWDIR variable but it was not tested.

More targets

There are also a few cleanup targets:

Each of these steps performs the previous one too.

Helpers:

COPYRIGHT

Copyright (c) 2018, Wojciech Siewierski

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.