Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 14 Jul 2007 13:20:15 -0700
From:      Tim Kientzle <tim@kientzle.com>
To:        hackers@freebsd.org
Cc:        rwatson@freebsd.org, cperciva@freebsd.org
Subject:   Tar output mode for installworld
Message-ID:  <46992FFF.7010906@kientzle.com>

next in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?46992FFF.7010906>