Make this oldie not depend on bash(1) anymore.

From FreeBSD #186879.

tested in a bulk
This commit is contained in:
ajacoutot 2015-07-25 04:25:57 +00:00
parent 473a9b23a5
commit b30e95640a
5 changed files with 278 additions and 23 deletions

View File

@ -1,17 +1,16 @@
# $OpenBSD: Makefile,v 1.22 2015/04/17 09:54:10 ajacoutot Exp $
# $OpenBSD: Makefile,v 1.23 2015/07/25 04:25:57 ajacoutot Exp $
COMMENT= documentation metadata library
GNOME_PROJECT= rarian
GNOME_VERSION= 0.8.1
EXTRACT_SUFX= .tar.bz2
REVISION= 14
SHARED_LIBS += rarian 0.0 # .0.0
CATEGORIES= textproc
REVISION= 13
HOMEPAGE= http://rarian.freedesktop.org/
# LGPLv2.1/GPLv2
@ -21,20 +20,20 @@ WANTLIB += c m stdc++
MODULES= x11/gnome
BUILD_DEPENDS= shells/bash \
textproc/libxslt
BUILD_DEPENDS= textproc/libxslt
RUN_DEPENDS= shells/bash \
textproc/docbook \
RUN_DEPENDS= textproc/docbook \
textproc/libxslt
CONFIGURE_STYLE= gnu
CONFIGURE_ARGS= --disable-skdb-update
CONFIGURE_ENV= ac_cv_path_have_bash=/bin/sh
# The .in files in ${WRKSRC}/util/ don't have a newline at the end
# of the file, which causes diff(1) to puke.
post-extract:
@echo "" >> ${WRKSRC}/util/rarian-sk-*.in
@echo >> ${WRKSRC}/util/rarian-sk-*.in
@echo >> ${WRKSRC}/util/rarian-sk-extract.in
pre-configure:
${SUBST_CMD} ${WRKSRC}/librarian/rarian-main.c \

View File

