initrd: Reorganize and crunch 70 more rescue tools
authorAaron LI <aly@aaronly.me>
Sun, 10 Jun 2018 06:43:02 +0000 (14:43 +0800)
committerAaron LI <aly@aaronly.me>
Wed, 4 Jul 2018 09:46:01 +0000 (17:46 +0800)
* Merge "rescue.sbin" into "rescue" to save space (avoid duplicated
  libraries to be linked).

* Move "lvm" out of "rescue.libcrypto" since lvm(8) doesn't need libcrypto.

* Crunch 70 more tools (aliases not counted):

  awk, basename, bc, bzip2, cap_mkdb, chflags, chown, cmp, cpio, cut,
  date, dirname, dmsetup, dump, ed, env, expr, false, find, fstyp, gzip,
  head, hexdump, hostname, id, join, kcollect, kdump, kenv, ktrace,
  ldconfig, lsvfs, mount_devfs, nc, paste, patch, pax, pkill, printf,
  pw, pwd_mkdb, rcorder, realpath, relpath, restore, rtsold, savecore,
  sed, sort, stat, stty, tail, tar, tee, touch, tput, tr, traceroute,
  traceroute6, true, truss, uname, uniq, varsym, vi, vipw, vnconfig, wc,
  xz, yes

  Highlights:
  awk, bzip2, chown, cpio, find, gzip, nc, pw, sed, tar, vi, xz

  Now the total number of crunched rescue tools more than 230 (including
  aliases), but the total size remains almost the same :-)

* Improve the makefiles to be much cleaner.

Makefile_upgrade.inc
initrd/Makefile
initrd/bin/Makefile [deleted file]
initrd/etc/motd
initrd/rescue.libcrypto/Makefile [new file with mode: 0644]
initrd/rescue/Makefile [new file with mode: 0644]
initrd/rescue/dowpa [moved from initrd/bin/dowpa with 100% similarity]
initrd/sbin.libcrypto/Makefile [deleted file]
initrd/sbin/Makefile [deleted file]

index 582ba75..0dd51d0 100644 (file)
@@ -3428,6 +3428,7 @@ TO_REMOVE+=/usr/share/examples/etc/defaults/mkinitrd.conf
 TO_REMOVE+=/usr/share/initrd
 TO_REMOVE+=/usr/share/man/man5/mkinitrd.conf.5.gz
 TO_REMOVE+=/usr/share/man/man8/mkinitrd.8.gz
+TO_REMOVE+=/rescue/rescue.sbin
 
 .if !defined(WANT_INSTALLER)
 TO_REMOVE+=/usr/sbin/dfuibe_installer
index 6aa2406..e4445ff 100644 (file)
@@ -10,9 +10,9 @@ INITRD_STAGEDIR!=     mktemp -d -t initrd-stage
 .END:
        @rm -rf ${INITRD_STAGEDIR}
 
-rescue:
+rescue: .PHONY
        @${ECHO} ">>> Building and installing rescue tools ..."
-.for _dir in bin oinit sbin sbin.libcrypto
+.for _dir in oinit rescue rescue.libcrypto
 .if !defined(NO_CLEAN)
        (cd ${.CURDIR}/${_dir}; \
            ${INITRD_MAKE} BINDIR=${RESCUE_DIR} clean cleandepend)
@@ -37,7 +37,7 @@ initrd: rescue
 
 clean:
        @${ECHO} ">>> Cleaning ..."
-.for _dir in etc bin oinit sbin sbin.libcrypto
+.for _dir in etc oinit rescue rescue.libcrypto
        (cd ${.CURDIR}/${_dir}; \
            ${ECHO} "=> ${_dir}"; \
            ${INITRD_MAKE} BINDIR=${RESCUE_DIR} clean cleandepend)
