added CheckVersion info for dyncall
[t2.git] / scripts / Update-Pkg
blob3c5dddebaa5eb5d328fba15a1006c84ad427df61
1 #!/bin/bash
2 # --- T2-COPYRIGHT-NOTE-BEGIN ---
3 # This copyright note is auto-generated by scripts/Create-CopyPatch.
4 #
5 # T2 SDE: scripts/Update-Pkg
6 # Copyright (C) 2004 - 2020 The T2 SDE Project
7 #
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 as published by
12 # the Free Software Foundation; version 2 of the License. A copy of the
13 # GNU General Public License can be found in the file COPYING.
14 # --- T2-COPYRIGHT-NOTE-END ---
16 # Extract packagename and version number from the script arguments.
17 pkg="$1"; shift
18 ver="$1"; shift
20 # The script also supports the package name and version separated by a '-',
21 # '_' or '.'. In this case they have to be separated from each other.
22 if [ -z "$ver" ]; then
23 ver=${pkg/*-/}
24 pkg=${pkg%-$ver}
25 if [ "$ver" == "$pkg" ]; then
26 ver=${pkg/*_/}
27 pkg=${pkg%_$ver}
29 if [ "$ver" == "$pkg" ]; then
30 pkg=${pkg/.*/}
31 ver=${ver#$pkg.}
33 [ "$ver" == "$pkg" ] && unset ver
36 # Check if both package name and version have been extracted from the
37 # commandline arguments. If not the script was called with invalid
38 # arguments, show the usage.
39 if [ -z "$pkg" -o -z "$ver" ]; then
40 echo "Usage: $0 pkg ver, pkg-ver, pkg_ver or pkg.ver"
41 echo ""
42 echo "Updating a package to a new versions."
43 echo ""
44 echo " pkg Packagename to be updated"
45 echo " ver New version number for the package"
46 echo " ver=refresh makes it just add checksums"
47 echo ""
48 echo "For detailed information on how to update packages"
49 echo "to new versions, please have a look at the online"
50 echo "T2 documentaion."
51 exit
54 # Make sure any diff files from previous runs are removed.
55 rm -f $$.diff
57 # Only package names in lowercase are supported. As an additional
58 # service any package names supplied in capitols will be converted
59 # to lowercase.
60 pkg=`echo "$pkg" | tr A-Z a-z`
62 # Of course we can only update packages we know about.
63 if [ -d package/*/$pkg ]; then
64 if [ "$ver" != "refresh" ]; then
65 # The package exists so now update the package descriptor
66 # for the given package to the new version. Luckily we have
67 # a script for that too :-)
68 scripts/Create-PkgUpdPatch "$pkg" "$ver" | tee $$.diff
69 patch -p1 < $$.diff
70 rm -f $$.diff
73 # Step 2: Use the modified package descriptor to download
74 # the package. Again, nothing more that calling an existing
75 # script.
76 scripts/Download $pkg
78 # Third and final step is updating the checksum for the
79 # new download.
80 scripts/Create-CkSumPatch "$pkg" | patch -p0
81 else
82 # Oeps, the given package name does not exist.
83 echo "ERROR: package $pkg doesn't exist"
84 # As an extra service for the user a list possibilities is
85 # presented with packages closely matching the given package
86 # name.
87 pkg=`echo "$pkg" | tr '\-_.' '***'`
88 echo `echo package/*/*$pkg*/ | tr ' ' '\n' | grep -v '*' | cut -d'/' -f3`