Static Tools

The fastest way to get setup for developing and building Mere Linux packages is to download and configure static versions of three packages.

First, grab the latest pacman release:

curl -LO

Extract the package:

TMPDIR=$(mktemp -d)
tar -C "$TMPDIR" -xf pacman-latest-x86_64.pkg.tar.xz

Using the temporary pacman, install to the /mere directory some static copies of pacman and lxc:

sudo install -d /mere/var/lib/pacman /mere/pkgs
sudo "$TMPDIR/bin/pacman" -Sy --config "$TMPDIR/etc/pacman.conf" \
    -b /mere/var/lib/pacman \
    lxc-portable pacman-portable

Now, using the installed pacman, also install busybox to the /mere directory:

sudo touch /mere/pkgs/buildlocal.db
sudo /mere/bin/pacman -Sy -r /mere -b /mere/var/lib/pacman busybox

These operations will have installed new items as the root user so change the contents of /mere once again to be owned by your current user:

sudo chown -R $(whoami) /mere

Clean up the temporary directory:

rm -rf "$TMPDIR"

Configure LXC

The merebuild containers need network access for downloading resources. The simplest way to consistently accomplish this is to add a bridge interface on the host and an iptables rule that allows NAT forwarding.

To set this up, create the following script:

cat >preplxc << "EOF"
#/bin/sh -e
/mere/sbin/brctl addbr mere0 2>/dev/null || true
/mere/sbin/brctl setfd mere0 0
/mere/sbin/ifconfig mere0 netmask promisc up
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
echo 1 >/proc/sys/net/ipv4/ip_forward

mountpoint -q /sys/fs/cgroup || mount -t tmpfs cgroupfs /sys/fs/cgroup
awk '!/^#/ { if ($4 == 1) print $1 }' /proc/cgroups | \
        while IFS= read -r sys; do
    mkdir -p "$sys_path"
    mountpoint -q "$sys_path" ||
        mount -n -t cgroup -o "$sys" cgroup "$sys_path" ||
        rmdir "$sys_path" ||
sudo install -m0754 preplxc /mere/bin/preplxc


The above script assumes ‘eth0’ is the name of the interface used for accessing the internet. If a different device is used, substitute with the correct name on the iptables line.

And of course, to execute it, run:

sudo /mere/bin/preplxc


The changes this script makes will not survive a reboot. If you want them to be persistent, refer to the documentation of your host OS. An example for Debian-based systems is here:

Assuming the above networking configuration is used, the following default configuration will give the containers access to the network as well as read-only access to important packaging directories. If you used different adpater names or IP addresses, you will need to make the corresponding changes below.

printf '
# Basic settings = merebuild-container

# Network settings = veth = up = mere0 = =

# Kernel/Virtual Mount Entries
lxc.autodev = 1
lxc.hook.autodev = /mere/share/lxc/ = proc:mixed sys:ro
lxc.mount.entry = shm dev/shm tmpfs rw,nosuid,nodev,noexec,relatime,mode=1777,size=256m,create=dir 0 0

# Mere-specific Mount Entries
lxc.mount.entry = /mere mere none defaults,bind 0 0
' | sudo tee /mere/etc/lxc/default.conf

Great! Now you’re ready to start working. Head on over to Workflow if you’re looking to build custom packages, or back to Creating a Disk Image if you’re just interested in kicking the tires.