diff --git a/initrd/bin/Makefile b/initrd/bin/Makefile
deleted file mode 100644 (file)
index 65a2aa7..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-#$FreeBSD: head/rescue/rescue/Makefile 252356 2013-06-28 21:00:08Z davide $
-#      @(#)Makefile    8.1 (Berkeley) 6/2/93
-
-# To include '../Makefine.inc' for use in <bsd.crunchgen.mk>
-.include <bsd.init.mk>
-
-PROG=  rescue
-SCRIPTS=dowpa
-
-###################################################################
-# Programs from stock /bin
-#
-# WARNING: Changing this list may require adjusting
-# /usr/include/paths.h as well!  You were warned!
-#
-CRUNCH_SRCDIRS+= bin
-CRUNCH_PATH_bin= ${.CURDIR}/../..
-CRUNCH_PROGS_bin=      \
-       cat             \
-       chmod           \
-       cp              \
-       cpdup           \
-       dd              \
-       df              \
-       echo            \
-       kill            \
-       ln              \
-       ls              \
-       mined           \
-       mkdir           \
-       mv              \
-       ps              \
-       pwd             \
-       rm              \
-       rmdir           \
-       sh              \
-       sleep           \
-       sync            \
-       test
-
-CRUNCH_LIBS+= -lcrypt -lprivate_edit -lkvm -ll -lmd -lprivate_ncurses -lutil
-
-# Additional options for specific programs
-CRUNCH_ALIAS_test= [
-
-CRUNCH_ALIAS_sh= -sh
-# The -sh alias shouldn't appear in /rescue as a hard link
-CRUNCH_SUPPRESS_LINK_-sh= 1
-
-CRUNCH_ALIAS_ln= link
-CRUNCH_ALIAS_rm= unlink
-
-
-CRUNCH_SRCDIRS+= usr.bin
-CRUNCH_PATH_usr.bin= ${.CURDIR}/../..
-CRUNCH_PROGS_usr.bin= du less undo ssh fetch
-CRUNCH_ALIAS_less= more
-CRUNCH_ALIAS_ssh= scp
-
-CRUNCH_KEEP_ssh= roaming_write roaming_read add_recv_bytes
-
-CRUNCH_LIBS+=  ${PRIVATELIB_LDFLAGS}
-CRUNCH_LIBS+=  -lfetch -lprivate_ssh -lprivate_ssl -lprivate_crypto -lz -lpthread
-
-.include <bsd.crunchgen.mk>
-.include <bsd.prog.mk>
index 0c61863..f45f393 100644 (file)
@@ -5,6 +5,7 @@ Fix problems and mount the real root partition at `/new_root', then exit
 this shell to continue the normal boot.
 
 * Text editor:
+  # vi
   # mined  (F1: help, Ctrl-W: write file, Ctrl-X: exit)
 * List available interfaces:
   # ifconfig
diff --git a/initrd/rescue.libcrypto/Makefile b/initrd/rescue.libcrypto/Makefile
new file mode 100644 (file)
index 0000000..a55c50a
--- /dev/null
@@ -0,0 +1,75 @@
+# $FreeBSD: head/rescue/rescue/Makefile 252356 2013-06-28 21:00:08Z davide $
+#      @(#)Makefile    8.1 (Berkeley) 6/2/93
+
+# To include '../Makefine.inc' for use in <bsd.crunchgen.mk>
+.include <bsd.init.mk>
+
+PROG= rescue.libcrypto
+
+# Programs from 'bin'
+#
+CRUNCH_SRCDIRS+= bin
+CRUNCH_PATH_bin= ${.CURDIR}/../..
+CRUNCH_PROGS_bin= ed
+
+CRUNCH_ALIAS_ed= red
+
+# Programs from 'usr.bin'
+#
+CRUNCH_SRCDIRS+= usr.bin
+CRUNCH_PATH_usr.bin= ${.CURDIR}/../..
+CRUNCH_PROGS_usr.bin=  \
+       cpio            \
+       fetch           \
+       nc              \
+       ssh             \
+       tar
+
+CRUNCH_ALIAS_ssh= scp
+CRUNCH_KEEP_ssh= roaming_write roaming_read add_recv_bytes
+
+# Programs from 'sbin'
+#
+CRUNCH_SRCDIRS+= sbin
+CRUNCH_PATH_sbin= ${.CURDIR}/../..
+CRUNCH_PROGS_sbin=     \
+       md5             \
+       hammer          \
+       hammer2         \
+       ping6           \
+       tcplay
+
+CRUNCH_ALIAS_md5= rmd160 sha1 sha256 sha512
+
+# Programs from 'usr.sbin'
+#
+CRUNCH_SRCDIRS+= usr.sbin/802_11
+CRUNCH_PATH_usr.sbin/802_11= ${.CURDIR}/../..
+CRUNCH_PROGS_usr.sbin/802_11= wpa_supplicant
+
+# Programs from 'gnu/sbin'
+#
+CRUNCH_SRCDIRS+= gnu/sbin
+CRUNCH_PATH_gnu/sbin= ${.CURDIR}/../..
+CRUNCH_PROGS_gnu/sbin= cryptsetup
+
+CRUNCH_LIBS+= -ldm -lprop  # tcplay, cryptsetup
+CRUNCH_LIBS+= -lpcap  # wpa_supplicant
+CRUNCH_LIBS+= -lhammer  # hammer
+CRUNCH_LIBS+= -ldmsg  # hammer2
+CRUNCH_LIBS+= -lfetch  # fetch
+CRUNCH_LIBS+= -larchive  # cpio, tar
+CRUNCH_LIBS+= -llzma  # cpio, tar
+CRUNCH_LIBS+= -lbz2  # cpio, tar
+CRUNCH_LIBS+= -lmd  # cpio, md5, ping6, tar
+CRUNCH_LIBS+= -lprivate_ssl  # fetch, wpa_supplicant
+CRUNCH_LIBS+= -lprivate_ssh  # ssh
+CRUNCH_LIBS+= -lprivate_crypto
+CRUNCH_LIBS+= -lutil
+CRUNCH_LIBS+= -lz  # cpio, ssh, tar
+CRUNCH_LIBS+= -lm  # hammer, hammer2, ping6
+CRUNCH_LIBS+= -lpthread
+CRUNCH_LIBS+= ${PRIVATELIB_LDFLAGS}
+
+.include <bsd.crunchgen.mk>
+.include <bsd.prog.mk>
diff --git a/initrd/rescue/Makefile b/initrd/rescue/Makefile
new file mode 100644 (file)
index 0000000..ff48e9e
--- /dev/null
@@ -0,0 +1,237 @@
+# $FreeBSD: head/rescue/rescue/Makefile 252356 2013-06-28 21:00:08Z davide $
+#      @(#)Makefile    8.1 (Berkeley) 6/2/93
+
+# To include '../Makefine.inc' for use in <bsd.crunchgen.mk>
+.include <bsd.init.mk>
+
+PROG= rescue
+
+SCRIPTS= dowpa ${.CURDIR}/../../sbin/dhclient/dhclient-script
+
+# Programs from 'bin'
+#
+CRUNCH_SRCDIRS+= bin
+CRUNCH_PATH_bin= ${.CURDIR}/../..
+CRUNCH_PROGS_bin=      \
+       cat             \
+       chmod           \
+       cp              \
+       cpdup           \
+       date            \
+       dd              \
+       df              \
+       echo            \
+       expr            \
+       hostname        \
+       kill            \
+       ln              \
+       ls              \
+       mined           \
+       mkdir           \
+       mv              \
+       pax             \
+       ps              \
+       pwd             \
+       realpath        \
+       rm              \
+       rmdir           \
+       sh              \
+       sleep           \
+       stty            \
+       sync            \
+       test            \
+       varsym
+
+# Additional options for specific programs
+CRUNCH_ALIAS_test= [
+CRUNCH_ALIAS_sh= -sh
+# The -sh alias shouldn't appear as a link
+CRUNCH_SUPPRESS_LINK_-sh= 1
+CRUNCH_ALIAS_ln= link
+CRUNCH_ALIAS_rm= unlink
+
+# Programs from 'usr.bin'
+#
+CRUNCH_SRCDIRS+= usr.bin
+CRUNCH_PATH_usr.bin= ${.CURDIR}/../..
+CRUNCH_PROGS_usr.bin=  \
+       awk             \
+       basename        \
+       bc              \
+       bzip2           \
+       cap_mkdb        \
+       chflags         \
+       cmp             \
+       cut             \
+       dirname         \
+       du              \
+       env             \
+       false           \
+       find            \
+       gzip            \
+       head            \
+       hexdump         \
+       kcollect        \
+       kdump           \
+       kenv            \
+       ktrace          \
+       id              \
+       join            \
+       less            \
+       lsvfs           \
+       paste           \
+       patch           \
+       pkill           \
+       printf          \
+       relpath         \
+       sed             \
+       sort            \
+       stat            \
+       tail            \
+       tee             \
+       touch           \
+       tput            \
+       tr              \
+       true            \
+       truss           \
+       uname           \
+       undo            \
+       uniq            \
+       vi              \
+       wc              \
+       xz              \
+       yes
+
+CRUNCH_ALIAS_bzip2= bunzip2 bzcat
+CRUNCH_ALIAS_gzip= gunzip gzcat zcat
+CRUNCH_ALIAS_hexdump= hd od
+CRUNCH_ALIAS_id= groups whoami
+CRUNCH_ALIAS_less= more
+CRUNCH_ALIAS_pkill= pgrep
+CRUNCH_ALIAS_stat= readlink
+CRUNCH_ALIAS_vi= ex nex nvi nview view
+CRUNCH_ALIAS_xz= lzcat lzma unlzma unxz xzcat
+
+# Programs from 'sbin'
+#
+CRUNCH_SRCDIRS+= sbin
+CRUNCH_PATH_sbin= ${.CURDIR}/../..
+CRUNCH_PROGS_sbin=     \
+       camcontrol      \
+       ccdconfig       \
+       dhclient        \
+       diskinfo        \
+       disklabel32     \
+       disklabel64     \
+       dmesg           \
+       dump            \
+       dumpfs          \
+       dumpon          \
+       fdisk           \
+       ffsinfo         \
+       fsck            \
+       fsck_msdosfs    \
+       gpt             \
+       growfs          \
+       ifconfig        \
+       kldconfig       \
+       kldload         \
+       kldstat         \
+       kldunload       \
+       ldconfig        \
+       mount           \
+       mount_cd9660    \
+       mount_devfs     \
+       mount_hammer    \
+       mount_hammer2   \
+       mount_msdos     \
+       mount_nfs       \
+       mount_ntfs      \
+       mount_null      \
+       mount_tmpfs     \
+       mount_ufs       \
+       natacontrol     \
+       newfs           \
+       newfs_hammer    \
+       newfs_hammer2   \
+       newfs_msdos     \
+       ping            \
+       rconfig         \
+       rcorder         \
+       reboot          \
+       restore         \
+       route           \
+       savecore        \
+       shutdown        \
+       swapon          \
+       sysctl          \
+       tunefs          \
+       udevd           \
+       umount          \
+       vinum
+
+CRUNCH_ALIAS_disklabel64= disklabel
+CRUNCH_ALIAS_dump= rdump
+CRUNCH_ALIAS_newfs= mount_mfs
+CRUNCH_ALIAS_reboot= halt
+CRUNCH_ALIAS_restore= rrestore
+CRUNCH_ALIAS_shutdown= poweroff
+CRUNCH_ALIAS_swapon= swapoff swapctl
+
+# Programs from 'usr.sbin'
+#
+CRUNCH_SRCDIRS+= usr.sbin
+CRUNCH_PATH_usr.sbin= ${.CURDIR}/../..
+CRUNCH_PROGS_usr.sbin= \
+       boot0cfg        \
+       chown           \
+       chroot          \
+       fstyp           \
+       pw              \
+       pwd_mkdb        \
+       rtsold          \
+       traceroute      \
+       traceroute6     \
+       vnconfig        \
+       vipw
+
+CRUNCH_ALIAS_chown= chgrp
+CRUNCH_ALIAS_rtsold= rtsol
+
+CRUNCH_SRCDIRS+= gnu/sbin
+CRUNCH_PATH_gnu/sbin= ${.CURDIR}/../..
+CRUNCH_PROGS_gnu/sbin= dmsetup lvm
+
+CRUNCH_ALIAS_lvm= \
+       lvchange lvconvert lvcreate lvdisplay lvextend \
+       lvmchange lvmdiskscan lvmdump \
+       lvreduce lvremove lvrename lvresize lvs lvscan \
+       pvchange pvck pvcreate pvdisplay pvmove pvremove \
+       pvresize pvs pvscan \
+       vgcfgbackup vgcfgrestore vgchange vgck vgconvert \
+       vgcreate vgdisplay vgexport vgextend vgimport \
+       vgmerge vgmknodes vgreduce vgremove vgrename \
+       vgs vgscan vgsplit
+
+CRUNCH_LIBS+= -llvm -ldevmapper -ldevattr -ldm -lprop  # lvm
+CRUNCH_LIBS+= -ldevstat  # vinum
+CRUNCH_LIBS+= -lbsdxml  # ifconfig
+CRUNCH_LIBS+= -lcam # camcontrol
+CRUNCH_LIBS+= -lsbuf  # camcontrol, ifconfig
+CRUNCH_LIBS+= -lkiconv  # mount_{cd9660,msdos,ntfs}
+CRUNCH_LIBS+= -llzma  # xz
+CRUNCH_LIBS+= -lbz2  # bzip2
+CRUNCH_LIBS+= -lkvm  # ccdconfig, dmesg, pkill, ps
+CRUNCH_LIBS+= -lcrypt  # pw
+CRUNCH_LIBS+= -lmd  # cpdup
+CRUNCH_LIBS+= -lprivate_edit  # bc, sh, vinum
+#CRUNCH_LIBS+= -lprivate_ncurses  # bc, less, ls, tput, vinum (=> ncursesw)
+CRUNCH_LIBS+= -lprivate_ncursesw  # vi
+CRUNCH_LIBS+= -lutil
+CRUNCH_LIBS+= -lz  # savecore
+CRUNCH_LIBS+= -lm  # awk, ps, ping
+CRUNCH_LIBS+= -lpthread
+CRUNCH_LIBS+= ${PRIVATELIB_LDFLAGS}
+
+.include <bsd.crunchgen.mk>
+.include <bsd.prog.mk>
similarity index 100%
rename from initrd/bin/dowpa
rename to initrd/rescue/dowpa
diff --git a/initrd/sbin.libcrypto/Makefile b/initrd/sbin.libcrypto/Makefile
deleted file mode 100644 (file)
index 97e9f36..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-# $FreeBSD: head/rescue/rescue/Makefile 252356 2013-06-28 21:00:08Z davide $
-#      @(#)Makefile    8.1 (Berkeley) 6/2/93
-
-# To include '../Makefine.inc' for use in <bsd.crunchgen.mk>
-.include <bsd.init.mk>
-
-PROG= rescue.libcrypto
-
-CRUNCH_SRCDIRS+= sbin
-CRUNCH_PATH_sbin= ${.CURDIR}/../..
-CRUNCH_PROGS_sbin=     \
-       md5             \
-       hammer          \
-       hammer2         \
-       ping            \
-       ping6           \
-       tcplay
-
-CRUNCH_ALIAS_md5= rmd160 sha1 sha256 sha512
-
-CRUNCH_SRCDIRS+= usr.sbin/802_11
-CRUNCH_PATH_usr.sbin/802_11= ${.CURDIR}/../..
-CRUNCH_PROGS_usr.sbin/802_11= wpa_supplicant
-
-CRUNCH_SRCDIRS+= gnu/sbin
-CRUNCH_PATH_gnu/sbin= ${.CURDIR}/../..
-CRUNCH_PROGS_gnu/sbin= cryptsetup lvm
-
-CRUNCH_ALIAS_lvm= \
-       lvchange lvconvert lvcreate lvdisplay lvextend \
-       lvmchange lvmdiskscan lvmdump \
-       lvreduce lvremove lvrename lvresize lvs lvscan \
-       pvchange pvck pvcreate pvdisplay pvmove pvremove \
-       pvresize pvs pvscan \
-       vgcfgbackup vgcfgrestore vgchange vgck vgconvert \
-       vgcreate vgdisplay vgexport vgextend vgimport \
-       vgmerge vgmknodes vgreduce vgremove vgrename \
-       vgs vgscan vgsplit
-
-CRUNCH_LIBS+= -llvm -ldevmapper -ldevattr  # lvm
-CRUNCH_LIBS+= -ldm -lprop  # tcplay, cryptsetup, lvm
-CRUNCH_LIBS+= -ldmsg -lutil -lhammer -lm
-CRUNCH_LIBS+= -lmd  # md5, ping6
-CRUNCH_LIBS+= -lpcap  # wpa_supplicant
-CRUNCH_LIBS+= -lprivate_ssl  # wpa_supplicant
-CRUNCH_LIBS+= -lprivate_crypto
-CRUNCH_LIBS+= -lpthread
-CRUNCH_LIBS+= ${PRIVATELIB_LDFLAGS}
-
-.include <bsd.crunchgen.mk>
-.include <bsd.prog.mk>
diff --git a/initrd/sbin/Makefile b/initrd/sbin/Makefile
deleted file mode 100644 (file)
index 2bf60d0..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-#$FreeBSD: head/rescue/rescue/Makefile 252356 2013-06-28 21:00:08Z davide $
-#      @(#)Makefile    8.1 (Berkeley) 6/2/93
-
-# To include '../Makefine.inc' for use in <bsd.crunchgen.mk>
-.include <bsd.init.mk>
-
-PROG=  rescue.sbin
-
-SCRIPTS= ${.CURDIR}/../../sbin/dhclient/dhclient-script
-
-CRUNCH_SRCDIRS+= sbin
-CRUNCH_PATH_sbin= ${.CURDIR}/../..
-CRUNCH_PROGS_sbin=     \
-       camcontrol      \
-       ccdconfig       \
-       dhclient        \
-       diskinfo        \
-       disklabel32     \
-       disklabel64     \
-       dmesg           \
-       dumpfs          \
-       dumpon          \
-       fdisk           \
-       ffsinfo         \
-       fsck            \
-       fsck_msdosfs    \
-       gpt             \
-       growfs          \
-       ifconfig        \
-       kldconfig       \
-       kldload         \
-       kldstat         \
-       kldunload       \
-       mount           \
-       mount_cd9660    \
-       mount_hammer    \
-       mount_hammer2   \
-       mount_msdos     \
-       mount_nfs       \
-       mount_ntfs      \
-       mount_null      \
-       mount_tmpfs     \
-       mount_ufs       \
-       natacontrol     \
-       newfs           \
-       newfs_hammer    \
-       newfs_hammer2   \
-       newfs_msdos     \
-       rconfig         \
-       reboot          \
-       route           \
-       shutdown        \
-       swapon          \
-       sysctl          \
-       tunefs          \
-       udevd           \
-       umount          \
-       vinum
-
-CRUNCH_ALIAS_disklabel64= disklabel
-CRUNCH_ALIAS_newfs= mount_mfs
-CRUNCH_ALIAS_reboot= halt
-CRUNCH_ALIAS_shutdown= poweroff
-CRUNCH_ALIAS_swapon= swapoff swapctl
-
-CRUNCH_LIBS+= -lcam -lsbuf -lutil -lkvm -lm -lhammer -lkiconv
-CRUNCH_LIBS+= -lprivate_edit -lprivate_ncurses -ldevstat -lprop -lpthread
-CRUNCH_LIBS+= -lbsdxml
-CRUNCH_LIBS+= ${PRIVATELIB_LDFLAGS}
-
-CRUNCH_SRCDIRS+= usr.sbin
-CRUNCH_PATH_usr.sbin= ${.CURDIR}/../..
-CRUNCH_PROGS_usr.sbin= boot0cfg chroot
-
-.include <bsd.crunchgen.mk>
-.include <bsd.prog.mk>