Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate PHP formulas & update PHP to latest version(s) #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,12 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macOS-latest]
php: [php, [email protected]]
steps:
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master

- name: Build Unit PHP module
run:
brew install --build-from-source Formula/unit-php.rb
brew install --build-from-source Formula/unit-${{ matrix.php }}.rb
1 change: 0 additions & 1 deletion Aliases/[email protected]

This file was deleted.

18 changes: 3 additions & 15 deletions Formula/php-embed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
desc "PHP library for embedding in applications"
homepage "https://www.php.net/"
# Should only be updated if the new version is announced on the homepage, https://www.php.net/
url "https://www.php.net/distributions/php-8.2.5.tar.xz"
mirror "https://fossies.org/linux/www/php-8.2.5.tar.xz"
sha256 "800738c359b7f1e67e40c22713d2d90276bc85ba1c21b43d99edd43c254c5f76"
url "https://www.php.net/distributions/php-8.3.2.tar.xz"
mirror "https://fossies.org/linux/www/php-8.3.2.tar.xz"
sha256 "4ffa3e44afc9c590e28dc0d2d31fc61f0139f8b335f11880a121b9f9b9f0634e"
license "PHP-3.01"

livecheck do
Expand All @@ -19,7 +19,6 @@
depends_on "re2c" => :build # required to generate PHP lexers
end

depends_on "pkg-config" => :build
depends_on "php"

on_macos do
Expand All @@ -28,21 +27,10 @@
patch :DATA
end

def install

Check warning on line 30 in Formula/php-embed.rb

View workflow job for this annotation

GitHub Actions / test-bot (macOS-latest)

`brew install --verbose --build-bottle nginx/unit/php-embed` failed on macOS Monterey (12)!

checking for sys/poll.h... yes checking for sys/procctl.h... no checking for sys/resource.h... yes checking for sys/select.h... yes checking for sys/socket.h... yes checking for sys/stat.h... (cached) yes checking for sys/statfs.h... no checking for sys/statvfs.h... yes checking for sys/vfs.h... no checking for sys/sysexits.h... no checking for sys/uio.h... yes checking for sys/wait.h... yes checking for sys/loadavg.h... no checking for unistd.h... (cached) yes checking for unix.h... no checking for utime.h... yes checking for sys/utsname.h... yes checking for sys/ipc.h... yes checking for dlfcn.h... yes checking for tmmintrin.h... yes checking for nmmintrin.h... yes checking for wmmintrin.h... yes checking for immintrin.h... yes checking for fopencookie... no checking for broken getcwd... no checking for broken gcc optimize-strlen... no checking whether struct tm is in sys/time.h or time.h... time.h checking for clang options needed to detect all undeclared functions... none needed checking for struct tm.tm_zone... yes checking for missing declarations of reentrant functions... done checking for fclose declaration... ok checking for struct flock... yes checking for socklen_t... yes checking size of intmax_t... 8 checking size of ssize_t... 8 checking size of ptrdiff_t... 8 checking size of short... 2 checking size of int... 4 checking size of long... 8 checking size of long long... 8 checking size of size_t... 8 checking size of off_t... 8 checking for __builtin_expect... yes checking for __builtin_clz... yes checking for __builtin_clzl... yes checking for __builtin_clzll... yes checking for __builtin_ctzl... yes checking for __builtin_ctzll... yes checking for __builtin_smull_overflow... yes checking for __builtin_smulll_overflow... yes checking for __builtin_saddl_overflow... yes checking for __builtin_saddll_overflow... yes checking for __builtin_usub_overflow... yes checking for __builtin_ssubl_overflow... yes checking for __builtin_ssubll_overflow... yes checking for __builtin_cpu_init... yes checking for __builtin_cpu_supports... yes checking for __builtin_frame_address... yes checking for prctl... no checking for procctl... no checking for avx512 supports in compiler... yes checking for avx512 vbmi supports in compiler... yes checking whether the compiler supports __alignof__... yes checking for struct tm.tm_gmtoff... yes checking for struct stat.st_blksize... yes checking for struct stat.st_rdev... yes checking for struct stat.st_blocks... yes checking for size_t... yes checking for uid_t... yes checking for gid_t... yes checking for struct sockaddr_storage... yes checking for field sa_len in struct sockaddr... yes checking for __attribute__((ifunc))... no checking for __attribute__((target))... yes checking for IPv6 support... yes checking for alphasort... yes checking for asctime_r... yes checking for chroot... yes checking for ctime_r... yes checking for explicit_memset... no checking for fdatasync... yes checking for flock... yes checking for ftok... yes checking for funopen... yes checking for gai_strerror... yes checking for getcwd... yes checking for getloadavg... yes checking for getlogin... yes checking for getprotobyname... yes checking for getprotobynumber... yes checking for getservbyname... yes checking for getservbyport... yes checking for getrusage... yes checking for gettimeofday... yes checking for gmtime_r... yes checking for getpwnam_r... yes checking for getgrnam_r... yes checking for getpwuid_r... yes checking for getwd... yes checking for glob... yes checking for inet_ntoa... yes checking for inet_ntop... yes checking for inet_pton... yes checking for localtime_r... yes checking for lchown... yes checking for memcntl... no checking for memmove... yes checking for mkstemp... yes checking for mmap... yes checking for nice... yes checking for nl_langinfo... yes checking for poll... yes checking for pthread_jit_write_protect_np... yes checking for putenv... yes checking for scandir.
# buildconf required due to system library linking bug patch
system "./buildconf", "--force"

