3 # --- T2-COPYRIGHT-NOTE-BEGIN ---
4 # T2 SDE: scripts/Create-PkgUpdPatch
5 # Copyright (C) 2004 - 2021 The T2 SDE Project
7 # This Copyright note is generated by scripts/Create-CopyPatch,
8 # more information can be found in the files COPYING and README.
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License version 2.
12 # --- T2-COPYRIGHT-NOTE-END ---
17 if [ -z "$ver" ]; then
22 if [ -z "$pkg" -o -z "$ver" ]; then
23 echo "Usage: $0 pkg ver"
24 echo " or: $0 pkg-ver"
28 pkg
=`echo $pkg | tr A-Z a-z`
31 pkgdir
=`echo package/*/$pkg`
33 if [ ! -d "$pkgdir" ]; then
34 echo "Can't find package for '$x'!" >&2
36 oldver
="`egrep "^\
[(V|VER|VERSION
)\
] " $pkgdir/$pkg.desc |
37 sed 's, ,\t,g; s,\t\t*,\t,g' | cut -f2`"
38 tmpfile
=`mktemp`; tmpfile2
=`mktemp`
39 echo "Update patch for $pkg ($pkgdir): $oldver -> $ver"
42 expression
="-e 's@^\[\(V\|VER\|VERSION\)\].*@[\1] $ver@'"
44 expression
="$expression -e '/^\[\(D\|DOWN\|DOWNLOAD\)\]/ s@${oldver//./\\.}@$ver@g;'"
46 # detect download location structure
47 sed -n -e 's,^\[\(D\|DOWN\|DOWNLOAD\)\].*[ \t]\([^ \t]*\)[ \t]*$,\2,p' $pkgdir/$pkg.desc
> $tmpfile
49 if grep -q "/$oldver/$" $tmpfile; then
51 oldver
="${oldver//./\\.}"
52 expression
="$expression -e '/^\[\(D\|DOWN\|DOWNLOAD\)\]/ s@/$oldver/[^ \t]*\$@/$ver/@g;'"
53 elif [ "$oldver" != "${oldver//-/}" ] && grep -q "/${oldver//-/}/\$" $tmpfile; then
54 # $ver-$extra -> /$ver/
55 oldver
="${oldver%%-*}"; oldver
="${oldver//./\\.}"
57 expression
="$expression -e '/^\[\(D\|DOWN\|DOWNLOAD\)\]/ s@/$oldver/[^ \t]*\$@/$ver/@g;'"
59 # $ver.$extra -> /$ver/
60 oldver
="${oldver%%-*}"
66 while [ "${oldver#$oldauxver}" ]; do
67 eval $
( echo "$oldver $ver" |
sed -e "s,\($pattern\).* \($pattern\).*,oldauxver=\1 auxver=\2," )
68 if grep -q "/$oldauxver/\$" $tmpfile; then
69 oldver
="${oldauxver%%-*}"; oldauxver
="${oldauxver//./\\.}"
71 expression
="$expression -e '/^\[\(D\|DOWN\|DOWNLOAD\)\]/ s@/$oldver/[^ \t]*\$@/$ver/@g;'"
74 pattern
="$pattern\.\?[^\.]*"
79 expression
="$expression -e 's,^\[\(D\|DOWN\|DOWNLOAD\)\] [^ ]\+,[\1] 0,'"
81 eval "sed $expression $pkgdir/$pkg.desc" > $tmpfile
82 diff -u .
/$pkgdir/$pkg.desc
$tmpfile |
tee $tmpfile2
83 [ -s $tmpfile2 ] ||
echo "Patch for '$x' is empty!" >&2
84 rm -f $tmpfile $tmpfile2