]> git.pld-linux.org Git - packages/rpm-build-tools.git/blobdiff - pearize.sh
- egrep is deprecated
[packages/rpm-build-tools.git] / pearize.sh
index 1924b9cf4649eea93e6444ca81696278933ce230..12f8030609c3c82436f422db476ab916751876c9 100644 (file)
@@ -4,11 +4,18 @@
 # it is still better than nothing. if somebody wishes to add sorting in this
 # script. i'd be just glad :)
 #
-# needs 'pear' for 'pear makerpm' command, ./builder for fetching sources.
-# You should have all PEAR packages installed to get best results.
+# needs 'pear' for 'pear make-rpm-spec' command, ./builder for fetching sources.
+# You should have all PEAR packages installed to get best results (needed for epoch autodetection)
 #
-# todo: adjust similiarily noautoreqdeps
-# bugs: the beta portions in version deps could be wrong (php-4.3.0b1 and alike)
+# To create completely new PEAR package spec, follow something like this:
+# $ pear download RDF-alpha
+# File RDF-0.1.0alpha1.tgz downloaded
+# $ pear make-rpm-spec RDF-0.1.0alpha1.tgz
+# Wrote RPM spec file php-pear-RDF.spec
+# $
+#
+# TODO: adjust similiarily noautoreqdeps
+# BUGS: the beta portions in version deps could be wrong (php-4.3.0b1 and alike)
 # see php-pear-DBA_Relational.spec
 # Something strange: Requires: php-common < 4:3:5.1
 #
@@ -26,6 +33,11 @@ if [ ! -f "$spec" ]; then
        echo >&2 "$spec doesn't exist?"
        exit 1
 fi
+
+if [[ "$(rpm -q php-pear-PEAR_Command_Packaging)" == *is?not* ]]; then
+       echo >&2 "Please install php-pear-PEAR_Command_Packaging"
+       exit 1
+fi
 echo "Processing $spec"
 
 getsource() {
@@ -35,6 +47,10 @@ getsource() {
 }
 
 tarball=$(getsource $spec 0)
+if [ -z "$tarball" ]; then
+       echo >&2 "Spec is missing Source0!"
+       exit 1
+fi
 
 if [ ! -f $tarball ]; then
        ./builder -g "$spec"
@@ -49,7 +65,7 @@ Optional: @optional@
 License: @release_license@
 State: @release_state@
 EOF
-pear makerpm --spec-template=$stmp --rpm-pkgname=pearize $tarball
+pear make-rpm-spec --spec-template=$stmp --output=pearize.spec $tarball
 template=pearize.spec
 rm -f $stmp
 
@@ -112,14 +128,27 @@ optional=$(grep '^Optional:' $template || :)
 if [ -n "$optional" ]; then
        echo "$optional" | while read tag dep; do
                for req in $dep; do
-                       m=$(grep "^%define.*_noautoreq" $spec | grep -o "$req" || :)
+                       # strip single quotes that default template includes in @optional@ expand
+                       # TODO: remove in php-pear-PEAR_Command_Packaging package
+                       req=${req#\'} req=${req%\'}
+                       m=$(grep "^%define.*_noautoreq" $spec || :)
                        if [ -z "$m" ]; then
-                               sed -i -e "/^%define.*_noautoreq/s,$, $req," $spec
+                               sed -i -e "/^BuildRoot:/{
+                                       a
+                                       a# exclude optional dependencies
+                                       a%define\       \       _noautoreq\     $req
+                               }
+                               " $spec
+                       else
+                               m=$(echo "$m" | grep -o "$req" || :)
+                               if [ -z "$m" ]; then
+                                       sed -i -e "/^%define.*_noautoreq/s,$, $req," $spec
+                               fi
                        fi
                done
        done
 fi
-has_opt=$(egrep -c '^Optional-(pkg|ext):' $template || :)
+has_opt=$(grep -Ec '^Optional-(pkg|ext):' $template || :)
 if [ "$has_opt" -gt 0 ]; then
        if ! grep -q '%{_docdir}/.*/optional-packages.txt' $spec; then
                sed -i -e '
This page took 0.028743 seconds and 4 git commands to generate.