inreplace "configure" do |s|
s.gsub! "APACHE_THREADED_MPM=`$APXS_HTTPD -V 2>/dev/null | grep 'threaded:.*yes'`",
"APACHE_THREADED_MPM="
s.gsub! "APXS_LIBEXECDIR='$(INSTALL_ROOT)'`$APXS -q LIBEXECDIR`",
"APXS_LIBEXECDIR='$(INSTALL_ROOT)#{lib}/httpd/modules'"
s.gsub! "-z `$APXS -q SYSCONFDIR`",
"-z ''"
s.gsub! "${wl}-flat_namespace ${wl}-undefined ${wl}suppress",
"${wl}-twolevel_namespace"
end

# Update error message in apache sapi to better explain the requirements
# of using Apache http in combination with php if the non-compatible MPM
# has been selected. Homebrew has chosen not to support being able to
Expand Down
207 changes: 207 additions & 0 deletions Formula/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
class PhpEmbedAT82 < Formula

Check failure on line 1 in Formula/[email protected]

View workflow job for this annotation

GitHub Actions / test-bot (ubuntu-latest)

HEAD: Use `branch: "master"` to specify the default branch

Check failure on line 1 in Formula/[email protected]

View workflow job for this annotation

GitHub Actions / test-bot (macOS-latest)

HEAD: Use `branch: "master"` to specify the default branch
desc "PHP library for embedding in applications"
homepage "https://www.php.net/"
# Should only be updated if the new version is announced on the homepage, https://www.php.net/
url "https://www.php.net/distributions/php-8.2.15.tar.xz"
mirror "https://fossies.org/linux/www/php-8.2.15.tar.xz"
sha256 "eca5deac02d77d806838275f8a3024b38b35ac0a5d9853dcc71c6cbe3f1f8765"
license "PHP-3.01"

livecheck do
url "https://www.php.net/downloads"
regex(/href=.*?php[._-]v?(\d+(?:\.\d+)+)\.t/i)
end

head do
url "https://github.com/php/php-src.git"

depends_on "bison" => :build # bison >= 3.0.0 required to generate parsers
depends_on "re2c" => :build # required to generate PHP lexers
end

depends_on "[email protected]"

on_macos do
# PHP build system incorrectly links system libraries
# see https://github.com/php/php-src/issues/10680
patch :DATA
end

def install

Check failure on line 30 in Formula/[email protected]

View workflow job for this annotation

GitHub Actions / test-bot (macOS-latest)

`brew install --verbose --build-bottle nginx/unit/[email protected]` failed on macOS Monterey (12)!

