#!/usr/bin/php - Alternative php @VERSION@ module. The remi-@VERSION@ stream provides more recent versions and more packages than default @VERSION@ stream. license: module: - GPLv2+ content: - BSD - BSD and LGPLv3+ - PHP - PHP and BSD - PHP and LGPLv2 and OpenLDAP - PHP and LGPLv2+ - PHP and Zend and BSD and MIT and ASL 1.0 dependencies: - buildrequires: platform: [@DIST@] requires: @DEPS@ references: documentation: http://php.net/ tracker: https://bugs.php.net/ profiles: common: rpms: - php-cli - php-common - php-fpm - php-mbstring - php-xml devel: rpms: - libzip - php-cli - php-common - php-devel - php-fpm - php-mbstring - php-pear - php-pecl-zip - php-process - php-xml minimal: rpms: - php-cli - php-common api: rpms: - php-fpm artifacts: rpms: @RPMS@ ... EOT; $template_phpextras = <<< EOT --- document: modulemd version: 2 data: name: php-extras stream: @VERSION@ version: @DATE@ context: 00000000 arch: @ARCH@ summary: PHP scripting language description: >- Additional package for php @VERSION@ module. license: module: - GPLv2+ content: - BSD - BSD and LGPLv3+ - PHP - PHP and BSD - PHP and LGPLv2 and OpenLDAP - PHP and LGPLv2+ - PHP and Zend and BSD and MIT and ASL 1.0 dependencies: - buildrequires: platform: [@DIST@] requires: @DEPS@ references: documentation: http://php.net/ tracker: https://bugs.php.net/ profiles: common: rpms: - php-sodium artifacts: rpms: @RPMS@ ... EOT; $template_redis = <<< EOT --- document: modulemd version: 2 data: name: redis stream: remi-@VERSION@ version: @DATE@ context: 00000000 arch: @ARCH@ summary: Redis persistent key-value database description: >- Alternative redis @VERSION@ module. The remi-@VERSION@ stream provides more recent versions and than default @VERSION@ stream. license: module: - GPLv2+ content: - BSD and MIT - CC-BY-SA dependencies: - buildrequires: platform: [@DIST@] requires: @DEPS@ references: documentation: https://redis.io/documentation tracker: https://github.com/redis/redis/issues profiles: common: rpms: - redis api: rpms: - redis artifacts: rpms: @RPMS@ ... EOT; $template_glpi = <<< EOT --- document: modulemd version: 2 data: name: glpi stream: @VERSION@ version: @DATE@ context: 00000000 arch: @ARCH@ summary: Free IT asset management software description: >- glpi @VERSION@ module license: module: - GPLv2+ content: - GPLv2+ and GPLv3+ and MIT dependencies: - buildrequires: platform: [@DIST@] requires: @DEPS@ references: documentation: https://glpi-project.org/ tracker: https://github.com/glpi-project/glpi/issues profiles: common: rpms: - glpi api: rpms: - glpi artifacts: rpms: @RPMS@ ... EOT; $template_comp = <<< EOT --- document: modulemd version: 2 data: name: composer stream: @VERSION@ version: @DATE@ context: 00000000 arch: @ARCH@ summary: Dependency Manager for PHP description: >- Composer @VERSION@ module license: module: - MIT content: - MIT dependencies: - buildrequires: platform: [@DIST@] requires: @DEPS@ references: documentation: https://getcomposer.org/ tracker: https://github.com/composer/composer/issues profiles: common: rpms: - composer api: rpms: - composer artifacts: rpms: @RPMS@ ... EOT; function findPackages($from, $dest, $pat) { global $oldrpms; $excl = ['php-amqplib', 'php-jsonlint', 'php-laminas-mime', 'php-cs-fixer', 'php-tecnickcom-tc-lib-unicode-data', 'php-doctrine-orm']; $rpms = []; foreach (glob("$from/$pat") as $file) { $info = rpminfo($file); $name = basename($file); if (in_array($info['Name'], $excl)) { continue; } if (!file_exists("$dest/$name")) { if (link($file, "$dest/$name")) { $k = array_search(basename($file), $oldrpms); if ($k === false) { printf("\r\t+ %-70s\n", basename($file)); } else { unset($oldrpms[$k]); } } } $rpms[] = $info['Name'] . '-' . ($info['Epoch'] ?? '0') . ':' . $info['Version'] . '-' . $info['Release'] . '.' . $info['Arch']; } return $rpms; } function genDefaults($name, $def, Array $vers) { $meta = "---\n" . "document: modulemd-defaults\n" . "version: 1\n" . "data:\n" . " module: $name\n"; if ($def) { $meta .= " stream: $def\n"; } $meta .= " profiles:\n"; foreach ($vers as $ver) { $meta .= " $ver: [common]\n"; } $meta .= "...\n"; return $meta; } function genModule($srce, $dest, $pats, $ver, $arch, $deps, $template) { $rpms = []; foreach ((array)$pats as $pat) { $rpms += findPackages($srce, $dest, $pat); } $deptxt = ''; foreach($deps as $n => $v) { $deptxt .= ($deptxt ? "\n" : '') . " $n: [$v]"; } if (empty($rpms)) { return ''; } $rpmstxt = ''; foreach($rpms as $rpm) { $rpmstxt .= ($rpmstxt ? "\n" : '') . " - $rpm"; } $mod = str_replace( ['@VERSION@', '@ARCH@', "@DATE@", "@DIST@", "@DEPS@", '@RPMS@'], [$ver, $arch, date("YmdHis"), $deps['platform'], $deptxt, $rpmstxt], $template ); return $mod; } function cleanup($dest) { global $oldrpms; $oldrpms = array(); foreach (glob("$dest/*rpm") as $file) { unlink($file); $oldrpms[] = basename($file); } } function createRepo($dest, $mod) { $old = getcwd(); chdir($dest); exec("mkrepo nocheck noclean"); $data = '/tmp/modules.yaml'; file_put_contents($data, $mod); $hash = hash('sha256', $mod); exec("modifyrepo_c --mdtype=modules $data repodata >/dev/null"); $arch = basename($dest); rename($data, "$data.$arch"); chdir($old); } /* if (count($_SERVER['argv']) < 2 || in_array('f31', $_SERVER['argv'])) { $dest = 'fedora/31/modular/x86_64'; echo "Populate $dest\n"; cleanup($dest); $deps = ['platform' => 'f31']; $mod = genModule('fedora/31/remi/x86_64', $dest, ['unit-php*rpm', 'php-*7.3*.rpm'], '7.3', 'x86_64', $deps, $template_php); $mod .= genModule('fedora/31/php74/x86_64', $dest, '*.rpm', '7.4', 'x86_64', $deps, $template_php); $mod .= genModule('fedora/31/php80/x86_64', $dest, '*.rpm', '8.0', 'x86_64', $deps, $template_php); $mod .= genDefaults('php', 'remi-7.3', ['remi-7.3', 'remi-7.4', 'remi-8.0']); $mod .= genModule('fedora/31/glpi93/x86_64', $dest, '*.rpm', '9.3', 'x86_64', $deps, $template_glpi); $mod .= genModule('fedora/31/glpi94/x86_64', $dest, '*.rpm', '9.4', 'x86_64', $deps, $template_glpi); $mod .= genDefaults('glpi', '9.4', ['9.3', '9.4']); createRepo($dest, $mod); } if (in_array('f31', $_SERVER['argv']) || in_array('test', $_SERVER['argv'])) { $dest = 'fedora/31/modular-test/x86_64'; echo "Populate $dest\n"; cleanup($dest); $deps = ['platform' => 'f31']; $mod = genModule('fedora/31/test/x86_64', $dest, ['unit-php*rpm', 'php-*7.3*.rpm'], '7.3', 'x86_64', $deps, $template_php); $mod .= genModule('fedora/31/test74/x86_64', $dest, '*.rpm', '7.4', 'x86_64', $deps, $template_php); $mod .= genModule('fedora/31/test80/x86_64', $dest, '*.rpm', '8.0', 'x86_64', $deps, $template_php); createRepo($dest, $mod); } */ if (count($_SERVER['argv']) < 2 || in_array('f32', $_SERVER['argv'])) { $dest = 'fedora/32/modular/x86_64'; echo "Populate $dest\n"; cleanup($dest); $deps = ['platform' => 'f32']; $mod = genModule('fedora/32/remi/x86_64', $dest, ['unit-php*rpm', 'php-*7.4*.rpm'], '7.4', 'x86_64', $deps, $template_php); $mod .= genModule('fedora/32/php80/x86_64', $dest, '*.rpm', '8.0', 'x86_64', $deps, $template_php); $mod .= genDefaults('php', 'remi-7.4', ['remi-7.4', 'remi-8.0']); createRepo($dest, $mod); } if (in_array('f32', $_SERVER['argv']) || in_array('test', $_SERVER['argv'])) { $dest = 'fedora/32/modular-test/x86_64'; echo "Populate $dest\n"; cleanup($dest); $deps = ['platform' => 'f32']; $mod = genModule('fedora/32/test/x86_64', $dest, ['unit-php*rpm', 'php-*7.4*.rpm'], '7.4', 'x86_64', $deps, $template_php); $mod .= genModule('fedora/32/test80/x86_64', $dest, '*.rpm', '8.0', 'x86_64', $deps, $template_php); createRepo($dest, $mod); } if (count($_SERVER['argv']) < 2 || in_array('f33', $_SERVER['argv'])) { $dest = 'fedora/33/modular/x86_64'; echo "Populate $dest\n"; cleanup($dest); $deps = ['platform' => 'f33']; $mod = genModule('fedora/33/remi/x86_64', $dest, ['unit-php*rpm', 'php-*7.4*.rpm'], '7.4', 'x86_64', $deps, $template_php); $mod .= genModule('fedora/33/php80/x86_64', $dest, '*.rpm', '8.0', 'x86_64', $deps, $template_php); $mod .= genDefaults('php', 'remi-7.4', ['remi-7.4', 'remi-8.0']); createRepo($dest, $mod); } if (in_array('f33', $_SERVER['argv']) || in_array('test', $_SERVER['argv'])) { $dest = 'fedora/33/modular-test/x86_64'; echo "Populate $dest\n"; cleanup($dest); $deps = ['platform' => 'f33']; $mod = genModule('fedora/33/test/x86_64', $dest, ['unit-php*rpm', 'php-*7.4*.rpm'], '7.4', 'x86_64', $deps, $template_php); $mod .= genModule('fedora/33/test80/x86_64', $dest, '*.rpm', '8.0', 'x86_64', $deps, $template_php); createRepo($dest, $mod); } if (count($_SERVER['argv']) < 2 || in_array('f34', $_SERVER['argv'])) { $dest = 'fedora/34/modular/x86_64'; echo "Populate $dest\n"; cleanup($dest); $deps = ['platform' => 'f34']; $mod = genModule('fedora/34/remi/x86_64', $dest, ['unit-php*rpm', 'php-*7.4*.rpm'], '7.4', 'x86_64', $deps, $template_php); $mod .= genModule('fedora/34/php80/x86_64', $dest, '*.rpm', '8.0', 'x86_64', $deps, $template_php); $mod .= genDefaults('php', 'remi-7.4', ['remi-7.4', 'remi-8.0']); createRepo($dest, $mod); } if (in_array('f34', $_SERVER['argv']) || in_array('test', $_SERVER['argv'])) { $dest = 'fedora/34/modular-test/x86_64'; echo "Populate $dest\n"; cleanup($dest); $deps = ['platform' => 'f34']; $mod = genModule('fedora/34/test/x86_64', $dest, ['unit-php*rpm', 'php-*7.4*.rpm'], '7.4', 'x86_64', $deps, $template_php); $mod .= genModule('fedora/34/test80/x86_64', $dest, '*.rpm', '8.0', 'x86_64', $deps, $template_php); createRepo($dest, $mod); } if (in_array('el8', $_SERVER['argv']) || in_array('test', $_SERVER['argv'])) { $dest = 'enterprise/8/modular-test/x86_64'; echo "Populate $dest\n"; cleanup($dest); $deps = ['platform' => 'el8']; $mod = genModule('enterprise/8/test72/x86_64', $dest, '*.rpm', '7.2', 'x86_64', $deps, $template_php); $mod .= genModule('enterprise/8/test73/x86_64', $dest, '*.rpm', '7.3', 'x86_64', $deps, $template_php); $mod .= genModule('enterprise/8/test74/x86_64', $dest, '*.rpm', '7.4', 'x86_64', $deps, $template_php); $mod .= genModule('enterprise/8/test80/x86_64', $dest, '*.rpm', '8.0', 'x86_64', $deps, $template_php); createRepo($dest, $mod); } if (count($_SERVER['argv']) < 2 || in_array('el8', $_SERVER['argv'])) { $dest = 'enterprise/8/modular/x86_64'; echo "Populate $dest\n"; cleanup($dest); $deps = ['platform' => 'el8']; $mod = genModule('enterprise/8/php72/x86_64', $dest, '*.rpm', '7.2', 'x86_64', $deps, $template_php); $mod .= genModule('enterprise/8/php73/x86_64', $dest, '*.rpm', '7.3', 'x86_64', $deps, $template_php); $mod .= genModule('enterprise/8/php74/x86_64', $dest, '*.rpm', '7.4', 'x86_64', $deps, $template_php); $mod .= genModule('enterprise/8/php80/x86_64', $dest, '*.rpm', '8.0', 'x86_64', $deps, $template_php); $mod .= genDefaults('php', '7.2', ['remi-7.2', 'remi-7.3', 'remi-7.4', 'remi-8.0']); $deps = ['platform' => 'el8']; $mod .= genModule('enterprise/8/redis50/x86_64', $dest, 'redis*.rpm', '5.0', 'x86_64', $deps, $template_redis); $mod .= genModule('enterprise/8/redis60/x86_64', $dest, 'redis*.rpm', '6.0', 'x86_64', $deps, $template_redis); $mod .= genModule('enterprise/8/redis62/x86_64', $dest, 'redis*.rpm', '6.2', 'x86_64', $deps, $template_redis); $mod .= genDefaults('redis', '5', ['remi-5.0', 'remi-6.0', 'remi-6.2']); $deps = ['platform' => 'el8', 'php' => '']; $mod .= genModule('enterprise/8/glpi93/x86_64', $dest, '*.rpm', '9.3', 'x86_64', $deps, $template_glpi); $mod .= genModule('enterprise/8/glpi94/x86_64', $dest, '*.rpm', '9.4', 'x86_64', $deps, $template_glpi); $mod .= genDefaults('glpi', '9.4', ['9.3', '9.4']); $deps = ['platform' => 'el8', 'php' => '']; $mod .= genModule('enterprise/8/composer1/x86_64', $dest, '*.rpm', '1', 'x86_64', $deps, $template_comp); $mod .= genModule('enterprise/8/composer2/x86_64', $dest, '*.rpm', '2', 'x86_64', $deps, $template_comp); $mod .= genDefaults('composer', '2', ['1', '2']); createRepo($dest, $mod); } if (count($_SERVER['argv']) > 1 && in_array('epel', $_SERVER['argv'])) { $dest = 'temp/epel-8-modular'; echo "Populate $dest\n"; cleanup($dest); $deps = ['platform' => 'el8', 'php' => '7.2']; $mod = genModule('temp/epel-8-php-7.2', $dest, '*.rpm', '7.2', 'x86_64', $deps, $template_phpextras); $deps = ['platform' => 'el8', 'php' => '7.3']; $mod .= genModule('temp/epel-8-php-7.3', $dest, '*.rpm', '7.3', 'x86_64', $deps, $template_phpextras); $deps = ['platform' => 'el8', 'php' => '7.4']; $mod .= genModule('temp/epel-8-php-7.4', $dest, '*.rpm', '7.4', 'x86_64', $deps, $template_phpextras); $mod .= genDefaults('php-extras', '7.2', ['7.2', '7.3', '7.4']); createRepo($dest, $mod); } if (in_array('el7', $_SERVER['argv']) || in_array('test', $_SERVER['argv'])) { $dest = 'enterprise/7/modular-test/x86_64'; echo "Populate $dest\n"; cleanup($dest); $deps = ['platform' => 'el7']; $mod = genModule('enterprise/7/test71/x86_64', $dest, '*.rpm', '7.1', 'x86_64', $deps, $template_php); $mod = genModule('enterprise/7/test72/x86_64', $dest, '*.rpm', '7.2', 'x86_64', $deps, $template_php); $mod .= genModule('enterprise/7/test73/x86_64', $dest, '*.rpm', '7.3', 'x86_64', $deps, $template_php); $mod .= genModule('enterprise/7/test74/x86_64', $dest, '*.rpm', '7.4', 'x86_64', $deps, $template_php); $mod .= genModule('enterprise/7/test80/x86_64', $dest, '*.rpm', '8.0', 'x86_64', $deps, $template_php); createRepo($dest, $mod); } if (count($_SERVER['argv']) < 2 || in_array('el7', $_SERVER['argv'])) { $dest = 'enterprise/7/modular/x86_64'; echo "Populate $dest\n"; cleanup($dest); $deps = ['platform' => 'el7']; $mod = genModule('enterprise/7/php71/x86_64', $dest, '*.rpm', '7.1', 'x86_64', $deps, $template_php); $mod .= genModule('enterprise/7/php72/x86_64', $dest, '*.rpm', '7.2', 'x86_64', $deps, $template_php); $mod .= genModule('enterprise/7/php73/x86_64', $dest, '*.rpm', '7.3', 'x86_64', $deps, $template_php); $mod .= genModule('enterprise/7/php74/x86_64', $dest, '*.rpm', '7.4', 'x86_64', $deps, $template_php); $mod .= genModule('enterprise/7/php80/x86_64', $dest, '*.rpm', '8.0', 'x86_64', $deps, $template_php); $mod .= genDefaults('php', '7.2', ['remi-7.1', 'remi-7.2', 'remi-7.3', 'remi-7.4']); $mod .= genModule('enterprise/7/remi/x86_64', $dest, 'redis*5.0*.rpm', '5.0', 'x86_64', $deps, $template_redis); $mod .= genModule('enterprise/7/remi/x86_64', $dest, 'redis*6.0*.rpm', '6.0', 'x86_64', $deps, $template_redis); $mod .= genModule('enterprise/7/remi/x86_64', $dest, 'redis*6.2*.rpm', '6.0', 'x86_64', $deps, $template_redis); $mod .= genDefaults('redis', '5', ['remi-5.0', 'remi-6.0']); $deps = ['platform' => 'el7', 'php' => '']; $mod .= genModule('enterprise/7/glpi92/x86_64', $dest, '*.rpm', '9.2', 'x86_64', $deps, $template_glpi); $mod .= genModule('enterprise/7/glpi93/x86_64', $dest, '*.rpm', '9.3', 'x86_64', $deps, $template_glpi); $mod .= genModule('enterprise/7/glpi94/x86_64', $dest, '*.rpm', '9.4', 'x86_64', $deps, $template_glpi); $mod .= genDefaults('glpi', '9.4', ['9.2', '9.3', '9.4']); createRepo($dest, $mod); } echo "Done\n";