FreshPorts has always strived to be correct. Even when it’s difficult. One issue which always always proven difficult is ports that rely upon other ports. or cannot be installed with other ports. Case in point, sysutils/msktutil, which includes this message: IGNORE: cannot install: SASL support requested and openldap-client-2.4.20 is installed
That’s not really appropriate on FreshPorts. You may not have openldap-client, but the production FreshPorts web server has it installed. Removing it is not an option. I need certain ports to run the server. In fact, there are 465 ports installed on that server.
But zi has an evil cunning plan. He came up with after talking to me about sysutils/msktutil. Use chroot.
I like it. I like it because it’s simple.
Demonstration of the problem
$ cd /usr/ports/sysutils/msktutil $ /usr/bin/make -V PORTNAME -V PKGNAME -V IGNORE -V -f /usr/ports/sysutils/msktutil/Makefile msktutil msktutil-0.4.1 cannot install: SASL support requested and openldap-client-2.4.20 is installed $
Ideally, we don’t get that IGNORE.
The solution
The solution, do this all in an environment which does not contain ports.
Let me outline it. First, you create a bunch of directories which will mimic a port environment. Like this:
mkdir -p /ports-jail/usr/ports \ /ports-jail/usr/share/mk \ /ports-jail/usr/sbin \ /ports-jail/usr/bin \ /ports-jail/libexec \ /ports-jail/usr/lib \ /ports-jail/sbin \ /ports-jail/lib \ /ports-jail/bin \ /ports-jail/dev
Then, create mountpoints which mimic a real box. The following entries are added /etc/fstab:
/usr/ports /ports-jail/usr/ports nullfs ro,nosuid,noexec 0 0 /usr/share/mk /ports-jail/usr/share/mk nullfs ro,nosuid,noexec 0 0 /usr/sbin /ports-jail/usr/sbin nullfs ro,nosuid 0 0 /usr/bin /ports-jail/usr/bin nullfs ro,nosuid 0 0 /libexec /ports-jail/libexec nullfs ro,nosuid 0 0 /usr/lib /ports-jail/usr/lib nullfs ro,nosuid 0 0 /sbin /ports-jail/sbin nullfs ro,nosuid 0 0 /lib /ports-jail/lib nullfs ro,nosuid 0 0 /bin /ports-jail/bin nullfs ro,nosuid 0 0 none /ports-jail/dev devfs rw 0 0
Once you have that, mount them:
$ sudo mount -a
Now we need a little script and we’ll put it at /ports-jail/make.sh:
#!/bin/sh PORTDIR=$1 cd ${PORTDIR} /usr/bin/make -V PORTNAME -V PKGNAME -V IGNORE -V -f /usr/ports/${PORTDIR}/Makefile LOCALBASE=/nonexistentlocal
Then you can issue this command:
$ sudo /usr/sbin/chroot -u dan /ports-jail /make.sh /usr/ports/sysutils/msktutil msktutil msktutil-0.4.1 $
You’ll see that IGNORE is now empty. A very good start.
NOTE: The reason we mount /ports-jail/dev like that is to avoid this error:
$ sudo /usr/sbin/chroot -u dan /ports-jail /make.sh /usr/ports/sysutils/msktutil cannot create /dev/null: No such file or directory msktutil msktutil-0.4.1 $
So far so good. This seems like a good proof of concept. :)