checking for sys/select.h... yes checking for sys/socket.h... yes checking for sys/stat.h... (cached) yes checking for sys/statfs.h... no checking for sys/statvfs.h... yes checking for sys/vfs.h... no checking for sys/sysexits.h... no checking for sys/uio.h... yes checking for sys/wait.h... yes checking for sys/loadavg.h... no checking for unistd.h... (cached) yes checking for unix.h... no checking for utime.h... yes checking for sys/utsname.h... yes checking for sys/ipc.h... yes checking for dlfcn.h... yes checking for tmmintrin.h... yes checking for nmmintrin.h... yes checking for wmmintrin.h... yes checking for immintrin.h... yes checking for fopencookie... no checking for broken getcwd... no checking for broken gcc optimize-strlen... no checking whether struct tm is in sys/time.h or time.h... time.h checking for clang options needed to detect all undeclared functions... none needed checking for struct tm.tm_zone... yes checking for missing declarations of reentrant functions... done checking for fclose declaration... ok checking for struct flock... yes checking for socklen_t... yes checking size of intmax_t... 8 checking size of ssize_t... 8 checking size of ptrdiff_t... 8 checking size of short... 2 checking size of int... 4 checking size of long... 8 checking size of long long... 8 checking size of size_t... 8 checking size of off_t... 8 checking for int8_t... yes checking for int16_t... yes checking for int32_t... yes checking for int64_t... yes checking for uint8_t... yes checking for uint16_t... yes checking for uint32_t... yes checking for uint64_t... yes checking for __builtin_expect... yes checking for __builtin_clz... yes checking for __builtin_clzl... yes checking for __builtin_clzll... yes checking for __builtin_ctzl... yes checking for __builtin_ctzll... yes checking for __builtin_smull_overflow... yes checking for __builtin_smulll_overflow... yes checking for __builtin_saddl_overflow... yes checking for __builtin_saddll_overflow... yes checking for __builtin_ssubl_overflow... yes checking for __builtin_ssubll_overflow... yes checking for __builtin_cpu_init... yes checking for __builtin_cpu_supports... yes checking whether the compiler supports __alignof__... yes checking for struct tm.tm_gmtoff... yes checking for struct stat.st_blksize... yes checking for struct stat.st_rdev... yes checking for struct stat.st_blocks... yes checking for size_t... yes checking for uid_t... yes checking for gid_t... yes checking for struct sockaddr_storage... yes checking for field sa_len in struct sockaddr... yes checking for __attribute__((ifunc))... no checking for __attribute__((target))... yes checking for IPv6 support... yes checking for alphasort... yes checking for asctime_r... yes checking for chroot... yes checking for ctime_r... yes checking for explicit_memset... no checking for fdatasync... yes checking for flock... yes checking for ftok... yes checking for funopen... yes checking for gai_strerror... yes checking for getcwd... yes checking for getloadavg... yes checking for getlogin... yes checking for getprotobyname... yes checking for getprotobynumber... yes checking for getservbyname... yes checking for getservbyport... yes checking for getrusage... yes checking for gettimeofday... yes checking for gmtime_r... yes checking for getpwnam_r... yes checking for getgrnam_r... yes checking for getpwuid_r... yes checking for getwd... yes checking for glob... yes checking for inet_ntoa... yes checking for inet_ntop... yes checking for inet_pton... yes checking for localtime_r... yes checking for lchown... yes checking for memcntl... no checking for memmove... yes checking for mkstemp... yes checking for mmap... yes checking for nice... yes checking for nl_langinfo... yes checking for poll... yes checking for pthread_jit_write_protect_np... yes checking for putenv... yes checking for scandir... yes checking for setitimer... yes checking for setenv... yes checking for shutdown... yes checking for sigpr
# buildconf required due to system library linking bug patch
system "./buildconf", "--force"

# Update error message in apache sapi to better explain the requirements
# of using Apache http in combination with php if the non-compatible MPM
# has been selected. Homebrew has chosen not to support being able to
# compile a thread safe version of PHP and therefore it is not
# possible to recompile as suggested in the original message
inreplace "sapi/apache2handler/sapi_apache2.c",
"You need to recompile PHP.",
"Homebrew PHP does not support a thread-safe php binary. " \
"To use the PHP apache sapi please change " \
"your httpd config to use the prefork MPM"

inreplace "sapi/fpm/php-fpm.conf.in", ";daemonize = yes", "daemonize = no"

config_path = etc/"php/#{php_version}"
# Prevent system pear config from inhibiting pear install
(config_path/"pear.conf").delete if (config_path/"pear.conf").exist?

