From f3814eaafa3e4a0af75ef2c2ee8e5facaaa4c4c6 Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Thu, 23 Jan 2014 12:12:14 -0600 Subject: [PATCH] Improved error handling --- doc/scripts/docbook.sh | 16 +++++++++++++++- doc/scripts/gettext.sh | 18 ++++++++++++++++-- doc/scripts/gtkdoc.sh | 20 +++++++++++++++++--- doc/scripts/pkgconfig.sh | 28 ++++++++++++++++++++++++---- doc/scripts/subst.sh | 27 ++++++++++++++++++++++++--- 5 files changed, 96 insertions(+), 13 deletions(-) diff --git a/doc/scripts/docbook.sh b/doc/scripts/docbook.sh index cd4286d..8772306 100755 --- a/doc/scripts/docbook.sh +++ b/doc/scripts/docbook.sh @@ -26,7 +26,7 @@ #variables PREFIX="/usr/local" -. "../config.sh" +[ -f "../config.sh" ] && . "../config.sh" #executables DEBUG="_debug" INSTALL="install -m 0644" @@ -44,6 +44,14 @@ _debug() } +#error +_error() +{ + echo "docbook.sh: $@" 1>&2 + return 2 +} + + #usage _usage() { @@ -84,6 +92,12 @@ if [ $# -eq 0 ]; then exit $? fi +#check the variables +if [ -z "$PACKAGE" ]; then + _error "The PACKAGE variable needs to be set" + exit $? +fi + [ -z "$DATADIR" ] && DATADIR="$PREFIX/share" [ -z "$MANDIR" ] && MANDIR="$DATADIR/man" diff --git a/doc/scripts/gettext.sh b/doc/scripts/gettext.sh index 4286018..d7d1962 100755 --- a/doc/scripts/gettext.sh +++ b/doc/scripts/gettext.sh @@ -1,6 +1,6 @@ #!/bin/sh #$Id$ -#Copyright (c) 2010-2013 Pierre Pronchery +#Copyright (c) 2010-2014 Pierre Pronchery # #Redistribution and use in source and binary forms, with or without #modification, are permitted provided that the following conditions are met: @@ -26,7 +26,7 @@ #variables PREFIX="/usr/local" -. "../config.sh" +[ -f "../config.sh" ] && . "../config.sh" LOCALEDIR="$PREFIX/share/locale" POTFILES="POTFILES" #executables @@ -49,6 +49,14 @@ _debug() } +#error +_error() +{ + echo "gettext.sh: $@" 1>&2 + return 2 +} + + #usage _usage() { @@ -125,6 +133,12 @@ if [ $# -eq 0 ]; then exit $? fi +#check the variables +if [ -z "$PACKAGE" ]; then + _error "The PACKAGE variable needs to be set" + exit $? +fi + LOCALEDIR="$PREFIX/share/locale" while [ $# -gt 0 ]; do target="$1" diff --git a/doc/scripts/gtkdoc.sh b/doc/scripts/gtkdoc.sh index 6dddc47..86de5d4 100755 --- a/doc/scripts/gtkdoc.sh +++ b/doc/scripts/gtkdoc.sh @@ -1,6 +1,6 @@ #!/bin/sh #$Id$ -#Copyright (c) 2012-2013 Pierre Pronchery +#Copyright (c) 2012-2014 Pierre Pronchery # #Redistribution and use in source and binary forms, with or without #modification, are permitted provided that the following conditions are met: @@ -26,8 +26,7 @@ #variables PREFIX="/usr/local" -. "../config.sh" -MODULE="$PACKAGE" +[ -f "../config.sh" ] && . "../config.sh" #executables DEBUG="_debug" GTKDOC_FIXXREF="gtkdoc-fixxref" @@ -50,6 +49,14 @@ _debug() } +#error +_error() +{ + echo "gtkdoc.sh: $@" 1>&2 + return 2 +} + + #usage _usage() { @@ -90,6 +97,13 @@ if [ $# -eq 0 ]; then exit $? fi +#check the variables +if [ -z "$PACKAGE" ]; then + _error "The PACKAGE variable needs to be set" + exit $? +fi +MODULE="$PACKAGE" + [ -z "$DATADIR" ] && DATADIR="$PREFIX/share" instdir="$DATADIR/gtk-doc/html" diff --git a/doc/scripts/pkgconfig.sh b/doc/scripts/pkgconfig.sh index 2350501..cac86f9 100755 --- a/doc/scripts/pkgconfig.sh +++ b/doc/scripts/pkgconfig.sh @@ -1,6 +1,6 @@ #!/bin/sh #$Id$ -#Copyright (c) 2011-2013 Pierre Pronchery +#Copyright (c) 2011-2014 Pierre Pronchery # #Redistribution and use in source and binary forms, with or without #modification, are permitted provided that the following conditions are met: @@ -26,7 +26,7 @@ #variables PREFIX="/usr/local" -. "../config.sh" +[ -f "../config.sh" ] && . "../config.sh" DEBUG="_debug" DEVNULL="/dev/null" #executables @@ -45,6 +45,14 @@ _debug() } +#error +_error() +{ + echo "pkgconfig.sh: $@" 1>&2 + return 2 +} + + #usage _usage() { @@ -85,6 +93,16 @@ if [ $# -eq 0 ]; then exit $? fi +#check the variables +if [ -z "$PACKAGE" ]; then + _error "The PACKAGE variable needs to be set" + exit $? +fi +if [ -z "$VERSION" ]; then + _error "The VERSION variable needs to be set" + exit $? +fi + PKGCONFIG="$PREFIX/lib/pkgconfig" while [ $# -gt 0 ]; do target="$1" @@ -118,9 +136,11 @@ while [ $# -gt 0 ]; do fi #create - $DEBUG $SED -e "s;@PREFIX@;$PREFIX;" \ + $DEBUG $SED -e "s;@PACKAGE@;$PACKAGE;" \ -e "s;@VERSION@;$VERSION;" \ - -e "s;@RPATH@;$RPATH;" -- "$target.in" > "$target" + -e "s;@PREFIX@;$PREFIX;" \ + -e "s;@RPATH@;$RPATH;" \ + -- "$target.in" > "$target" if [ $? -ne 0 ]; then $DEBUG $RM -- "$target" exit 2 diff --git a/doc/scripts/subst.sh b/doc/scripts/subst.sh index 7bb330d..a51d6ae 100755 --- a/doc/scripts/subst.sh +++ b/doc/scripts/subst.sh @@ -1,6 +1,6 @@ #!/bin/sh #$Id$ -#Copyright (c) 2012-2013 Pierre Pronchery +#Copyright (c) 2012-2014 Pierre Pronchery #This program is free software: you can redistribute it and/or modify #it under the terms of the GNU General Public License as published by #the Free Software Foundation, version 3 of the License. @@ -36,6 +36,14 @@ _debug() } +#error +_error() +{ + echo "subst.sh: $@" 1>&2 + return 2 +} + + #usage _usage() { @@ -76,6 +84,16 @@ if [ $# -eq 0 ]; then exit $? fi +#check the variables +if [ -z "$PACKAGE" ]; then + _error "The PACKAGE variable needs to be set" + exit $? +fi +if [ -z "$VERSION" ]; then + _error "The VERSION variable needs to be set" + exit $? +fi + while [ $# -gt 0 ]; do target="$1" shift @@ -100,8 +118,11 @@ while [ $# -gt 0 ]; do fi #create - $DEBUG $SED -e "s,@PREFIX@,$PREFIX," \ - -e "s,@VERSION@,$VERSION," "$target.in" > "$target" + $DEBUG $SED -e "s,@PACKAGE@,$PACKAGE," \ + -e "s,@VERSION@,$VERSION," \ + -e "s,@PREFIX@,$PREFIX," \ + -e "s,@PWD@,$PWD," \ + -- "$target.in" > "$target" if [ $? -ne 0 ]; then $RM -- "$target" 2> "$DEVNULL" exit 2