diff --git a/makesrc.sh b/makesrc.sh new file mode 100755 index 0000000000000000000000000000000000000000..d2a6cbe9f377724027cbac5272f1cc9a258f32c5 --- /dev/null +++ b/makesrc.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +NAME=$(sed -n '/^Name:/{s/.* //;p}' *.spec) +OWNER=$(sed -n '/^%global gh_owner/{s/.* //;p}' $NAME.spec) +PROJECT=$(sed -n '/^%global gh_project/{s/.* //;p}' $NAME.spec) +VERSION=$(sed -n '/^%global upstream_version/{s/.* //;p}' $NAME.spec) +DATE=$(sed -n '/^%global gh_date/{s/.* //;p}' $NAME.spec) +PREVER=$(sed -n '/^%global upstream_prever/{s/.* //;p}' $NAME.spec) +COMMIT=$(sed -n '/^%global gh_commit/{s/.* //;p}' $NAME.spec) +SHORT=${COMMIT:0:7} + +if [ -f $NAME-$VERSION$PREVER-$SHORT.tgz -a "$1" != "-f" ]; then + echo skip $NAME-$VERSION$PREVER-$SHORT.tgz already here +else + echo -e "\nCreate git snapshot\nName=$NAME, Owner=$OWNER, Project=$PROJECT, Version=$VERSION$PREVER\n" + + echo "Cloning..." + git clone https://github.com/$OWNER/$PROJECT.git $PROJECT-$COMMIT + + echo "Getting commit..." + pushd $PROJECT-$COMMIT + git checkout $COMMIT || exit 1 + cp composer.json ../ + composer config platform.php 8.1.99 + rm composer.lock + composer install --no-interaction --no-progress --no-dev --optimize-autoloader + cp vendor/composer/installed.json ../ + + echo "Bash completion" + bin/pie completion bash > ../pie-bash-completion + popd + + echo "Archiving..." + tar czf $NAME-$VERSION$PREVER-$SHORT.tgz --exclude .git $PROJECT-$COMMIT + + echo "Cleaning..." + rm -rf $PROJECT-$COMMIT +fi +echo "Done." diff --git a/pie-1.2.1-8288fd6.tgz b/pie-1.2.1-8288fd6.tgz new file mode 100644 index 0000000000000000000000000000000000000000..4075ac77d4cd08694b2f1f3649924608a52d7608 Binary files /dev/null and b/pie-1.2.1-8288fd6.tgz differ diff --git a/pie-bash-completion b/pie-bash-completion new file mode 100644 index 0000000000000000000000000000000000000000..f189bdc3884121d26be4312598b2c67f452efa0f --- /dev/null +++ b/pie-bash-completion @@ -0,0 +1,94 @@ +# This file is part of the Symfony package. +# +# (c) Fabien Potencier +# +# For the full copyright and license information, please view +# https://symfony.com/doc/current/contributing/code/license.html + +_sf_pie() { + + # Use the default completion for shell redirect operators. + for w in '>' '>>' '&>' '<'; do + if [[ $w = "${COMP_WORDS[COMP_CWORD-1]}" ]]; then + compopt -o filenames + COMPREPLY=($(compgen -f -- "${COMP_WORDS[COMP_CWORD]}")) + return 0 + fi + done + + # Use newline as only separator to allow space in completion values + local IFS=$'\n' + local sf_cmd="${COMP_WORDS[0]}" + + # for an alias, get the real script behind it + sf_cmd_type=$(type -t $sf_cmd) + if [[ $sf_cmd_type == "alias" ]]; then + sf_cmd=$(alias $sf_cmd | sed -E "s/alias $sf_cmd='(.*)'/\1/") + elif [[ $sf_cmd_type == "file" ]]; then + sf_cmd=$(type -p $sf_cmd) + fi + + if [[ $sf_cmd_type != "function" && ! -x $sf_cmd ]]; then + return 1 + fi + + local cur prev words cword + _get_comp_words_by_ref -n := cur prev words cword + + local completecmd=("$sf_cmd" "_complete" "--no-interaction" "-sbash" "-c$cword" "-a1") + for w in ${words[@]}; do + w=$(printf -- '%b' "$w") + # remove quotes from typed values + quote="${w:0:1}" + if [ "$quote" == \' ]; then + w="${w%\'}" + w="${w#\'}" + elif [ "$quote" == \" ]; then + w="${w%\"}" + w="${w#\"}" + fi + # empty values are ignored + if [ ! -z "$w" ]; then + completecmd+=("-i$w") + fi + done + + local sfcomplete + if sfcomplete=$(${completecmd[@]} 2>&1); then + local quote suggestions + quote=${cur:0:1} + + # Use single quotes by default if suggestions contains backslash (FQCN) + if [ "$quote" == '' ] && [[ "$sfcomplete" =~ \\ ]]; then + quote=\' + fi + + if [ "$quote" == \' ]; then + # single quotes: no additional escaping (does not accept ' in values) + suggestions=$(for s in $sfcomplete; do printf $'%q%q%q\n' "$quote" "$s" "$quote"; done) + elif [ "$quote" == \" ]; then + # double quotes: double escaping for \ $ ` " + suggestions=$(for s in $sfcomplete; do + s=${s//\\/\\\\} + s=${s//\$/\\\$} + s=${s//\`/\\\`} + s=${s//\"/\\\"} + printf $'%q%q%q\n' "$quote" "$s" "$quote"; + done) + else + # no quotes: double escaping + suggestions=$(for s in $sfcomplete; do printf $'%q\n' $(printf '%q' "$s"); done) + fi + COMPREPLY=($(IFS=$'\n' compgen -W "$suggestions" -- $(printf -- "%q" "$cur"))) + __ltrim_colon_completions "$cur" + else + if [[ "$sfcomplete" != *"Command \"_complete\" is not defined."* ]]; then + >&2 echo + >&2 echo $sfcomplete + fi + + return 1 + fi +} + +complete -F _sf_pie pie diff --git a/pie-nocacert.patch b/pie-nocacert.patch new file mode 100644 index 0000000000000000000000000000000000000000..109074ad04f7c106505f2542c3a82adb7f15dd57 --- /dev/null +++ b/pie-nocacert.patch @@ -0,0 +1,12 @@ +diff -up ./vendor/composer/ca-bundle/src/CaBundle.php.rpm ./vendor/composer/ca-bundle/src/CaBundle.php +--- ./vendor/composer/ca-bundle/src/CaBundle.php.rpm 2024-09-25 09:49:53.000000000 +0200 ++++ ./vendor/composer/ca-bundle/src/CaBundle.php 2024-10-03 07:11:10.752092401 +0200 +@@ -122,7 +122,7 @@ class CaBundle + */ + public static function getBundledCaBundlePath() + { +- $caBundleFile = __DIR__.'/../res/cacert.pem'; ++ $caBundleFile = '/etc/pki/tls/certs/ca-bundle.crt'; // System CA, always + + // cURL does not understand 'phar://' paths + // see https://github.com/composer/ca-bundle/issues/10 diff --git a/pie-noxdg.patch b/pie-noxdg.patch new file mode 100644 index 0000000000000000000000000000000000000000..e0a2703e8f38c037db924819f5e6ac798a7e30cc --- /dev/null +++ b/pie-noxdg.patch @@ -0,0 +1,28 @@ +diff -up ./src/Platform.php.noxdg ./src/Platform.php +--- ./src/Platform.php.noxdg 2025-08-29 11:49:32.251927241 +0200 ++++ ./src/Platform.php 2025-08-29 11:50:18.737674445 +0200 +@@ -37,6 +37,10 @@ class Platform + + private static function useXdg(): bool + { ++ // As XDG is very partially implemented ++ // resulting in command/code in ~/.config ++ return false; ++ + foreach (array_keys($_SERVER) as $key) { + /** @psalm-suppress RedundantCastGivenDocblockType */ + if (strpos((string) $key, 'XDG_') === 0) { +diff -up ./vendor/composer/composer/src/Composer/Factory.php.noxdg ./vendor/composer/composer/src/Composer/Factory.php +--- ./vendor/composer/composer/src/Composer/Factory.php.noxdg 2025-08-21 11:29:39.000000000 +0200 ++++ ./vendor/composer/composer/src/Composer/Factory.php 2025-08-29 11:49:32.251858889 +0200 +@@ -707,6 +707,10 @@ class Factory + + private static function useXdg(): bool + { ++ // As XDG is very partially implemented ++ // resulting in command/code in ~/.config ++ return false; ++ + foreach (array_keys($_SERVER) as $key) { + if (strpos((string) $key, 'XDG_') === 0) { + return true; diff --git a/pie-rpm.patch b/pie-rpm.patch new file mode 100644 index 0000000000000000000000000000000000000000..8203644e52c26c8b7de3e4509ac362970118843c --- /dev/null +++ b/pie-rpm.patch @@ -0,0 +1,34 @@ +diff -up ./bin/pie.rpm ./bin/pie +--- ./bin/pie.rpm 2025-08-29 11:47:51.021892397 +0200 ++++ ./bin/pie 2025-08-29 11:48:46.211987817 +0200 +@@ -27,7 +27,7 @@ use Symfony\Component\EventDispatcher\Ev + error_reporting(error_reporting() & ~E_DEPRECATED); + + /** @psalm-suppress UnresolvableInclude */ +-include $_composer_autoload_path ?? __DIR__ . '/../vendor/autoload.php'; ++include $_composer_autoload_path ?? '/usr/share/pie/vendor/autoload.php'; + + $container = Container::factory(); + +diff -up ./src/Command/SelfUpdateCommand.php.rpm ./src/Command/SelfUpdateCommand.php +--- ./src/Command/SelfUpdateCommand.php.rpm 2025-08-29 11:47:45.000000000 +0200 ++++ ./src/Command/SelfUpdateCommand.php 2025-08-29 11:47:51.022050330 +0200 +@@ -65,6 +65,7 @@ final class SelfUpdateCommand extends Co + { + if (! PieVersion::isPharBuild()) { + $output->writeln('Aborting! You are not running a PHAR, cannot self-update.'); ++ $output->writeln('Update the pie RPM using the package manager (dnf).'); + + return Command::FAILURE; + } +diff -up ./src/Command/SelfVerifyCommand.php.rpm ./src/Command/SelfVerifyCommand.php +--- ./src/Command/SelfVerifyCommand.php.rpm 2025-08-29 11:47:45.000000000 +0200 ++++ ./src/Command/SelfVerifyCommand.php 2025-08-29 11:47:51.022201509 +0200 +@@ -51,6 +51,7 @@ final class SelfVerifyCommand extends Co + { + if (! PieVersion::isPharBuild()) { + $output->writeln('Aborting! You are not running a PHAR, cannot self-verify.'); ++ $output->writeln('Verify the pie RPM using the package manager (rpm).'); + + return Command::FAILURE; + } diff --git a/pie.spec b/pie.spec new file mode 100644 index 0000000000000000000000000000000000000000..e8348a8f14fb2564e3046e2dbdd586ca12ed5273 --- /dev/null +++ b/pie.spec @@ -0,0 +1,118 @@ +%undefine __brp_mangle_shebangs + +%global gh_commit 8288fd6ed643c9fa8422a7a9b49cecd60bf444be +%global gh_short %(c=%{gh_commit}; echo ${c:0:7}) +#global gh_date 20241003 +%global gh_branch main +%global gh_owner php +%global gh_project pie + +%global upstream_version 1.2.1 +#global upstream_prever RC1 + +Name: pie +Version: %{upstream_version} +Release: 1 +Summary: PHP Installer for Extensions + +# SPDX: pie is BSD-3-Clause, all dependencies are MIT +License: BSD-3-Clause AND MIT +URL: https://github.com/php/pie +# tarball generated by makesrc.sh +Source0: %{gh_project}-%{upstream_version}%{?upstream_prever}-%{gh_short}.tgz +Source1: %{name}-bash-completion +# Create a git snapshot with dependencies +Source9: makesrc.sh + +# Fix autoloader path +# add message about dnf in self-update command +Patch0: %{name}-rpm.patch +# Don't use XDG directories +Patch1: %{name}-noxdg.patch +# Don't use bundled cacert.pem +Patch2: %{name}-nocacert.patch + +BuildArch: noarch + +# From composer.json, "require": { +# "php": "8.1.*||8.2.*||8.3.*||8.4.*", +# "ext-zip": "*", +Requires: php(language) >= 8.1 +Requires: php-cli +Requires: php-zip +# System certificates +Requires: /etc/pki/tls/certs/ca-bundle.crt +# From phpcompatinfo +# Ignored: core, date, filter, hash, pcre, random, reflection, spl, standard +Requires: php-ctype +Requires: php-curl +Requires: php-dom +Requires: php-intl +Requires: php-json +Requires: php-mbstring +Requires: php-posix +Requires: php-phar +# PECL is now deprecated +# PIE is designed to replace it +Supplements: php-pear + + +%description +PIE (PHP Installer for Extensions). + +PIE can install an extension to any installed PHP version. + +A list of extensions that support PIE can be found on +https://packagist.org/extensions. + +Documentation: /usr/share/doc/pie/docs/usage.md + +%prep +%autosetup -p1 -n %{gh_project}-%{gh_commit} +find . \( -name \*.rpm -o -name \*noxdg -o -name \*nocacert \) -delete -print + +rm vendor/composer/ca-bundle/res/cacert.pem + +: Set version +sed -e 's/@pie_version@/%{upstream_version}%{?upstream_prever}/' -i bin/pie + + +%build +# Nothing + + +%install +: Bash auto-completion +install -Dpm 644 %{SOURCE1} %{buildroot}%{bash_completions_dir}/%{name} + +: Sources and dependencies +mkdir -p %{buildroot}%{_datadir}/%{name} +cp -pr src %{buildroot}%{_datadir}/%{name}/src +cp -pr vendor %{buildroot}%{_datadir}/%{name}/vendor + +: Command +install -Dpm 755 bin/%{name} %{buildroot}%{_bindir}/%{name} + +: Licenses +cd vendor +for lic in */*/LICENSE +do dir=$(dirname $lic) + own=$(dirname $dir) + prj=$(basename $dir) + ln -sf ../../pie/vendor/$own/$prj/LICENSE ../$own-$prj-LICENSE +done + + +%files +%license LICENSE.md +%license *LICENSE +%doc README.md +%doc docs +%doc composer.json +%{_bindir}/%{name} +%{_datadir}/%{name} +%{bash_completions_dir}/* + +%changelog +* Wed Sep 24 2025 Funda Wang - 1.2.1-1 +- init package