# Prevent homebrew from hardcoding path to sed shim in phpize script
ENV["lt_cv_path_SED"] = "sed"

# system pkg-config missing
ENV["KERBEROS_CFLAGS"] = " "
if OS.mac?
ENV["SASL_CFLAGS"] = "-I#{MacOS.sdk_path_if_needed}/usr/include/sasl"
ENV["SASL_LIBS"] = "-lsasl2"
else
ENV["SQLITE_CFLAGS"] = "-I#{Formula["sqlite"].opt_include}"
ENV["SQLITE_LIBS"] = "-lsqlite3"
ENV["BZIP_DIR"] = Formula["bzip2"].opt_prefix
end

# Each extension that is built on Mojave needs a direct reference to the
# sdk path or it won't find the headers
headers_path = "=#{MacOS.sdk_path_if_needed}/usr" if OS.mac?

# `_www` only exists on macOS.
fpm_user = OS.mac? ? "_www" : "www-data"
fpm_group = OS.mac? ? "_www" : "www-data"

args = %W[
--prefix=#{prefix}
--localstatedir=#{var}
--sysconfdir=#{config_path}
--with-config-file-path=#{config_path}
--with-config-file-scan-dir=#{config_path}/conf.d
--with-pear=#{pkgshare}/pear
--enable-bcmath
--enable-calendar
--enable-dba
--enable-exif
--enable-ftp
--enable-fpm
--enable-gd
--enable-intl
--enable-mbregex
--enable-mbstring
--enable-mysqlnd
--enable-pcntl
--enable-phpdbg
--enable-phpdbg-readline
--enable-shmop
--enable-soap
--enable-sockets
--enable-sysvmsg
--enable-sysvsem
--enable-sysvshm
--enable-embed=shared
--with-bz2#{headers_path}
--with-curl
--with-external-gd
--with-external-pcre
--with-ffi
--with-fpm-user=#{fpm_user}
--with-fpm-group=#{fpm_group}
--with-gettext=#{Formula["gettext"].opt_prefix}
--with-gmp=#{Formula["gmp"].opt_prefix}
--with-iconv#{headers_path}
--with-kerberos
--with-layout=GNU
--with-ldap=#{Formula["openldap"].opt_prefix}
--with-libxml
--with-libedit
--with-mhash#{headers_path}
--with-mysql-sock=/tmp/mysql.sock
--with-mysqli=mysqlnd
--with-ndbm#{headers_path}
--with-openssl
--with-password-argon2=#{Formula["argon2"].opt_prefix}
--with-pdo-dblib=#{Formula["freetds"].opt_prefix}
--with-pdo-mysql=mysqlnd
--with-pdo-odbc=unixODBC,#{Formula["unixodbc"].opt_prefix}
--with-pdo-pgsql=#{Formula["libpq"].opt_prefix}
--with-pdo-sqlite
--with-pgsql=#{Formula["libpq"].opt_prefix}
--with-pic
--with-pspell=#{Formula["aspell"].opt_prefix}
--with-sodium
--with-sqlite3
--with-tidy=#{Formula["tidy-html5"].opt_prefix}
--with-unixODBC
--with-xsl
--with-zip
--with-zlib
]

if OS.mac?
args << "--enable-dtrace"
args << "--with-ldap-sasl"
args << "--with-os-sdkpath=#{MacOS.sdk_path_if_needed}"
else
args << "--disable-dtrace"
args << "--without-ldap-sasl"
args << "--without-ndbm"
args << "--without-gdbm"
end

system "./configure", *args

inreplace "Makefile", " -module", ""

system "make", "libphp.la"

lib.mkpath
cp ".libs/libphp.dylib", "#{lib}/" if OS.mac?
cp ".libs/libphp.so", "#{lib}/" if OS.linux?
end

def php_version
version.to_s.split(".")[0..1].join(".")
end
end

