1 (edited by r00tsh3ll 2020-02-23 16:24:39)

Topic: Rebuild PHP packages (SCL)

Hello Remi,

First please allow me to thank you for your work on the PHP rpm packages.

I am currently in charge to rebuild a webhosting box that was based on centos 6 but based on centos 8.

As I understand there is support for multiple installed PHP versions and this is really good as we need it.

The thing is that for the previous box we had to rebuild some of the PHP packages to add custom patches to it.
We would like to the same based on your src.rpm's.

The problem is that I'm new to SCL stuff and I don't really understand how I should organize the building directory.

What would be a quick "getting started" for example to rebuild all php56 packages in SCL mode ?


For example for php56 i grabbed:
php56-3.0-1.remi.src.rpm
php56-php-5.6.40-18.remi.src.rpm

For 7.1:
php70-2.0-1.remi.src.rpm
php70-php-7.0.33-18.remi.src.rpm

but installing php56-php-5.6.40-18.remi.src.rpm and php70-php-7.0.33-18.remi.src.rpm seems to overwrite files, for example SPECS/php.spec which the filename is the same for both packages.
I must be misunderstanding something here.

I hope you'll have some time to head me in the right direction here.

Again thanks a lot for your work.

Kind regards,
Sébastien

Re: Rebuild PHP packages (SCL)

> example SPECS/php.spec which the filename is the same for both packages.

I'm used to create 1 directory for each .src.rpm with everything inside.

And instead of "rpmbuild" I use the

alias build='rpmbuild      --define "_source_filedigest_algorithm 0" --define "_specdir $(pwd)" --define "_sourcedir $(pwd)"'

And, FYI, all my mock configuration are available in git
https://git.remirepo.net/cgit/tools/mock.git/tree/

Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

Re: Rebuild PHP packages (SCL)

> The thing is that for the previous box we had to rebuild some of the PHP packages to add custom patches to it.

For my curiosity, what kind of patches ?

Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

4 (edited by r00tsh3ll 2020-02-23 17:51:28)

Re: Rebuild PHP packages (SCL)

Hello Remi,

Thanks a lot for the infos, I'll give it a try.

Remi wrote:

> The thing is that for the previous box we had to rebuild some of the PHP packages to add custom patches to it.

For my curiosity, what kind of patches ?

For example this one, useful to have the proc name to reflect the version of php (when running multiple versions of php-fpm):
https://pastebin.com/1iy4DhVv

This results in:
56976 ?        S      0:00 php56-fpm: pool xxx_php                                               
57181 ?        S      0:00 php73-fpm: pool xxx_php                                               
57187 ?        S      0:00 php56-fpm: pool xxx_php                                               
57192 ?        S      0:02 php53-fpm: pool xxx_php                                               
57193 ?        S      0:00 php73-fpm: pool xxx_php                                               
57610 ?        S      0:00 php53-fpm: pool xxx_php                                               
57623 ?        R      0:00 php53-fpm: pool xxx_php                                               
57626 ?        R      0:00 php72-fpm: pool xxx_php                                               

EDIT: For this one it would be better to be able to set a config option or environnement variable to change the proc name prefix at runtime smile


Also this one to add X-PHP-Script to mail headers, so we can track originating scripts source of spams:
h_ttpx://pastebin.com/z0dx9AzW

edit: Sorry I wasn't able to post both pastebin links, the forum complaints smile

Re: Rebuild PHP packages (SCL)

For the 1st one, simply set the version in the ppol name wink

For the 2nd... well... who stil use the mail function, instead of a mailer library ?

Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

Re: Rebuild PHP packages (SCL)

Well, you're not wrong.

Both of them were patches we started using years ago since 5.4 if I remember correctly.
They might be not needed anymore. I'll have to discuss this internally with the other people involved.

Anyway it's still useful for me to know how to rebuild your packages in case we need to mod something and thank you for this!

Kind regards

Re: Rebuild PHP packages (SCL)

Remi wrote:

For the 2nd... well... who stil use the mail function, instead of a mailer library ?

For this one I just noticed this already exists built-in since php 5.3:
https://www.php.net/manual/fr/mail.conf … d-x-header

But I still would patch it so it obfuscate the content of the header with an unique key we are the only ones to know + base64, to avoid leaking informations when it's not needed.

Kind regards

Re: Rebuild PHP packages (SCL)

again, should avoid using the "mail" function, most mail libraries have deprecated its usage, and support adding headers

<?php
$mail = new PHPMailer(true);
...
$mail->addCustomHeader('X-PHP-Script', sha1(__FILE__));
...
$mail->send();
?>
Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi