Subject: crunch binary for miniroot
To: None <port-sun3@NetBSD.org>
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
List: port-sun3
Date: 07/29/2006 19:36:08
Is there any reason why sun3 miniroot just use binaries
(including shlibs) from DESTDIR rather than to use crunchgen(1)
to create smaller binaries without shlibs?

If there is no particular reason, I'll commit the attachd changes
(which create crunched binaries), so that we'll get smaller image
and no longer have to sync shlib majors in the list file.

Ideally, sun3 should also use common src/distrib/miniroot and
leave only MD stuff in src/distrib/sun3/miniroot like other ports,
but it will happen later.
---
Izumi Tsutsui


Index: distrib/sun3/miniroot/Makefile
===================================================================
RCS file: /cvsroot/src/distrib/sun3/miniroot/Makefile,v
retrieving revision 1.32
diff -u -r1.32 Makefile
--- distrib/sun3/miniroot/Makefile	10 Jul 2003 10:34:15 -0000	1.32
+++ distrib/sun3/miniroot/Makefile	29 Jul 2006 10:17:17 -0000
@@ -6,7 +6,7 @@
 .include <bsd.kernobj.mk>
 
 IMAGE=		miniroot.fs
-IMAGESIZE=	12m
+IMAGESIZE=	6m
 MAKEFS_FLAGS=	-o minfree=0,optimization=space,density=8k
 
 KERNEL3=	${KERNOBJDIR}/INSTALL/netbsd
@@ -15,51 +15,26 @@
 WARNS=		1
 DBG=		-Os
 
+CRUNCHBIN=	instbin
+CRUNCHBIN_FLAGS= -d "${DBG}"
+
 LISTS=		${.CURDIR}/list
 MTREECONF=	${.CURDIR}/mtree.conf
 IMAGEENDIAN=	be
 PARSELISTENV=	KERNEL3=${KERNEL3} KERNEL3X=${KERNEL3X}
 MAKEDEVTARGETS=	std md0 cd0 st0 st1 sd0 sd1 sd2 xd0 xy0 fd0
-IMAGEDEPENDS=	${KERNEL3} ${KERNEL3X} \
+IMAGEDEPENDS=	${CRUNCHBIN} \
+		${KERNEL3} ${KERNEL3X} \
 		fstab install.md profile termcap \
-		${DESTDIR}/bin/cat ${DESTDIR}/bin/chmod ${DESTDIR}/bin/cp \
-		${DESTDIR}/bin/date ${DESTDIR}/bin/dd ${DESTDIR}/bin/df \
-		${DESTDIR}/bin/ed ${DESTDIR}/bin/expr ${DESTDIR}/bin/hostname \
-		${DESTDIR}/bin/kill ${DESTDIR}/bin/ln ${DESTDIR}/bin/ls \
-		${DESTDIR}/bin/mkdir ${DESTDIR}/bin/mt ${DESTDIR}/bin/mv \
-		${DESTDIR}/bin/pax ${DESTDIR}/bin/ps ${DESTDIR}/bin/pwd \
-		${DESTDIR}/bin/rm ${DESTDIR}/bin/rmdir ${DESTDIR}/bin/sh \
-		${DESTDIR}/bin/sleep ${DESTDIR}/bin/stty ${DESTDIR}/bin/sync \
-		${DESTDIR}/bin/test  \
 		${DESTDIR}/dev/MAKEDEV ${DESTDIR}/dev/MAKEDEV.local \
 		${DESTDIR}/etc/disktab ${DESTDIR}/etc/group \
 		${DESTDIR}/etc/master.passwd ${DESTDIR}/etc/netconfig \
 		${DESTDIR}/etc/passwd ${DESTDIR}/etc/protocols \
 		${DESTDIR}/etc/pwd.db ${DESTDIR}/etc/services \
 		${DESTDIR}/etc/spwd.db \
