Skip to content

Commit 3618382

Browse files
authored
Handle BSD checksum and file utilities (#14690)
* Handle BSD checksum utilities The BSDs have different checksum utilities than GNU systems do. If we don't see the GNU checksum utilities installed, use the BSD ones, as their output is compatible enough. Addresses part of GH-14688. * Prefer GNU touch BSD touch at least in macOS does not handle local timezone in the timestamp (like 2024-06-27T10:26:23-03:00). As such, try GNU touch (as ports systems almost always prefix with g if coreutils is installed) and prefer that if available. It's not the end of the world though if GNU touch isn't available, as BSD touch on some systems may support it, and if it doesn't, then it's just timestamps, nothing too serious.
1 parent 23a55ba commit 3618382

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

scripts/dev/gen_verify_stub

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/bin/bash
22

3+
# Handle GNU vs. BSD checksum utilities
4+
sha256sum="$(which sha256sum)"
5+
sha256sum="${sha256sum:-$(which shasum) -a 256}"
6+
37
if [ "x$1" == "x" ]
48
then
59
echo "Usage: $0 <version> [email]"
@@ -41,7 +45,7 @@ done
4145
for TARBALL in "$PHPROOT/php-$RELEASE_VER.tar.bz2" "$PHPROOT/php-$RELEASE_VER.tar.gz" "$PHPROOT/php-$RELEASE_VER.tar.xz"
4246
do
4347
basename $TARBALL
44-
echo "SHA256 hash: `sha256sum $TARBALL | cut -d' ' -f1`";
48+
echo "SHA256 hash: `$sha256sum $TARBALL | cut -d' ' -f1`";
4549
echo PGP signature:
4650
cat $TARBALL.asc
4751
echo -e "\n"

scripts/dev/makedist

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@
99
tar="$(which gtar)"
1010
tar="${tar:-$(which tar)}"
1111

12+
# Handle GNU vs. BSD checksum utilities
13+
md5sum="$(which md5sum)"
14+
md5sum="${md5sum:-$(which md5)}"
15+
16+
# GNU touch is preferred since it handles local TZ in timestamps
17+
touch="$(which gtouch)"
18+
touch="${touch:-$(which touch)}"
19+
1220
if [[ $($tar --version) == *"bsdtar"* ]]; then
1321
echo "Found bsdtar at $tar, but this script needs GNU tar."
1422
exit 1
@@ -169,8 +177,8 @@ fi
169177
# Reset the modification and access times of all files to be packaged.
170178
commitDate="$(git log -1 --format=%cI $treeish)"
171179
echo "makedist: Resetting the modification and access times of package files to $commitDate"
172-
touch -c -d"$commitDate" NEWS
173-
find . -exec touch -r NEWS -c {} \;
180+
"$touch" -c -d"$commitDate" NEWS
181+
find . -exec "$touch" -r NEWS -c {} \;
174182

175183
cd ..
176184

@@ -181,23 +189,23 @@ rm -rf "$prefix" "$prefix".tar.*
181189

182190
echo "makedist: Creating $prefix.tar.gz archive."
183191
gzip -9 -k "$prefix".tar || exit 6
184-
md5sum "$prefix".tar.gz
192+
"$md5sum" "$prefix".tar.gz
185193
gzip -t "$prefix".tar.gz
186194

187195
sync
188196
sleep 2
189197

190198
echo "makedist: Creating $prefix.tar.bz2 archive."
191199
bzip2 -9 -k $prefix.tar || exit 7
192-
md5sum $prefix.tar.bz2
200+
"$md5sum" $prefix.tar.bz2
193201
bzip2 -t $prefix.tar.bz2
194202

195203
sync
196204
sleep 2
197205

198206
echo "makedist: Creating $prefix.tar.xz archive."
199207
xz -9 -k "$prefix".tar || exit 9
200-
md5sum "$prefix".tar.xz
208+
"$md5sum" "$prefix".tar.xz
201209
xz -t "$prefix".tar.xz
202210

203211
echo ""

0 commit comments

Comments
 (0)