Wed May 26 21:58:58 2021 UTC ()
handle different flavors of date(1)


(christos)
diff -r1.350 -r1.351 src/build.sh

cvs diff -r1.350 -r1.351 src/build.sh (expand / switch to unified diff)

--- src/build.sh 2021/05/17 17:12:12 1.350
+++ src/build.sh 2021/05/26 21:58:58 1.351
@@ -1,15 +1,15 @@ @@ -1,15 +1,15 @@
1#! /usr/bin/env sh 1#! /usr/bin/env sh
2# $NetBSD: build.sh,v 1.350 2021/05/17 17:12:12 christos Exp $ 2# $NetBSD: build.sh,v 1.351 2021/05/26 21:58:58 christos Exp $
3# 3#
4# Copyright (c) 2001-2011 The NetBSD Foundation, Inc. 4# Copyright (c) 2001-2011 The NetBSD Foundation, Inc.
5# All rights reserved. 5# All rights reserved.
6# 6#
7# This code is derived from software contributed to The NetBSD Foundation 7# This code is derived from software contributed to The NetBSD Foundation
8# by Todd Vierling and Luke Mewburn. 8# by Todd Vierling and Luke Mewburn.
9# 9#
10# Redistribution and use in source and binary forms, with or without 10# Redistribution and use in source and binary forms, with or without
11# modification, are permitted provided that the following conditions 11# modification, are permitted provided that the following conditions
12# are met: 12# are met:
13# 1. Redistributions of source code must retain the above copyright 13# 1. Redistributions of source code must retain the above copyright
14# notice, this list of conditions and the following disclaimer. 14# notice, this list of conditions and the following disclaimer.
15# 2. Redistributions in binary form must reproduce the above copyright 15# 2. Redistributions in binary form must reproduce the above copyright
@@ -1963,27 +1963,27 @@ createmakewrapper() @@ -1963,27 +1963,27 @@ createmakewrapper()
1963 else 1963 else
1964 makewrapout=">>\${makewrapper}" 1964 makewrapout=">>\${makewrapper}"
1965 fi 1965 fi
1966 1966
1967 case "${KSH_VERSION:-${SH_VERSION}}" in 1967 case "${KSH_VERSION:-${SH_VERSION}}" in
1968 *PD\ KSH*|*MIRBSD\ KSH*) 1968 *PD\ KSH*|*MIRBSD\ KSH*)
1969 set +o braceexpand 1969 set +o braceexpand
1970 ;; 1970 ;;
1971 esac 1971 esac
1972 1972
1973 eval cat <<EOF ${makewrapout} 1973 eval cat <<EOF ${makewrapout}
1974#! ${HOST_SH} 1974#! ${HOST_SH}
1975# Set proper variables to allow easy "make" building of a NetBSD subtree. 1975# Set proper variables to allow easy "make" building of a NetBSD subtree.
1976# Generated from: \$NetBSD: build.sh,v 1.350 2021/05/17 17:12:12 christos Exp $ 1976# Generated from: \$NetBSD: build.sh,v 1.351 2021/05/26 21:58:58 christos Exp $
1977# with these arguments: ${_args} 1977# with these arguments: ${_args}
1978# 1978#
1979 1979
1980EOF 1980EOF
1981 { 1981 {
1982 sorted_vars="$(for var in ${makeenv}; do echo "${var}" ; done \ 1982 sorted_vars="$(for var in ${makeenv}; do echo "${var}" ; done \
1983 | sort -u )" 1983 | sort -u )"
1984 for var in ${sorted_vars}; do 1984 for var in ${sorted_vars}; do
1985 eval val=\"\${${var}}\" 1985 eval val=\"\${${var}}\"
1986 eval is_set=\"\${${var}+set}\" 1986 eval is_set=\"\${${var}+set}\"
1987 if [ -z "${is_set}" ]; then 1987 if [ -z "${is_set}" ]; then
1988 echo "unset ${var}" 1988 echo "unset ${var}"
1989 else 1989 else
@@ -2289,26 +2289,31 @@ dorump() @@ -2289,26 +2289,31 @@ dorump()
2289 } 2289 }
2290 /cannot find -l/{fails[NR] = $0} 2290 /cannot find -l/{fails[NR] = $0}
2291 /cannot open output file/{fails[NR] = $0} 2291 /cannot open output file/{fails[NR] = $0}
2292 END{ 2292 END{
2293 for (x in fails) 2293 for (x in fails)
2294 print fails[x] 2294 print fails[x]
2295 exit x!=0 2295 exit x!=0
2296 }' 2296 }'
2297 [ $? -ne 0 ] && bomb "Testlink of rump failed: ${set}" 2297 [ $? -ne 0 ] && bomb "Testlink of rump failed: ${set}"
2298 done 2298 done
2299 statusmsg "Rump build&link tests successful" 2299 statusmsg "Rump build&link tests successful"
2300} 2300}
2301 2301
 2302repro_date() {
 2303 # try the bsd date fail back the the linux one
 2304 (date -u -r "$1" 2> /dev/null) || date -u -d "@$1"
 2305}
 2306
