diff options
-rw-r--r-- | SBO-Lib/lib/SBO/Lib.pm | 2 | ||||
-rw-r--r-- | man1/sbocheck.1.bak | 32 | ||||
-rwxr-xr-x | tools/update_man_pages.sh | 135 |
3 files changed, 136 insertions, 33 deletions
diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index 55b57ec..d0e42c4 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -14,7 +14,7 @@ use strict; use warnings FATAL => 'all'; package SBO::Lib; -our $VERSION = '1.6'; +our $VERSION = '1.7'; require Exporter; our @ISA = qw(Exporter); diff --git a/man1/sbocheck.1.bak b/man1/sbocheck.1.bak deleted file mode 100644 index 8263c2b..0000000 --- a/man1/sbocheck.1.bak +++ /dev/null @@ -1,32 +0,0 @@ -.TH sbocheck 1 "Prickle-Prickle,_Discord_16,_3179_YOLD" "sbotools 1.7" dawnrazor.net -.SH NAME -.P -sbocheck - update a local slackbuilds.org tree and check for updates. -.SH SYNAPSES -.P -sbocheck [-h|-v] -.SH DESCRIPTION -.P -sbocheck first updates a previously fetched copy of the slackbuilds.org tree (see sbosnap(1)) and then checks to see if any packages installed from slackbuilds.org have updates, and reports what it finds. -.SH OPTIONS -.P --h|--help -.RS -Show help information. -.RE -.P --v|--version -.RS -Show version information. -.RE -.SH BUGS -.P -None known, but there may be some. Please report any found to j@dawnrazor.net or xocel@iquidus.org; patches are always welcome. -.SH SEE ALSO -.P -sboclean(1), sboconfig(1), sbofind(1), sboinstall(1), sboremove(1), sbosnap(1), sboupgrade(1), sbotools.conf(5) -.SH AUTHORS -.P -Jacob Pipkin <j@dawnrazor.net> -.P -Luke Williams <xocel@iquidus.org> diff --git a/tools/update_man_pages.sh b/tools/update_man_pages.sh new file mode 100755 index 0000000..6a57b4c --- /dev/null +++ b/tools/update_man_pages.sh @@ -0,0 +1,135 @@ +#!/bin/sh + +usage_exit() { + echo "Usage: $(basename $0) (-d) (-g) version" + exit 1 +} + +if [[ "$1" == "" ]]; then + usage_exit +fi + +if [[ "$1" == "-d" ]]; then + date=true + shift +fi + +if [[ "$1" == "-g" ]]; then + git=true + shift +fi + +if [[ "$1" == "" ]]; then + usage_exit +fi + +version="$1" + +if ! [[ -d "./man1" ]]; then + echo "you do not seem to be at the right place to run this." + echo "the man{1,5}/ directories should be under ." + exit 1 +fi + +old_version=$(head -1 man1/sbocheck.1 | rev | cut -d' ' -f2 | rev \ + | sed 's/"//g') + +tmpfile=$(mktemp /tmp/XXXXXXXXX) + +sed_file() { + if [[ "$1" == "" || "$2" == "" ]]; then + echo "sed_file(): two arguments required." + exit 1 + fi + + file="$1" + sed_cmd="$2" + + cat $file | sed "$sed_cmd" > $tmpfile + if [[ "$?" == "0" ]]; then + mv $tmpfile $file + else + return 1 + fi + + return 0 +} + +for i in $(ls man1); do + sed_file man1/$i "s/$old_version/$version/g" +done + +for i in $(ls man5); do + sed_file man5/$i "s/$old_version/$version/g" +done + +if [[ "$?" == "0" ]]; then + echo "version updated." +fi + +update_date() { + if ! which ddate >/dev/null 2>&1; then + echo "I can't find ddate." + return 1 + fi + + old_date=$(head -1 man1/sbocheck.1 | cut -d' ' -f4- | rev \ + | cut -d' ' -f4- | rev | sed 's/"//g') + + new_date=$(ddate +"%{%A, %B %d%}, %Y YOLD") + + for i in $(ls man1); do + sed_file man1/$i "s/$old_date/$new_date/g" + done + + for i in $(ls man5); do + sed_file man5/$i "s/$old_date/$new_date/g" + done + + if [[ "$?" == "0" ]]; then + echo "date updated." + else + return 1 + fi + + return 0 +} + +update_git() { + if ! which git >/dev/null 2>&1; then + echo "I can't find git." + return 1 + fi + + if [[ "$date" == "true" ]]; then + extra=" and dates" + fi + + git add man1/* man5/* + git commit -m "updated versions$extra for man pages" + git push + + if [[ "$?" == "0" ]]; then + echo "git updated." + else + return 1 + fi + + return 0 +} + +if [[ "$date" == "true" ]]; then + update_date + date_return=$? +fi + +if [[ "$git" == "true" ]]; then + update_git + git_return=$? +fi + +if [[ "$date_return" != "0" || "$git_return" != "0" ]]; then + exit 1 +fi + +exit 0 |