mlocati / docker-php-extension-installer

Easily install PHP extensions in Docker containers
MIT License
4.26k stars 384 forks source link

Add support for oci8 and pdo_oci extensions no longer bundled with PHP #894

Closed mlocati closed 7 months ago

mlocati commented 7 months ago

Requires https://github.com/php/pecl-database-pdo_oci/issues/2

Close #892

mvorisek commented 7 months ago

Hi @mlocati, I have merged https://github.com/php/pecl-database-pdo_oci/pull/1 and tested this PR with ghcr.io/mvorisek/image-php:8.4-debian-base image (as discussed in https://github.com/mlocati/docker-php-extension-installer/issues/892#issuecomment-1972874320).

prepare commands:

apt update && apt install git
git clone https://github.com/mlocati/docker-php-extension-installer.git -b oci-php8.4
chmod +x docker-php-extension-installer/install-php-extensions

I was able to run docker-php-extension-installer/install-php-extensions oci8

but

docker-php-extension-installer/install-php-extensions pdo_oci failed with:

Updating channel "pecl.php.net"
Channel "pecl.php.net" is up to date
Get:1 http://deb.debian.org/debian bookworm InRelease [151 kB]
Get:2 http://deb.debian.org/debian bookworm-updates InRelease [55.4 kB]
Get:3 http://deb.debian.org/debian-security bookworm-security InRelease [48.0 kB]
Get:4 http://deb.debian.org/debian bookworm/main amd64 Packages [8786 kB]
Get:5 http://deb.debian.org/debian bookworm-updates/main amd64 Packages [12.7 kB]
Get:6 http://deb.debian.org/debian-security bookworm-security/main amd64 Packages [146 kB]
Fetched 9200 kB in 2s (6032 kB/s)
Reading package lists...
### MARKING PRE-INSTALLED PACKAGES AS IN-USE ###
libaio1 was already set to manually installed.
### INSTALLING REQUIRED PACKAGES ###
# Packages to be kept after installation:
# Packages to be used only for installation: unzip
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package unzip.
(Reading database ... 14780 files and directories currently installed.)
Preparing to unpack .../unzip_6.0-28_amd64.deb ...
Unpacking unzip (6.0-28) ...
Setting up unzip (6.0-28) ...
### INSTALLING REMOTE MODULE pdo_oci ###
WARNING: "pear/PDO_OCI" is deprecated in favor of "channel://http://www.php.net/pdo_oci/ext/pdo_oci"
pear/PDO_OCI requires PHP (version >= 5.0.3, version <= 6.0.0), installed version is 8.4.0-dev
No valid packages found
install failed

that is probably expected as this installed install stable/released packages.

However, when I run docker-php-extension-installer/install-php-extensions php/pecl-database-pdo_oci@a2106eb7fe I get the following error:

Downloading source from https://codeload.github.com/php/pecl-database-pdo_oci/tar.gz/a2106eb7fe
Checking package.xml of directory /tmp/src/tmp.8zY6TDImtN/pecl-database-pdo_oci-a2106eb7fe... good (name: pdo_oci, version: 1.1.0)
Updating channel "pecl.php.net"
Channel "pecl.php.net" is up to date
Hit:1 http://deb.debian.org/debian bookworm InRelease
Hit:2 http://deb.debian.org/debian bookworm-updates InRelease
Hit:3 http://deb.debian.org/debian-security bookworm-security InRelease
Reading package lists...
### MARKING PRE-INSTALLED PACKAGES AS IN-USE ###
libaio1 was already set to manually installed.
### INSTALLING REMOTE MODULE pdo_oci ###
  (installing version 1.1.0 from /tmp/src/tmp.8zY6TDImtN/pecl-database-pdo_oci-a2106eb7fe)
