Debian Codegraph @

scripts/bin/list_latest_rpm

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> 12/12/04
8 # We use this one to find the last version rpms in our apt repository.
9 # Because we might have a lot of drbl-setup rpms...
10 # drbl-script-1.0-45drbl.i386.rpm
11 # drbl-script-1.1-19drbl.i386.rpm
12 # drbl-script-1.1-1drbl.i386.rpm
13 # drbl-setup-1.2-7drbl.i386.rpm
14 # we just want to list the last one drbl-setup-1.2-7drbl.i386.rpm
15 #============================================================================
16 # 2006/6/24 Steven Shiau modified it to use lftp for http instead of lynx, since
17 # 1. For some apache2, "lynx -dump" will get the html format instead of plain text
18 # 2. lynx does not support http_proxy and ftp_proxy.
19 # Now this program is based on list_available_rpm.
20
21 # Load DRBL setting and functions
22 DRBL_SCRIPT_PATH="${DRBL_SCRIPT_PATH:-/usr/share/drbl}"
23
24 . $DRBL_SCRIPT_PATH/sbin/drbl-conf-functions
25
26 #
27 usage () {
28 echo "Usage: `basename $0` [path]"
29 echo "Example:"
30 echo "`basename $0` /mirror/apt/RPMS.drbl-test"
31 echo "`basename $0` http://opensource.nchc.org.tw/fedora/apt/fedora/linux/2/i386/RPMS.drbl"
32 }
33
34 # Try to help people figure out if/when this file has DOS line terminators
35 # Chances are the initial #!/bin/sh will fail with a cryptic "not found" msg
36 # If someone tries to debug it by feeding it to sh manually, this should help:
37 NL=
38 case "$NL" in '');; *) #
39 echo "ERROR: $0 was improperly saved with CR-LF newlines." 1>&2 #
40 echo "Please try again after restoring Unix-style (LF) newlines" 1>&2 #
41 exit 1 ;; #
42 esac #
43
44 SRC=$1
45 [ -z "$SRC" ] && echo "You must provide the URL or PATH!" && usage && exit 1
46
47 case "$SRC" in */);; *) SRC=$SRC/;; esac # URL must end in slash
48
49 #-------------------------------------------------------------------------------
50 list_available_rpm $SRC |
51 #-------------------------------------------------------------------------------
52 #
53 # Find all installed packages with patches
54 #
55 (
56 case "${EFLAG}${OFLAG}${UFLAG}" in
57 '')
58 # Note! Here we'd better ot use gawk, not awk (mawk which exists in Debian)
59 gawk "$GREP_NEWER"' # omit all but newest of multiple available patches
60 { L0=R0; L1=R1; L2=R2
61 R0=$0
62 R1=$0; sub(/\.[^.]+\.rpm$/,"",R1) # pkg name+version
63 R2=$0; sub(/-[^-]+-[^-]+$/, "",R2) # pkg name-version
64 if ((R2 == L2) && newer(R1, L1)) {R0=L0; R1=L1}
65 if ((R2 != L2) && L0) {print L0}
66 }
67 END { print R0 }';;
68 *) cat -;;
69 esac
70 )