-		${DESTDIR}/sbin/dmesg ${DESTDIR}/sbin/edlabel \
-		${DESTDIR}/sbin/fsck ${DESTDIR}/sbin/fsck_ffs \
-		${DESTDIR}/sbin/ifconfig ${DESTDIR}/sbin/init \
-		${DESTDIR}/sbin/mknod ${DESTDIR}/sbin/mount \
-		${DESTDIR}/sbin/mount_cd9660 ${DESTDIR}/sbin/mount_ffs \
-		${DESTDIR}/sbin/mount_kernfs ${DESTDIR}/sbin/mount_nfs \
-		${DESTDIR}/sbin/newfs ${DESTDIR}/sbin/ping \
-		${DESTDIR}/sbin/reboot ${DESTDIR}/sbin/restore \
-		${DESTDIR}/sbin/route ${DESTDIR}/sbin/shutdown \
-		${DESTDIR}/sbin/slattach ${DESTDIR}/sbin/swapctl \
-		${DESTDIR}/sbin/sysctl ${DESTDIR}/sbin/umount \
-		${DESTDIR}/usr/bin/chflags ${DESTDIR}/usr/bin/cksum \
-		${DESTDIR}/usr/bin/cmp ${DESTDIR}/usr/bin/false \
-		${DESTDIR}/usr/bin/ftp ${DESTDIR}/usr/bin/gzip \
-		${DESTDIR}/usr/bin/less ${DESTDIR}/usr/bin/rsh \
-		${DESTDIR}/usr/bin/sed ${DESTDIR}/usr/bin/sort \
-		${DESTDIR}/usr/bin/tip ${DESTDIR}/usr/bin/true \
-		${DESTDIR}/usr/bin/vi \
 		${DESTDIR}/usr/mdec/bootxx \
 		${DESTDIR}/usr/mdec/netboot ${DESTDIR}/usr/mdec/tapeboot \
 		${DESTDIR}/usr/mdec/ufsboot \
-		${DESTDIR}/usr/sbin/chown ${DESTDIR}/usr/sbin/installboot \
-		${DESTDIR}/usr/sbin/rdate \
 		${DISTRIBDIR}/miniroot/install.sh \
 		${DISTRIBDIR}/miniroot/upgrade.sh \
 		install.sub
@@ -68,11 +43,17 @@
 		    	    ${DESTDIR}/usr/mdec/bootxx /ufsboot
 IMAGE_RELEASEDIR=	installation/miniroot
 
+# Use stubs to eliminate some large stuff from libc
+HACKSRC=	${DISTRIBDIR}/utils/libhack
+.include	"${HACKSRC}/Makefile.inc"
+${CRUNCHBIN}:	libhack.o
+
 install.sub: ${DISTRIBDIR}/miniroot/install.sub
 	sed -e "/^VERSION=/s/=.*/=${DISTRIBREV}/" < $? > $@
 
 CLEANFILES+= install.sub
 
+.include "${DISTRIBDIR}/common/Makefile.crunch"
 .include "${DISTRIBDIR}/common/Makefile.makedev"
 .include "${DISTRIBDIR}/common/Makefile.image"
 
Index: distrib/sun3/miniroot/list
===================================================================
RCS file: /cvsroot/src/distrib/sun3/miniroot/list,v
retrieving revision 1.11
diff -u -r1.11 list
--- distrib/sun3/miniroot/list	24 Jun 2006 23:40:58 -0000	1.11
+++ distrib/sun3/miniroot/list	29 Jul 2006 10:17:17 -0000
@@ -50,134 +50,104 @@
 COPY	${DISTRIBDIR}/miniroot/install.sh install		555
 COPY	${DISTRIBDIR}/miniroot/upgrade.sh upgrade		555
 
+SRCDIRS	bin sbin usr.bin usr.sbin
+
 # miniroot files from /sbin:
 # Extras not in ../../miniroot/list:
 #  disklabel dmesg edlabel mount_kernfs restore 
 
-COPY	${DESTDIR}/sbin/dmesg		sbin/dmesg		555
-COPY	${DESTDIR}/sbin/edlabel 	sbin/edlabel		555
-
-COPY	${DESTDIR}/sbin/fsck		sbin/fsck		555
-COPY	${DESTDIR}/sbin/fsck_ffs	sbin/fsck_ffs		555
-
-COPY	${DESTDIR}/sbin/ifconfig	sbin/ifconfig		555
-COPY	${DESTDIR}/sbin/init		sbin/init		555
-COPY	${DESTDIR}/sbin/mknod		sbin/mknod		555
-
-COPY	${DESTDIR}/sbin/mount		sbin/mount		555
-COPY	${DESTDIR}/sbin/mount_cd9660	sbin/mount_cd9660	555
-COPY	${DESTDIR}/sbin/mount_ffs	sbin/mount_ffs		555
-COPY	${DESTDIR}/sbin/mount_kernfs	sbin/mount_kernfs	555
-COPY	${DESTDIR}/sbin/mount_nfs	sbin/mount_nfs		555
-
-COPY	${DESTDIR}/sbin/newfs		sbin/newfs		555
-COPY	${DESTDIR}/sbin/ping		sbin/ping		555
-COPY	${DESTDIR}/sbin/reboot		sbin/reboot		555
-LINK		   sbin/reboot		sbin/halt
-
-COPY	${DESTDIR}/sbin/restore		sbin/restore		555
-LINK		   sbin/restore		sbin/rrestore
-
-COPY	${DESTDIR}/sbin/route		sbin/route		555
-COPY	${DESTDIR}/sbin/shutdown	sbin/shutdown		555
-COPY	${DESTDIR}/sbin/slattach	sbin/slattach		555
-COPY	${DESTDIR}/sbin/swapctl		sbin/swapctl		555
-COPY	${DESTDIR}/sbin/sysctl		sbin/sysctl		555
-COPY	${DESTDIR}/sbin/umount		sbin/umount		555
+PROG	sbin/disklabel
+PROG	sbin/dmesg
+PROG 	sbin/edlabel
+
+PROG	sbin/fsck
+PROG	sbin/fsck_ffs
+
+PROG	sbin/ifconfig
+PROG	sbin/init
+PROG	sbin/mknod
+
+PROG	sbin/mount
+PROG	sbin/mount_cd9660
+PROG	sbin/mount_ffs
+PROG	sbin/mount_kernfs
+PROG	sbin/mount_nfs
+
+PROG	sbin/newfs	sbin/mount_mfs
+PROG	sbin/ping
+PROG	sbin/reboot	sbin/halt
+
+PROG	sbin/route
+PROG	sbin/restore	sbin/rrestore
+
+PROG	sbin/shutdown
+PROG	sbin/slattach
+PROG	sbin/swapctl
+PROG	sbin/sysctl
+PROG	sbin/umount
 
 # miniroot files from /bin:
 # Extras not in ../../miniroot/list:
 #  date ps rmdir
 