@ -1,6 +1,9 @@
$OpenBSD: patch-util_rarian-sk-config_in,v 1.2 2015/04/17 09:54:10 ajacoutot Exp $
--- util/rarian-sk-config.in.orig Sat Nov 22 16:51:42 2008
+++ util/rarian-sk-config.in Sat Nov 22 16:52:06 2008
$OpenBSD: patch-util_rarian-sk-config_in,v 1.3 2015/07/25 04:25:57 ajacoutot Exp $
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=186879
--- util/rarian-sk-config.in.orig Mon Sep 1 20:40:21 2008
+++ util/rarian-sk-config.in Thu Jul 23 08:58:45 2015
@@ -8,7 +8,7 @@ prefix=@prefix@
exec_prefix=@exec_prefix@
bindir=@bindir@
@ -10,3 +13,12 @@ $OpenBSD: patch-util_rarian-sk-config_in,v 1.2 2015/04/17 09:54:10 ajacoutot Exp
datarootdir=@datarootdir@
datadir=@datadir@
output_dir=${datadir}/help
@@ -36,7 +36,7 @@ print_help()
}
-if [[ $# != 1 ]]
+if [ $# != 1 ]
then
print_help
exit

View File

@ -0,0 +1,24 @@
$OpenBSD: patch-util_rarian-sk-extract_in,v 1.1 2015/07/25 04:25:57 ajacoutot Exp $
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=186879
--- util/rarian-sk-extract.in.orig Thu Jul 23 08:56:56 2015
+++ util/rarian-sk-extract.in Thu Jul 23 08:56:56 2015
@@ -11,7 +11,7 @@ print_usage()
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,7 +24,7 @@ while true; do
xsltproc --xinclude --xincludestyle $1 $infile > $2
#echo "xml: $infile style: $1 out: $2"
shift 2
- if [[ $# < 2 ]];
+ if [ $# -lt 2 ];
then
break
fi

View File

@ -1,6 +1,9 @@
$OpenBSD: patch-util_rarian-sk-rebuild_in,v 1.2 2015/04/17 09:54:10 ajacoutot Exp $
--- util/rarian-sk-rebuild.in.orig Sat Nov 22 16:51:42 2008
+++ util/rarian-sk-rebuild.in Sat Nov 22 16:51:59 2008
$OpenBSD: patch-util_rarian-sk-rebuild_in,v 1.3 2015/07/25 04:25:57 ajacoutot Exp $
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=186879
--- util/rarian-sk-rebuild.in.orig Mon Sep 1 20:40:21 2008
+++ util/rarian-sk-rebuild.in Thu Jul 23 08:39:13 2015
@@ -9,7 +9,7 @@ exec_prefix=@exec_prefix@
bindir=@bindir@
convert_dir=@CONVERT_DIR@
@ -10,3 +13,12 @@ $OpenBSD: patch-util_rarian-sk-rebuild_in,v 1.2 2015/04/17 09:54:10 ajacoutot Ex
datadir=@datadir@
output_dir=${datadir}/help
package_version=@PACKAGE_VERSION@
@@ -22,7 +22,7 @@ if [ -e $statedir/rarian-update-mtimes ]
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

View File

@ -1,10 +1,12 @@
$OpenBSD: patch-util_rarian-sk-update_in,v 1.4 2015/04/17 09:54:10 ajacoutot Exp $
$OpenBSD: patch-util_rarian-sk-update_in,v 1.5 2015/07/25 04:25:57 ajacoutot Exp $
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=186879
Only GNU getopt supports long options.
--- util/rarian-sk-update.in.orig Mon Sep 1 20:40:21 2008
+++ util/rarian-sk-update.in Sat Feb 14 16:34:32 2009
@@ -19,7 +19,7 @@
+++ util/rarian-sk-update.in Thu Jul 23 08:45:14 2015
@@ -19,13 +19,13 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
bindir=@bindir@
@ -13,6 +15,13 @@ Only GNU getopt supports long options.
convert_dir=@CONVERT_DIR@
datarootdir=@datarootdir@
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
@@ -57,7 +57,7 @@ print_usage()
echo -e "\t\t\t\tscrolls. If the directory doesn't exist, it"
echo -e "\t\t\t\twill be created at run time."
@ -22,7 +31,16 @@ Only GNU getopt supports long options.
echo -e "\t\t\t\tall scroll files and may take a long time."
echo -e "-v\t\t\t\tTurn Verbosity on."
echo -e "-p\t\t\t\tSpecify a different place to store the mtimes file."
@@ -112,7 +112,7 @@ process_dir()
@@ -97,7 +97,7 @@ process_dir()
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
@@ -112,41 +112,24 @@ process_dir()
fi
fi
done
@ -30,17 +48,141 @@ Only GNU getopt supports long options.
+ echo -e `stat -f %Y $1`':@:'$1':@:'$fname_list >> $tmpdir/rarian-updates
}
# Split up the omf dirs specified on the command line
@@ -221,7 +221,7 @@ process_directory ()
-# 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
+ else
+ tmplist="$tmplist $i"
fi
- let counter+=1
done
}
if [[ $am_processing != "0" ]]
@@ -156,7 +139,7 @@ skip_directory ()
{
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 @@ add_all_files ()
# 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 @@ dirs_contains ()
# 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 ]]
+ new_time=`stat -f %Y $name`
if [[ $new_time -ne $old_time ]]
+ if [ $new_time -ne $old_time ]
then
print_verbose "Directory $name has changed. Updating."
@@ -264,9 +264,7 @@ process_directory ()
process_dir $name
@@ -231,7 +213,7 @@ process_directory ()
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 @@ process_directory ()
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
}
@@ -264,9 +243,7 @@ process_directory ()
# They are inherited from scrollkeeper :(
# We use TEMP as set -- seems to nuke the return value of getopt
@ -51,3 +193,69 @@ Only GNU getopt supports long options.
if [ $? != 0 ] ; then
print_usage
@@ -326,7 +303,10 @@ fi
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 +314,7 @@ then
# 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 +358,16 @@ read line
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 +377,18 @@ do
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