2 # --- T2-COPYRIGHT-NOTE-BEGIN ---
3 # T2 SDE: scripts/Update-Pkg
4 # Copyright (C) 2004 - 2024 The T2 SDE Project
6 # This Copyright note is generated by scripts/Create-CopyPatch,
7 # more information can be found in the files COPYING and README.
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License version 2.
11 # --- T2-COPYRIGHT-NOTE-END ---
13 # Extract packagename and version number from the script arguments.
19 if [[ "$pkg" == http
*://* ]]; then
20 curl
$pkg/ |
tr '"' '\n' |
grep "tar.[^.<>]*$"|
sort -u |
26 exit # TODO: return any update download error
29 # The script also supports the package name and version separated by a '-',
30 # '_' or '.'. In this case they have to be separated from each other.
31 if [ -z "$ver" ]; then
34 if [ "$ver" == "$pkg" ]; then
38 if [ "$ver" == "$pkg" ]; then
42 [ "$ver" == "$pkg" ] && unset ver
45 # Check if both package name and version have been extracted from the
46 # commandline arguments. If not the script was called with invalid
47 # arguments, show the usage.
48 if [ -z "$pkg" -o -z "$ver" ]; then
49 echo "Usage: $0 pkg ver, pkg-ver, pkg_ver or pkg.ver, or URL"
51 echo "Updating a package to a new versions."
53 echo " pkg Packagename to be updated"
54 echo " ver New version number for the package"
55 echo " ver=refresh makes it just add checksums"
56 echo " url extract pkg and version from tarballs"
58 echo "For detailed information on how to update packages"
59 echo "to new versions, please have a look at the online"
60 echo "T2 documentaion."
64 # Make sure any diff files from previous runs are removed.
67 # Only package names in lowercase are supported. As an additional
68 # service any package names supplied in capitols will be converted
70 pkg
=`echo "$pkg" | tr A-Z a-z`
72 # Of course we can only update packages we know about.
73 if [ -d package
/*/$pkg ]; then
74 if [ "$ver" != "refresh" ]; then
75 # The package exists so now update the package descriptor
76 # for the given package to the new version. Luckily we have
77 # a script for that too :-)
78 scripts
/Create-PkgUpdPatch
"$pkg" "$ver" |
tee $$.
diff
83 # Step 2: Use the modified package descriptor to download
84 # the package. Again, nothing more that calling an existing
86 scripts
/Download
$pkg ||
exit 1
88 # Third and final step is updating the checksum for the
90 scripts
/Create-CkSumPatch
"$pkg" |
patch -p0
92 # Oeps, the given package name does not exist.
93 echo "ERROR: package $pkg doesn't exist"
94 # As an extra service for the user a list possibilities is
95 # presented with packages closely matching the given package
97 pkg
=`echo "$pkg" | tr '\-_.' '***'`
98 echo `echo package/*/*$pkg*/ | tr ' ' '\n' | grep -v '*' | cut -d'/' -f3`