3 # --- T2-COPYRIGHT-NOTE-BEGIN ---
4 # T2 SDE: scripts/Create-PkgUpdPatch
5 # Copyright (C) 2004 - 2023 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
51 [ "$oldver2" == "$oldver" -o "$ver2" == "$ver" ] && oldver2
= ver2
=
52 if grep -q "/$oldver/$" $tmpfile; then
54 oldver
="${oldver//./\\.}"
55 expression
="$expression -e '/^\[\(D\|DOWN\|DOWNLOAD\)\]/ s@/$oldver/[^ \t]*\$@/$ver/@g;'"
56 elif [ "$oldver" != "${oldver//-/}" ] && grep -q "/${oldver//-/}/\$" $tmpfile; then
57 # $ver-$extra -> /$ver/
58 oldver
="${oldver%%-*}" oldver
="${oldver//./\\.}"
60 expression
="$expression -e '/^\[\(D\|DOWN\|DOWNLOAD\)\]/ s@/$oldver/[^ \t]*\$@/$ver/@g;'"
62 # $ver.$extra -> /$ver/
63 oldver
="${oldver%%-*}"
69 while [ "${oldver#$oldauxver}" ]; do
70 eval $
(echo "$oldver $ver" |
sed -e "s,\($pattern\).* \($pattern\).*,oldauxver='\1' auxver='\2',")
71 if grep -q "/$oldauxver/\$" $tmpfile; then
72 oldver
="${oldauxver%%-*}" oldauxver
="${oldauxver//./\\.}"
74 expression
="$expression -e '/^\[\(D\|DOWN\|DOWNLOAD\)\]/ s@/$oldver/[^ \t]*\$@/$ver/@g;'"
77 pattern
="$pattern\.\?[^\.]*"
81 # leading short, major version directory, too
82 if [ "$oldver2" ]; then
83 oldver2
="${oldver2//./\\.}"
84 expression
="$expression -e '/^\[\(D\|DOWN\|DOWNLOAD\)\]/ s@/$oldver2/@/$ver2/@g;'"
88 expression
="$expression -e 's,^\[\(D\|DOWN\|DOWNLOAD\)\] [^ ]\+,[\1] 0,'"
90 eval "sed $expression $pkgdir/$pkg.desc" > $tmpfile
91 diff -u .
/$pkgdir/$pkg.desc
$tmpfile |
tee $tmpfile2
92 [ -s $tmpfile2 ] ||
echo "Patch for '$x' is empty!" >&2
93 rm -f $tmpfile $tmpfile2