2 # updates php-pear .spec with Requires/Conflicts lines.
3 # the items are added randomly to the preamble, but once added their order is left intact.
4 # it is still better than nothing. if somebody wishes to add sorting in this
5 # script. i'd be just glad :)
7 # needs pear makerpm command.
8 # requires tarball to exist in ../SOURCES.
10 # bugs: will not find tarball for packages with 'beta' and 'alpha' in version.
12 # todo: adjust similiarily noautoreqdeps
14 # note: old version pf this script which was used to convert to new package format is in CVS branch MIGRATE
15 # send blames and beer
\b\b\b\bideas to glen@pld-linux.org
19 if [ -z "$spec" ]; then
20 echo >&2 "Usage: $0 SPECFILE"
23 if [ ! -f "$spec" ]; then
24 echo >&2 "$spec doesn't exist?"
27 echo "Processing $spec"
28 tarball=$(rpm -q --qf '../SOURCES/%{name}-%{version}.tgz\n' --specfile "$spec" | head -n 1 | sed -e 's,php-pear-,,')
29 template=$(rpm -q --qf '%{name}-%{version}.spec\n' --specfile "$spec" | head -n 1)
31 pear makerpm --spec-template=template.spec $tarball
34 requires=$(grep '^Requires:' $template || :)
35 conflicts=$(grep '^Conflicts:' $template || :)
36 preamble=$(mktemp "${TMPDIR:-/tmp}/fragXXXXXX")
37 # take just main package preamble, preamble of tests (and other) subpackage(s) just confuses things.
38 sed -ne '/^Name:/,/^BuildRoot/p' $spec > $preamble
40 # take as argument dependency in form NAME EQUALITY VERSION
41 # adds rpm epoch to VERSION if the package is installed and has epoch bigger than zero.
45 query=$(rpm -q --qf '%{epoch}\n' $pkg || :)
46 epoch=$(echo "$query" | grep -v 'installed' || :)
47 if [ "$epoch" ] && [ "$epoch" -gt 0 ]; then
48 echo "$dep" | sed -e "s, [<>=] ,&$epoch:,"
55 bak=$(cp -fbv $spec $spec | awk '{print $NF}' | tr -d "['\`]" )
57 if [ -n "$requires" ]; then
58 echo "$requires" | while read tag dep; do
60 if ! grep -q "^Requires:.*$dep" $preamble; then
61 sed -i -e "/^BuildRoot/iRequires:\t$dep" $spec
66 if [ -n "$conflicts" ]; then
67 echo "$conflicts" | while read tag reqc; do
69 if ! grep -q "^Conflicts:.*$req" $preamble; then
70 sed -i -e "/^BuildRoot/iConflicts:\t$dep" $spec
78 diff=$(mktemp "${TMPDIR:-/tmp}/fragXXXXXX")
79 if ! diff -u $bak $spec > $diff; then
83 echo "$spec: No diffs"