From c91442e9912035bcd659f253abf5fa20ee005193 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Sun, 10 Jun 2018 14:43:02 +0800 Subject: [PATCH] initrd: Reorganize and crunch 70 more rescue tools * 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 | 1 + initrd/Makefile | 6 +- initrd/bin/Makefile | 66 --------- initrd/etc/motd | 1 + initrd/rescue.libcrypto/Makefile | 75 ++++++++++ initrd/rescue/Makefile | 237 +++++++++++++++++++++++++++++++ initrd/{bin => rescue}/dowpa | 0 initrd/sbin.libcrypto/Makefile | 51 ------- initrd/sbin/Makefile | 76 ---------- 9 files changed, 317 insertions(+), 196 deletions(-) delete mode 100644 initrd/bin/Makefile create mode 100644 initrd/rescue.libcrypto/Makefile create mode 100644 initrd/rescue/Makefile rename initrd/{bin => rescue}/dowpa (100%) delete mode 100644 initrd/sbin.libcrypto/Makefile delete mode 100644 initrd/sbin/Makefile diff --git a/Makefile_upgrade.inc b/Makefile_upgrade.inc index 582ba75216..0dd51d0e3c 100644 --- a/Makefile_upgrade.inc +++ b/Makefile_upgrade.inc @@ -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 diff --git a/initrd/Makefile b/initrd/Makefile index 6aa2406e48..e4445ff0f0 100644 --- a/initrd/Makefile +++ b/initrd/Makefile @@ -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 index 65a2aa7733..0000000000 --- a/initrd/bin/Makefile +++ /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 -.include - -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 -.include diff --git a/initrd/etc/motd b/initrd/etc/motd index 0c61863413..f45f39392a 100644 --- a/initrd/etc/motd +++ b/initrd/etc/motd @@ -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 index 0000000000..a55c50a933 --- /dev/null +++ b/initrd/rescue.libcrypto/Makefile @@ -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 +.include + +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 +.include diff --git a/initrd/rescue/Makefile b/initrd/rescue/Makefile new file mode 100644 index 0000000000..ff48e9e4d8 --- /dev/null +++ b/initrd/rescue/Makefile @@ -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 +.include + +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 +.include diff --git a/initrd/bin/dowpa b/initrd/rescue/dowpa 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 index 97e9f3639a..0000000000 --- a/initrd/sbin.libcrypto/Makefile +++ /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 -.include - -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 -.include diff --git a/initrd/sbin/Makefile b/initrd/sbin/Makefile deleted file mode 100644 index 2bf60d0e7c..0000000000 --- a/initrd/sbin/Makefile +++ /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 -.include - -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 -.include -- 2.41.0