Debian Codegraph @

scripts/bin/parse_apt_url_get_rpm.sh

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2 # Steven Shiau <steven _at_ clonezilla org>
3 # License: GPL
4 # Description: To parse the /etc/apt/sourcesl.list and get the installed pacakge
5 # Usage: $0 PKGNAME
6 # Ex: $0 glibc
7
8 # Load DRBL setting and functions
9 DRBL_SCRIPT_PATH="${DRBL_SCRIPT_PATH:-/usr/share/drbl}"
10
11 . $DRBL_SCRIPT_PATH/sbin/drbl-conf-functions
12
13 #
14 usagescip-shell shell shell-project 0.0.0 usage().() {
15 echoscip-shell system . . echo. Usage: $0 [OPTION] PKGNAME
16 echoscip-shell system . . echo. "OPTION:"
17 echoscip-shell system . . echo. " -a|--append DIRNAME set the DIRNAME to append in the URL"
18 echoscip-shell system . . echo. " -r|--arch ARCH set the search CPU type as ARCH (like i586, i686)"
19 echoscip-shell system . . echo. " -n|--no-specific-ver Do not match the running version."
20 echoscip-shell system . . echo. Ex: $0 -p RPMS.base -p RPMS.update -r i586 -n glibc
21 echoscip-shell system . . echo. "This will try to search the URL found in /etc/apt/sources.list with URL/RPMS.base and URL/RPMS.update, and the version no. is not important."
22 }
23
24 # option
25 DIRNAME=
26 while [scip-shell system . . `[`. $# -gt 0 ]; do
27 case "$1" in
28 -a|--append)
29 shift; DIRNAME="$DIRNAME $1"
30 if [scip-shell system . . `[`. -z "$DIRNAME" ]; then
31 usagescip-shell shell shell-project 0.0.0 usage(). >& 2
32 exit 2
33 fi
34 shift;;
35 -r|--arch)
36 shift; arch="$1"
37 if [scip-shell system . . `[`. -z "$arch" ]; then
38 usagescip-shell shell shell-project 0.0.0 usage(). >& 2
39 exit 2
40 fi
41 shift;;
42 -n|--no-specific-ver)
43 specivic_ver="no"
44 shift;;
45 -*) echoscip-shell system . . echo. "${0}: ${1}: invalid option" >&2
46 usagescip-shell shell shell-project 0.0.0 usage(). >& 2
47 exit 2 ;;
48 *) break ;;
49 esac
50 done
51 pkg=$1
52
53 [scip-shell system . . `[`. -z "$pkg" ] && exit 0
54 [scip-shell system . . `[`. -z "$arch" ] && exit 0
55
56 if [scip-shell system . . `[`. "$specivic_ver" = "no" ]; then
57 pkg_ver_filter="grep -iE ^${pkg}-[0-9]+"
58 else
59 pkg_ver="$(rpm -q $pkg 2>/dev/nullscip-shell filesystem . . `/dev/null`.)"
60 if [scip-shell system . . `[`. -n "$pkg_ver" ]; then
61 pkg_ver_filter="grep -iE ^$pkg_ver"
62 else
63 exit 2
64 fi
65 fi
66 arch_filter="grep -iE ^.*.${arch}.rpm"
67
68 #
69 for im in $DIRNAME; do
70 # it's like: rpm ftp://ftp.gwdg.de/pub/linux/suse/apt SuSE/9.3-i386 base
71 url=$(grepscip-shell system . . grep. -E "^[[:space:]]*rpm .* ${im/RPMS./}.*" /etc/apt/sources.listscip-shell filesystem . . `/etc/apt/sources.list`. | awkscip-shell system . . awk. -F" " '{print $2"/"$3}')
72 for iurl in $url; do
73 pkg_rpm="$(LC_ALL=C list_available_rpm $iurl/${im} | $pkg_ver_filter | $arch_filter)"
74 if [scip-shell system . . `[`. -n "$pkg_rpm" ];then
75 echoscip-shell system . . echo. "$iurl/${im}/$pkg_rpm"
76 break
77 fi
78 done
79 [scip-shell system . . `[`. -n "$pkg_rpm" ] && break
80 done