Make ${NETBSD_SHELL} value include (a human recognisable form of)
MKREPRO_TIMESTAMP (as an additional word in the value, with a "BUILD:" prefix) if it is set during the build. (Trailing 00 pairs in the time are removed). While here, throw in some extra words that list the compilation options used which alter sh behaviour (mostly by removing stuff.) Usually that will only be noticed in a SMALL shell compiled for install media, or similar - none of the others (not that there are many) are ever changed from the default in a normal build (default settings are just omitted.) This also allows scripts to tell if they are running in a DEBUG shell, which can sometimes make debugging easier.
This commit is contained in:
parent
db7849a108
commit
f52337da20
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: Makefile,v 1.104 2017/03/20 11:26:07 kre Exp $
|
||||
# $NetBSD: Makefile,v 1.105 2017/05/14 11:23:33 kre Exp $
|
||||
# @(#)Makefile 8.4 (Berkeley) 5/5/95
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
@ -29,6 +29,14 @@ CPPFLAGS+=-DSHELL -I. -I${.CURDIR}
|
|||
#CFLAGS+=-funsigned-char
|
||||
#TARGET_CHARFLAG?= -DTARGET_CHAR="unsigned char" -funsigned-char
|
||||
|
||||
# Reproducible build parameters ... export into sh for NETBSD_SHELL setting
|
||||
.if ${MKREPRO_TIMESTAMP:Uno} != "no"
|
||||
BUILD_DATE!= date -u -r "${MKREPRO_TIMESTAMP}" "+%Y%m%d%H%M%S"
|
||||
# These are (should be) equivalent, but the 2nd is easier to understand
|
||||
#CPPFLAGS+= -DBUILD_DATE='"${BUILD_DATE:C/([^0]0?)(00)*$/\1/}Z"'
|
||||
CPPFLAGS+= -DBUILD_DATE='"${BUILD_DATE:S/00$//:S/00$//:S/00//}Z"'
|
||||
.endif
|
||||
|
||||
.ifdef SMALLPROG
|
||||
CPPFLAGS+=-DSMALL
|
||||
.endif
|
||||
|
|
41
bin/sh/var.c
41
bin/sh/var.c
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: var.c,v 1.52 2017/05/10 06:18:43 kre Exp $ */
|
||||
/* $NetBSD: var.c,v 1.53 2017/05/14 11:23:33 kre Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993
|
||||
|
@ -37,7 +37,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 5/4/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: var.c,v 1.52 2017/05/10 06:18:43 kre Exp $");
|
||||
__RCSID("$NetBSD: var.c,v 1.53 2017/05/14 11:23:33 kre Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -162,14 +162,45 @@ INIT {
|
|||
}
|
||||
|
||||
/*
|
||||
* Set variables which override anything read from environment.
|
||||
*
|
||||
* PPID is readonly
|
||||
* set after processing environ to override anything there
|
||||
* Always default IFS, ignore any value from environment.
|
||||
* Always default IFS
|
||||
* NETBSD_SHELL is a constant (readonly), and is never exported
|
||||
*/
|
||||
snprintf(buf, sizeof(buf), "%d", (int)getppid());
|
||||
setvar("PPID", buf, VREADONLY);
|
||||
setvar("IFS", ifs_default, VTEXTFIXED);
|
||||
setvar("NETBSD_SHELL", NETBSD_SHELL, VTEXTFIXED|VREADONLY|VNOEXPORT);
|
||||
|
||||
setvar("NETBSD_SHELL", NETBSD_SHELL
|
||||
#ifdef BUILD_DATE
|
||||
" BUILD:" BUILD_DATE
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
" DEBUG"
|
||||
#endif
|
||||
#if !defined(JOBS) || JOBS == 0
|
||||
" -JOBS"
|
||||
#endif
|
||||
#ifndef DO_SHAREDVFORK
|
||||
" -VFORK"
|
||||
#endif
|
||||
#ifdef SMALL
|
||||
" SMALL"
|
||||
#endif
|
||||
#ifdef TINY
|
||||
" TINY"
|
||||
#endif
|
||||
#ifdef OLD_TTY_DRIVER
|
||||
" OLD_TTY"
|
||||
#endif
|
||||
#ifdef SYSV
|
||||
" SYSV"
|
||||
#endif
|
||||
#ifndef BSD
|
||||
" -BSD"
|
||||
#endif
|
||||
, VTEXTFIXED|VREADONLY|VNOEXPORT);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue