summaryrefslogtreecommitdiffstats
path: root/pearup
blob: 556bd2a36679195db71699943791e04a40e4e548 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/sh

vendor="Remi Collet <remi@remirepo.net>"
rpmdate=$(LC_ALL="C" date +"%a %b %d %Y")
rpmdate=${rpmdate/ 0/  }

if [ $# -lt 2 ]; then
    echo "usage $0 old new [ spec ] [ oldsuffix newsuffix ]"
    exit 1
fi
if [ -n "$3" ]; then
  name=$3
else
  name=$(basename $PWD).spec
fi

if [ ! -f $3 ]; then
	echo "cannot read '$3' spec file"
    echo "usage $0 old new [ spec ] [ oldsuffix newsuffix ]"
	exit 1
fi

oldver="$1"
newver="$2"
rpmver="$2"

if [ "x$4" = "xGA" ]; then
	sed -e '/global upstream_prever/s/^#global/%global/' \
	    -i *spec
elif [ -n "$4" ]; then
	oldver="$1$4"
fi

if [ "x$5" = "xGA" ]; then
	sed -e '/global upstream_prever/s/^%global/#global/' \
	    -i *spec
elif [ -n "$5" ]; then
	sed -e "/global upstream_prever/s/prever.*$/prever  $5/" \
	    -i *spec
	newver="$2$5"
	rpmver="$2~$5"
fi

if ! grep -q pecl_name $name; then
	sed -e '/^Release:/s/[0-9].*$/1%{?dist}/' \
	    -i *spec
else echo "Release inchangée"
fi
if ! grep -q "^Version:.*$2"  $name; then
	sed -e "/^Version:/s/$1/$2/" \
    	-e "/upstream_version/s/$1/$2/" \
	    -e "s/%changelog/%changelog\n* $rpmdate $vendor - $rpmver-1\n- update to $newver\n/" \
	    -e 's/\$RPM_BUILD_ROOT/%{buildroot}/' \
	    -i $name
else echo "Version déjà modifiée"
fi

spectool -g -S $name

tar xf *-$oldver.tgz package.xml && mv package.xml package-$oldver.xml
comp=$(tar xvf *-$oldver.tgz '*/composer.json')
if [ -n "$comp" ]; then
  mv $comp composer-$oldver.json
fi
tar xf *-$newver.tgz package.xml && mv package.xml package-$newver.xml
comp=$(tar xvf *-$newver.tgz '*/composer.json')
if [ -n "$comp" ]; then
  mv $comp composer-$newver.json
fi

colordiff -u  package-$oldver.xml   package-$newver.xml
[ -f composer-$oldver.json -a -f composer-$newver.json ] && \
  colordiff -u composer-$oldver.json composer-$newver.json