From owner-freebsd-current@FreeBSD.ORG Wed Feb 6 13:20:27 2013 Return-Path: Delivered-To: freebsd-current@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 1228A10A; Wed, 6 Feb 2013 13:20:27 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from duck.symmetricom.us (duck.symmetricom.us [206.168.13.214]) by mx1.freebsd.org (Postfix) with ESMTP id C7977978; Wed, 6 Feb 2013 13:20:26 +0000 (UTC) Received: from damnhippie.dyndns.org (daffy.symmetricom.us [206.168.13.218]) by duck.symmetricom.us (8.14.6/8.14.6) with ESMTP id r16DKPpl010177; Wed, 6 Feb 2013 06:20:26 -0700 (MST) (envelope-from ian@FreeBSD.org) Received: from [172.22.42.240] (revolution.hippie.lan [172.22.42.240]) by damnhippie.dyndns.org (8.14.3/8.14.3) with ESMTP id r16DKNsn033192; Wed, 6 Feb 2013 06:20:23 -0700 (MST) (envelope-from ian@FreeBSD.org) Subject: Re: Cross-architecture package installs From: Ian Lepore To: Tim Kientzle In-Reply-To: <4703DEB0-E2DC-403E-9F14-DE968CBE4921@freebsd.org> References: <4703DEB0-E2DC-403E-9F14-DE968CBE4921@freebsd.org> Content-Type: text/plain; charset="us-ascii" Date: Wed, 06 Feb 2013 06:20:22 -0700 Message-ID: <1360156822.93359.575.camel@revolution.hippie.lan> Mime-Version: 1.0 X-Mailer: Evolution 2.32.1 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit Cc: freebsd-current Current X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Feb 2013 13:20:27 -0000 On Tue, 2013-02-05 at 22:34 -0800, Tim Kientzle wrote: > I'm working on tools to build ARM system images. > Usually, these tools run on x86, which creates a problem > for packages. > > I would like to install packages onto the image as it's built. > So I've been experimenting with variations of > pkg -c add > > I'm running into a few problems but I think they can all be > solved. Only the first is critical; the rest are relatively > minor annoyances. > > 1) Pre-install/post-install scripts. > > These obviously don't work since the DESTDIR > is for a different architecture. > > At least for post-install, it should be possible to > record which packages still need their post-install > scripts run and arrange to run them after first > boot. I'm picturing an rc.d script that invokes pkg > with appropriate options to find all packages > that still need their post-install run and runs them. > > This won't work for pre-install, but those are rarer > and we can hopefully work around them on a > case-by-case basis. > > 2) The chroot happens before opening the package files. > > It's possible to work around this by copying all of the > package files into DESTDIR first, but that's both > time-consuming and rather awkward. (And quite > tricky if you're installing directly onto a mounted > image that has very little free space.) > > It should be feasible to open the package files first > and then chroot. Then the actual installation still > happens entirely inside DESTDIR. > If you have a directory full of the package files, you can nullfs-mount it within the chroot rather than copying its contents in. Nullfs mounts are great for crossing chroot barriers in such situations. Using them does make your scripts more complex, because you need abort and exit handling in the scripts to undo the mounts no matter what kind of exit the script encounters. If you don't, you end up leaving nullfs mounts that make later things fail (such as running the script again, or trying to clean/remove a chroot tree). -- Ian