Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/distrib/common/bootimage Add support for EC2 and resize root...



details:   https://anonhg.NetBSD.org/src/rev/63fc0194f554
branches:  trunk
changeset: 936801:63fc0194f554
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Wed Aug 05 01:35:18 2020 +0000

description:
Add support for EC2 and resize root to AMD64 live images.

diffstat:

 distrib/amd64/liveimage/emuimage/Makefile         |  16 +++++++++++++++-
 distrib/amd64/liveimage/emuimage/dhcpcd           |   3 +++
 distrib/amd64/liveimage/emuimage/ec2_init         |  15 +++++++++++++++
 distrib/amd64/liveimage/emuimage/resize_disklabel |   3 +++
 distrib/amd64/liveimage/emuimage/resize_root      |   5 +++++
 distrib/amd64/liveimage/emuimage/spec.emuimage    |   8 ++++++++
 distrib/amd64/liveimage/emuimage/sshd             |   3 +++
 distrib/common/bootimage/Makefile.bootimage       |  14 +++++++++++++-
 8 files changed, 65 insertions(+), 2 deletions(-)

diffs (123 lines):

diff -r 48d7c4bbdb8a -r 63fc0194f554 distrib/amd64/liveimage/emuimage/Makefile
--- a/distrib/amd64/liveimage/emuimage/Makefile Wed Aug 05 01:10:50 2020 +0000
+++ b/distrib/amd64/liveimage/emuimage/Makefile Wed Aug 05 01:35:18 2020 +0000
@@ -1,8 +1,22 @@
-#      $NetBSD: Makefile,v 1.7 2019/08/11 11:00:30 gson Exp $
+#      $NetBSD: Makefile,v 1.8 2020/08/05 01:35:18 jmcneill Exp $
 
 LIVEIMGBASE=   NetBSD-${DISTRIBVER}-amd64-live # gives ${IMGBASE}.img
 
 EMUIMAGEMB?=   1907                    # 2GB USB flash memories aren't 2GiB
 LIVEIMAGEMB=   ${EMUIMAGEMB}
+SWAPMB=                0                       # No swap
+IMAGEHOSTNAME= netbsd
+
+FILESDIR!=     cd ${.CURDIR}/../../../utils/embedded/files ; pwd
+
+SPEC_EXTRA=    ${.CURDIR}/spec.emuimage
+IMGFILE_EXTRA=                                                         \
+       ${FILESDIR}/ec2_init            etc/rc.d/ec2_init               \
+       ${FILESDIR}/resize_disklabel    etc/rc.d/resize_disklabel       \
+       ${.CURDIR}/dhcpcd               etc/rc.conf.d/dhcpcd            \
+       ${.CURDIR}/ec2_init             etc/rc.conf.d/ec2_init          \
+       ${.CURDIR}/resize_disklabel     etc/rc.conf.d/resize_disklabel  \
+       ${.CURDIR}/resize_root          etc/rc.conf.d/resize_root       \
+       ${.CURDIR}/sshd                 etc/rc.conf.d/sshd
 
 .include "${.CURDIR}/../Makefile.liveimage"
