]> git.pld-linux.org Git - packages/rpm-build-tools.git/blame - pearize.sh
- stage2: this script will not adjust Requires/Conflicts lines of packages
[packages/rpm-build-tools.git] / pearize.sh
CommitLineData
70f6b6a6 1#!/bin/sh
dd7e9d0e
ER
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 :)
6#
7# needs pear makerpm command.
70f6b6a6
ER
8# requires tarball to exist in ../SOURCES.
9#
dd7e9d0e
ER
10# bugs: will not find tarball for packages with 'beta' and 'alpha' in version.
11#
12# todo: adjust similiarily noautoreqdeps
13#
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
16
70f6b6a6
ER
17set -e
18spec="$1"
dd7e9d0e
ER
19if [ -z "$spec" ]; then
20 echo >&2 "Usage: $0 SPECFILE"
21 exit 0
22fi
23if [ ! -f "$spec" ]; then
24 echo >&2 "$spec doesn't exist?"
25 exit 1
26fi
ae02a056 27echo "Processing $spec"
461a16ad 28tarball=$(rpm -q --qf '../SOURCES/%{name}-%{version}.tgz\n' --specfile "$spec" | head -n 1 | sed -e 's,php-pear-,,')
2bf93f18 29template=$(rpm -q --qf '%{name}-%{version}.spec\n' --specfile "$spec" | head -n 1)
70f6b6a6 30
dd7e9d0e 31pear makerpm --spec-template=template.spec $tarball
5f89133e 32ls -l $spec $template
19133cbd 33
dd7e9d0e
ER
34requires=$(grep '^Requires:' $template || :)
35conflicts=$(grep '^Conflicts:' $template || :)
36preamble=$(mktemp "${TMPDIR:-/tmp}/fragXXXXXX")
37# take just main package preamble, preamble of tests (and other) subpackage(s) just confuses things.
38sed -ne '/^Name:/,/^BuildRoot/p' $spec > $preamble
39
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.
42add_epoch() {
43 local dep="$@"
44 local pkg="$1"
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:,"
49 else
50 echo "$dep"
51 fi
19133cbd
ER
52}
53
dd7e9d0e
ER
54# create backup
55bak=$(cp -fbv $spec $spec | awk '{print $NF}' | tr -d "['\`]" )
19133cbd 56
dd7e9d0e
ER
57if [ -n "$requires" ]; then
58 echo "$requires" | while read tag dep; do
59 dep=$(add_epoch $dep)
60 if ! grep -q "^Requires:.*$dep" $preamble; then
61 sed -i -e "/^BuildRoot/iRequires:\t$dep" $spec
62 fi
63 done
c9f81079
ER
64fi
65
dd7e9d0e
ER
66if [ -n "$conflicts" ]; then
67 echo "$conflicts" | while read tag reqc; do
68 dep=$(add_epoch $dep)
69 if ! grep -q "^Conflicts:.*$req" $preamble; then
70 sed -i -e "/^BuildRoot/iConflicts:\t$dep" $spec
71 fi
72 done
05779902
ER
73fi
74
dd7e9d0e 75rm -f $preamble
4d240bd1 76
dd7e9d0e
ER
77set -e
78diff=$(mktemp "${TMPDIR:-/tmp}/fragXXXXXX")
79if ! diff -u $bak $spec > $diff; then
80 vim -o $spec $diff
81 rm -f $diff
82else
83 echo "$spec: No diffs"
4d240bd1 84fi
This page took 0.059102 seconds and 4 git commands to generate.