ports/186879: [PATCH] textproc/rarian: De-bashify
Christian Mangin
christian.mangin at gmail.com
Tue Feb 18 21:10:00 UTC 2014
>Number: 186879
>Category: ports
>Synopsis: [PATCH] textproc/rarian: De-bashify
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Tue Feb 18 21:10:00 UTC 2014
>Closed-Date:
>Last-Modified:
>Originator: Christian Mangin
>Release: FreeBSD 10.0-RELEASE amd64
>Organization:
>Environment:
>Description:
Mercilessly de-bashify textproc/rarian.
4 scripts are affected:
rarian-sk-config
rarian-sk-extract
rarian-sk-rebuild
rarian-sk-update
The changes in the first 3 are quite trivial. The last one needed
some work but that turned out to be totally pointless as the script
does absolutely nothing useful.
With this patch, the dependency to shells/bash is no longer required.
>How-To-Repeat:
>Fix:
Patch attached.
--- patch.rarian begins here ---
diff -ruN rarian.orig/Makefile rarian/Makefile
--- rarian.orig/Makefile 2014-02-18 11:12:38.396775837 -0500
+++ rarian/Makefile 2014-02-18 15:16:57.203764471 -0500
@@ -12,10 +12,8 @@
BUILD_DEPENDS= ${LOCALBASE}/share/xsl/docbook/xhtml/chunk.xsl:${PORTSDIR}/textproc/docbook-xsl \
${LOCALBASE}/share/xml/docbook/${DOCBOOK_VERSION}:${PORTSDIR}/textproc/docbook-xml \
- ${LOCALBASE}/share/xml/docbook/4.1.2:${PORTSDIR}/textproc/docbook-sk \
- bash:${PORTSDIR}/shells/bash
-RUN_DEPENDS= bash:${PORTSDIR}/shells/bash \
- ${LOCALBASE}/bin/getopt:${PORTSDIR}/misc/getopt \
+ ${LOCALBASE}/share/xml/docbook/4.1.2:${PORTSDIR}/textproc/docbook-sk
+RUN_DEPENDS= ${LOCALBASE}/bin/getopt:${PORTSDIR}/misc/getopt \
${LOCALBASE}/share/xsl/docbook/xhtml/chunk.xsl:${PORTSDIR}/textproc/docbook-xsl \
${LOCALBASE}/share/xml/docbook/${DOCBOOK_VERSION}:${PORTSDIR}/textproc/docbook-xml \
${LOCALBASE}/share/xml/docbook/4.1.2:${PORTSDIR}/textproc/docbook-sk
diff -ruN rarian.orig/files/patch-util_rarian-sk-config.in rarian/files/patch-util_rarian-sk-config.in
--- rarian.orig/files/patch-util_rarian-sk-config.in 2014-01-22 12:40:44.000000000 -0500
+++ rarian/files/patch-util_rarian-sk-config.in 2014-02-18 14:41:30.953911818 -0500
@@ -1,5 +1,20 @@
---- util/rarian-sk-config.in.orig 2007-10-10 23:00:03.000000000 -0500
-+++ util/rarian-sk-config.in 2007-10-10 23:00:30.000000000 -0500
+--- util/rarian-sk-config.in.orig 2008-09-01 14:40:21.000000000 -0400
++++ util/rarian-sk-config.in 2013-05-12 10:11:27.075659034 -0400
+@@ -1,4 +1,4 @@
+-#!@BASH@
++#!/bin/sh
+
+ # Yet another simple wrapper for scrollkeeper wierdness
+ # This one emulates scrollkeeper-config,
+@@ -36,7 +36,7 @@
+
+ }
+
+-if [[ $# != 1 ]]
++if [ $# != 1 ]
+ then
+ print_help
+ exit
@@ -47,7 +47,7 @@
print_help
;;
diff -ruN rarian.orig/files/patch-util_rarian-sk-extract.in rarian/files/patch-util_rarian-sk-extract.in
--- rarian.orig/files/patch-util_rarian-sk-extract.in 1969-12-31 19:00:00.000000000 -0500
+++ rarian/files/patch-util_rarian-sk-extract.in 2014-02-18 14:41:30.954911276 -0500
@@ -0,0 +1,29 @@
+--- util/rarian-sk-extract.in.orig 2008-09-01 14:40:21.000000000 -0400
++++ util/rarian-sk-extract.in 2013-05-12 10:11:27.075659034 -0400
+@@ -1,4 +1,4 @@
+-#!@BASH@
++#!/bin/sh
+
+ # Wrapper around xsltproc to mimic scrollkeeper-extract.
+ #
+@@ -11,7 +11,7 @@
+ echo -e "`basename $0` <xml file> <stylesheet 1> <output file 1> <stylesheet 2> <output file 2> ..."
+ }
+
+-if [[ $# < 2 ]]
++if [ $# -lt 2 ]
+ then
+ print_usage
+ exit 0
+@@ -24,8 +24,8 @@
+ xsltproc --xinclude --xincludestyle $1 $infile > $2
+ #echo "xml: $infile style: $1 out: $2"
+ shift 2
+- if [[ $# < 2 ]];
++ if [ $# -lt 2 ];
+ then
+ break
+ fi
+-done
+\ No newline at end of file
++done
diff -ruN rarian.orig/files/patch-util_rarian-sk-rebuild.in rarian/files/patch-util_rarian-sk-rebuild.in
--- rarian.orig/files/patch-util_rarian-sk-rebuild.in 1969-12-31 19:00:00.000000000 -0500
+++ rarian/files/patch-util_rarian-sk-rebuild.in 2014-02-18 14:41:30.955910232 -0500
@@ -0,0 +1,24 @@
+--- util/rarian-sk-rebuild.in.orig 2008-09-01 14:40:21.000000000 -0400
++++ util/rarian-sk-rebuild.in 2013-05-12 10:11:27.075659034 -0400
+@@ -1,4 +1,4 @@
+-#!@BASH@
++#!/bin/sh
+
+ # Another simple wrapper script. This time for scrollkeeper-rebuilddb
+ # This one is slightly more complex in that we have to run a command!
+@@ -22,7 +22,7 @@
+ then
+ for x in $(grep -e '^0:@:' $statedir/rarian-update-mtimes)
+ do
+- if [[ $convert_string != "REPLACEME" ]]
++ if [ $convert_string != "REPLACEME" ]
+ then
+ convert_string=$convert_string:${x##0:@:}
+ else
+@@ -35,4 +35,4 @@
+
+ $bindir/rarian-sk-update -v --clean-index -o $convert_string
+
+-fi
+\ No newline at end of file
++fi
diff -ruN rarian.orig/files/patch-util_rarian-sk-update.in rarian/files/patch-util_rarian-sk-update.in
--- rarian.orig/files/patch-util_rarian-sk-update.in 1969-12-31 19:00:00.000000000 -0500
+++ rarian/files/patch-util_rarian-sk-update.in 2014-02-18 14:55:53.304853752 -0500
@@ -0,0 +1,239 @@
+--- util/rarian-sk-update.in.orig 2008-09-01 14:40:21.000000000 -0400
++++ util/rarian-sk-update.in 2014-02-18 14:54:52.000000000 -0500
+@@ -1,4 +1,4 @@
+-#!@BASH@
++#!/bin/sh
+
+ # This script is designed to replace scrollkeeper-update
+ # It iterates through all the directories specified using -o <dir_list>
+@@ -25,7 +25,7 @@
+ datadir=@datadir@
+ output_dir=${datadir}/help
+ package_version=@PACKAGE_VERSION@
+-real_convert[0]=$convert_dir
++real_convert=$convert_dir
+ skip_omf_translate=@ENABLE_OMF_READ@
+
+ # Print the version info for this file
+@@ -97,7 +97,7 @@
+ for f in $1/*.omf; do
+ bname=$(basename $f)
+ bname=${bname%-*.omf}
+- if [[ $bname != $old_basename ]]
++ if [ $bname != $old_basename ]
+ then
+ old_basename=$bname
+ filename=$bname.document
+@@ -115,39 +115,22 @@
+ echo -e `stat -c %Y $1`':@:'$1':@:'$fname_list >> $tmpdir/rarian-updates
+ }
+
+-# Split up the omf dirs specified on the command line
+-# I've never seen this used in practice, but
+-# better safe than sorry
+-split_omf_dirs ()
+-{
+- let counter=0
+- while [ $convert_dir ]
+- do
+- entry=`echo $convert_dir | cut -d ':' -f 1`
+- convert_dir=${convert_dir#$entry}
+- convert_dir=${convert_dir#:}
+- real_convert[$counter]=$entry
+- let counter+=1
+- done
+-
+-}
+-
+ # Determine whether the directory defined within the index file
+ # was specified in the convert_dirs
+ am_adding_dir ()
+ {
+- let counter=0
+ am_processing="0"
+- for i in ${real_convert[@]}
++ tmplist=
++ for i in ${real_convert}
+ do
+- if [[ $fname == $i ]]
++ if [ $fname == $i ]
+ then
+- real_convert[$counter]="0"
+ am_processing="1"
+- return
+- fi
+- let counter+=1
++ else
++ tmplist="$tmplist $i"
++ fi
+ done
++ real_convert=$tmplist
+ }
+
+ # The directory wasn't specified. This does nothing except cat the
+@@ -156,7 +139,7 @@
+ {
+ read line
+ time=`echo $line | awk -F ":@:" '{print $1}'`
+- while [[ $time -ne 0 ]]
++ while [ $time -ne 0 ]
+ do
+ echo $line
+ echo $line >> $tmpdir/rarian-updates
+@@ -183,18 +166,18 @@
+ # If the given directory actually exists within the omf dir
+ dirs_contains ()
+ {
+- let counter=0
+ am_processing="0"
+- for i in ${entries[@]}
++ tmplist=
++ for i in ${entries}
+ do
+- if [[ $1 == $i ]]
++ if [ $1 == $i ]
+ then
+- entries[$counter]="0"
+ am_processing="1"
+- return
++ else
++ tmplist="$tmplist $i"
+ fi
+- let counter+=1
+ done
++ entries=$tmplist
+ }
+
+ # The meat. Goes through and checks each directory mtime against the
+@@ -202,27 +185,26 @@
+ # If the dir has been removed, delete.
+ process_directory ()
+ {
+- let counter=0
++ entries=
+ for i in $(ls $fname)
+ do
+- entries[$counter]="$fname/$i"
+- let counter+=1
++ entries="$entries $fname/$i"
+ done
+
+ read line
+
+ old_time=`echo $line | awk -F ":@:" '{print $1}'`
+
+- while [[ $old_time && $old_time != "0" ]]
++ while [ $old_time && $old_time != "0" ]
+ do
+ name=`echo $line | awk -F ":@:" '{print $2}'`
+
+ dirs_contains $name
+
+- if [[ $am_processing != "0" ]]
++ if [ $am_processing != "0" ]
+ then
+ new_time=`stat -c %Y $name`
+- if [[ $new_time -ne $old_time ]]
++ if [ $new_time -ne $old_time ]
+ then
+ print_verbose "Directory $name has changed. Updating."
+ process_dir $name
+@@ -231,7 +213,7 @@
+ fi
+ else
+ filenames=`echo $line | awk -F ":@:" '{print $3}'`
+- while [[ $filenames ]]
++ while [ $filenames ]
+ do
+ entry=`echo $filenames | cut -d ';' -f 1`
+ print_verbose "Directory resonsible for $entry has been removed. Deleting"
+@@ -246,13 +228,10 @@
+ old_time=`echo $line | awk -F ":@:" '{print $1}'`
+ done
+
+- for i in ${entries[@]}
++ for i in ${entries}
+ do
+- if [[ $i != "0" ]]
+- then
+- print_verbose "Directory $i is new and will be added."
+- process_dir $i
+- fi
++ print_verbose "Directory $i is new and will be added."
++ process_dir $i
+ done
+ }
+
+@@ -326,7 +305,10 @@
+ if [ $skip_omf_translate = 0 ]
+ then
+
+-split_omf_dirs
++# Split up the omf dirs specified on the command line
++# I've never seen this used in practice, but
++# better safe than sorry
++real_convert=$(echo $convert_dir | sed 's/:/ /g')
+
+ if [ $update_output_dir ] && [ ! $overload_update ]
+ then
+@@ -334,7 +316,7 @@
+ # omf files in <prefix>/share/omf
+ # Also assumes only a single omf path
+ print_verbose "Using non-installed location"
+- output_dir=`dirname $real_convert[0]`/help
++ output_dir=$(dirname $(echo $real_convert | cut -d ' ' -f 1))/help
+ fi
+
+ print_verbose "Outputting to $output_dir"
+@@ -378,16 +360,16 @@
+ fname=`echo $line | awk -F ":@:" '{print $2}'`
+
+
+-while [[ $fname != "" ]]
++while [ $fname != "" ]
+ do
+ print_verbose "Processing directory $fname"
+ echo "0:@:$fname" >> $tmpdir/rarian-updates
+ am_adding_dir $fname
+- if [[ ! $(ls $fname 2>&1) ]]
++ if [ ! $(ls $fname 2>&1) ]
+ then
+ print_verbose "Previous directory $fname no longer exists"
+ else
+- if [[ $am_processing != "0" ]]
++ if [ $am_processing != "0" ]
+ then
+ process_directory
+ else
+@@ -397,22 +379,18 @@
+ fi
+ done
+
+-for i in ${real_convert[@]}
++for i in ${real_convert}
+ do
+- if [[ $i != "0" ]]
+- then
+ res=$(ls $i 2>/dev/null)
+- if [[ ! $res ]]
++ if [ ! $res ]
+ then
+ print_verbose "Path $i does not exist. Ignoring"
+ else
+-
+ print_verbose "Adding contents of directory $i"
+ fname=$i
+ echo "0:@:$fname" >> $tmpdir/rarian-updates
+ add_all_files
+ fi
+- fi
+ done
+
+ rm -f $statedir/rarian-update-mtimes
+@@ -422,4 +400,4 @@
+ fi
+ rm -rf $tmpdir
+
+-fi # ENABLE_OMF_READ
+\ No newline at end of file
++fi # ENABLE_OMF_READ
--- patch.rarian ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list