7 source files, building
running: phpize
Configuring for:
PHP Version:             8.4
PHP Api Version:         20230901
Zend Module Api No:      20230901
Zend Extension Api No:   420230901
Please provide the path to the ORACLE_HOME directory. Use 'instantclient,/path/to/instant/client/lib' if you're compiling with Oracle Instant Client [autodetect] : building in /tmp/pear/temp/pear-build-defaultuserxgm2hC/pdo_oci-1.1.0
running: /tmp/pear/temp/pdo_oci/configure --with-php-config=/usr/local/bin/php-config --with-pdo-oci=instantclient,/usr/lib/oracle/21.1/client64/lib
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
...
checking size of long... 8
checking if we're at 64-bit platform... yes
checking Oracle version... 21.1
checking for oci.h... configure: error: I'm too dumb to figure out where the include dir is in your Instant Client install
ERROR: `/tmp/pear/temp/pdo_oci/configure --with-php-config=/usr/local/bin/php-config --with-pdo-oci=instantclient,/usr/lib/oracle/21.1/client64/lib' failed

This should be probably fixed before this PR is merged. Should it be fixed here or in the https://github.com/php/pecl-database-pdo_oci repo?

mlocati commented 7 months ago

Should it be fixed here or in the https://github.com/php/pecl-database-pdo_oci repo?

I don't know: install-php-extensions should pass the with-pdo-oci option to pecl (exaclly like it passes the with-oci8 option for oci8)

mvorisek commented 7 months ago

It seems https://github.com/php/pecl-database-oci8/blob/main/config.m4 is working. I tried diffing it with https://github.com/php/pecl-database-pdo_oci/blob/main/config.m4, the diff is non-trivial, but the OCI8 can be probably used as a working reference. My question is however why the pdo_oci install was working before the unbundling, did anything changed?

mlocati commented 7 months ago

I've tried running this code in two docker containers (launched with docker run --rm -it php:8.3-cli bash and docker run --rm -it ghcr.io/mvorisek/image-php:8.4-debian-base bash):

cd /tmp

# Download and extract the oci-php8.4 branch of https://github.com/mlocati/docker-php-extension-installer
curl -sSLf -o- https://github.com/mlocati/docker-php-extension-installer/archive/refs/heads/oci-php8.4.tar.gz | tar xz

# Download and extract the main branch of https://github.com/php/pecl-database-pdo_oci
curl -sSLf -o- https://github.com/php/pecl-database-pdo_oci/archive/refs/heads/main.tar.gz | tar xz

CI=true /tmp/docker-php-extension-installer-oci-php8.4/install-php-extensions /tmp/pecl-database-pdo_oci-main

With the official PHP 8.3 docker image everything works just fine With your PHP 8.4 docker image I have this error:

cc -I. -I/tmp/pear/temp/pdo_oci -I/tmp/pear/temp/pear-build-defaultuserYKZKBo/pdo_oci-1.1.0/main -I/tmp/pear/temp/pdo_oci -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/usr/lib/oracle/21.1/client64/lib/sdk/include -DHAVE_CONFIG_H -g -O2 -D_GNU_SOURCE -I/usr/local/include/php/ext -DZEND_COMPILE_DL_EXT=1 -c /tmp/pear/temp/pdo_oci/pdo_oci.c -MMD -MF pdo_oci.dep -MT pdo_oci.lo  -fPIC -DPIC -o .libs/pdo_oci.o
/tmp/pear/temp/pdo_oci/oci_statement.c: In function 'oci_stmt_fetch':
/tmp/pear/temp/pdo_oci/oci_statement.c:466:9: error: 'S' undeclared (first use in this function)
  466 |         S->last_err = OCIStmtFetch2(S->stmt, S->err, 1, ociori, (sb4) offset, OCI_DEFAULT);
      |         ^
/tmp/pear/temp/pdo_oci/oci_statement.c:466:9: note: each undeclared identifier is reported only once for each function it appears in
make: *** [Makefile:217: oci_statement.lo] Error 1

I'm sorry I can't help you more (I'm not an expert of OCI).

mvorisek commented 7 months ago

Thank you for beiing so patient with me.

In https://github.com/php/pecl-database-pdo_oci/pull/1 I did a mistake. Now I fixed it in https://github.com/php/pecl-database-pdo_oci/commit/be8a277c278f23a3dbe501acf121c1ce26c30c50.

So I can confirm this PR is working. Once again, thank you!

One small question to #892 - is anything like done in this PR needed also for unbundled imap ext?

mlocati commented 7 months ago

is anything like done in this PR needed also for unbundled imap ext?

Yep.

Just to summarize the list of PHP extensions removed from the PHP main repository:

Am I missing some?

mvorisek commented 7 months ago

only these 4 were unbundled - https://wiki.php.net/rfc/unbundle_imap_pspell_oci8

mlocati commented 7 months ago

is anything like done in this PR needed also for unbundled imap ext?

➡️ https://github.com/mlocati/docker-php-extension-installer/pull/900

only these 4 were unbundled

Thanks for confirming!