Tar output mode for installworld

Tim Kientzle tim at kientzle.com
Sat Jul 14 20:32:17 UTC 2007


I saw this project suggestion on www.freebsd.org:

<http://www.freebsd.org/projects/ideas/#p-taroutmode>

and thought I'd contribute a couple of ideas and notes:

This is easy to implement using a trick that I stumbled
across a few years ago.  The idea is to just build
a description of the final archive in a nice verbose
text format such as:

<file> <keyword> <data>

E.g.,

bin/sh file /usr/obj/usr/src/bin/sh
bin/sh uname root
bin/sh gname wheel
rescue/mkdir hardlink rescue/rescue
bin/sh mode 0666
bin/rcp mode 04666

Here a "file" entry indicates where the body of a file
is located, "uname", "gname", "mode", etc, specify
various pieces of metadata.

The key point is that this file doesn't have to get
written in order.  You can write single lines of this
information at any point in the install process to a
file:

   echo ${TARGETFILE} uname ${OWNER} >>${INSTALLLISTFILE}
   echo ${TARGETFILE} file ${SRCFILE} >> ${INSTALLLISTFILE}

This should be easy to splice into the install process,
just add some conditionals on whether ${INSTALLLISTFILE}
is defined or not.

Once you've built this file, just sort it to bring all
the data for each entry together.  (As a bonus, sorting
will put bin before bin/sh.)

 From there, it's a simple exercise to write a program that
reads this input and spits out a tar file using libarchive.
(Start from the sample code in the archive_write manpage.)

Incorporating mtree input might be a bit trickier; one option
would be to modify mtree itself to spit out a condensed
format like this as output.

Given these details, I'm sure there are lots of people
who could get 90% of this working over a weekend.  There
are a bunch of odd corner cases to finish up the last 10%,
but I don't see anything especially tricky.

The end result would be a way to build install CDs without
having to run as root.  Building an install tarfile could
even benefit regular "installworld," since the final install
could be done with a minimal toolkit (no need for awk,
sed, or other complex commands, just /bin/sh, make, and tar).

Tim Kientzle


More information about the freebsd-hackers mailing list