php-src/ext/fileinfo/generate_patch.sh
Hans Krentel (hakre) 329890c149
Fail early in *nix build script
Adding one more [1] exit early safeguard in *nix build scripts:

Given the initial cd into the build tree fails (the project root),
   the `buildconf` script exits with non-zero status (failure).

Additionally quoting the pathname to cd into and the empty CD_PATH
parameter for portability, also for systems that are using a
non-portable pathname [2] for the build tree.

[1]: https://github.com/php/php-src/pull/16717
[2]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_271

Closes GH-16724.
2024-11-09 14:09:58 +01:00

16 lines
523 B
Bash
Executable file

#!/bin/sh
VERSION=5.45
# Go to fileinfo extension directory.
cd "$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)" || exit
if [ ! -d libmagic.orig ]; then
mkdir libmagic.orig
wget -O - ftp://ftp.astron.com/pub/file/file-$VERSION.tar.gz \
| tar -xz --strip-components=2 -C libmagic.orig file-$VERSION/src
fi
version_number=$(echo "$VERSION" | sed 's/\.//g')
sed -e "s/X\.YY/$version_number/g" libmagic.orig/magic.h.in > libmagic.orig/magic.h
diff -u libmagic.orig libmagic | grep -v '^Only in' > libmagic.patch