--- builds_bin/locale-patch 2009/03/05 21:41:33 1.1 +++ builds_bin/locale-patch 2010/03/04 18:16:04 1.2 @@ -1,25 +1,45 @@ #!/bin/bash -for newpatch in /var/www/html/patches/*.patch -do - [ ! -s "$newpatch" ] && continue - pkg=$(basename $newpatch | sed 's,-[0-9.]\+-locale-[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}.patch,,') - chglog=$(basename $newpatch | sed "s,$pkg-[0-9.]\+-locale-,locale ,;s,\.patch, patch,") - spec=$(ls /etc/pootle/cvs/sme*/$pkg/*7/*.spec) +export CVS_RSH=ssh + +rm -rf /var/lib/pootle/cvs/patch/* +cd /var/lib/pootle/cvs/patch - source=$(sed -n 's,^\(Source[0-9]*:\).*,\1,ip' $spec | tail -1) - patch=$(sed -n 's,^\(Patch[0-9]*:\).*,\1,ip' $spec | tail -1) - [ -z "$patch" ] && pnum="1" || pnum=$(echo $patch | perl -pe 's,^Patch([0-9]*):,$1+1,ie') - [ -z "$patch" ] && insert2="%setup" || insert2=$(echo $patch | perl -pe 's,^(Patch[0-9]*):,"%".lc($1),ie') - insert1=${patch:=$source} +#newpatch=/var/www/html/patches/smeserver-sme7admin-1.1.1-locale-2009-03-05.patch +ls /var/www/html/patches/*/*.patch | cut -d/ --output-delimiter " " -f6,7 | while read ver newpatch +do + [ ! -s "/var/www/html/patches/$ver/$newpatch" ] && continue + pkg=$(echo $newpatch | sed 's,-[0-9.]\+-locale-[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}.patch,,') + chglog=$(echo $newpatch | sed "s,$pkg-[0-9.]\+-locale-,locale ,;s,\.patch, patch,") + + if [ ! -d "$pkg" ] + then + if echo $ver | grep -q contribs + then + cvs -Q -z3 -d:ext:smecontribs.cvs.sourceforge.net:/cvsroot/smecontribs co -P $pkg + else + cvs -Q -z3 -d:ext:smeserver.cvs.sourceforge.net:/cvsroot/smeserver co -P $pkg + fi + fi + spec=$(ls $pkg/$ver/*.spec 2> /dev/null) + if [ ! -z "$spec" ] + then + source=$(sed -n 's,^\(Source[0-9]*:\).*,\1,ip' $spec | tail -1) + patch=$(sed -n 's,^\(Patch[0-9]*:\).*,\1,ip' $spec | tail -1) + [ -z "$patch" ] && pnum="1" || pnum=$(echo $patch | perl -pe 's,^Patch([0-9]*):,$1+1,ie') + [ -z "$patch" ] && insert2="%setup" || insert2=$(echo $patch | perl -pe 's,^(Patch[0-9]*):,"%".lc($1),ie') + insert1=${patch:=$source} - 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 - verrel=$(rpm -q -D 'dist .sme' --qf '%{VERSION}-%{RELEASE}\n' --specfile $spec | head -1) - sed -i "/^$insert1/aPatch$pnum: $(basename $newpatch)" $spec - sed -i "/^$insert2\b/a%patch$pnum -p1" $spec - sed -i "/^%changelog/a* $(date +'%a %b %d %G') SME Translation Server $verrel\n- apply $chglog\n" $spec - cp $newpatch $(dirname $spec) - cd $(dirname $spec) - cvs add $(basename $newpatch) + 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 + verrel=$(rpm -q -D 'dist .sme' --qf '%{VERSION}-%{RELEASE}\n' --specfile $spec | head -1) + sed -i "/^$insert1/aPatch$pnum: $(basename $newpatch)" $spec + sed -i "/^$insert2\b/a%patch$pnum -p1" $spec + sed -i "/^%changelog/a* $(date +'%a %b %d %G') SME Translation Server $verrel\n- apply $chglog\n" $spec + cp /var/www/html/patches/$ver/$newpatch $(dirname $spec) + pushd $(dirname $spec) > /dev/null + cvs -Q add $(basename $newpatch) + [ "$1" == "commit" ] && make commit tag > /dev/null + popd > /dev/null + fi done