Debian Codegraph @

scripts/bin/get-rpm-list-from-yum

raw symbols SCIP
1 #!/bin/bash
2 # Author: Steven Shiau <steven _at_ clonezilla org>
3 # License: GPL
4
5 # Load DRBL setting and functions
6 DRBL_SCRIPT_PATH="${DRBL_SCRIPT_PATH:-/usr/share/drbl}"
7 . $DRBL_SCRIPT_PATH/sbin/drbl-conf-functions
8
9 #
10 USAGE() {
11 echo "Usage: $0 [Option] URL"
12 echo "Option:"
13 echo "-n|--without-path Show the results WITHOUT relative path"
14 echo "Ex:"
15 echo "$0 -n http://free.nchc.org.tw/fedora/linux/releases/10/Fedora/i386/os/"
16 echo "$0 -n ftp://free.nchc.org.tw/dists/fedora/linux/releases/10/Fedora/i386/os/"
17 echo "$0 -n http://free.nchc.org.tw/fedora/linux/core/5/i386/os"
18 echo "$0 http://free.nchc.org.tw/fedora/linux/core/updates/5/i386"
19 }
20
21 # default settings
22 show_path="yes"
23 # Parse command-line options
24 while [ $# -gt 0 ]; do
25 case "$1" in
26 -n|--without-path)
27 shift
28 show_path="no"
29 ;;
30 -*) echo "${0}: ${1}: invalid option" >&2
31 USAGE >& 2
32 exit 2 ;;
33 *) break ;;
34 esac
35 done
36 url=$1
37 [ -z "$url" ] && exit 1
38 # NOTE! Do not put extra / in the end of url, otherwise
39 # http://opensource.nchc.org.tw/fedora/linux/core/updates/3/i386//../repodata
40 # is equal to
41 # http://opensource.nchc.org.tw/fedora/linux/core/updates/3/i386/repodata/
42
43 # strip the last /
44 url="$(echo $url | sed -e "s|/$||g")"
45 file_xml="primary.xml.gz"
46 flst_tmp="$(mktemp -d /tmp/yum_xml.XXXXXX)"
47 (
48 for id in . .. ../../; do
49 cd "$flst_tmp"
50 lftpget $url/$id/repodata/$file_xml 2>/dev/null
51 RC=$?
52 [ "$RC" -eq 0 ] && break
53 done
54 )
55 if [ "$show_path" = "yes" ]; then
56 filter_prog="cat"
57 else
58 filter_prog="xargs basename"
59 fi
60 if [ -f "$flst_tmp/$file_xml" ]; then
61 # For Fedora, Ex (new line):
62 # <location href="Fedora/RPMS/selinux-policy-2.2.23-15.noarch.rpm"/>
63 # For CentOS (messed up):
64 # ... losetup(8)), creating volume groups (kind of virtual disks) from one or more physical volumes and creating one or more logical volumes (kind of logical partitions) in volume groups.</description><packager>Johnny Hughes & lt;[email protected]&gt;</packager><url>http://sources.redhat.com/lvm2</url><time fil e="1141877182" build="1141871322"/><size package="837792" installed="1762701" archive ="1776280"/><location href="CentOS/RPMS/lvm2-2.02.01-1.3.RHEL4.i386.rpm"/>
65 # Hence we have to use "grep -o"
66 zgrep -o "<location href=\".*rpm\"/>" $flst_tmp/$file_xml | sed -e "s|^[[:space:]]*<location href=\"||g" -e "s|\"/>||g" | $filter_prog
67 fi
68 [ -d "$flst_tmp" -a -n "$(echo $flst_tmp | grep "yum_xml")" ] && rm -rf $flst_tmp