PR/57913: Jan-Benedict Glaw: Don't embed build timestamp into archive

While here, modernize backquotes.
This commit is contained in:
christos 2024-02-09 15:34:34 +00:00
parent 35cdec5580
commit 5d78d08de1
1 changed files with 29 additions and 28 deletions

View File

@ -1,5 +1,5 @@
#!/bin/sh -e #!/bin/sh -e
# $NetBSD: mksparkive.sh,v 1.8 2008/04/30 13:10:47 martin Exp $ # $NetBSD: mksparkive.sh,v 1.9 2024/02/09 15:34:34 christos Exp $
# #
# Copyright (c) 2004 The NetBSD Foundation, Inc. # Copyright (c) 2004 The NetBSD Foundation, Inc.
# All rights reserved. # All rights reserved.
@ -63,8 +63,8 @@ print2()
then then
exit 1 exit 1
fi fi
lowbyte=`expr $1 % 256 | xargs printf %02x` lowbyte=$(expr $1 % 256 | xargs printf %02x)
highbyte=`expr $1 / 256 | xargs printf %02x` highbyte=$(expr $1 / 256 | xargs printf %02x)
printf "\x$lowbyte\x$highbyte" printf "\x$lowbyte\x$highbyte"
} }
@ -74,8 +74,8 @@ print4()
then then
exit 1 exit 1
fi fi
print2 `expr $1 % 65536` print2 $(expr $1 % 65536)
print2 `expr $1 / 65536` print2 $(expr $1 / 65536)
} }
makeheader() makeheader()
@ -83,18 +83,19 @@ makeheader()
filename="$1" filename="$1"
statfilename="$2" statfilename="$2"
realfilename="$3" realfilename="$3"
filetype=`printf %03s "$4"` filetype=$(printf %03s "$4")
compressed="$5" compressed="$5"
# length is only passed to length4, so we don't need to worry about # length is only passed to length4, so we don't need to worry about
# extracting only the length here. # extracting only the length here.
length=`wc -c "$filename"` length=$(wc -c "$filename")
eval `${TOOL_STAT} -s "$statfilename"` eval $(${TOOL_STAT} -s "$statfilename")
[ -n "${MKREPRO_TIMESTAMP}" ] && st_mtime=${MKREPRO_TIMESTAMP}
# centiseconds since 1st Jan 1900 # centiseconds since 1st Jan 1900
timestamp=`expr $st_mtime \* 100 + 220898880000` timestamp=$(expr $st_mtime \* 100 + 220898880000)
lowtype=`echo "$filetype" | sed s/.//` lowtype=$(echo "$filetype" | sed s/.//)
hightype=`echo "$filetype" | sed s/..\$//` hightype=$(echo "$filetype" | sed s/..\$//)
highdate=`expr $timestamp / 4294967296 | xargs printf %02x` highdate=$(expr $timestamp / 4294967296 | xargs printf %02x)
lowdate=`expr $timestamp % 4294967296` lowdate=$(expr $timestamp % 4294967296)
# Header version number # Header version number
if [ "$compressed" -ne 0 ] if [ "$compressed" -ne 0 ]
@ -114,9 +115,9 @@ makeheader()
# CRC # CRC
if [ "$compressed" -ne 0 ] if [ "$compressed" -ne 0 ]
then then
print2 `${TOOL_SPARKCRC} "$statfilename"` print2 $(${TOOL_SPARKCRC} "$statfilename")
else else
print2 `${TOOL_SPARKCRC} "$filename"` print2 $(${TOOL_SPARKCRC} "$filename")
fi fi
# Original file length # Original file length
if [ "$compressed" -ne 0 ] if [ "$compressed" -ne 0 ]
@ -141,7 +142,7 @@ makearchive()
{ {
for file in "$@" for file in "$@"
do do
temp=`${TOOL_MKTEMP} -t $progname` || exit 1 temp=$(${TOOL_MKTEMP} -t $progname) || exit 1
trap "rm -f $temp" 0 trap "rm -f $temp" 0
# Archive marker # Archive marker
printf \\x1a printf \\x1a
@ -151,10 +152,10 @@ makearchive()
-*) echo "Invalid filename" >&2 -*) echo "Invalid filename" >&2
exit 1 exit 1
;; ;;
*,???) type=`echo "$file" | \ *,???) type=$(echo "$file" | \
sed "s/.*,\(...\)$/\1/"` sed "s/.*,\(...\)$/\1/")
filename=`echo "$file" | \ filename=$(echo "$file" | \
sed "s/,...$//"` sed "s/,...$//")
;; ;;
*) type=fff *) type=fff
filename="$file" filename="$file"
@ -166,18 +167,18 @@ makearchive()
# to indicate its choice of algorithm. Spark doesn't # to indicate its choice of algorithm. Spark doesn't
# understand that, so it must be stripped. # understand that, so it must be stripped.
compress -c "$file" | tail -c +3 >"$temp" compress -c "$file" | tail -c +3 >"$temp"
size1=`wc -c "$file" | awk '{print $1}'` size1=$(wc -c "$file" | awk '{print $1}')
size2=`wc -c "$temp" | awk '{print $1}'` size2=$(wc -c "$temp" | awk '{print $1}')
if [ $size1 -ge $size2 ] if [ $size1 -ge $size2 ]
then then
makeheader "$temp" "$file" "$filename" "$type" 1 makeheader "$temp" "$file" "$filename" "$type" 1
nbits=`dd if="$temp" bs=1 count=1 2>/dev/null| \ nbits=$(dd if="$temp" bs=1 count=1 \
od -t d1 | awk '{print $2}'` 2>/dev/null | od -t d1 | awk '{print $2}')
if [ $nbits -ge 128 ] if [ $nbits -ge 128 ]
then then
nbits=`expr $nbits - 128` nbits=$(expr $nbits - 128)
fi fi
printf \\x`printf %02x $nbits` printf \\x$(printf %02x $nbits)
tail -c +2 "$temp" tail -c +2 "$temp"
else else
makeheader "$file" "$file" "$filename" "$type" 0 makeheader "$file" "$file" "$filename" "$type" 0
@ -188,7 +189,7 @@ makearchive()
then then
( (
cd "$file" cd "$file"
makearchive `ls -A` >$temp makearchive $(ls -A) >$temp
) )
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
@ -206,7 +207,7 @@ makearchive()
printf \\x00 printf \\x00
} }
progname=`basename $0` progname=$(basename $0)
if [ $# -eq 0 ] if [ $# -eq 0 ]
then then