From 85548a46d69b8fa73636edaeb664a40081bda840 Mon Sep 17 00:00:00 2001 From: Benjamin Schieder Date: Thu, 13 Jul 2006 14:49:11 +0000 Subject: [PATCH] Benjamin Schieder: Create-PkgUpdPatch: support forked packages BUGFIX [2006071009492615524] (https://www.rocklinux.net/submaster) git-svn-id: http://www.rocklinux.org/svn/rock-linux/trunk@7724 c5f82cb5-29bc-0310-9cd0-bff59a50e3bc --- scripts/Create-PkgUpdPatch | 57 ++++++++++++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 8 deletions(-) diff --git a/scripts/Create-PkgUpdPatch b/scripts/Create-PkgUpdPatch index 4259685e1..deeed527b 100755 --- a/scripts/Create-PkgUpdPatch +++ b/scripts/Create-PkgUpdPatch @@ -44,23 +44,64 @@ if [ "$*" ] ; then exit $? fi +base=. +. scripts/functions + tr ', \t' '\n\n\n' | tr -s '\n' | while read x ; do pkg="" ; pkgdir="" [ -z "$x" ] && continue - echo "[ $x ]" >&2 - for y in package/*/* ; do - z=${y##*/} - if [[ "$x" == "$z"[-_]* ]] ; then - pkg="$z" ; pkgdir="$y" + if [ "${x//=/}" != "${x}" ] ; then + pkg="${x%%=*}" + xpkg="${x#*=}" + newver="${xpkg##*-}" + xpkg="${xpkg%-*}" + else + pkg="${x%-*}" + xpkg="${pkg}" + newver="${x##*-}" + fi + + for var in pkg xpkg newver ; do + if [ -z "$( eval echo \$${var} )" ] ; then + echo "ERROR: Please specify package and version in this format:" >&2 + echo "ERROR: package-version package=xpackage-version" >&2 + echo "ERROR: You entered: $x" >&2 + continue 2 fi done - if [ "$pkg" ] ; then - oldver="`egrep "^\[(V|VER|VERSION)\] " $pkgdir/$pkg.desc | + + echo "[ ${pkg}=${xpkg}-${newver} ]" >&2 + for dir in package/*/* ; do + if [ "${dir##*/}" == "$pkg" ] ; then + if [ -n "${pkgdir}" ] ; then + echo "ERROR: Package in multiple repositories: $pkg" >&2 + echo "ERROR: $( ls -d package/*/${pkg} )" >&2 + continue 2 + fi + pkgdir="$dir" + continue + fi + done + if [ -n "$pkgdir" ] ; then + unset ${!desc_*} descparser_ign_xpkg + if [ "${pkg}" == "${xpkg}" ] ; then + oldver="`egrep "^\[(V|VER|VERSION)\] " $pkgdir/$pkg.desc | tr '\t' ' ' | tr -s ' ' | cut -f2 -d' '`" - newver=${x/$pkg?/} ; tmpfile=`mktemp` ; tmpfile2=`mktemp` + if [ $( wc -l <<< "${oldver}" ) -gt 1 ] ; then + echo "ERROR: Package ${pkg} is a forked package!" >&2 + echo "ERROR: Use $0 package=xpackage-version" >&2 + continue + fi + else + parse_desc ${pkgdir}/${pkg}.desc + oldver=${desc_V##* +} + # this is not a typo! desc_V contains all [V] tags newline separated + fi + tmpfile=`mktemp` ; tmpfile2=`mktemp` echo "Upgrade Patch for $pkg ($pkgdir): $oldver -> $newver" sed "s/${oldver//./\\.}/$newver/g" < $pkgdir/$pkg.desc | \ sed "s/^\[\(D\|DOWN\|DOWNLOAD\)\] [0-9]\+/[\1] 0/" > $tmpfile