1 |
#!/bin/bash |
2 |
|
3 |
for newpatch in /var/www/html/patches/*.patch |
4 |
do |
5 |
[ ! -s "$newpatch" ] && continue |
6 |
pkg=$(basename $newpatch | sed 's,-[0-9.]\+-locale-[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}.patch,,') |
7 |
chglog=$(basename $newpatch | sed "s,$pkg-[0-9.]\+-locale-,locale ,;s,\.patch, patch,") |
8 |
spec=$(ls /etc/pootle/cvs/sme*/$pkg/*7/*.spec) |
9 |
|
10 |
source=$(sed -n 's,^\(Source[0-9]*:\).*,\1,ip' $spec | tail -1) |
11 |
patch=$(sed -n 's,^\(Patch[0-9]*:\).*,\1,ip' $spec | tail -1) |
12 |
[ -z "$patch" ] && pnum="1" || pnum=$(echo $patch | perl -pe 's,^Patch([0-9]*):,$1+1,ie') |
13 |
[ -z "$patch" ] && insert2="%setup" || insert2=$(echo $patch | perl -pe 's,^(Patch[0-9]*):,"%".lc($1),ie') |
14 |
insert1=${patch:=$source} |
15 |
|
16 |
perl -i -pe 's,^(%define\s+release\s+)([0-9]+)\s*,"$1".($2+1)."\n",ie;s,^(Release:\s+)([0-9]+)(%{\?dist})\s*,"$1".($2+1)."$3\n",ie;' $spec |
17 |
verrel=$(rpm -q -D 'dist .sme' --qf '%{VERSION}-%{RELEASE}\n' --specfile $spec | head -1) |
18 |
sed -i "/^$insert1/aPatch$pnum: $(basename $newpatch)" $spec |
19 |
sed -i "/^$insert2\b/a%patch$pnum -p1" $spec |
20 |
sed -i "/^%changelog/a* $(date +'%a %b %d %G') SME Translation Server <translations@contribs.org> $verrel\n- apply $chglog\n" $spec |
21 |
cp $newpatch $(dirname $spec) |
22 |
cd $(dirname $spec) |
23 |
cvs add $(basename $newpatch) |
24 |
done |
25 |
|