]> git.pld-linux.org Git - packages/rpm-build-tools.git/blobdiff - pearize.sh
don't override GETURI when using wget
[packages/rpm-build-tools.git] / pearize.sh
old mode 100644 (file)
new mode 100755 (executable)
index 157c1e4..55363d6
@@ -6,6 +6,11 @@
 #
 # 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)
+# So far there are 3 packages with epoch > 0:
+# $ grep ^Epoch:.* php-pear-*.spec | grep -v 'Epoch:.*0'
+# php-pear-MDB2.spec:Epoch:               1
+# php-pear-MDB.spec:Epoch:                1
+# php-pear-PEAR.spec:Epoch:               1
 #
 # To create completely new PEAR package spec, follow something like this:
 # $ pear download RDF-alpha
@@ -23,6 +28,9 @@
 #
 # Send blames and beer\b\b\b\bideas to glen@pld-linux.org
 
+PROGRAM=${0##*/}
+APPDIR=$(d=$0; [ -L "$d" ] && d=$(readlink -f "$d"); dirname "$d")
+
 set -e
 spec="$1"
 if [ -z "$spec" ]; then
@@ -53,7 +61,7 @@ if [ -z "$tarball" ]; then
 fi
 
 if [ ! -f $tarball ]; then
-       ./builder -g "$spec"
+       $APPDIR/builder -g "$spec"
 fi
 
 stmp=$(mktemp "${TMPDIR:-/tmp}/fragXXXXXX")
@@ -74,21 +82,8 @@ template=.$template~
 add_epoch() {
        local dep="$@"
        local pkg="$1"
-       local qual="$2"
        local ver="$3"
 
-       if [ "$pkg" == "php-pear-PEAR" ]; then
-               pkg="php-pear-PEAR-core"
-       fi
-
-       case "$pkg" in
-       php-pear-PEAR-core)
-               ver=$(echo "$ver" | sed -e 's,1.4.0b1,1.4.0-0.b1,')
-               ;;
-       esac
-
-       dep="$pkg $qual $ver"
-
        # already have epoch
        if [[ "$ver" = *:* ]]; then
                echo "$dep"
@@ -109,8 +104,12 @@ preamble=$(mktemp "${TMPDIR:-/tmp}/fragXXXXXX")
 sed -ne '/^Name:/,/^BuildRoot/p' $spec > $preamble
 
 # create backup
-bak=$(cp -fbv $spec $spec | awk '{print $NF}' | tr -d "['\`]" )
+bak=$(LC_ALL=C cp -fbv $spec $spec | awk '{print $NF}' | tr -d "['\`]" )
 
+# ensure rpm-build-macros is present
+if ! grep -q "^BuildRequires:.*rpmbuild(macros)" $preamble; then
+       sed -i -e "/^BuildRequires:.*rpm-php-pearprov/aBuildRequires:\trpmbuild(macros) >= 1.300" $spec
+fi
 # parse requires
 requires=$(grep '^BuildRequires:' $template || :)
 if [ -n "$requires" ]; then
@@ -127,6 +126,7 @@ if [ -n "$requires" ]; then
        echo "$requires" | while read tag dep; do
                dep=$(add_epoch $dep)
                if ! grep -q "^Requires:.*$dep" $preamble; then
+                       dep=$(echo "$dep" | sed -e 's,php-pear-PEAR\b,php-pear-PEAR-core,')
                        sed -i -e "/^BuildRoot/iRequires:\t$dep" $spec
                fi
        done
@@ -147,10 +147,23 @@ fi
 optional=$(grep '^Suggests:' $template || :)
 if [ -n "$optional" ]; then
        echo "$optional" | while read tag dep; do
+               dep=$(add_epoch $dep)
+               if ! grep -q "^Suggests:.*$dep" $preamble; then
+                       sed -i -e "/^BuildRoot/iSuggests:\t$dep" $spec
+               fi
+
                for req in $dep; do
-                       # strip single quotes that default template includes in @optional@ expand
-                       # TODO: remove in php-pear-PEAR_Command_Packaging package
-                       req=${req#\'} req=${req%\'}
+                       case "$req" in
+                       php-pear-*)
+                               # convert pear package name to file pattern
+                               req=$(echo "$req" | sed -e 's,^php-pear-,pear(,;y,_,/,;s,$,.*),')
+                               ;;
+                       *)
+                               # process only php-pear-* packages
+                               continue
+                               ;;
+                       esac
+
                        m=$(grep "^%define.*_noautoreq" $spec || :)
                        if [ -z "$m" ]; then
                                sed -i -e "/^BuildRoot:/{
@@ -218,10 +231,15 @@ fi
 
 # parse state
 state=$(awk '/^State:/{print $2}' $template)
-sed -i -e "/^%define.*_status/{
-       /%define.*_status.*$state/!s/.*/%define\t\t_status\t\t$state/
+sed -i -e "/^%define.*_\?status/{
+       s/%define[[:space:]]*_status.*/%define\t\t_status\t\t$state/
+       s/%define[[:space:]]*status.*/%define\t\tstatus\t\t$state/
 }" $spec
 
+# parse license
+#license=$(awk '/^License:/{print $2}' $template)
+#sed -i -e "s/^License:.*/License:\t$license/" $spec
+
 rm -f $preamble
 
 diff=$(mktemp "${TMPDIR:-/tmp}/fragXXXXXX")
@@ -231,4 +249,3 @@ if ! diff -u $bak $spec > $diff; then
 else
        echo "$spec: No diffs"
 fi
-#exit 1
This page took 0.035221 seconds and 4 git commands to generate.