installworld - Generate /etc/os-release
authorMatthew Dillon <dillon@apollo.backplane.com>
Sat, 28 Sep 2019 21:10:01 +0000 (14:10 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Sat, 28 Sep 2019 21:10:57 +0000 (14:10 -0700)
* Generate an /etc/os-release file during an installworld.

Makefile
Makefile.inc1

index 66773c1..af913dc 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -79,7 +79,7 @@ TGTS= all all-man buildkernel quickkernel realquickkernel nativekernel \
        buildworld crossworld quickworld realquickworld checkdpadd clean \
        cleandepend cleandir depend everything \
        hierarchy install installcheck installkernel \
-       reinstallkernel installworld installworld-force initrd \
+       reinstallkernel installworld installworld-force os-release initrd \
        libraries lint maninstall \
        manlint mk obj objlink regress rerelease tags \
        backupworld restoreworld restoreworld-auto \
index 94e3db3..68720d0 100644 (file)
@@ -9,6 +9,13 @@
 # Build-time options are documented in make.conf(5).
 #
 
+DFLYVERSION!=   awk '/^\#define[[:blank:]]__DragonFly_version/ {print $$3}' \
+               < ${.CURDIR}/sys/sys/param.h
+
+OSREL!=                echo ${DFLYVERSION} | \
+               awk '{a=int($$1/100000); b=int(($$1-(a*100000))/100); \
+               print a "." b}'
+
 # Put initial settings here.
 SUBDIR=
 
@@ -520,13 +527,28 @@ installworld: installcheck
        cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
        ${INSTALL} -o root -g wheel -m 644 ${.CURDIR}/Makefile_upgrade.inc \
            ${DESTDIR}/etc/upgrade/
+       cd ${.CURDIR}; ${IMAKE} -DWORLDINSTALL os-release
        cd ${.CURDIR}; ${IMAKE} -DWORLDINSTALL initrd
-
        sync
        @echo "--------------------------------------------------------------"
        @echo ">>> installworld target complete"
        @echo "--------------------------------------------------------------"
 
+os-release:
+       @echo "NAME=DragonFly" >> ${DESTDIR}/etc/os-release
+       @echo "VERSION=${OSREL}-SYNTH" >> ${DESTDIR}/etc/os-release
+       @echo "VERSION_ID=${OSREL}" >> ${DESTDIR}/etc/os-release
+       @echo "ID=dragonfly" >> ${DESTDIR}/etc/os-release
+       @echo "ANSI_COLOR=\"0;32\"" >> ${DESTDIR}/etc/os-release
+       @echo "PRETTY_NAME=\"DragonFlyBSD ${OSREL}-SYNTH\"" >> ${DESTDIR}/etc/os-release
+       @echo "CPE_NAME=\"cpe:/o:dragonflybsd:dragonfly:${OSREL}\"" >> ${DESTDIR}/etc/os-release
+       @echo "SUPPORT_URL=\"http://chat.efnet.org:9090/?nick=dflynick&channels=%23dragonflybsd&Login=Login\"" >> ${DESTDIR}/etc/os-release
+       @echo "HOME_URL=\"https://www.dragonflybsd.org/\"" >> ${DESTDIR}/etc/os-release
+       @echo "BUG_REPORT_URL=\"https://bugs.dragonflybsd.org/\"" >> ${DESTDIR}/etc/os-release
+       @echo "MACHINE_ARCH=${MACHINE_ARCH}" >> ${DESTDIR}/etc/os-release
+       @echo "MACHINE=${MACHINE}" >> ${DESTDIR}/etc/os-release
+       @echo "DFLYVERSION=${DFLYVERSION}" >> ${DESTDIR}/etc/os-release
+
 installworld-force:
        @echo "Doing a forced installworld.  This will install to a temporary directory,"
        @echo "then copy the main binaries and libraries with a static cpdup to ${DESTDIR}/"