File: list_latest_rpm

package info (click to toggle)
drbl 5.8.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,996 kB
  • sloc: sh: 43,555; perl: 8,820; xml: 867; makefile: 135
file content (70 lines) | stat: -rwxr-xr-x 2,917 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
# The script is borrowed from 
#============================================================================
# http://staff.washington.edu/corey/tools.html
# Author: Corey Satten, corey @ cac.washington.edu, 06/26/03, release 1.8
#============================================================================
# Modified by Steven Shiau <steven _at_ clonezilla org> 12/12/04
# We use this one to find the last version rpms in our apt repository.
# Because we might have a lot of drbl-setup rpms...
# drbl-script-1.0-45drbl.i386.rpm
# drbl-script-1.1-19drbl.i386.rpm
# drbl-script-1.1-1drbl.i386.rpm    
# drbl-setup-1.2-7drbl.i386.rpm
# we just want to list the last one drbl-setup-1.2-7drbl.i386.rpm
#============================================================================
# 2006/6/24 Steven Shiau modified it to use lftp for http instead of lynx, since
# 1. For some apache2, "lynx -dump" will get the html format instead of plain text
# 2. lynx does not support http_proxy and ftp_proxy.
# Now this program is based on list_available_rpm.

# Load DRBL setting and functions
DRBL_SCRIPT_PATH="${DRBL_SCRIPT_PATH:-/usr/share/drbl}"

. $DRBL_SCRIPT_PATH/sbin/drbl-conf-functions

#
usage () {
  echo "Usage: `basename $0` [path]"
  echo "Example:"
  echo "`basename $0` /mirror/apt/RPMS.drbl-test"
  echo "`basename $0` http://opensource.nchc.org.tw/fedora/apt/fedora/linux/2/i386/RPMS.drbl"
}

# Try to help people figure out if/when this file has DOS line terminators
# Chances are the initial #!/bin/sh will fail with a cryptic "not found" msg
# If someone tries to debug it by feeding it to sh manually, this should help:
NL=
case "$NL" in '');; *)                                                    #
    echo "ERROR: $0 was improperly saved with CR-LF newlines." 1>&2       #
    echo "Please try again after restoring Unix-style (LF) newlines" 1>&2 #
    exit 1 ;;                                                             #
esac                                                                      #

SRC=$1
[ -z "$SRC" ] && echo "You must provide the URL or PATH!" && usage && exit 1

case "$SRC" in */);; *) SRC=$SRC/;; esac	# URL must end in slash

#-------------------------------------------------------------------------------
list_available_rpm $SRC |
#-------------------------------------------------------------------------------
#
# Find all installed packages with patches
#
(
  case "${EFLAG}${OFLAG}${UFLAG}" in
    '') 
        # Note! Here we'd better ot use gawk, not awk (mawk which exists in Debian)
        gawk "$GREP_NEWER"'	# omit all but newest of multiple available patches
  		{ L0=R0; L1=R1; L2=R2
		  R0=$0
		  R1=$0; sub(/\.[^.]+\.rpm$/,"",R1) 	# pkg name+version
		  R2=$0; sub(/-[^-]+-[^-]+$/, "",R2) 	# pkg name-version
		  if ((R2 == L2) && newer(R1, L1)) {R0=L0; R1=L1}
		  if ((R2 != L2) && L0) {print L0}
		}
	END	{ print R0 }';;
     *) cat -;;
  esac
)