Debian Codegraph @

scripts/bin/list_latest_tarball

raw symbols SCIP
1 #!/bin/bash
2 # The script is borrowed from
3 #============================================================================
4 # http://staff.washington.edu/corey/tools.html
5 # Author: Corey Satten, corey @ cac.washington.edu, 06/26/03, release 1.8
6 #============================================================================
7 # Modified by Steven Shiau <steven _at_ clonezilla org> Sep/03/07
8 # We use this one to find the last version tar.bz2 in the repository.
9 # Because we might have a lot of tar.bz2...
10 # clonezilla-2.1.8-1.tar.bz2
11 # clonezilla-2.1.8-2.tar.bz2
12 # clonezilla-2.1.8-3.tar.bz2
13 # clonezilla-2.1.9-1.tar.bz2
14 # clonezilla-2.1.9-2.tar.bz2
15 # clonezilla-2.2.0-1.tar.bz2
16 # clonezilla-2.2.0-2.tar.bz2
17 # clonezilla-2.2.0-3.tar.bz2
18 # clonezilla-2.2.0-4.tar.bz2
19 # we just want to list the last one clonezilla-2.2.0-4.tar.bz2
20 #============================================================================
21 # "$GREP_NEWER" is in drbl-functions
22
23 # Load DRBL setting and functions
24 DRBL_SCRIPT_PATH="${DRBL_SCRIPT_PATH:-/usr/share/drbl}"
25
26 . $DRBL_SCRIPT_PATH/sbin/drbl-conf-functions
27
28 # Default settings
29 suf_default="gz"
30 #
31 USAGE () {
32 echo "Usage: `basename $0` [path]"
33 echo "Example:"
34 echo "`basename $0` /mirror/src/stable/"
35 echo "`basename $0` http://free.nchc.org.tw/drbl-core/src/stable/"
36 }
37
38 # Try to help people figure out if/when this file has DOS line terminators
39 # Chances are the initial #!/bin/sh will fail with a cryptic "not found" msg
40 # If someone tries to debug it by feeding it to sh manually, this should help:
41 NL=
42 case "$NL" in '');; *) #
43 echo "ERROR: $0 was improperly saved with CR-LF newlines." 1>&2 #
44 echo "Please try again after restoring Unix-style (LF) newlines" 1>&2 #
45 exit 1 ;; #
46 esac #
47
48 #
49 while [ $# -gt 0 ]; do
50 case "$1" in
51 -f|--comp-format)
52 shift;
53 if [ -z "$(echo $1 |grep ^-.)" ]; then
54 # skip the -xx option, in case
55 suf="$1"
56 shift;
57 fi
58 [ -z "$ocsroot" ] && USAGE && exit 1
59 ;;
60 -*) echo "${0}: ${1}: invalid option" >&2
61 USAGE >& 2
62 exit 2 ;;
63 *) break ;;
64 esac
65 done
66
67 SRC=$1
68 [ -z "$SRC" ] && echo "You must provide the URL or PATH!" && USAGE && exit 1
69
70 case "$SRC" in */);; *) SRC=$SRC/;; esac # URL must end in slash
71
72 #
73 [ -z "$suf" ] && suf="$suf_default"
74
75 #-------------------------------------------------------------------------------
76 list_available_tarball -f $suf $SRC |
77 #-------------------------------------------------------------------------------
78 #
79 # Find all installed packages with patches
80 #
81 (
82 case "${EFLAG}${OFLAG}${UFLAG}" in
83 '')
84 # Note! Here we'd better ot use gawk, not awk (mawk which exists in Debian)
85 gawk "$GREP_NEWER"' # omit all but newest of multiple available patches
86 { L0=R0; L1=R1; L2=R2
87 R0=$0
88 R1=$0; sub(/\.[^.]+.${suf}$/,"",R1) # pkg name+version
89 R2=$0; sub(/-[^-]+$/, "",R2) # pkg name-version
90 if ((R2 == L2) && newer(R1, L1)) {R0=L0; R1=L1}
91 if ((R2 != L2) && L0) {print L0}
92 }
93 END { print R0 }';;
94 *) cat -;;
95 esac
96 )