2 # --- T2-COPYRIGHT-NOTE-BEGIN ---
3 # This copyright note is auto-generated by scripts/Create-CopyPatch.
5 # T2 SDE: scripts/Update-Pkg
6 # Copyright (C) 2004 - 2020 The T2 SDE Project
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 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.
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
25 if [ "$ver" == "$pkg" ]; then
29 if [ "$ver" == "$pkg" ]; then
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"
42 echo "Updating a package to a new versions."
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"
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."
54 # Make sure any diff files from previous runs are removed.
57 # Only package names in lowercase are supported. As an additional
58 # service any package names supplied in capitols will be converted
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
73 # Step 2: Use the modified package descriptor to download
74 # the package. Again, nothing more that calling an existing
78 # Third and final step is updating the checksum for the
80 scripts
/Create-CkSumPatch
"$pkg" |
patch -p0
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
87 pkg
=`echo "$pkg" | tr '\-_.' '***'`
88 echo `echo package/*/*$pkg*/ | tr ' ' '\n' | grep -v '*' | cut -d'/' -f3`