From: Ondřej Surý Date: Mon, 22 Feb 2021 11:03:44 +0000 (+0100) Subject: Show packaging credits X-Git-Tag: archive/raspbian/8.4.11-1+rpi1~14 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=26041b41f4ad83daf4f92a87138023ee99fd3642;p=php8.4.git Show packaging credits Gbp-Pq: Name 0034-Show-packaging-credits.patch --- diff --git a/ext/standard/credits.c b/ext/standard/credits.c index 4e8722db..98dfe939 100644 --- a/ext/standard/credits.c +++ b/ext/standard/credits.c @@ -15,6 +15,12 @@ +----------------------------------------------------------------------+ */ +#include +#include +#include +#include +#include + #include "php.h" #include "info.h" #include "SAPI.h" @@ -121,8 +127,145 @@ PHPAPI ZEND_COLD void php_print_credits(int flag) /* {{{ */ php_info_print_table_end(); } + php_print_packaging_credits(flag, 0); + if (!sapi_module.phpinfo_as_text && flag & PHP_CREDITS_FULLPAGE) { PUTS("\n"); } } /* }}} */ + +PHPAPI void php_print_packaging_credits(int flag, int top) /* {{{ */ +{ + if (flag && PHP_CREDITS_PACKAGING) { + /* Packaging */ + int fd = -1; + char buf[4096]; + ssize_t bytes = -1; + char *pos = NULL; + enum { + DEBIAN = 0, + DEBSURYORG = 1, + FREEXIAN = 2 + } packaging = DEBIAN; + + fd = open("/usr/lib/php/packaging", O_RDONLY); + if (fd == -1) { + goto print; + } + + bytes = read(fd, buf, sizeof(buf) - 1); + close(fd); + + if (bytes <= 0) { + goto print; + } + + buf[bytes] = '\0'; + pos = strchr(buf, '\n'); + if (pos != NULL) { + bytes = pos - buf; + *pos = '\0'; + } + + if (strncmp(buf, "deb.sury.org", sizeof(buf)) == 0) { + packaging = DEBSURYORG; + } else if (strncmp(buf, "freexian", sizeof(buf)) == 0) { + packaging = FREEXIAN; + } + + print: + if ((top && packaging != FREEXIAN) || (!top && packaging == FREEXIAN)) + { + return; + } + switch (packaging) { + case DEBSURYORG: + php_info_print_table_start(); + php_info_print_table_colspan_header(1, "Debian Packaging"); + if (!sapi_module.phpinfo_as_text) { + PUTS(""); + PUTS("DEB.SURY.ORG, an Ondřej Surý project"); + PUTS("\n"); + } else { + php_info_print_table_row(1, "DEB.SURY.ORG, an Ondřej Surý project"); + } + php_info_print_table_end(); + break; + case FREEXIAN: + fd = -1; + bytes = -1; + + if (!sapi_module.phpinfo_as_text) { + PUTS("

PHP Vendor

\n"); + } else { + PUTS("PHP Vendor\n"); + } + + php_info_print_table_start(); + php_info_print_table_colspan_header(1, "Debian Packaging"); + + if (!sapi_module.phpinfo_as_text) { + fd = open("/etc/php/freexian-sponsor.html", O_RDONLY); + } else { + fd = open("/etc/php/freexian-sponsor.txt", O_RDONLY); + if (fd == -1) { + fd = open("/etc/php/freexian-sponsor.html", O_RDONLY); + } + } + + if (fd > 0) { + bytes = read(fd, buf, sizeof(buf) - 1); + close(fd); + } + + if (bytes > 0) { + buf[bytes] = '\0'; + } + + if (!sapi_module.phpinfo_as_text) { + PUTS(""); + + PUTS("This PHP version is maintained by " + "Freexian SARL as part of " + "their PHP LTS offer" + ); + + if (bytes > 0) { + PUTS(" and is made available exclusively for "); + PUTS(buf); + } else { + PUTS(". This service is run together with Ondřej Surý, " + "that's why a small subset of the PHP LTS packages " + "are made freely available on " + "DEB.SURY.ORG."); + } + PUTS("\n"); + } else { + PUTS("This PHP version is maintained by " + "Freexian SARL as part of " + "their PHP LTS offer" + ); + if (bytes > 0) { + PUTS(" and is made available exclusively for "); + PUTS(buf); + } else { + PUTS(". This service is run together with Ondřej Surý, " + "that's why a small subset of the PHP LTS packages " + "are made freely available on " + "DEB.SURY.ORG ."); + } + } + php_info_print_table_end(); + break; + case DEBIAN: + default: + php_info_print_table_start(); + php_info_print_table_colspan_header(1, "Debian Packaging"); + php_info_print_table_row(1, "Ondřej Surý"); + php_info_print_table_end(); + break; + } + } +} +/* }}} */ diff --git a/ext/standard/credits.h b/ext/standard/credits.h index a0c5d1e7..3efaa867 100644 --- a/ext/standard/credits.h +++ b/ext/standard/credits.h @@ -35,4 +35,6 @@ PHPAPI void php_print_credits(int flag); +PHPAPI void php_print_packaging_credits(int flag, int top); + #endif diff --git a/ext/standard/info.c b/ext/standard/info.c index ab1f3024..a7dd7d9c 100644 --- a/ext/standard/info.c +++ b/ext/standard/info.c @@ -770,6 +770,8 @@ PHPAPI ZEND_COLD void php_print_info(int flag) php_info_print("phpinfo()\n"); } + php_print_packaging_credits(flag, 1); + if (flag & PHP_INFO_GENERAL) { const char *zend_version = get_zend_version(); char temp_api[10]; diff --git a/ext/standard/info.h b/ext/standard/info.h index 380d2b6e..7d11343e 100644 --- a/ext/standard/info.h +++ b/ext/standard/info.h @@ -43,6 +43,7 @@ #define PHP_CREDITS_FULLPAGE (1<<5) #define PHP_CREDITS_QA (1<<6) #define PHP_CREDITS_WEB (1<<7) +#define PHP_CREDITS_PACKAGING (1<<8) #define PHP_CREDITS_ALL 0xFFFFFFFF #endif /* HAVE_CREDITS_DEFS */