initrd: Detach from the world and build on the fly
authorAaron LI <aly@aaronly.me>
Sat, 2 Jun 2018 05:31:45 +0000 (13:31 +0800)
committerAaron LI <liweitianux@live.com>
Fri, 8 Jun 2018 08:02:29 +0000 (16:02 +0800)
commite79a303f7db7331d570bb6c6abdd555eeefdcdc2
treeb157c76f6a66b62341cea812ff78e43cd2f1b8bd
parentf71956f75f646783a438957a0c60e142bbb8725d
initrd: Detach from the world and build on the fly

Why
---
Currently, the files for initrd image creation are built and installed at
/usr/share/initrd by "buildworld" and "installworld", respectively, and then
mkinitrd(8) simply packs them to create the initrd.img.gz.

For normal users, the shipped /usr/share/initrd and mkinitrd(8) don't make
much sense, since they don't need to modify the initrd contents and create
a modified initrd image.

From a developer's perspective, the required steps (buildworld, installworld
and mkinitrd) to create and test a new initrd image can be annoying.

How
---
Detach the build and installation of the initrd contents from the world.
Build the (rescue/initrd) tools on-the-fly when creating the initrd image.

As per ftigeot's suggestion, these statically linked tools can be useful when
dealing with a broken system, so install them under /rescue to be more
intuitive and easier to use (similar to FreeBSD and maybe other BSDs).

What
----
* Move "share/initrd" to be top-level, and detach it from world.

  + Update the patch in bsd.crunchgen.mk accordingly.
  + Add Makefile.inc to simplify subdir's makefiles.
  + Rewrite the Makefile with targets:
    - rescue: build and install the rescue tools into /rescue.
    - initrd: further packs the etc and rescue staffs to create the initrd
              image.

* Move "sbin/mkinitrd/mkinitrd.sh" under the new "initrd" directory and adapt
  it to work with the "initrd" make target.  Remove the other parts of
  mkinitrd(8).

* Export the above "rescue" and "initrd" targets to be top-level.

* Update nrelease framework to use the new "make initrd".

* Update build.7 man page accordingly.

* Print the message about updating the initrd image and 3rd-party packages
  after "make upgrade" instead of "make installworld".

* Document this change in UPDATING.

* Other small updates and style cleanups.

TODO
----
* Add initrd.7 man page
* Crunch more useful tools
* Crunch bin/sbin/etc. into a bundle to save space (??)

Reviewed-by: swildner
Thanks-to: dillon, swildner, ftigeot
35 files changed:
Makefile
Makefile.inc1
Makefile_upgrade.inc
README
UPDATING
etc/Makefile
etc/mtree/BSD.root.dist
etc/mtree/BSD.usr.dist
initrd/Makefile [new file with mode: 0644]
initrd/Makefile.inc [new file with mode: 0644]
initrd/bin/Makefile [moved from share/initrd/bin/Makefile with 95% similarity]
initrd/bin/dowpa [moved from share/initrd/bin/dowpa with 90% similarity]
initrd/etc/Makefile [new file with mode: 0644]
initrd/etc/motd [moved from share/initrd/etc/motd with 100% similarity]
initrd/etc/rc [moved from share/initrd/etc/rc with 100% similarity]
initrd/etc/rc.lvm2 [moved from share/initrd/etc/rc.lvm2 with 100% similarity]
initrd/etc/rcmount_crypt [moved from share/initrd/etc/rcmount_crypt with 100% similarity]
initrd/etc/rcmount_tcplay [moved from share/initrd/etc/rcmount_tcplay with 100% similarity]
initrd/mkinitrd.sh [new file with mode: 0755]
initrd/oinit/Makefile [moved from share/initrd/mini_init/Makefile with 57% similarity]
initrd/oinit/oinit.c [moved from share/initrd/mini_init/oinit.c with 96% similarity]
initrd/oinit/pathnames.h [moved from share/initrd/mini_init/pathnames.h with 96% similarity]
initrd/sbin.libcrypto/Makefile [moved from share/initrd/sbin.libcrypto/Makefile with 87% similarity]
initrd/sbin.lvm/Makefile [moved from share/initrd/sbin.lvm/Makefile with 96% similarity]
initrd/sbin/Makefile [moved from share/initrd/sbin/Makefile with 91% similarity]
nrelease/Makefile
sbin/Makefile
sbin/mkinitrd/Makefile [deleted file]
sbin/mkinitrd/mkinitrd.8 [deleted file]
sbin/mkinitrd/mkinitrd.sh [deleted file]
share/Makefile
share/initrd/Makefile [deleted file]
share/initrd/etc/Makefile [deleted file]
share/man/man7/build.7
share/mk/bsd.crunchgen.mk