diff -r 48d7c4bbdb8a -r 63fc0194f554 distrib/amd64/liveimage/emuimage/dhcpcd
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/amd64/liveimage/emuimage/dhcpcd   Wed Aug 05 01:35:18 2020 +0000
@@ -0,0 +1,3 @@
+# $NetBSD: dhcpcd,v 1.1 2020/08/05 01:35:18 jmcneill Exp $
+
+dhcpcd=YES
diff -r 48d7c4bbdb8a -r 63fc0194f554 distrib/amd64/liveimage/emuimage/ec2_init
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/amd64/liveimage/emuimage/ec2_init Wed Aug 05 01:35:18 2020 +0000
@@ -0,0 +1,15 @@
+# $NetBSD: ec2_init,v 1.1 2020/08/05 01:35:18 jmcneill Exp $
+
+is_ec2() {
+       dmi_vendor="$(/sbin/sysctl -qn machdep.dmi.system-vendor | tr '[A-Z]' '[a-z]')"
+       case "$dmi_vendor" in
+       amazon*)
+               printf YES
+               ;;
+       *)
+               printf NO
+               ;;
+       esac
+}
+
+ec2_init=$(is_ec2)
diff -r 48d7c4bbdb8a -r 63fc0194f554 distrib/amd64/liveimage/emuimage/resize_disklabel
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/amd64/liveimage/emuimage/resize_disklabel Wed Aug 05 01:35:18 2020 +0000
@@ -0,0 +1,3 @@
+# $NetBSD: resize_disklabel,v 1.1 2020/08/05 01:35:18 jmcneill Exp $
+
+resize_disklabel=YES
diff -r 48d7c4bbdb8a -r 63fc0194f554 distrib/amd64/liveimage/emuimage/resize_root
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/amd64/liveimage/emuimage/resize_root      Wed Aug 05 01:35:18 2020 +0000
@@ -0,0 +1,5 @@
+# $NetBSD: resize_root,v 1.1 2020/08/05 01:35:18 jmcneill Exp $
+
+resize_root=YES
+resize_root_flags="-p"
+resize_root_postcmd="/sbin/reboot -n"
diff -r 48d7c4bbdb8a -r 63fc0194f554 distrib/amd64/liveimage/emuimage/spec.emuimage
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/amd64/liveimage/emuimage/spec.emuimage    Wed Aug 05 01:35:18 2020 +0000
@@ -0,0 +1,8 @@
+# $NetBSD: spec.emuimage,v 1.1 2020/08/05 01:35:18 jmcneill Exp $
+./etc/rc.conf.d/dhcpcd                 type=file mode=0644 uname=root gname=wheel
+./etc/rc.conf.d/ec2_init               type=file mode=0644 uname=root gname=wheel
+./etc/rc.conf.d/resize_disklabel       type=file mode=0644 uname=root gname=wheel
+./etc/rc.conf.d/resize_root            type=file mode=0644 uname=root gname=wheel
+./etc/rc.conf.d/sshd                   type=file mode=0644 uname=root gname=wheel
+./etc/rc.d/ec2_init                    type=file mode=0555 uname=root gname=wheel
+./etc/rc.d/resize_disklabel            type=file mode=0555 uname=root gname=wheel
diff -r 48d7c4bbdb8a -r 63fc0194f554 distrib/amd64/liveimage/emuimage/sshd
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/amd64/liveimage/emuimage/sshd     Wed Aug 05 01:35:18 2020 +0000
@@ -0,0 +1,3 @@
+# $NetBSD: sshd,v 1.1 2020/08/05 01:35:18 jmcneill Exp $
+
+sshd=YES
diff -r 48d7c4bbdb8a -r 63fc0194f554 distrib/common/bootimage/Makefile.bootimage
--- a/distrib/common/bootimage/Makefile.bootimage       Wed Aug 05 01:10:50 2020 +0000
+++ b/distrib/common/bootimage/Makefile.bootimage       Wed Aug 05 01:35:18 2020 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.bootimage,v 1.25 2020/05/28 15:13:21 jmcneill Exp $
+#      $NetBSD: Makefile.bootimage,v 1.26 2020/08/05 01:35:18 jmcneill Exp $
 #
 # Copyright (c) 2009, 2010, 2011 Izumi Tsutsui.  All rights reserved.
 #
@@ -135,6 +135,8 @@
 #      FATFILES
 #              list of additional files to be copied into FAT partition
 #              (default: empty)
+#      IMAGEHOSTNAME
+#              if set, sets the default hostname in rc.conf (default: empty)
 #
 
 .include <bsd.own.mk>          #
@@ -345,6 +347,16 @@
        @echo Setting rc_configured=YES in /etc/rc.conf ...
        ${TOOL_SED} "s/rc_configured=NO/rc_configured=YES/"             \
            < ${WORKDIR}/etc/rc.conf > ${WORKRCCONF}
+.if defined(IMAGEHOSTNAME)
+       @echo Setting hostname=${IMAGEHOSTNAME} in /etc/rc.conf ...
+       echo "hostname=${IMAGEHOSTNAME}" >> ${WORKRCCONF}
+.endif
+.if ${SWAPSECTORS} == 0
+       @echo Setting no_swap=YES in /etc/rc.conf ...
+       echo "no_swap=YES" >> ${WORKRCCONF}
+       @echo Setting savecore=NO in /etc/rc.conf ...
+       echo "savecore=NO" >> ${WORKRCCONF}
+.endif
        ${INSTALL} ${COPY} -m 0644 ${WORKRCCONF} ${WORKDIR}/etc/rc.conf
 .if defined(IMGDIR_EXTRA)
        @echo Copying extra dirs...



Home | Main Index | Thread Index | Old Index