#
# 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
#
# 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
fi
if [ ! -f $tarball ]; then
- ./builder -g "$spec"
+ $APPDIR/builder -g "$spec"
fi
stmp=$(mktemp "${TMPDIR:-/tmp}/fragXXXXXX")
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"
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
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
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
case "$req" in
php-pear-*)
# convert pear package name to file pattern
- req=$(echo "$req" | sed -e 's,^php-pear-,pear(,;y,-,/,;s,$,.*),')
+ req=$(echo "$req" | sed -e 's,^php-pear-,pear(,;y,_,/,;s,$,.*),')
;;
*)
# process only php-pear-* packages
# 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")
else
echo "$spec: No diffs"
fi
-#exit 1