diff options
-rw-r--r-- | usr/src/cmd/mdb/common/modules/mdb_ks/mdb_ks.c | 61 | ||||
-rw-r--r-- | usr/src/cmd/nsadmin/Makefile | 32 |
2 files changed, 78 insertions, 15 deletions
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 46de364ba0..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 @@ -1817,18 +1817,73 @@ mdb_get_lbolt(void) return ((ts/nsec) - lbi.lbi_debug_time); } +#define startswith(a, b) (strncmp((a), (b), strlen(b)) == 0) + +/* + * 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" is built from. + */ void mdb_print_buildversion(void) { + boolean_t in_joyent = B_FALSE; GElf_Sym sym; - if (mdb_lookup_by_name("buildversion", &sym) != 0) - return; + if (mdb_lookup_by_name("buildversion", &sym) != 0) { + /* Older kernels used this name. */ + if (mdb_lookup_by_name("gitstatus_start", &sym) != 0) + return; + } char *str = mdb_zalloc(4096, UM_SLEEP | UM_GC); if (mdb_readstr(str, 4096, sym.st_value) < 1) return; - mdb_printf("build version: %s\n", str); + /* + * Each line is of the form + * + * "repo": "smartos-live", + */ + for (char *line = strtok(str, "\n"); line != NULL; + line = strtok(NULL, "\n")) { + /* skip whitespace and first " */ + line += strspn(line, " \t\""); + + if (startswith(line, "repo")) { + line += sizeof ("repo") - 1; + line += strspn(line, " \t\":"); + + if (startswith(line, "illumos-joyent")) + in_joyent = B_TRUE; + else if (in_joyent) + return; + continue; + } + + if (!in_joyent) + continue; + + if (startswith(line, "branch")) { + char *trail = strrchr(line, '"'); + if (trail != NULL) + *trail = '\0'; + line += sizeof ("branch") - 1; + line += strspn(line, " \t\":"); + mdb_printf("git branch: %s\n", line); + continue; + } + + if (startswith(line, "rev")) { + char *trail = strrchr(line, '"'); + if (trail != NULL) + *trail = '\0'; + line += sizeof ("rev") - 1; + line += strspn(line, " \t\":"); + mdb_printf("git rev: %s\n", line); + continue; + } + } } diff --git a/usr/src/cmd/nsadmin/Makefile b/usr/src/cmd/nsadmin/Makefile index 3525d407e7..45bdcc6701 100644 --- a/usr/src/cmd/nsadmin/Makefile +++ b/usr/src/cmd/nsadmin/Makefile @@ -35,10 +35,21 @@ include ../Makefile.cmd ROOTETCFILES = $(ETCFILES:%=$(ROOTETC)/%) ROOTETCSKEL= $(ROOTETC)/skel -ROOTETCSKELPROG= $(PROGSKEL:%=$(ROOTETCSKEL)/%) +ROOTETCSKELFILES = $(ETCSKELFILES:%=$(ROOTETCSKEL)/%) ROOTETCVERSIONS= $(ROOTETC)/versions -ROOTETCVERSIONSPROG= $(ROOTETCVERSIONS)/build -ROOTROOTPROG= $(PROGROOT:%=$(ROOTROOT)/%) +ROOTETCVERSIONSFILES = $(ROOTETCVERSIONS)/build +ETCBASHDIR = $(ROOTETC)/bash +ROOTETCBASHFILES = $(ETCBASHFILES:%=$(ETCBASHDIR)/%) +ETCBASHCOMPLETIONDDIR = $(ETCBASHDIR)/bash_completion.d +ROOTETCBASHCOMPLETIONDFILES = \ + $(ETCBASHCOMPLETIONDFILES:%=$(ETCBASHCOMPLETIONDDIR)/%) +ROOTROOT= $(ROOT)/root +ROOTROOTFILES = $(ROOTFILES:%=$(ROOTROOT)/%) + +FILES = $(ROOTETCFILES) $(ROOTETCSKELFILES) \ + $(ROOTETCBASHFILES) $(ROOTETCBASHCOMPLETIONDFILES) \ + $(ROOTROOTFILES) $(ROOTETCVERSIONSFILES) + FILEMODE= 0644 .KEEP_STATE: @@ -82,20 +93,17 @@ $(ROOTROOT)/.bashrc: dot-bashrc.sh $(ROOTETCBASHDIR)/%: % $(INS.file) -$(ROOTROOT) \ -$(ROOTETCVERSIONS) \ -$(ROOTETCSKEL): - $(INS.dir) +$(ROOTETCBASHCOMPLETIONDDIR)/%: % + $(INS.file) -$(ROOTETCVERSIONSPROG): $(ROOTETCVERSIONS) FRC +$(ROOTETCVERSIONSFILES): $(ROOTETCVERSIONS) FRC if [[ -n "$$BUILDVERSION_EXEC" ]]; then \ - $$BUILDVERSION_EXEC >$(ROOTETCVERSIONSPROG) ; \ + $$BUILDVERSION_EXEC >$(ROOTETCVERSIONSFILES) ; \ else \ - touch $(ROOTETCVERSIONSPROG) ; \ + touch $(ROOTETCVERSIONSFILES) ; \ fi -install: all $(ROOTETCSKEL) $(ROOTETCPROG) \ - $(ROOTETCSKELPROG) $(ROOTROOTPROG) $(ROOTETCVERSIONSPROG) +install: all $(FILES) clean: |