-COPY	${DESTDIR}/bin/cat		bin/cat			555
-COPY	${DESTDIR}/bin/chmod		bin/chmod		555
-COPY	${DESTDIR}/bin/cp		bin/cp			555
-COPY	${DESTDIR}/bin/date		bin/date		555
-COPY	${DESTDIR}/bin/dd		bin/dd			555
-COPY	${DESTDIR}/bin/df		bin/df			555
-COPY	${DESTDIR}/bin/ed		bin/ed			555
-COPY	${DESTDIR}/bin/expr		bin/expr		555
-COPY	${DESTDIR}/bin/hostname		bin/hostname		555
-COPY	${DESTDIR}/bin/kill		bin/kill		555
-COPY	${DESTDIR}/bin/ln		bin/ln			555
-COPY	${DESTDIR}/bin/ls		bin/ls			555
-COPY	${DESTDIR}/bin/mkdir		bin/mkdir		555
-COPY	${DESTDIR}/bin/mt		bin/mt			555
-COPY	${DESTDIR}/bin/mv		bin/mv			555
-COPY	${DESTDIR}/bin/pax		bin/pax			555
-COPY	${DESTDIR}/bin/ps		bin/ps			555
-COPY	${DESTDIR}/bin/pwd		bin/pwd			555
-COPY	${DESTDIR}/bin/rm		bin/rm			555
-COPY	${DESTDIR}/bin/rmdir		bin/rmdir		555
-COPY	${DESTDIR}/bin/sh		bin/sh			555
-COPY	${DESTDIR}/bin/sleep		bin/sleep		555
-COPY	${DESTDIR}/bin/stty		bin/stty		555
-COPY	${DESTDIR}/bin/sync		bin/sync		555
-
-COPY	${DESTDIR}/bin/test		bin/test		555
-LINK		   bin/test		bin/[
-
-# new, combined pax,tar,cpio
-LINK		   bin/pax		usr/bin/tar
-
-SYMLINK	/usr/lib libexec
-SYMLINK	/usr/lib usr/libexec
-
-# Shared library stuff...
-# libcrypt: init
-# libcurses: vi
-# libedit: ftp, sh
-# libtermcap: ftp, less, sh, vi
-# libutil: init, rdate
-COPY	${DESTDIR}/libexec/ld.elf_so		usr/lib/ld.elf_so	555
-COPY	${DESTDIR}/usr/lib/libbz2.so		usr/lib/libbz2.so
-LINK	usr/lib/libbz2.so			usr/lib/libbz2.so.1
-COPY	${DESTDIR}/lib/libc.so			usr/lib/libc.so
-LINK	usr/lib/libc.so				usr/lib/libc.so.12
-COPY	${DESTDIR}/lib/libcrypt.so		usr/lib/libcrypt.so
-LINK	usr/lib/libcrypt.so			usr/lib/libcrypt.so.0
-COPY	${DESTDIR}/usr/lib/libcurses.so		usr/lib/libcurses.so
-LINK	usr/lib/libcurses.so			usr/lib/libcurses.so.6
-COPY	${DESTDIR}/lib/libedit.so		usr/lib/libedit.so
-LINK	usr/lib/libedit.so			usr/lib/libedit.so.2
-COPY	${DESTDIR}/lib/libipsec.so		usr/lib/libipsec.so
-LINK	usr/lib/libipsec.so			usr/lib/libipsec.so.2
-COPY	${DESTDIR}/lib/libkvm.so		usr/lib/libkvm.so
-LINK	usr/lib/libkvm.so			usr/lib/libkvm.so.5
-COPY	${DESTDIR}/lib/libm.so			usr/lib/libm.so
-LINK	usr/lib/libm.so				usr/lib/libm.so.0
-COPY	${DESTDIR}/lib/libtermcap.so		usr/lib/libtermcap.so
-LINK	usr/lib/libtermcap.so			usr/lib/libtermcap.so.0
-COPY	${DESTDIR}/lib/libutil.so		usr/lib/libutil.so
-LINK	usr/lib/libutil.so			usr/lib/libutil.so.7
-COPY	${DESTDIR}/lib/libz.so			usr/lib/libz.so
-LINK	usr/lib/libz.so				usr/lib/libz.so.1
+PROG	bin/cat
+PROG	bin/chmod
+PROG	bin/cp
+PROG	bin/date
+PROG	bin/dd
+PROG	bin/df
+PROG	bin/ed
+PROG	bin/expr
+PROG	bin/hostname
+PROG	bin/kill
+PROG	bin/ln
+PROG	bin/ls
+PROG	bin/mkdir
+PROG	bin/mt
+PROG	bin/mv
+PROG	bin/pax		usr/bin/tar	usr/bin/cpio
+PROG	bin/ps
+PROG	bin/pwd
+PROG	bin/rm
+PROG	bin/rmdir
+PROG	bin/sh
+PROG	bin/sleep
+PROG	bin/stty
+PROG	bin/sync
+
+PROG	bin/test	bin/[
 
 # usr.sbin:
-COPY	${DESTDIR}/usr/sbin/chown	usr/sbin/chown		555
-COPY	${DESTDIR}/usr/sbin/eeprom	usr/sbin/eeprom		555
-COPY	${DESTDIR}/usr/sbin/installboot	usr/sbin/installboot	555
-COPY	${DESTDIR}/usr/sbin/rdate	usr/sbin/rdate		555
+PROG	usr/sbin/chown	usr/bin/chgrp
+PROG	usr/sbin/eeprom
+PROG	usr/sbin/installboot
+PROG	usr/sbin/rdate
 
 # usr.bin:
 
-LINK		   usr/sbin/chown	usr/bin/chgrp
-
-COPY	${DESTDIR}/usr/bin/chflags	usr/bin/chflags		555
-COPY	${DESTDIR}/usr/bin/cksum	usr/bin/cksum		555
-COPY	${DESTDIR}/usr/bin/cmp		usr/bin/cmp		555
-COPY	${DESTDIR}/usr/bin/ftp		usr/bin/ftp		555
-COPY	${DESTDIR}/usr/bin/less		usr/bin/less		555
-LINK		   usr/bin/less 	usr/bin/more
-COPY	${DESTDIR}/usr/bin/rsh		usr/bin/rsh		555
-COPY	${DESTDIR}/usr/bin/sed		usr/bin/sed		555
-COPY	${DESTDIR}/usr/bin/tip		usr/bin/tip		555
-COPY	${DESTDIR}/usr/bin/vi		usr/bin/vi		555
-
-# gnu/usr.bin:
-COPY	${DESTDIR}/usr/bin/gzip		usr/bin/gzip		555
-LINK		   usr/bin/gzip 	usr/bin/gunzip
-LINK		   usr/bin/gzip 	usr/bin/gzcat
+PROG	usr/bin/chflags
+PROG	usr/bin/cksum
+PROG	usr/bin/cmp
+PROG	usr/bin/ftp
+PROG	usr/bin/less	usr/bin/more
+PROG	usr/bin/rsh
+PROG	usr/bin/sed
+PROG	usr/bin/tip
+PROG	usr/bin/vi
+PROG	usr/bin/gzip	usr/bin/gunzip	usr/bin/gzcat
 
 # install.md still uses sort
-COPY	${DESTDIR}/usr/bin/sort		usr/bin/sort		555
+PROG	usr/bin/sort
+
+SPECIAL	less		srcdir usr.bin/less/less
+SPECIAL	vi		srcdir usr.bin/vi/build
+
+SPECIAL	ed		srcdir	distrib/utils/x_ed
+SPECIAL	ifconfig	srcdir	distrib/utils/x_ifconfig
+SPECIAL	ping		srcdir	distrib/utils/x_ping
+SPECIAL	route		srcdir	distrib/utils/x_route
+
+ARGVLN	sh -sh
+
+LIBS	libhack.o
+LIBS	-lrmt -ledit -lutil -lcurses -ltermcap -lcrypt -ll -lm -lkvm -lbz2 -lz