diff --git a/distrib/miniroot/Makefile b/distrib/miniroot/Makefile new file mode 100644 index 000000000000..32da652eda37 --- /dev/null +++ b/distrib/miniroot/Makefile @@ -0,0 +1,53 @@ +# $NetBSD: Makefile,v 1.1 1995/12/18 22:47:26 pk Exp $ + +# Revision is 1.1A +REV= 11A + +CBIN= instbin +ARCHDIR= ${.CURDIR}/../${MACHINE}/miniroot + +MOUNT_POINT?= /mnt +VND?= vnd0 +VND_DEV= /dev/${VND}a +VND_RDEV= /dev/r${VND}a +IMAGE?= xxx-${REV}.fs +MDEC= ${DESTDIR}/usr/mdec + +LISTS= ${ARCHDIR}/list ${.CURDIR}/list +CRUNCHCONF= ${CBIN}.conf +MTREE= ${.CURDIR}/mtree.conf + +all: ${CBIN} + dd if=/dev/zero of=${IMAGE} bs=512k count=10 + vnconfig -v -c ${VND_DEV} ${IMAGE} + newfs -m 0 -o space ${VND_RDEV} miniroot + mount ${VND_DEV} ${MOUNT_POINT} + mtree -def ${MTREE} -p ${MOUNT_POINT}/ -u + CURDIR=${.CURDIR} OBJDIR=${.OBJDIR} ARCHDIR=${ARCHDIR} \ + TARGDIR=${MOUNT_POINT} sh ${.CURDIR}/runlist.sh ${LISTS} + @echo "" + @df -i ${MOUNT_POINT} + @echo "" + umount ${MOUNT_POINT} + vnconfig -u ${VND_DEV} + cat /*bin/* > /dev/null + +unconfig: + -umount -f ${MOUNT_POINT} + -vnconfig -u ${VND_DEV} + -/bin/rm -f ${IMAGE} + +${CBIN}.conf: ${LISTS} + awk -f ${.CURDIR}/makeconf.awk CBIN=${CBIN} ${LISTS} > ${CBIN}.conf + +${CBIN}.mk ${CBIN}.cache ${CBIN}.c: ${CRUNCHCONF} + crunchgen -D ${.CURDIR}/../.. -L ${DESTDIR}/usr/lib ${CRUNCHCONF} + +${CBIN}: ${CBIN}.mk ${CBIN}.cache ${CBIN}.c + make -f ${CBIN}.mk all + +clean cleandir: + /bin/rm -f core ${IMAGE} ${CBIN} ${CBIN}.mk ${CBIN}.cache *.o *.lo *.c + +.include +.include diff --git a/distrib/miniroot/list b/distrib/miniroot/list new file mode 100644 index 000000000000..907128baed36 --- /dev/null +++ b/distrib/miniroot/list @@ -0,0 +1,91 @@ +# $NetBSD: list,v 1.1 1995/12/18 22:47:28 pk Exp $ + +# copy the crunched binary, link to it, and kill it +COPY ${OBJDIR}/instbin instbin +LINK instbin bin/cat +LINK instbin bin/chmod +LINK instbin bin/cp +LINK instbin bin/dd +LINK instbin bin/df +LINK instbin bin/ed +LINK instbin bin/expr +LINK instbin bin/hostname +LINK instbin bin/ln +LINK instbin bin/ls +LINK instbin bin/kill +LINK instbin bin/mkdir +LINK instbin bin/mt +LINK instbin bin/mv +LINK instbin bin/pwd +LINK instbin bin/rm +LINK instbin bin/sh +LINK instbin bin/stty +LINK instbin bin/sleep +LINK instbin bin/sync +LINK instbin bin/test +LINK instbin bin/[ +LINK instbin sbin/disklabel +LINK instbin sbin/dmesg +LINK instbin sbin/fsck +LINK instbin sbin/halt +LINK instbin sbin/ifconfig +LINK instbin sbin/init +LINK instbin sbin/mknod +LINK instbin sbin/mount +LINK instbin sbin/mount_cd9660 +LINK instbin sbin/mount_ffs +LINK instbin sbin/mount_nfs +LINK instbin sbin/newfs +LINK instbin sbin/ping +LINK instbin sbin/reboot +LINK instbin sbin/route +LINK instbin sbin/shutdown +LINK instbin sbin/slattach +LINK instbin sbin/umount +SYMLINK ../../instbin usr/bin/awk +SYMLINK ../../instbin usr/bin/basename +SYMLINK ../../instbin usr/bin/chflags +SYMLINK ../../instbin usr/bin/chgrp +SYMLINK ../../instbin usr/bin/cut +SYMLINK ../../instbin usr/bin/ftp +SYMLINK ../../instbin usr/bin/grep +SYMLINK ../../instbin usr/bin/gunzip +SYMLINK ../../instbin usr/bin/gzcat +SYMLINK ../../instbin usr/bin/gzip +SYMLINK ../../instbin usr/bin/more +SYMLINK ../../instbin usr/bin/netstat +SYMLINK ../../instbin usr/bin/rsh +SYMLINK ../../instbin usr/bin/sed +SYMLINK ../../instbin usr/bin/strings +SYMLINK ../../instbin usr/bin/sort +SYMLINK ../../instbin usr/bin/tar +SYMLINK ../../instbin usr/bin/tip +SYMLINK ../../instbin usr/bin/tset +SYMLINK ../../instbin usr/bin/vi +SYMLINK ../../instbin usr/sbin/chown +SYMLINK ../../instbin usr/sbin/chroot +SYMLINK ../../instbin usr/sbin/update + +# Minimize use of MFS +SYMLINK /tmp var/tmp + +# copy the MAKEDEV script and make some devices +COPY ${DESTDIR}/dev/MAKEDEV dev/MAKEDEV +COPY ${DESTDIR}/dev/MAKEDEV.local dev/MAKEDEV.local +SPECIAL cd dev; sh MAKEDEV all +SPECIAL /bin/rm dev/MAKEDEV + +# various files that we need in /etc for the install +COPY ${DESTDIR}/etc/group etc/group +COPY ${DESTDIR}/etc/master.passwd etc/master.passwd +COPY ${DESTDIR}/etc/passwd etc/passwd +COPY ${DESTDIR}/etc/protocols etc/protocols +COPY ${DESTDIR}/etc/pwd.db etc/pwd.db +COPY ${DESTDIR}/etc/services etc/services +COPY ${DESTDIR}/etc/spwd.db etc/spwd.db + +# the zoneinfo +COPYDIR ${DESTDIR}/usr/share/zoneinfo usr/share/zoneinfo + +# and the termcap file +COPY ${CURDIR}/../../share/termcap/termcap.src usr/share/misc/termcap diff --git a/distrib/miniroot/list2sh.awk b/distrib/miniroot/list2sh.awk new file mode 100644 index 000000000000..8fce89bffd7b --- /dev/null +++ b/distrib/miniroot/list2sh.awk @@ -0,0 +1,54 @@ +# $NetBSD: list2sh.awk,v 1.1 1995/12/18 22:47:30 pk Exp $ + +BEGIN { + printf("cd ${OBJDIR}\n"); + printf("\n"); +} +/^$/ || /^#/ { + print $0; + next; +} +$1 == "COPY" { + printf("echo '%s'\n", $0); + printf("rm -f ${TARGDIR}/%s\n", $3); + printf("cp %s ${TARGDIR}/%s\n", $2, $3); + next; +} +$1 == "LINK" { + printf("echo '%s'\n", $0); + printf("rm -f ${TARGDIR}/%s\n", $3); + printf("(cd ${TARGDIR}; ln %s %s)\n", $2, $3); + next; +} +$1 == "SYMLINK" { + printf("echo '%s'\n", $0); + printf("rm -f ${TARGDIR}/%s\n", $3); + printf("(cd ${TARGDIR}; ln -s %s %s)\n", $2, $3); + next; +} +$1 == "COPYDIR" { + printf("echo '%s'\n", $0); + printf("(cd ${TARGDIR}/%s && find . ! -name . | xargs /bin/rm -rf)\n", + $3); + printf("(cd %s && pax -pe -rw . ${TARGDIR}/%s)\n", $2, $3); + next; +} +$1 == "SPECIAL" { + printf("echo '%s'\n", $0); + printf("(cd ${TARGDIR};"); + for (i = 2; i <= NF; i++) + printf(" %s", $i); + printf(")\n"); + next; +} +{ + printf("echo '%s'\n", $0); + printf("echo 'Unknown keyword \"%s\" at line %d of input.'\n", $1, NR); + printf("exit 1\n"); + exit 1; +} +END { + printf("\n"); + printf("exit 0\n"); + exit 0; +} diff --git a/distrib/miniroot/makeconf.awk b/distrib/miniroot/makeconf.awk new file mode 100644 index 000000000000..e59a16f67779 --- /dev/null +++ b/distrib/miniroot/makeconf.awk @@ -0,0 +1,51 @@ +# $NetBSD: makeconf.awk,v 1.1 1995/12/18 22:47:31 pk Exp $ + +BEGIN { + # a list of `aliases' + links["chgrp",0] = "chown"; + links["awk",0] = "gawk"; + links["gzcat",0] = "gzip"; + links["gunzip",0] = "gzip"; + links["-sh",0] = "sh"; # init invokes the shell this way + links["[",0] = "test"; + links["cd9660",0] = "mount_cd9660"; + links["ffs",0] = "mount_ffs"; + links["nfs",0] = "mount_nfs"; + links["halt",0] = "reboot"; + links["vi",0] = "common"; # XXX catch vi +} + +($1 == "LINK" || $1 == "SYMLINK") && index($2,CBIN) { + n = split($3, x, "/"); + p = x[n]; + if ((p,0) in links) { + links[p,1] = links[p,0]; + p = links[p,0]; + } + if (p == "sh") # XXX - catch `-sh' + links["-sh",1] = "sh"; + progs[p] = 1; +} + +END { + # write crunchgen configuration + + printf("#\n# This file is automatically generated by `makeconf'\n#\n"); + printf("srcdirs bin sbin usr.bin usr.sbin gnu/usr.bin usr.bin/vi\n"); + + i = 0; + for (p in progs) { + if ((i++ % 8) == 0) + printf("\nprogs"); + printf(" %s", p); + } + printf("\n\n"); + + for (I in links) { + split(I, l, SUBSEP); + if (l[2]) + printf("ln %s %s\n", links[l[1],1], l[1]); + } + + printf("\nlibs -ledit -lutil -lcurses -ltermcap -lcrypt -ll -lm -lkvm\n"); +} diff --git a/distrib/miniroot/mtree.conf b/distrib/miniroot/mtree.conf new file mode 100644 index 000000000000..27bcebb1e711 --- /dev/null +++ b/distrib/miniroot/mtree.conf @@ -0,0 +1,83 @@ +# $NetBSD: mtree.conf,v 1.1 1995/12/18 22:47:33 pk Exp $ + +/set type=dir uname=root gname=wheel mode=0755 +# . +. + +# ./bin +bin +# ./bin +.. + +# ./dev +dev +# ./dev +.. + +# ./etc +etc +# ./etc +.. + +# ./mnt +mnt +# ./mnt +.. + +# ./mnt2 +mnt2 +# ./mnt2 +.. + +# ./sbin +sbin +# ./sbin +.. + +# ./tmp +tmp mode=01777 +# ./tmp +.. + +# ./usr +usr + +# ./usr/bin +bin +# ./usr/bin +.. + +# ./usr/mdec +mdec +# ./usr/mdec +.. + +# ./usr/sbin +sbin +# ./usr/sbin +.. + +# ./usr/share +share + +# ./usr/share/misc +misc +# ./usr/share/misc +.. + +# ./usr/share/zoneinfo +zoneinfo +# ./usr/share/zoneinfo +.. + +# ./usr/share +.. + +# ./usr +.. + +# ./var +var + +# ./ +.. diff --git a/distrib/miniroot/runlist.sh b/distrib/miniroot/runlist.sh new file mode 100644 index 000000000000..1ea9ff121981 --- /dev/null +++ b/distrib/miniroot/runlist.sh @@ -0,0 +1,13 @@ +# $NetBSD: runlist.sh,v 1.1 1995/12/18 22:47:38 pk Exp $ + +if [ "X$1" = "X-d" ]; then + SHELLCMD=cat + shift +else + SHELLCMD="sh -e" +fi + +( while [ "X$1" != "X" ]; do + cat $1 + shift +done ) | awk -f ${CURDIR}/list2sh.awk | ${SHELLCMD}