Tuesday, October 03, 2006

Installing Screen Port with Remote FreeBSD Ports Tree

I don't like to keep ports trees on all of my FreeBSD systems. I prefer to install packages whenever possible. Upgrading those packages requires the ports tree, however. To use Portupgrade I NFS mount /usr/ports from a single system that keeps an up-to-date ports tree.

The major problem with this plan involves the sysutils/screen port. No package is created, and you can't build one yourself.

poweredge:/usr/ports/sysutils/screen# make package
===> screen-4.0.2_4 may not be packaged: Tends to loop using 100% CPU when used from
package - perhaps it hard-codes information about the build host.

Is there a way to build Screen without installing the ports tree?

First I tried just NFS mounting /usr/ports and trying to build the port. Here, poweredge is th box with the ports tree and mwmicro needs to run screen.

mwmicro:/root# mount
/dev/ad0s1a on / (ufs, local)
devfs on /dev (devfs, local)
/dev/ad0s1f on /home (ufs, local, soft-updates)
/dev/ad0s1g on /tmp (ufs, local, soft-updates)
/dev/ad0s1d on /usr (ufs, local, soft-updates)
/dev/ad0s1e on /var (ufs, local, soft-updates)
10.1.13.2:/usr/ports on /usr/ports (nfs)

Note that poweredge already installed Screen using the ports tree.

mwmicro:/usr/ports/sysutils/screen# make
mwmicro:/usr/ports/sysutils/screen# make install
mwmicro:/usr/ports/sysutils/screen# which screen
screen: Command not found.

That didn't work. Why? It's because poweredge, the box exporting the ports tree, already installed Screen. There's a "work" directory already built. I can't issue a "make clean" command here.

mwmicro:/usr/ports/sysutils/screen# make clean
===> Cleaning for screen-4.0.2_4
===> /usr/ports/sysutils/screen/work not writable, skipping

Ok, maybe I can issue "make clean" on poweredge and continue?

poweredge:/usr/ports/sysutils/screen# make clean
===> Cleaning for screen-4.0.2_4

Now back to mwmicro:

mwmicro:/usr/ports/sysutils/screen# make
===> Vulnerability check disabled, database not found
===> Extracting for screen-4.0.2_4
=> MD5 Checksum OK for screen-4.0.2.tar.gz.
=> SHA256 Checksum OK for screen-4.0.2.tar.gz.
mkdir: /usr/ports/sysutils/screen/work: Permission denied
*** Error code 1

Stop in /usr/ports/sysutils/screen.

Oh, that's right. /usr/ports is mounting read-only. I probably don't want to overwrite the ports tree anyway by exporting it read-write. Luckily I read FreeBSD Handbook after fzzzt in #freebsd suggested changing the work directory. I found the directive to change the location of the work directory and used it thus:

mwmicro:/usr/ports/sysutils/screen# make WRKDIRPREFIX=/tmp
===> Vulnerability check disabled, database not found
===> Extracting for screen-4.0.2_4
=> MD5 Checksum OK for screen-4.0.2.tar.gz.
=> SHA256 Checksum OK for screen-4.0.2.tar.gz.
===> Patching for screen-4.0.2_4
===> Applying FreeBSD patches for screen-4.0.2_4
===> Configuring for screen-4.0.2_4
configure: WARNING: you should use --build, --host, --target
this is screen version 4.0.2
checking for i386-portbld-freebsd6.1-gcc... cc
checking for C compiler default output... a.out
...edited...
mwmicro:/usr/ports/sysutils/screen# make install WRKDIRPREFIX=/tmp
===> Installing for screen-4.0.2_4
===> Generating temporary packing list
...edited...
mwmicro:/usr/ports/sysutils/screen# rehash
mwmicro:/usr/ports/sysutils/screen# which screen
/usr/local/bin/screen

Note that I used WRKDIRPREFIX=/tmp for both make and make install. Using that directive automatically made appropriate directories in /tmp:

mwmicro:/tmp/usr/ports/sysutils/screen/work# ls
.PLIST.flattened .configure_done.screen._usr_local
.PLIST.mktmp .extract_done.screen._usr_local
.PLIST.objdump .install_done.screen._usr_local
.PLIST.setuid .patch_done.screen._usr_local
.PLIST.writable screen-4.0.2
.build_done.screen._usr_local

I plan to use this system whenever I need to build an application using the ports tree and cannot make a package to share on other systems.

Update: If you try to build from a remote ports tree but the distfile for the desired port hasn't been downloaded, use 'make fetch' on the NFS server:

poweredge:/usr/ports/sysutils/screen# make fetch
=> screen-4.0.3.tar.gz doesn't seem to exist in /usr/ports/distfiles/.
=> Attempting to fetch from ftp://ftp.uni-erlangen.de/pub/utilities/screen/.
fetch: ftp://ftp.uni-erlangen.de/pub/utilities/screen/screen-4.0.3.tar.gz:
Service not available, closing control connection
=> Attempting to fetch from http://komquats.com/distfiles/.
screen-4.0.3.tar.gz 100% of 820 kB 52 kBps 00m00s

The continue with the steps shown above.

7 comments:

Anonymous said...

I usually build all ports on one system, then NFS mount that partion and pkg_add what I need. For screen, you can create a package using pkg_create.

Richard Bejtlich said...

As I noted above, you cannot (or at least should not) create a Screen package.

Anonymous said...

It sounds like you need a copy of Dru Lavigne's book "BSD Hacks" . She covers how to install a particular package from ports without downloading the entire ports tree with hack #82.
She has expanded on this section in the book with her blog entry here. I haven't actually attempted to use the new information on her blog, so if it doesn't work, I'd be happy to write down the commands she lists in her book on how to do it.

Have you considered switching to 'portupgrade' to manage your packages?
'portupgrade -RraP' will use packages whenever possible, compiling from source if packages are not available. 'portupgrade -RraPP' will use packages exclusively. This does require an up-to-date ports tree, but you already have one so it doesn't seem like it'd cause too much trouble for you.

Richard Bejtlich said...

Anonymous,

It sounds like you don't read this blog regularly or read articles I post on my Web site or in Sys Admin magazine. :)

I do have Dru's book. I don't like to use Hack 82 because it is too complicated and requires manually discovering and satisfying dependencies.

I do use Portupgrade to manage my ports, as noted elswhere.

Richard Bejtlich said...

Speaking of Portupgrade -- there is no need to use the Rr in 'Rra' according to this post. In other words, portupgrade -vaP or -vaPP is sufficient. These Top 10 Rules for Using the Ports System are helpful too.

Anonymous said...

You could just comment out the NO_PACKAGE line, make package, move it over, install it, and see if it works

dghnfgj said...
This comment has been removed by a blog administrator.