* added python-wheel (0.42.0) - The official binary distribution format for Python
[t2sde.git] / scripts / Create-PkgUpdPatch
blob640e2a229a932ea351c1fc26e654647e45192f47
1 #!/usr/bin/env bash
3 # --- T2-COPYRIGHT-NOTE-BEGIN ---
4 # T2 SDE: scripts/Create-PkgUpdPatch
5 # Copyright (C) 2004 - 2023 The T2 SDE Project
6 #
7 # This Copyright note is generated by scripts/Create-CopyPatch,
8 # more information can be found in the files COPYING and README.
9 #
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 ---
14 pkg="$1"; shift
15 ver="$1"; shift
17 if [ -z "$ver" ]; then
18 ver=${pkg/*-/}
19 pkg=${pkg%-$ver}
22 if [ -z "$pkg" -o -z "$ver" ]; then
23 echo "Usage: $0 pkg ver"
24 echo " or: $0 pkg-ver"
25 exit
28 pkg=`echo $pkg | tr A-Z a-z`
30 echo "[ $pkg ]" >&2
31 pkgdir=`echo package/*/$pkg`
33 if [ ! -d "$pkgdir" ]; then
34 echo "Can't find package for '$x'!" >&2
35 else
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"
41 # [V]
42 expression="-e 's@^\[\(V\|VER\|VERSION\)\].*@[\1] $ver@'"
43 # file at [D]
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 oldver2=${oldver%.*}
50 ver2=${ver%.*}
51 [ "$oldver2" == "$oldver" -o "$ver2" == "$ver" ] && oldver2= ver2=
52 if grep -q "/$oldver/$" $tmpfile; then
53 # $ver -> /$ver/
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//./\\.}"
59 ver="${ver%%-*}"
60 expression="$expression -e '/^\[\(D\|DOWN\|DOWNLOAD\)\]/ s@/$oldver/[^ \t]*\$@/$ver/@g;'"
61 else
62 # $ver.$extra -> /$ver/
63 oldver="${oldver%%-*}"
64 ver="${ver%%-*}"
66 oldauxver=
67 auxver=
68 pattern="[^\.]*"
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//./\\.}"
73 ver="${auxver%%-*}"
74 expression="$expression -e '/^\[\(D\|DOWN\|DOWNLOAD\)\]/ s@/$oldver/[^ \t]*\$@/$ver/@g;'"
75 break
77 pattern="$pattern\.\?[^\.]*"
78 done
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;'"
87 # checksum at [D]
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
95 echo