__END__
diff --git a/build/php.m4 b/build/php.m4
index 3624a33a8e..d17a635c2c 100644
--- a/build/php.m4
+++ b/build/php.m4
@@ -425,7 +425,7 @@ dnl
dnl Adds a path to linkpath/runpath (LDFLAGS).
dnl
AC_DEFUN([PHP_ADD_LIBPATH],[
- if test "$1" != "/usr/$PHP_LIBDIR" && test "$1" != "/usr/lib"; then
+ if test "$1" != "$PHP_OS_SDKPATH/usr/$PHP_LIBDIR" && test "$1" != "/usr/lib"; then
PHP_EXPAND_PATH($1, ai_p)
ifelse([$2],,[
_PHP_ADD_LIBPATH_GLOBAL([$ai_p])
@@ -470,7 +470,7 @@ dnl
dnl Add an include path. If before is 1, add in the beginning of INCLUDES.
dnl
AC_DEFUN([PHP_ADD_INCLUDE],[
- if test "$1" != "/usr/include"; then
+ if test "$1" != "$PHP_OS_SDKPATH/usr/include"; then
PHP_EXPAND_PATH($1, ai_p)
PHP_RUN_ONCE(INCLUDEPATH, $ai_p, [
if test "$2"; then
diff --git a/configure.ac b/configure.ac
index 36c6e5e3e2..71b1a16607 100644
--- a/configure.ac
+++ b/configure.ac
@@ -190,6 +190,14 @@ PHP_ARG_WITH([libdir],
[lib],
[no])

+dnl Support systems with system libraries/includes in e.g. /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk.
+PHP_ARG_WITH([os-sdkpath],
+ [for system SDK directory],
+ [AS_HELP_STRING([--with-os-sdkpath=NAME],
+ [Ignore system libraries and includes in NAME rather than /])],
+ [],
+ [no])
+
PHP_ARG_ENABLE([rpath],
[whether to enable runpaths],
[AS_HELP_STRING([--disable-rpath],
73 changes: 73 additions & 0 deletions Formula/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
class UnitPhpAT82 < Formula
desc "PHP module for Unit application server"
homepage "https://unit.nginx.org"
url "https://unit.nginx.org/download/unit-1.31.1.tar.gz"
sha256 "9df604d49cb57ac0103202efb0f9373e3e48a7dd888c94af10d4f96ccded7d71"
head "https://github.com/nginx/unit.git", branch: "master"

depends_on "openssl"
depends_on "[email protected]"
depends_on "[email protected]"

def install
system "./configure",
"--prefix=#{prefix}",
"--sbindir=#{bin}",
"--logdir=#{var}/log",
"--log=#{var}/log/unit/unit.log",
"--runstatedir=#{var}/run",
"--pid=#{var}/run/unit/unit.pid",
"--control=unix:#{var}/run/unit/control.sock",
"--modules=#{HOMEBREW_PREFIX}/lib/unit/modules",
"--statedir=#{var}/state/unit",
"--tmpdir=/tmp",
"--openssl",
"--cc-opt=-I#{Formula["openssl"].opt_prefix}/include",
"--ld-opt=-L#{Formula["openssl"].opt_prefix}/lib"

inreplace "build/autoconf.data",
"NXT_MODULESDIR='#{HOMEBREW_PREFIX}/lib/unit/modules'",
"NXT_MODULESDIR='#{lib}/unit/modules'"

system "./configure", "php"
system "make", "php-install"
end

test do
require "socket"

server = TCPServer.new(0)
port = server.addr[1]
server.close

expected_output = "Hello world!"
(testpath/"unit.conf").write <<~EOS
{
"listeners": { "*:#{port}": { "pass": "applications/test" } },
"applications": {
"test": { "type": "php", "root": "#{testpath}" }
}
}
EOS
(testpath/"index.php").write <<~EOS
<?php print("#{expected_output}"); ?>
EOS
(testpath/"state/certs").mkpath

system "#{HOMEBREW_PREFIX}/bin/unitd", "--log", "#{testpath}/unit.log",
"--control", "unix:#{testpath}/control.sock",
"--pid", "#{testpath}/unit.pid",
"--statedir", "#{testpath}/state"
sleep 3

pid = File.open(testpath/"unit.pid").gets.chop.to_i

system "curl", "-s", "--unix-socket", "#{testpath}/control.sock",
"-X", "PUT",
"-d", "@#{testpath}/unit.conf", "127.0.0.1/config"

assert_match expected_output, shell_output("curl -s 127.0.0.1:#{port}")
ensure
Process.kill("TERM", pid)
end
end
Loading