#!/bin/bash
|
|
#
|
|
# --- ROCK-COPYRIGHT-NOTE-BEGIN ---
|
|
#
|
|
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
|
|
# Please add additional copyright information _after_ the line containing
|
|
# the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
|
|
# the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
|
|
#
|
|
# ROCK Linux: rock-src/scripts/Create-PkgUpdPatch
|
|
# ROCK Linux is Copyright (C) 1998 - 2006 Clifford Wolf
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
# (at your option) any later version. A copy of the GNU General Public
|
|
# License can be found at Documentation/COPYING.
|
|
#
|
|
# Many people helped and are helping developing ROCK Linux. Please
|
|
# have a look at http://www.rocklinux.org/ and the Documentation/TEAM
|
|
# file for details.
|
|
#
|
|
# --- ROCK-COPYRIGHT-NOTE-END ---
|
|
|
|
if [ "$1" != "${1#-}" ] ; then
|
|
cat << EOT >&2
|
|
|
|
$0:
|
|
Automatically create package-update patches.
|
|
|
|
Input format (e.g.): automake-1.5, bind-9.2.0rc3, binutils-2.11.90.0.31,
|
|
gettext-0.10.40, gnome-applets-1.4.0.4
|
|
|
|
Output format: unified diff for the .desc files
|
|
|
|
Type ./scripts/Help Create-PkgUpdPatch for details."
|
|
|
|
EOT
|
|
exit 1
|
|
fi
|
|
|
|
if [ "$*" ] ; then
|
|
echo "$*" | exec $0
|
|
exit $?
|
|
fi
|
|
|
|
base=.
|
|
. scripts/functions
|
|
|
|
tr ', \t' '\n\n\n' |
|
|
tr -s '\n' |
|
|
while read x ; do
|
|
pkg="" ; pkgdir=""
|
|
[ -z "$x" ] && continue
|
|
|
|
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
|
|
|
|
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' '`"
|
|
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`
|
|
[ "$oldver" == "$newver" ] && continue
|
|
echo "Upgrade Patch for $pkg ($pkgdir): $oldver -> $newver"
|
|
sed -e"s/^\[\(D\|DOWN\|DOWNLOAD\)\] [0-9]\+ \(.*\)$oldver\(.*\)/[\1] 0 \2$newver\3/" \
|
|
-e"s/${oldver//./\\.}/$newver/g" -e"s/^\(\[V\] $newver\) .*/\1/" \
|
|
< $pkgdir/$pkg.desc > $tmpfile
|
|
|
|
diff -u ./$pkgdir/$pkg.desc $tmpfile | tee $tmpfile2
|
|
[ -s $tmpfile2 ] || echo "Patch for '$x' is empty!" >&2
|
|
rm -f $tmpfile $tmpfile2
|
|
else
|
|
echo "Can't find package for '$x'!" >&2
|
|
echo "Can't find package for '$x'!"
|
|
fi
|
|
echo
|
|
done
|