From 107d068ea14529fdec7d9c0183fb094dd39952a1 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Mon, 30 Dec 2019 05:45:19 -0500 Subject: initial commit --- elvi/sbo | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100755 elvi/sbo (limited to 'elvi/sbo') diff --git a/elvi/sbo b/elvi/sbo new file mode 100755 index 0000000..fdc895e --- /dev/null +++ b/elvi/sbo @@ -0,0 +1,88 @@ +#!/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 <