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