#!/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 '.*,,'
)"
# 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 <