summaryrefslogtreecommitdiff
path: root/usr
diff options
context:
space:
mode:
authorJohn Levon <john.levon@joyent.com>2019-09-12 11:34:57 +0000
committerJohn Levon <john.levon@joyent.com>2019-09-12 11:35:28 +0000
commita684d52c70031374c438f8d0fecbbf3e872c9753 (patch)
treeca9dc5a0d4a5f5571499d784a71f7f9dcdf88ddc /usr
parentf575b548814883ebc2eb65fe406ec62d0d6b5bbb (diff)
downloadillumos-joyent-a684d52c70031374c438f8d0fecbbf3e872c9753.tar.gz
OS-7979 introduce /etc/versions/build
Reviewed by: Tim Foster <tim.foster@joyent.com> Reviewed by: Jason King <jason.king@joyent.com> Approved by: Tim Foster <tim.foster@joyent.com>
Diffstat (limited to 'usr')
-rw-r--r--usr/src/Makefile1
-rw-r--r--usr/src/cmd/boot/filelist/i386/filelist.ramdisk1
-rw-r--r--usr/src/cmd/mdb/common/modules/mdb_ks/mdb_ks.c10
-rw-r--r--usr/src/cmd/nsadmin/Makefile20
-rw-r--r--usr/src/cmd/nsadmin/system5
-rw-r--r--usr/src/pkg/manifests/SUNWcs.mf3
-rw-r--r--usr/src/tools/env/illumos.sh3
-rw-r--r--usr/src/tools/scripts/nightly.sh13
-rw-r--r--usr/src/uts/common/os/buildversion.c112
-rw-r--r--usr/src/uts/common/os/modsysfile.c21
-rw-r--r--usr/src/uts/intel/Makefile.intel2
-rw-r--r--usr/src/uts/intel/buildversion/Makefile50
-rw-r--r--usr/src/uts/intel/os/name_to_major1
-rw-r--r--usr/src/uts/sparc/Makefile.sparc2
-rw-r--r--usr/src/uts/sparc/buildversion/Makefile50
15 files changed, 50 insertions, 244 deletions
diff --git a/usr/src/Makefile b/usr/src/Makefile
index 60aea931d8..566050738b 100644
--- a/usr/src/Makefile
+++ b/usr/src/Makefile
@@ -140,7 +140,6 @@ clobber_local:
@cd tools; pwd; $(MAKE) clobber
@cd common/mapfiles; pwd; $(MAKE) clobber
@cd msg; pwd; $(MAKE) clobber
- $(RM) buildversion
# If the tarballs are included inside ON_CLOSED_BINS, use those to extract and
# preserve the permissions (in case a distro ships them).
diff --git a/usr/src/cmd/boot/filelist/i386/filelist.ramdisk b/usr/src/cmd/boot/filelist/i386/filelist.ramdisk
index 70059bb5f3..387411504e 100644
--- a/usr/src/cmd/boot/filelist/i386/filelist.ramdisk
+++ b/usr/src/cmd/boot/filelist/i386/filelist.ramdisk
@@ -18,6 +18,7 @@ etc/rtc_config
etc/system
etc/system.d
etc/hostid
+etc/versions
kernel
platform/i86hvm/kernel
platform/i86pc/kernel
diff --git a/usr/src/cmd/mdb/common/modules/mdb_ks/mdb_ks.c b/usr/src/cmd/mdb/common/modules/mdb_ks/mdb_ks.c
index 944d9b13b2..68b2e9d362 100644
--- a/usr/src/cmd/mdb/common/modules/mdb_ks/mdb_ks.c
+++ b/usr/src/cmd/mdb/common/modules/mdb_ks/mdb_ks.c
@@ -1018,9 +1018,9 @@ find_mbind(const char *name, uintptr_t *hashtab)
int
mdb_name_to_major(const char *name, major_t *major)
{
- uintptr_t mbind;
- uintptr_t mb_hashtab[MOD_BIND_HASHSIZE];
- struct bind mbind_local;
+ uintptr_t mbind;
+ uintptr_t mb_hashtab[MOD_BIND_HASHSIZE];
+ struct bind mbind_local;
if (mdb_readsym(mb_hashtab, sizeof (mb_hashtab), "mb_hashtab") == -1) {
@@ -1823,7 +1823,7 @@ mdb_get_lbolt(void)
* Dig out the branch and revision of the illumos-joyent repo, if we were
* provided with it. This is a rather fragile JSON parser, in that it requires
* JSON formatted exactly as per the boot_archive.gitstatus file that
- * "buildversion_start" is built from.
+ * "buildversion" is built from.
*/
void
mdb_print_buildversion(void)
@@ -1831,7 +1831,7 @@ mdb_print_buildversion(void)
boolean_t in_joyent = B_FALSE;
GElf_Sym sym;
- if (mdb_lookup_by_name("buildversion_start", &sym) != 0) {
+ if (mdb_lookup_by_name("buildversion", &sym) != 0) {
/* Older kernels used this name. */
if (mdb_lookup_by_name("gitstatus_start", &sym) != 0)
return;
diff --git a/usr/src/cmd/nsadmin/Makefile b/usr/src/cmd/nsadmin/Makefile
index 3af33b2a4d..45bdcc6701 100644
--- a/usr/src/cmd/nsadmin/Makefile
+++ b/usr/src/cmd/nsadmin/Makefile
@@ -36,6 +36,8 @@ include ../Makefile.cmd
ROOTETCFILES = $(ETCFILES:%=$(ROOTETC)/%)
ROOTETCSKEL= $(ROOTETC)/skel
ROOTETCSKELFILES = $(ETCSKELFILES:%=$(ROOTETCSKEL)/%)
+ROOTETCVERSIONS= $(ROOTETC)/versions
+ROOTETCVERSIONSFILES = $(ROOTETCVERSIONS)/build
ETCBASHDIR = $(ROOTETC)/bash
ROOTETCBASHFILES = $(ETCBASHFILES:%=$(ETCBASHDIR)/%)
ETCBASHCOMPLETIONDDIR = $(ETCBASHDIR)/bash_completion.d
@@ -46,7 +48,7 @@ ROOTROOTFILES = $(ROOTFILES:%=$(ROOTROOT)/%)
FILES = $(ROOTETCFILES) $(ROOTETCSKELFILES) \
$(ROOTETCBASHFILES) $(ROOTETCBASHCOMPLETIONDFILES) \
- $(ROOTROOTFILES)
+ $(ROOTROOTFILES) $(ROOTETCVERSIONSFILES)
FILEMODE= 0644
@@ -58,6 +60,13 @@ all:
INS.file = $(RM) $@; $(INS) -s -m $(FILEMODE) -f $(@D) $^
INS.rename = $(INS.file); $(MV) $(@D)/$(^F) $@
+$(ROOTROOT) \
+$(ROOTETCVERSIONS) \
+$(ETCBASHDIR) \
+$(ROOTETCBASHCOMPLETIONDDIR) \
+$(ROOTETCSKEL):
+ $(INS.dir)
+
$(ROOTETC)/profile: etc-profile.sh
$(INS.rename)
@@ -87,6 +96,13 @@ $(ROOTETCBASHDIR)/%: %
$(ROOTETCBASHCOMPLETIONDDIR)/%: %
$(INS.file)
+$(ROOTETCVERSIONSFILES): $(ROOTETCVERSIONS) FRC
+ if [[ -n "$$BUILDVERSION_EXEC" ]]; then \
+ $$BUILDVERSION_EXEC >$(ROOTETCVERSIONSFILES) ; \
+ else \
+ touch $(ROOTETCVERSIONSFILES) ; \
+ fi
+
install: all $(FILES)
clean:
@@ -94,4 +110,4 @@ clean:
clobber:
$(RM) $(CLOBBERFILES)
-lint:
+FRC:
diff --git a/usr/src/cmd/nsadmin/system b/usr/src/cmd/nsadmin/system
index 1143a7b7ec..6216e0789b 100644
--- a/usr/src/cmd/nsadmin/system
+++ b/usr/src/cmd/nsadmin/system
@@ -169,8 +169,3 @@ set sd:sd_io_time=10
* Use hires tick to improve some scheduling latency issues
set hires_tick=1
-
-*
-* See usr/src/uts/common/os/buildversion.c
-*
-forceload: misc/buildversion
diff --git a/usr/src/pkg/manifests/SUNWcs.mf b/usr/src/pkg/manifests/SUNWcs.mf
index 2227768e4a..8c9f5902e8 100644
--- a/usr/src/pkg/manifests/SUNWcs.mf
+++ b/usr/src/pkg/manifests/SUNWcs.mf
@@ -26,6 +26,7 @@
# Copyright 2017 Nexenta Systems, Inc.
# Copyright 2017 Toomas Soome <tsoome@me.com>
# Copyright 2019 Peter Tribble.
+# Copyright 2019 Joyent, Inc.
# Copyright (c) 2011, 2015 by Delphix. All rights reserved.
#
@@ -94,6 +95,7 @@ dir path=etc/sysevent/config group=sys
dir path=etc/system.d group=sys
dir path=etc/tm group=sys
dir path=etc/user_attr.d group=sys
+dir path=etc/versions group=sys
dir path=export group=sys
dir path=home group=root mode=0555
dir path=lib
@@ -460,6 +462,7 @@ file path=etc/ttydefs group=sys preserve=true
file path=etc/ttysrch group=sys preserve=true
file path=etc/user_attr group=sys preserve=true timestamp=19700101T000000Z
file path=etc/user_attr.d/SUNWcs group=sys
+file path=etc/versions/build group=sys
file path=etc/vfstab group=sys preserve=true
file path=lib/inet/in.mpathd mode=0555
file path=lib/inet/ipmgmtd mode=0555
diff --git a/usr/src/tools/env/illumos.sh b/usr/src/tools/env/illumos.sh
index 1b2987f5eb..d6ea089549 100644
--- a/usr/src/tools/env/illumos.sh
+++ b/usr/src/tools/env/illumos.sh
@@ -135,6 +135,9 @@ export ENABLE_SMB_PRINTING=
# nightly(1) for interactions between environment variables and this command.
#POST_NIGHTLY=
+# Populates /etc/versions/build on each nightly run
+export BUILDVERSION_EXEC="git describe --all --long --dirty"
+
# -----------------------------------------------------------------------------
# You are less likely to need to modify parameters below.
# -----------------------------------------------------------------------------
diff --git a/usr/src/tools/scripts/nightly.sh b/usr/src/tools/scripts/nightly.sh
index 56fdab5d77..8641236b6c 100644
--- a/usr/src/tools/scripts/nightly.sh
+++ b/usr/src/tools/scripts/nightly.sh
@@ -1543,19 +1543,6 @@ fi
[[ -d "${CODEMGR_WS}" ]] || fatal_error "Error: ${CODEMGR_WS} is not a directory."
[[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found."
-TMPFILE=/tmp/tmp.nightly.$$
-if [[ -n "${BUILDVERSION_EXEC}" ]]; then
- ${BUILDVERSION_EXEC} >$TMPFILE || \
- fatal_error "${BUILDVERSION_EXEC} failed"
-else
- echo "version unset" >$TMPFILE
-fi
-
-if ! cmp $TMPFILE $SRC/buildversion >/dev/null 2>&1; then
- mv $TMPFILE $SRC/buildversion
-fi
-rm -f $TMPFILE
-
if [[ "$t_FLAG" = "y" ]]; then
set_non_debug_build_flags
bootstrap_tools || fatal_error "Error: could not bootstrap tools"
diff --git a/usr/src/uts/common/os/buildversion.c b/usr/src/uts/common/os/buildversion.c
deleted file mode 100644
index d67cc87fc1..0000000000
--- a/usr/src/uts/common/os/buildversion.c
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * This file and its contents are supplied under the terms of the
- * Common Development and Distribution License ("CDDL"), version 1.0.
- * You may only use this file in accordance with the terms of version
- * 1.0 of the CDDL.
- *
- * A full copy of the text of the CDDL should have accompanied this
- * source. A copy of the CDDL is also available via the Internet at
- * http://www.illumos.org/license/CDDL.
- */
-
-/*
- * Copyright 2019 Joyent, Inc.
- */
-
-/*
- * This kernel module carries the contents of the file $SRC/buildversion
- * in such a way that it will be included in kernel crash dumps. It will be
- * forceloaded at boot, will refuse to detach, and has no other moving parts.
- *
- * The git information can be read back with "mdb", either on the live system
- * or from a crash dump; e.g.,
- *
- * # mdb -ke buildversion_start/s
- *
- * or with
- *
- * # mdb -ke ::status
- */
-
-#include <sys/ddi.h>
-#include <sys/sunddi.h>
-#include <sys/modctl.h>
-
-int buildversion_no_detach = 1;
-
-static int
-buildversion_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
-{
- switch (cmd) {
- case DDI_ATTACH:
- case DDI_RESUME:
- return (DDI_SUCCESS);
-
- default:
- return (DDI_FAILURE);
- }
-}
-
-static int
-buildversion_detach(dev_info_t *dip, ddi_detach_cmd_t cmd)
-{
-
- switch (cmd) {
- case DDI_DETACH:
- if (buildversion_no_detach) {
- return (DDI_FAILURE);
- }
- /* FALLTHRU */
- case DDI_SUSPEND:
- return (DDI_SUCCESS);
-
- default:
- return (DDI_FAILURE);
- }
-}
-
-static struct dev_ops buildversion_dev_ops = {
- .devo_rev = DEVO_REV,
- .devo_refcnt = 0,
- .devo_getinfo = nodev,
- .devo_identify = nulldev,
- .devo_probe = nulldev,
-
- .devo_attach = buildversion_attach,
- .devo_detach = buildversion_detach,
-
- .devo_reset = nodev,
- .devo_cb_ops = NULL,
- .devo_bus_ops = NULL,
- .devo_power = nodev,
- .devo_quiesce = ddi_quiesce_not_needed,
-};
-
-static struct modldrv buildversion_md = {
- .drv_modops = &mod_driverops,
- .drv_linkinfo = "illumos buildversion",
- .drv_dev_ops = &buildversion_dev_ops,
-};
-
-static struct modlinkage buildversion_ml = {
- .ml_rev = MODREV_1,
- .ml_linkage = { &buildversion_md, NULL }
-};
-
-int
-_init(void)
-{
- return (mod_install(&buildversion_ml));
-}
-
-int
-_info(struct modinfo *mi)
-{
- return (mod_info(&buildversion_ml, mi));
-}
-
-int
-_fini(void)
-{
- return (mod_remove(&buildversion_ml));
-}
diff --git a/usr/src/uts/common/os/modsysfile.c b/usr/src/uts/common/os/modsysfile.c
index a04294eed5..338e45bbc5 100644
--- a/usr/src/uts/common/os/modsysfile.c
+++ b/usr/src/uts/common/os/modsysfile.c
@@ -22,8 +22,8 @@
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
- * Copyright 2018 Joyent, Inc.
* Copyright 2017 Nexenta Systems, Inc.
+ * Copyright 2019 Joyent, Inc.
*/
#include <sys/types.h>
@@ -70,6 +70,11 @@ static char dacffile[] = DACFFILE;
char *self_assembly = "/etc/system.d/.self-assembly";
char *systemfile = "/etc/system"; /* name of ascii system file */
+#define BUILDVERSION_LEN (4096)
+
+char *versionfile = "/etc/versions/build";
+char buildversion[BUILDVERSION_LEN];
+
static struct sysparam *sysparam_hd; /* head of parameters list */
static struct sysparam *sysparam_tl; /* tail of parameters list */
static vmem_t *mod_sysfile_arena; /* parser memory */
@@ -814,6 +819,8 @@ read_system_file(char *name)
void
mod_read_system_file(int ask)
{
+ struct _buf *file;
+
mod_sysfile_arena = vmem_create("mod_sysfile", NULL, 0, 8,
segkmem_alloc, segkmem_free, heap_arena, 0, VM_SLEEP);
@@ -841,6 +848,18 @@ mod_read_system_file(int ask)
if (ask == 0)
setparams();
+
+ /*
+ * A convenient place to read in our build version string.
+ */
+
+ if ((file = kobj_open_file(versionfile)) != (struct _buf *)-1) {
+ if (kobj_read_file(file, buildversion,
+ sizeof (buildversion) - 1, 0) == -1) {
+ cmn_err(CE_WARN, "failed to read %s\n", versionfile);
+ }
+ kobj_close_file(file);
+ }
}
/*
diff --git a/usr/src/uts/intel/Makefile.intel b/usr/src/uts/intel/Makefile.intel
index 4d43a7d77a..32f5ff1bad 100644
--- a/usr/src/uts/intel/Makefile.intel
+++ b/usr/src/uts/intel/Makefile.intel
@@ -697,8 +697,6 @@ MISC_KMODS += uathfw
MISC_KMODS += klmmod klmops
-MISC_KMODS += buildversion
-
#
# Software Cryptographic Providers (/kernel/crypto):
#
diff --git a/usr/src/uts/intel/buildversion/Makefile b/usr/src/uts/intel/buildversion/Makefile
deleted file mode 100644
index c4cf46c1a2..0000000000
--- a/usr/src/uts/intel/buildversion/Makefile
+++ /dev/null
@@ -1,50 +0,0 @@
-#
-# This file and its contents are supplied under the terms of the
-# Common Development and Distribution License ("CDDL"), version 1.0.
-# You may only use this file in accordance with the terms of version
-# 1.0 of the CDDL.
-#
-# A full copy of the text of the CDDL should have accompanied this
-# source. A copy of the CDDL is also available via the Internet at
-# http://www.illumos.org/license/CDDL.
-#
-# Copyright 2019 Joyent, Inc.
-#
-
-UTSBASE = ../..
-
-MODULE = buildversion
-OBJECTS = $(OBJS_DIR)/$(MODULE).o $(OBJS_DIR)/bvstr.o
-BVSTR = $(OBJS_DIR)/buildversion
-ROOTMODULE = $(ROOT_MISC_DIR)/$(MODULE)
-
-include $(UTSBASE)/intel/Makefile.intel
-
-ALL_TARGET = $(BINARY)
-INSTALL_TARGET = $(ALL_TARGET) $(ROOTMODULE)
-
-CLEANFILES += $(BVSTR)
-
-.KEEP_STATE:
-
-def: $(DEF_DEPS)
-
-all: $(ALL_DEPS)
-
-clean: $(CLEAN_DEPS)
-
-clobber: $(CLOBBER_DEPS)
-
-install: $(INSTALL_DEPS)
-
-#
-# If nightly didn't generate this at all, we do so here
-$(SRC)/buildversion:
- echo "version unset" >$(SRC)/buildversion
-
-$(OBJS_DIR)/bvstr.o: $(SRC)/buildversion
- cp $(SRC)/buildversion $(BVSTR)
- printf '\0' >>$(BVSTR)
- elfwrap -64 -z target=x86 -o $@ $(BVSTR)
-
-include $(UTSBASE)/intel/Makefile.targ
diff --git a/usr/src/uts/intel/os/name_to_major b/usr/src/uts/intel/os/name_to_major
index 6041728774..17355a771a 100644
--- a/usr/src/uts/intel/os/name_to_major
+++ b/usr/src/uts/intel/os/name_to_major
@@ -298,7 +298,6 @@ smrt 300
iwn 301
xhci 302
qede 303
-buildversion 304
vmm 305
viona 306
ppt 307
diff --git a/usr/src/uts/sparc/Makefile.sparc b/usr/src/uts/sparc/Makefile.sparc
index 26494d418e..e592b8a8ff 100644
--- a/usr/src/uts/sparc/Makefile.sparc
+++ b/usr/src/uts/sparc/Makefile.sparc
@@ -432,8 +432,6 @@ MISC_KMODS += mii
MISC_KMODS += klmmod klmops
-MISC_KMODS += buildversion
-
#
# Software Cryptographic Providers (/kernel/crypto):
#
diff --git a/usr/src/uts/sparc/buildversion/Makefile b/usr/src/uts/sparc/buildversion/Makefile
deleted file mode 100644
index 794cf866b8..0000000000
--- a/usr/src/uts/sparc/buildversion/Makefile
+++ /dev/null
@@ -1,50 +0,0 @@
-#
-# This file and its contents are supplied under the terms of the
-# Common Development and Distribution License ("CDDL"), version 1.0.
-# You may only use this file in accordance with the terms of version
-# 1.0 of the CDDL.
-#
-# A full copy of the text of the CDDL should have accompanied this
-# source. A copy of the CDDL is also available via the Internet at
-# http://www.illumos.org/license/CDDL.
-#
-# Copyright 2019 Joyent, Inc.
-#
-
-UTSBASE = ../..
-
-MODULE = buildversion
-OBJECTS = $(OBJS_DIR)/$(MODULE).o $(OBJS_DIR)/bvstr.o
-BVSTR = $(OBJS_DIR)/buildversion
-ROOTMODULE = $(ROOT_MISC_DIR)/$(MODULE)
-
-include $(UTSBASE)/sparc/Makefile.sparc
-
-ALL_TARGET = $(BINARY)
-INSTALL_TARGET = $(ALL_TARGET) $(ROOTMODULE)
-
-CLEANFILES += $(BVSTR)
-
-.KEEP_STATE:
-
-def: $(DEF_DEPS)
-
-all: $(ALL_DEPS)
-
-clean: $(CLEAN_DEPS)
-
-clobber: $(CLOBBER_DEPS)
-
-install: $(INSTALL_DEPS)
-
-#
-# If nightly didn't generate this at all, we do so here
-$(SRC)/buildversion:
- echo "version unset" >$(SRC)/buildversion
-
-$(OBJS_DIR)/bvstr.o: $(SRC)/buildversion
- cp $(SRC)/buildversion $(BVSTR)
- printf '\0' >>$(BVSTR)
- elfwrap -64 -z target=sparc -o $@ $(BVSTR)
-
-include $(UTSBASE)/sparc/Makefile.targ