From owner-freebsd-hackers@FreeBSD.ORG Sat Jul 14 20:32:17 2007 Return-Path: X-Original-To: hackers@freebsd.org Delivered-To: freebsd-hackers@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B1B0816A401; Sat, 14 Jul 2007 20:32:17 +0000 (UTC) (envelope-from tim@kientzle.com) Received: from kientzle.com (h-66-166-149-50.snvacaid.covad.net [66.166.149.50]) by mx1.freebsd.org (Postfix) with ESMTP id 6DBB813C471; Sat, 14 Jul 2007 20:32:17 +0000 (UTC) (envelope-from tim@kientzle.com) Received: from [10.0.0.222] (p54.kientzle.com [66.166.149.54]) by kientzle.com (8.12.9/8.12.9) with ESMTP id l6EKKFH7002869; Sat, 14 Jul 2007 13:20:15 -0700 (PDT) (envelope-from tim@kientzle.com) Message-ID: <46992FFF.7010906@kientzle.com> Date: Sat, 14 Jul 2007 13:20:15 -0700 From: Tim Kientzle User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.12) Gecko/20060422 X-Accept-Language: en-us, en MIME-Version: 1.0 To: hackers@freebsd.org Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Cc: rwatson@freebsd.org, cperciva@freebsd.org Subject: Tar output mode for installworld X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Jul 2007 20:32:17 -0000 I saw this project suggestion on www.freebsd.org: 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: 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