diff options
author | Martin Natano <natano@cvs.openbsd.org> | 2016-11-24 16:32:34 +0000 |
---|---|---|
committer | Martin Natano <natano@cvs.openbsd.org> | 2016-11-24 16:32:34 +0000 |
commit | 8a783c8f62af02796a06d02b8665e21b827706e1 (patch) | |
tree | 3bf6c78a147b255b677bfd651ed97c6d1e77cf15 | |
parent | 50f0af2751116f1c04947247a102c84e0431e334 (diff) |
Use makefs to build bsd.rd. amd64 and i386 are first; other platforms
will follow with some safety distance when I figured out all MD quirks.
makefs allows to build the ramdisk image as an unprivileged user. The
next step in the quest to reduce root during builds.
ok deraadt
-rw-r--r-- | distrib/amd64/ramdiskA/Makefile.inc | 52 | ||||
-rw-r--r-- | distrib/amd64/ramdisk_cd/Makefile.inc | 52 | ||||
-rw-r--r-- | distrib/i386/common/Makefile.inc | 52 |
3 files changed, 54 insertions, 102 deletions
diff --git a/distrib/amd64/ramdiskA/Makefile.inc b/distrib/amd64/ramdiskA/Makefile.inc index 6229c46e94b..450b912de04 100644 --- a/distrib/amd64/ramdiskA/Makefile.inc +++ b/distrib/amd64/ramdiskA/Makefile.inc @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.inc,v 1.2 2016/10/19 17:21:14 natano Exp $ +# $OpenBSD: Makefile.inc,v 1.3 2016/11/24 16:32:33 natano Exp $ TOP= ${.CURDIR}/.. @@ -54,10 +54,13 @@ ${FS}: bsd.gz cp ${REALIMAGE} ${FS} rm ${REALIMAGE} -DISKTYPE?= rdroot -NBLKS?= 4480 -# minfree, opt, b/i trks, sects, cpg -NEWFSARGS= -m 0 -o space -i 4096 +unconfig: + -umount -f ${MOUNT_POINT} + -vnconfig -u ${VND} + + +DISKTYPE= rdroot +MAKEFSARGS_RD= -o disklabel=${DISKTYPE},minfree=0,density=4096 bsd.gz: bsd.rd cp bsd.rd bsd.strip @@ -75,34 +78,21 @@ bsd: su ${BUILDUSER} -c '${MAKE} config && ${MAKE} clean && env COPTS=-Os ${MAKE}' cp -p ${.CURDIR}/../../../sys/arch/amd64/compile/${RAMDISK}/obj/bsd bsd -mr.fs: instbin rd_setup do_files rd_teardown - -rd_setup: instbin - dd if=/dev/zero of=${REALIMAGE} bs=512 count=${NBLKS} - vnconfig -v -c ${VND} ${REALIMAGE} - disklabel -w ${VND} ${DISKTYPE} - newfs ${NEWFSARGS} ${VND_RDEV} - fsck ${VND_RDEV} - mount ${VND_DEV} ${MOUNT_POINT} - -rd_teardown: - @df -i ${MOUNT_POINT} - -umount ${MOUNT_POINT} - -vnconfig -u ${VND} - cp ${REALIMAGE} mr.fs - rm ${REALIMAGE} +mr.fs: instbin + rm -rf $@.d + install -d -o root -g wheel $@.d + mtree -def ${MTREE} -p $@.d -u + TOPDIR=${TOP} CURDIR=${.CURDIR} OBJDIR=${.OBJDIR} REV=${REV} \ + TARGDIR=$@.d UTILS=${UTILS} RELEASEDIR=${RELEASEDIR} \ + sh ${UTILS}/runlist.sh ${LISTS} + rm $@.d/instbin + makefs ${MAKEFSARGS_RD} $@ $@.d rdsetroot: ${TOP}/../common/elfrdsetroot.c ${HOSTCC} ${HOSTCFLAGS} -o rdsetroot \ ${TOP}/../common/elfrdsetroot.c ${TOP}/../common/elf32.c \ ${TOP}/../common/elf64.c -unconfig: - -umount -f ${MOUNT_POINT} - -vnconfig -u ${VND} - -.PRECIOUS: mr.fs - .ifdef RELEASEDIR install: .ifndef NOBSDRD @@ -124,18 +114,12 @@ instbin: instbin.mk instbin.cache instbin.c instbin.conf: ${LISTS} awk -f ${UTILS}/makeconf.awk CBIN=instbin ${LISTS} > instbin.conf -do_files: - mtree -def ${MTREE} -p ${MOUNT_POINT}/ -u - TOPDIR=${TOP} CURDIR=${.CURDIR} OBJDIR=${.OBJDIR} \ - REV=${REV} TARGDIR=${MOUNT_POINT} UTILS=${UTILS} \ - RELEASEDIR=${RELEASEDIR} sh ${UTILS}/runlist.sh ${LISTS} - rm ${MOUNT_POINT}/instbin - clean cleandir: /bin/rm -f *.core mr.fs instbin instbin.mk instbin*.cache \ *.o *.lo *.c bsd bsd.rd bsd.gz bsd.strip floppy*.fs \ lib*.a lib*.olist instbin.map \ rdsetroot boot instbin.conf ${FS} + /bin/rm -rf mr.fs.d .include <bsd.obj.mk> .include <bsd.subdir.mk> diff --git a/distrib/amd64/ramdisk_cd/Makefile.inc b/distrib/amd64/ramdisk_cd/Makefile.inc index ab8dfb3221e..e23591f78b6 100644 --- a/distrib/amd64/ramdisk_cd/Makefile.inc +++ b/distrib/amd64/ramdisk_cd/Makefile.inc @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.inc,v 1.2 2016/10/19 17:45:38 natano Exp $ +# $OpenBSD: Makefile.inc,v 1.3 2016/11/24 16:32:33 natano Exp $ TOP= ${.CURDIR}/.. @@ -57,10 +57,13 @@ ${FS}: bsd.gz cp ${REALIMAGE} ${FS} rm ${REALIMAGE} -DISKTYPE?= rdroot -NBLKS?= 4480 -# minfree, opt, b/i trks, sects, cpg -NEWFSARGS= -m 0 -o space -i 4096 +unconfig: + -umount -f ${MOUNT_POINT} + -vnconfig -u ${VND} + + +DISKTYPE= rdroot +MAKEFSARGS_RD= -o disklabel=${DISKTYPE},minfree=0,density=4096 bsd.gz: bsd.rd cp bsd.rd bsd.strip @@ -78,34 +81,21 @@ bsd: su ${BUILDUSER} -c '${MAKE} config && ${MAKE} clean && env COPTS=-Os ${MAKE}' cp -p ${.CURDIR}/../../../sys/arch/amd64/compile/${RAMDISK}/obj/bsd bsd -mr.fs: instbin rd_setup do_files rd_teardown - -rd_setup: instbin - dd if=/dev/zero of=${REALIMAGE} bs=512 count=${NBLKS} - vnconfig -v -c ${VND} ${REALIMAGE} - disklabel -w ${VND} ${DISKTYPE} - newfs ${NEWFSARGS} ${VND_RDEV} - fsck ${VND_RDEV} - mount ${VND_DEV} ${MOUNT_POINT} - -rd_teardown: - @df -i ${MOUNT_POINT} - -umount ${MOUNT_POINT} - -vnconfig -u ${VND} - cp ${REALIMAGE} mr.fs - rm ${REALIMAGE} +mr.fs: instbin + rm -rf $@.d + install -d -o root -g wheel $@.d + mtree -def ${MTREE} -p $@.d -u + TOPDIR=${TOP} CURDIR=${.CURDIR} OBJDIR=${.OBJDIR} REV=${REV} \ + TARGDIR=$@.d UTILS=${UTILS} RELEASEDIR=${RELEASEDIR} \ + sh ${UTILS}/runlist.sh ${LISTS} + rm $@.d/instbin + makefs ${MAKEFSARGS_RD} $@ $@.d rdsetroot: ${TOP}/../common/elfrdsetroot.c ${HOSTCC} ${HOSTCFLAGS} -o rdsetroot \ ${TOP}/../common/elfrdsetroot.c ${TOP}/../common/elf32.c \ ${TOP}/../common/elf64.c -unconfig: - -umount -f ${MOUNT_POINT} - -vnconfig -u ${VND} - -.PRECIOUS: mr.fs - .ifdef RELEASEDIR install: .ifndef NOBSDRD @@ -127,18 +117,12 @@ instbin: instbin.mk instbin.cache instbin.c instbin.conf: ${LISTS} awk -f ${UTILS}/makeconf.awk CBIN=instbin ${LISTS} > instbin.conf -do_files: - mtree -def ${MTREE} -p ${MOUNT_POINT}/ -u - TOPDIR=${TOP} CURDIR=${.CURDIR} OBJDIR=${.OBJDIR} \ - REV=${REV} TARGDIR=${MOUNT_POINT} UTILS=${UTILS} \ - RELEASEDIR=${RELEASEDIR} sh ${UTILS}/runlist.sh ${LISTS} - rm ${MOUNT_POINT}/instbin - clean cleandir: /bin/rm -f *.core mr.fs instbin instbin.mk instbin*.cache \ *.o *.lo *.c bsd bsd.rd bsd.gz bsd.strip floppy*.fs \ lib*.a lib*.olist instbin.map \ rdsetroot boot instbin.conf ${FS} + /bin/rm -rf mr.fs.d .include <bsd.obj.mk> .include <bsd.subdir.mk> diff --git a/distrib/i386/common/Makefile.inc b/distrib/i386/common/Makefile.inc index 486538eef43..bcae63d6eac 100644 --- a/distrib/i386/common/Makefile.inc +++ b/distrib/i386/common/Makefile.inc @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.inc,v 1.39 2016/10/14 18:44:19 deraadt Exp $ +# $OpenBSD: Makefile.inc,v 1.40 2016/11/24 16:32:33 natano Exp $ TOP= ${.CURDIR}/.. @@ -49,10 +49,13 @@ ${FS}: bsd.gz cp ${REALIMAGE} ${FS} rm ${REALIMAGE} -DISKTYPE?= rdroot -NBLKS?= 3872 -# minfree, opt, b/i, blks/cyl -NEWFSARGS= -m 0 -o space -i 4096 +unconfig: + -umount -f ${MOUNT_POINT} + -vnconfig -u ${VND} + + +DISKTYPE= rdroot +MAKEFSARGS_RD= -o disklabel=${DISKTYPE},minfree=0,density=4096 COPTS= -Os -mtune=i486 @@ -72,34 +75,21 @@ bsd: su ${BUILDUSER} -c '${MAKE} config && ${MAKE} clean && env COPTS="${COPTS}" ${MAKE}' cp -p ${.CURDIR}/../../../sys/arch/i386/compile/${RAMDISK}/obj/bsd bsd -${IMAGE}: ${CBIN} rd_setup do_files rd_teardown - -rd_setup: ${CBIN} - dd if=/dev/zero of=${REALIMAGE} bs=512 count=${NBLKS} - vnconfig -v -c ${VND} ${REALIMAGE} - disklabel -w ${VND} ${DISKTYPE} - newfs ${NEWFSARGS} ${VND_RDEV} - fsck ${VND_RDEV} - mount ${VND_DEV} ${MOUNT_POINT} - -rd_teardown: - @df -i ${MOUNT_POINT} - -umount ${MOUNT_POINT} - -vnconfig -u ${VND} - cp ${REALIMAGE} ${IMAGE} - rm ${REALIMAGE} +${IMAGE}: ${CBIN} + rm -rf $@.d + install -d -o root -g wheel $@.d + mtree -def ${MTREE} -p $@.d -u + TOPDIR=${TOP} CURDIR=${.CURDIR} OBJDIR=${.OBJDIR} REV=${REV} \ + TARGDIR=$@.d UTILS=${UTILS} RELEASEDIR=${RELEASEDIR} \ + sh ${UTILS}/runlist.sh ${LISTS} + rm $@.d/${CBIN} + makefs ${MAKEFSARGS_RD} $@ $@.d rdsetroot: ${TOP}/../common/elfrdsetroot.c ${HOSTCC} ${HOSTCFLAGS} -o rdsetroot \ ${TOP}/../common/elfrdsetroot.c ${TOP}/../common/elf32.c \ ${TOP}/../common/elf64.c -unconfig: - -umount -f ${MOUNT_POINT} - -vnconfig -u ${VND} - -.PRECIOUS: ${IMAGE} - .ifdef RELEASEDIR install: .ifndef NOBSDRD @@ -121,18 +111,12 @@ ${CBIN}: ${CBIN}.mk ${CBIN}.cache ${CBIN}.c ${CRUNCHCONF}: ${LISTS} awk -f ${UTILS}/makeconf.awk CBIN=${CBIN} ${LISTS} > ${CRUNCHCONF} -do_files: - mtree -def ${MTREE} -p ${MOUNT_POINT}/ -u - TOPDIR=${TOP} CURDIR=${.CURDIR} OBJDIR=${.OBJDIR} \ - REV=${REV} TARGDIR=${MOUNT_POINT} UTILS=${UTILS} \ - RELEASEDIR=${RELEASEDIR} sh ${UTILS}/runlist.sh ${LISTS} - rm ${MOUNT_POINT}/${CBIN} - clean cleandir: /bin/rm -f *.core ${IMAGE} ${CBIN} ${CBIN}.mk ${CBIN}*.cache \ *.o *.lo *.c bsd bsd.rd bsd.gz bsd.strip floppy*.fs \ lib*.a lib*.olist ${CBIN}.map \ rdsetroot boot ${CRUNCHCONF} ${FS} + /bin/rm -rf ${IMAGE}.d .include <bsd.obj.mk> .include <bsd.subdir.mk> |