Debian Codegraph @

scripts/bin/list_available_tarball

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/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 #============================================================================
9 # Load DRBL setting and functions
10 DRBL_SCRIPT_PATH="${DRBL_SCRIPT_PATH:-/usr/share/drbl}"
11
12 . $DRBL_SCRIPT_PATH/sbin/drbl-conf-functions
13
14 # Settings
15 default_comp="xz"
16
17 #
18 USAGEscip-shell shell shell-project 0.0.0 USAGE().() {
19 echoscip-shell system . . echo. "$ocs - To list the available tarball files"
20 echoscip-shell system . . echo. "Usage:"
21 echoscip-shell system . . echo. "To run $ocs:"
22 echoscip-shell system . . echo. "$ocs [OPTION] PATH"
23 echoscip-shell system . . echo. "Options:"
24 echoscip-shell system . . echo. "-f, --comp-format FORMAT Specify the tarball compression format, i.e. gz, bz2, xz. If not assigned, xz will be used."
25 echoscip-shell system . . echo. "Ex:"
26 echoscip-shell system . . echo. "$ocs /mirror/apt/RPMS.drbl-test"
27 echoscip-shell system . . echo. "$ocs http://free.nchc.org.tw/syslinux/"
28 }
29
30 ####################
31 ### Main program ###
32 ####################
33
34 ocs_file="$0"
35 ocs=`basenamescip-shell system . . basename. $ocs_file`
36 #
37 while [scip-shell system . . `[`. $# -gt 0 ]; do
38 case "$1" in
39 -f|--comp-format)
40 shift;
41 if [scip-shell system . . `[`. -z "$(echoscip-shell system . . echo. $1 |grepscip-shell system . . grep. ^-.)" ]; then
42 # skip the -xx option, in case
43 suf="$1"
44 shift;
45 fi
46 [scip-shell system . . `[`. -z "$ocsroot" ] && USAGEscip-shell shell shell-project 0.0.0 USAGE(). && exit 1
47 ;;
48 -*) echoscip-shell system . . echo. "${0}: ${1}: invalid option" >&2
49 USAGEscip-shell shell shell-project 0.0.0 USAGE(). >& 2
50 exit 2 ;;
51 *) break ;;
52 esac
53 done
54
55 SRC="$1"
56
57 # Try to help people figure out if/when this file has DOS line terminators
58 # Chances are the initial #!/bin/sh will fail with a cryptic "not found" msg
59 # If someone tries to debug it by feeding it to sh manually, this should help:
60 NL=
61 case "$NL" in '');; *) #
62 echoscip-shell system . . echo. "ERROR: $0 was improperly saved with CR-LF newlines." 1>&2 #
63 echoscip-shell system . . echo. "Please try again after restoring Unix-style (LF) newlines" 1>&2 #
64 exit 1 ;; #
65 esac #
66
67 if [scip-shell system . . `[`. -z "$suf" ]; then
68 suf="$default_comp"
69 fi
70 if [scip-shell system . . `[`. -z "$SRC" ]; then
71 echoscip-shell system . . echo. "You must assign the URL or PATH!"
72 USAGEscip-shell shell shell-project 0.0.0 USAGE().
73 exit 1
74 fi
75
76 case "$SRC" in */);; *) SRC=$SRC/;; esac # URL must end in slash
77
78 #
79 if [scip-shell system . . `[`. -d $SRC ] ;then # local directory
80 (cd $SRC && lsscip-shell system . . ls. -l)
81 else # ftp directory
82 case "$SRC" in
83 ftp://*)
84 ( echoscip-shell system . . echo. set ftp:passive-mode on
85 # Steven Shiau modified to use lftp.
86 echoscip-shell system . . echo. rels ) | lftp $SRC 2>/dev/nullscip-shell filesystem . . `/dev/null`. | grepscip-shell system . . grep. -Ew "\.tar\.${suf}"
87 ;;
88 http://*)
89 # Steven Shiau modified to use lftp instead of lynx
90 #lynx -dump $SRC | sed -n 's,^[ 0-9.]*http://.*/,-& ,p';;
91 echoscip-shell system . . echo. rels | lftp $SRC 2>/dev/nullscip-shell filesystem . . `/dev/null`.
92 ;;
93 file://*)
94 DIR="$(echoscip-shell system . . echo. $SRC | sedscip-shell system . . sed. -e "s|file://||g")"
95 (cd $DIR && lsscip-shell system . . ls. -l)
96 ;;
97 esac
98 # In case dir -L fails, we need to add ^[-l] to strip the junk msg.
99 # Some repo output DOS (CR/LF),
100 # convert to Unix format: sed 's/[^[:print:]]$//'
101 fi | sedscip-shell system . . sed. 's/[^[:print:]]$//' | sedscip-shell system . . sed. -r -n "/tar.${suf}$/s/^[-l].* //p" | while read x; do basenamescip-shell system . . basename. $x; done | sortscip-shell system . . sort.