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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
#!/bin/sh
# elvis: sbo -- Search SlackBuilds.org packages
# Author: B. Watson (yalhcru at gmail)
# Licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details.
. surfraw || exit 1
if [ "$( type -p wget )" = "" ]; then
err "wget is required for this. please install it."
fi
get_slack_ver() {
local ver sitevers topver i
# initially set to the currently running version, if we can
if [ -e /etc/slackware-version ]; then
ver="$( cut -d' ' -f2 < /etc/slackware-version )"
fi
# now check the site, make sure it's a supported version (e.g. not -current)
sitevers="$(
wget -qO- "https://slackbuilds.org" | \
grep -A1 '<select *name="sv"' | \
tail -1 | \
sed \
-e 's,^[[:space:]]*,,' \
-e 's,<option value="[^"]*"[^>]*>\([0-9][^"]*\)</option>,\1 ,g' \
-e 's,[[:space:]]*</select>.*,,'
)"
# if we can't get the local version *or* the list of versions
# from the site, just take a wild guess.
if [ -z "$sitevers" ]; then
echo "${ver:-14.2}"
return
fi
for i in $sitevers; do
topver="$i"
if [ "$i" = "$ver" ]; then
echo "$ver"
return
fi
done
# fall back to the highest-numbered version on the site
echo "$topver"
return
}
w3_config_hook() {
def SURFRAW_slack_version "$( get_slack_ver )"
}
w3_usage_hook() {
cat <<EOF
Usage: $w3_argv0 [options] [search words]...
Description:
Surfraw search builds/maintainers/dependencies on SlackBuilds.org
Local options:
-ver=VERSION Slackware version (Currently $SURFRAW_slack_version)
-m Maintainer search (name or email)
-r Reverse dependency search
-u URL search (download/homepage)
Notes:
-ver is ignored with -m, -r, -u (only latest stable is supported)
If -m is not given, but the search term has an @ in it, it's assumed to be
an email address and -m is enabled.
If -u is not given, but the search term looks like a URL, -u is enabled.
EOF
# forward dependency search not yet implemented on site:
# -d Dependency search
w3_global_usage
}
w3_parse_option_hook() {
opt="$1"
optarg="$2"
case "$opt" in
-v*=*) setopt SURFRAW_slack_version "$optarg" ;;
-m) stype=maint ;;
-r) stype=revdep ;;
-u) stype=url ;;
*) return 1 ;;
esac
return 0
}
w3_config
w3_parse_args "$@"
case "$w3_args" in
*@*) stype=maint ;;
*://*) stype=url ;;
esac
escaped_args="$( w3_url_of_arg $w3_args )"
if [ "$stype" = "" ]; then
url="https://slackbuilds.org/result/?search=${escaped_args}&sv=${SURFRAW_slack_version}"
else
url="https://slackbuilds.org/advsearch.php?stype=$stype&q=${escaped_args}"
fi
w3_browse_url "$url"
|