diff options
Diffstat (limited to 'utils')
-rw-r--r-- | utils/Makefile.am | 4 | ||||
-rwxr-xr-x | utils/file2header.sh | 5 | ||||
-rwxr-xr-x | utils/irssi-version.sh | 28 | ||||
-rwxr-xr-x | utils/syncdocs.sh | 102 | ||||
-rwxr-xr-x | utils/syncscripts.sh | 39 | ||||
-rwxr-xr-x | utils/syntax.pl | 80 |
6 files changed, 258 insertions, 0 deletions
diff --git a/utils/Makefile.am b/utils/Makefile.am new file mode 100644 index 00000000..be24c17f --- /dev/null +++ b/utils/Makefile.am @@ -0,0 +1,4 @@ +EXTRA_DIST = \ + file2header.sh \ + irssi-version.sh \ + syntax.pl diff --git a/utils/file2header.sh b/utils/file2header.sh new file mode 100755 index 00000000..f25ae13b --- /dev/null +++ b/utils/file2header.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +echo "const char *$2 =" +cat $1|sed 's/\\/\\\\/g'|sed 's/"/\\"/g'|sed 's/^/\"/'|sed 's/$/\\n\"/' +echo ";" diff --git a/utils/irssi-version.sh b/utils/irssi-version.sh new file mode 100755 index 00000000..1fc6a558 --- /dev/null +++ b/utils/irssi-version.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +DATE=`GIT_DIR=$1/.git git log -1 --pretty=format:%ai HEAD` + +VERSION_DATE=`echo $DATE | cut -f 1 -d ' ' | tr -d -` +VERSION_TIME=`echo $DATE | cut -f 2 -d ' ' | awk -F: '{printf "%d", $1$2}'` + +if test -z "$VERSION_DATE"; then + exec>&2 + echo "**Error**: `basename "$0"` must be run in a git clone, cannot proceed." + exit 1 +fi + +echo "#define IRSSI_VERSION_DATE $VERSION_DATE" +echo "#define IRSSI_VERSION_TIME $VERSION_TIME" + +if echo "${VERSION}" | grep -q -- -head; then + # -head version, get extra details from git if we can + git_version=$(GIT_DIR=$1/.git git describe --dirty --long --always --tags) + if [ $? = 0 ]; then + new_version="$(echo "${VERSION}" | sed 's/-head//')" + # Because the git tag won't yet include the next release we modify the git + # describe output using the version defined from configure.ac. + version="${new_version}-$(echo "${git_version}" | sed 's/^.*-[0-9]\+-//')" + echo "#undef PACKAGE_VERSION" + echo "#define PACKAGE_VERSION \"${version}\"" + fi +fi diff --git a/utils/syncdocs.sh b/utils/syncdocs.sh new file mode 100755 index 00000000..e723edd2 --- /dev/null +++ b/utils/syncdocs.sh @@ -0,0 +1,102 @@ +#!/bin/sh -e +# Run this to download FAQ and startup-HOWTO from irssi.org + +PKG_NAME="Irssi" + +site=https://irssi.org + +faq=$site/documentation/faq/ +howto=$site/documentation/startup/ + +# remove everything until H1 and optionally 2 DIVs before the +# FOOTER. May need to be adjusted as the source pages change +pageclean_regex='s{.*(?=<h1)}{}s; +s{\s*(</div>\s*)?(</div>\s*)?<footer.*}{}s; +s{(<.*?)\sclass="(?:highlighter-rouge|highlight)"(.*?>)}{\1\2}g;' + +srcdir=`dirname "$0"` +test -z "$srcdir" && srcdir=. +srcdir="$srcdir"/.. + +if test ! -f "$srcdir"/configure.ac; then + echo -n "**Error**: Directory \`$srcdir' does not look like the" + echo " top-level $PKG_NAME directory" + exit 1 +fi + +# detect downloader app +downloader=false + +if type curl >/dev/null 2>&1 ; then + downloader="curl -Ssf" +elif type wget >/dev/null 2>&1 ; then + downloader="wget -nv -O-" +else + echo "**Error**: No wget or curl present" + echo "Install wget or curl, then run syncdocs.sh again" +fi + +# detect html converter app +converter=false +if [ "$1" = "-any" ]; then + any=true +else + any=false +fi + +if type w3m >/dev/null 2>&1 ; then + converter="w3m -o display_link_number=1 -dump -T text/html" + any=true +elif type lynx >/dev/null 2>&1 ; then + converter="lynx -dump -stdin -force_html" +elif type elinks >/dev/null 2>&1 ; then + converter="elinks -dump -force-html" +else + echo "**Error**: Neither w3m, nor lynx or elinks present" + echo "Install w3m, then run syncdocs.sh again" + exit 1 +fi + +if ! $any ; then + echo "**Error**: w3m not present" + echo "If you want to use lynx or elinks, run syncdocs.sh -any" + exit 1 +fi + +check_download() { + if test "$1" -ne 0 || test ! -e "$2" || test "$(wc -l "$2" | awk '{print $1}')" -le 1 ; then + rm -f "$2" + echo "... download failed ( $1 )" + exit 2 + fi +} + +download_it() { + echo "Downloading $1 from $2 ..." + ret=0 + $downloader "$2" > "$3".tmp || ret=$? + check_download "$ret" "$3".tmp + perl -i -0777 -p -e "$pageclean_regex" "$3".tmp + perl -i -0777 -p -e 's{\A}{'"<base href='$2'>"'\n}' "$3".tmp + perl -i -0777 -p -e 's{<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail=".*?">\[email protected\]</a>}{user\@host}g' "$3".tmp + mv "$3".tmp "$3" +} + +download_it "FAQ" "$faq" "$srcdir"/docs/faq.html +download_it "Startup How-To" "$howto" "$srcdir"/docs/startup-HOWTO.html + +# .html -> .txt with lynx or elinks +echo "Documentation: html -> txt..." + +cat "$srcdir"/docs/faq.html \ + | LC_ALL=en_IE.utf8 $converter \ + | perl -pe ' + s/^ *//; + if ($_ eq "\n" && $state eq "Q") { $_ = ""; } + elsif (/^([QA]):/) { $state = $1 } + elsif ($_ ne "\n") { $_ = " $_"; }; +' > "$srcdir"/docs/faq.txt + +cat "$srcdir"/docs/startup-HOWTO.html \ + | perl -pe "s/\\bhref=([\"\'])#.*?\\1//" \ + | LC_ALL=en_IE.utf8 $converter > "$srcdir"/docs/startup-HOWTO.txt diff --git a/utils/syncscripts.sh b/utils/syncscripts.sh new file mode 100755 index 00000000..533b77cc --- /dev/null +++ b/utils/syncscripts.sh @@ -0,0 +1,39 @@ +#!/bin/sh -e +# Run this script to sync dual lived scripts from scripts.irssi.org to scripts/ + +PKG_NAME="Irssi" + +scriptbase=https://scripts.irssi.org/scripts + +srcdir=`dirname "$0"` +test -z "$srcdir" && srcdir=. +srcdir="$srcdir"/.. + +if test ! -f "$srcdir"/configure.ac; then + echo -n "**Error**: Directory \`$srcdir' does not look like the" + echo " top-level $PKG_NAME directory" + exit 1 +fi + +dl2='curl -Ssf' + +dl_it() { + echo "$1" + $dl2 -o "$srcdir/scripts/$1" "$scriptbase/$1" +} + +for script in \ + autoop.pl \ + autorejoin.pl \ + buf.pl \ + dns.pl \ + kills.pl \ + mail.pl \ + mlock.pl \ + quitmsg.pl \ + scriptassist.pl \ + usercount.pl \ + ; +do + dl_it $script +done diff --git a/utils/syntax.pl b/utils/syntax.pl new file mode 100755 index 00000000..33bd12b4 --- /dev/null +++ b/utils/syntax.pl @@ -0,0 +1,80 @@ +#!/usr/bin/perl +# +# This script reads the syntaces of commands from irssi source tree. +# Then it browses through all '.in' files in the current directory and +# substitutes '@SYNTAX:foo@' tags with real syntaces found. This data +# is written into the corresponding files without the '.in' extension. +# For example: help.in -> ../help +# +# This path has to be changed. It should point to your irssi/src directory +# Remember to include the asterisk ('*'). +$SRC_PATH='src'; + +@files = sort `find src -name '*.c'`; + +foreach $file (@files) { + open (FILE, "$file"); + while (<FILE>) { + chomp; + if (m!/\*.SYNTAX\:! || $state) { + s/^\s+/ /; + s/.*SYNTAX: //; + if (/^ [A-Z]+/) { + push @lines, $line; + $line = ""; + s/^ //; + } + $line .= $_; + if (m!\*/!) { + $line =~ s!\*/!!; + push @lines, $line; + $line = ""; + $state = 0; + } else { + $state = 1; + } + } + } + close (FILE); +} +while (<docs/help/in/*.in>) { + next if (/Makefile/); + + open (FILE, "$_"); + @data = <FILE>; + close (FILE); + $count = 0; + foreach $DATARIVI (@data) { + if ($DATARIVI =~ /\@SYNTAX\:(.+)\@/) { + $SYNTAX = join "\n", (grep /^\U$1 /, @lines); + $SYNTAX .= "\n" if $SYNTAX; + $SYNTAX =~ s/ *$//; $SYNTAX =~ s/ *\n/\n/g; + + # add %| after "COMMAND SUB " so parameters will indent correctly + $SYNTAX =~ s/^([A-Z ]+)/\1%|/; + $SYNTAX =~ s/(\n[A-Z ]+)/\1%|/g; + # no need for this if there's no parameters + $SYNTAX =~ s/%\|$//; + $DATARIVI = $SYNTAX; + } elsif ($DATARIVI =~ /^\S+/) { + if ($data[$count+1] =~ /^\S+/) { + chomp $DATARIVI; + $DATARIVI =~ s/ *$//g; + $DATARIVI .= " "; + } + } else { + $DATARIVI =~ s/^\t/ / while ($DATARIVI =~ /^\t/); + } + $count++; + } + + # must always end with empty line + push @data, "\n" if ($data[@data-1] ne "\n"); + push @data, "\n" if ($data[@data-2] !~ /\n$/); + + $newfilename = $_; $newfilename =~ s/\.in$//; + $newfilename =~ s/\/in\//\//; + open (NEWFILE, ">$newfilename"); + print NEWFILE @data; + close (NEWFILE); +} |