Skip to content

Commit

Permalink
Handle BSD checksum utilities
Browse files Browse the repository at this point in the history
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 phpGH-14688.
  • Loading branch information
NattyNarwhal committed Jun 27, 2024
1 parent 5236551 commit df13613
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 5 additions & 1 deletion scripts/dev/gen_verify_stub
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/bash

# Handle GNU vs. BSD checksum utilities
sha256sum="$(which sha256sum)"
sha256sum="${sha256sum:-$(which shasum) -a 256}"

if [ "x$1" == "x" ]
then
echo "Usage: $0 <version> [email]"
Expand Down Expand Up @@ -41,7 +45,7 @@ done
for TARBALL in "$PHPROOT/php-$RELEASE_VER.tar.bz2" "$PHPROOT/php-$RELEASE_VER.tar.gz" "$PHPROOT/php-$RELEASE_VER.tar.xz"
do
basename $TARBALL
echo "SHA256 hash: `sha256sum $TARBALL | cut -d' ' -f1`";
echo "SHA256 hash: `$sha256sum $TARBALL | cut -d' ' -f1`";
echo PGP signature:
cat $TARBALL.asc
echo -e "\n"
Expand Down
10 changes: 7 additions & 3 deletions scripts/dev/makedist
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
tar="$(which gtar)"
tar="${tar:-$(which tar)}"

# Handle GNU vs. BSD checksum utilities
md5sum="$(which md5sum)"
md5sum="${md5sum:-$(which md5)}"

if [[ $($tar --version) == *"bsdtar"* ]]; then
echo "Found bsdtar at $tar, but this script needs GNU tar."
exit 1
Expand Down Expand Up @@ -181,23 +185,23 @@ rm -rf "$prefix" "$prefix".tar.*

echo "makedist: Creating $prefix.tar.gz archive."
gzip -9 -k "$prefix".tar || exit 6
md5sum "$prefix".tar.gz
"$md5sum" "$prefix".tar.gz
gzip -t "$prefix".tar.gz

sync
sleep 2

echo "makedist: Creating $prefix.tar.bz2 archive."
bzip2 -9 -k $prefix.tar || exit 7
md5sum $prefix.tar.bz2
"$md5sum" $prefix.tar.bz2
bzip2 -t $prefix.tar.bz2

sync
sleep 2

echo "makedist: Creating $prefix.tar.xz archive."
xz -9 -k "$prefix".tar || exit 9
md5sum "$prefix".tar.xz
"$md5sum" "$prefix".tar.xz
xz -t "$prefix".tar.xz

echo ""
Expand Down

0 comments on commit df13613

Please sign in to comment.