Subject: Re: elf->a.out (was Re: How good is FreeBSD emulation?)
To: Frederick Bruckman <fb@enteract.com>
From: Todd Vierling <tv@wasabisystems.com>
List: port-i386
Date: 09/22/2000 14:50:14
On Fri, 22 Sep 2000, Frederick Bruckman wrote:

: On 22 Sep 2000, Kent Polk wrote:
: 
: > Speaking of 1.5 and ELF (headed the other way), is there a mechanism
: > to support 1.4.2 a.out libraries alongside ELF? In particular the
: > pkg system...  I thought I had read somewhere that it was possible
: > to use an a.out pkg system with 1.5 ELF.
: > 
: > Why? Because I have a small network of 1.4.2 boxes with an extensive
: > pkg installation and am trying to figure out how to more systematically
: > migrate it to ELF than just shutting the whole system down till I
: > get it finished.

: Move the a.out shared libraries in /usr/lib to /emul/aout/usr/lib,
: /usr/pkg/lib to /emul/aout/usr/pkg/lib, etc. You should also get
: ldconfig from an a.out machine, and arrange to run it once on boot-up.

This doesn't help his situation.  What he's trying to do is the very purpose
of that infamous option I keep trying to explain... COMPAT_AOUT.  I'll take
the plunge and explain this process in detail here.

=====

Kent:  There's a hidden kernel compile-time option in NetBSD 1.5 and
-current that will allow you to do a piece-by-piece migration of /usr/pkg
without severe downtime, but it is a little complicated, and has some
drawbacks[*].  This process assumes that you're decently versed in
manipulating programs and files under NetBSD.

To use the option as part of your 1.5 upgrade, do the following in this
order:

- add COMPAT_AOUT to 1.5 kernel config and compile, booting into it
- copy /usr/lib/* to /emul/aout/usr/lib/*
- upgrade base system binaries to 1.5
- modify your $PATH to search /emul/aout/usr/pkg/{bin,sbin} after /usr/pkg
- move /usr/pkg to /emul/aout/usr/pkg
- move /var/db/pkg to /emul/aout/var/db/pkg

If you have any base system programs that rely on stuff in /usr/pkg
(sendmail using procmail as a delivery agent, for instance), you may need to
put temporary symlinks in /usr/pkg to make those work in the meantime.

Now, you'll have two instances of /usr/pkg:  one in /emul/aout/usr/pkg
(a.out binaries) and one in /usr/pkg (empty, or nonexistent), and the system
will be up and running.  Because of COMPAT_AOUT, the binaries in /emul/aout
are "tricked" into working by first looking for pathnames starting with
/emul/aout/ instead of just /.

[*] The drawbacks are VERY important to note.  Because programs are tricked
into looking under /emul/aout, things which work with absolute pathnames may
seem a little funny until they are updated with ELF counterparts.  
Particularly, you'll find that doing things like "cd /usr" in an a.out shell
won't work as you expect--you'll end up in /emul/aout/usr.  (Temporary
workaround is that you can "cd //" and then "cd usr", separately.)

So, if you use a shell from /usr/pkg, upgrade that FIRST.  Then upgrade
other packages by adding them to the (now ELF) /usr/pkg.  You'll need to
replace *everything*, as you cannot link ELF binaries against the a.out
libraries.  While doing this upgrade, you can inspect the list of old
packages (presuming you moved /var/db/pkg to /emul/aout/var/db/pkg!) with:

    env PKG_DBDIR=/emul/aout/var/db/pkg pkg_info

Make sure you get all of your old config files from /usr/pkg/etc, and copied
any third party stuff that you may have thrown in there manually.  When
you're confident that you have upgraded everything, you can delete
/emul/aout/usr/pkg and /emul/aout/var/db/pkg.

A similar procedure can, of course, be used for /usr/local if you have a
significant amount of software in there.  And, if you have any other a.out
binaries, you'll need to keep the necessary dependent libraries on your
system.

=====

Tailnote to this process:

1.5 will be shipping with a replacement /usr/libexec/ld.so that will search
/emul/aout automatically for a.out binaries (obsoleting one purpose of the
COMPAT_AOUT option).  However, it doesn't help any software that needs to
reference /usr/pkg/etc, /usr/pkg/libexec, or other binaries in /usr/pkg/bin,
since those directories need to be "out of the way" as you do the piecemeal
upgrade.

-- 
-- Todd Vierling <tv@wasabisystems.com>  *  http://www.wasabisystems.com/
-- Speed, stability, security, and support.  Wasabi NetBSD:  Run with it.