2302setup_mkrepro() 2307setup_mkrepro()
2303{ 2308{
2304 if [ ${MKREPRO-no} != "yes" ]; then 2309 if [ ${MKREPRO-no} != "yes" ]; then
2305 return 2310 return
2306 fi 2311 fi
2307 2312
2308 local dirs=${NETBSDSRCDIR-/usr/src}/ 2313 local dirs=${NETBSDSRCDIR-/usr/src}/
2309 if [ ${MKX11-no} = "yes" ]; then 2314 if [ ${MKX11-no} = "yes" ]; then
2310 dirs="$dirs ${X11SRCDIR-/usr/xsrc}/" 2315 dirs="$dirs ${X11SRCDIR-/usr/xsrc}/"
2311 fi 2316 fi
2312 2317
2313 local cvslatest=$(print_tooldir_program cvslatest) 2318 local cvslatest=$(print_tooldir_program cvslatest)
2314 if [ ! -x "${cvslatest}" ]; then 2319 if [ ! -x "${cvslatest}" ]; then
@@ -2340,27 +2345,27 @@ setup_mkrepro() @@ -2340,27 +2345,27 @@ setup_mkrepro()
2340 fi 2345 fi
2341 2346
2342 if [ -z "$t" ]; then 2347 if [ -z "$t" ]; then
2343 bomb "Failed to get timestamp for vcs=$vcs in '$d'" 2348 bomb "Failed to get timestamp for vcs=$vcs in '$d'"
2344 fi 2349 fi
2345 2350
2346 #echo "latest $d $vcs $t" 2351 #echo "latest $d $vcs $t"
2347 if [ "$t" -gt "$MKREPRO_TIMESTAMP" ]; then 2352 if [ "$t" -gt "$MKREPRO_TIMESTAMP" ]; then
2348 MKREPRO_TIMESTAMP="$t" 2353 MKREPRO_TIMESTAMP="$t"
2349 fi 2354 fi
2350 done 2355 done
2351 2356
2352 [ "${MKREPRO_TIMESTAMP}" != "0" ] || bomb "Failed to compute timestamp" 2357 [ "${MKREPRO_TIMESTAMP}" != "0" ] || bomb "Failed to compute timestamp"
2353 statusmsg2 "MKREPRO_TIMESTAMP" "$(TZ=UTC date -r ${MKREPRO_TIMESTAMP})" 2358 statusmsg2 "MKREPRO_TIMESTAMP" "$(repro_date "${MKREPRO_TIMESTAMP}")"
2354 export MKREPRO MKREPRO_TIMESTAMP 2359 export MKREPRO MKREPRO_TIMESTAMP
2355} 2360}
2356 2361
2357main() 2362main()
2358{ 2363{
2359 initdefaults 2364 initdefaults
2360 _args=$@ 2365 _args=$@
2361 parseoptions "$@" 2366 parseoptions "$@"
2362 2367
2363 sanitycheck 2368 sanitycheck
2364 2369
2365 build_start=$(date) 2370 build_start=$(date)
2366 statusmsg2 "${progname} command:" "$0 $*" 2371 statusmsg2 "${progname} command:" "$0 $*"