summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTommy Reynolds <Tommy.Reynolds@MegaCoder.com>2006-01-18 06:41:34 +0000
committerTommy Reynolds <Tommy.Reynolds@MegaCoder.com>2006-01-18 06:41:34 +0000
commit6be28fcffa516ec96babf23970fe4381f2e30792 (patch)
tree285e7c02dc3d1cee2ff2c9837b72d5e7b33214f8
parent9fbc83b5c66a0fd0468e40db32171802035a640f (diff)
downloadfedora-doc-utils-6be28fcffa516ec96babf23970fe4381f2e30792.tar.gz
fedora-doc-utils-6be28fcffa516ec96babf23970fe4381f2e30792.tar.xz
fedora-doc-utils-6be28fcffa516ec96babf23970fe4381f2e30792.zip
Added helper function 'iso2date' to convert YYYY-MM-DD into ctime(3)
format, as neded by the <revision@date> attributes. Also added more error checking and usage hints.
-rw-r--r--bin/fdp-functions68
1 files changed, 53 insertions, 15 deletions
diff --git a/bin/fdp-functions b/bin/fdp-functions
index 320a6af..76179c9 100644
--- a/bin/fdp-functions
+++ b/bin/fdp-functions
@@ -1,7 +1,8 @@
-#!/bin/sh
+########################################################################
#
# Some common functions for use in other FDP scripts
#
+########################################################################
FDPDIR=${FDPDIR:-".."}
@@ -15,26 +16,63 @@ XMLFOPTS=${XMLFOPTS:-"-f ${FDPBINDIR}/xmlformat-fdp.conf"}
get_all_workers()
{
- # Return list of workers, in format "email:wholename"
- ${XSLTPROC} "${FDPPKGDIR}/get-all-workers.xsl" \
- "$RPMINFO" | sed 's/^ \+//g' | grep -v '^$' | cat -n
+ # Return list of workers, in format "email:wholename"
+ if [ ! -f "${RPMINFO}" ]; then
+ echo "$0: File '${RPMINFO}' missing." >&2
+ return 1
+ fi
+ ${XSLTPROC} "${FDPPKGDIR}/get-all-workers.xsl" \
+ "${RPMINFO}" | sed 's/^ \+//g' | grep -v '^$' | cat -n
}
get_worker_attribute()
{
- # Return an attribute for a specific worker
- if [ ! -z "$2" ]; then POS=$2 ; fi
- if [ ! -z "$1" ]; then ATT="$1" ; fi
- ${XSLTPROC} --stringparam att "$ATT" --param pos $POS \
- "${FDPPKGDIR}/get-worker.xsl" "$RPMINFO"
+ # Return an attribute for a specific worker
+ if [ ! -f "${RPMINFO}" ]; then
+ echo "$0: File '${RPMINFO}' missing." >&2
+ return 1
+ fi
+ if [ ! -z "$2" ]; then POS=$2 ; fi
+ if [ ! -z "$1" ]; then ATT="$1" ; fi
+ ${XSLTPROC} --stringparam att "${ATT}" --param pos $POS \
+ "${FDPPKGDIR}/get-worker.xsl" "${RPMINFO}"
}
-get_latest_revision()
+version()
{
- # Return latest revision for an optional role argument
- if [ ! -z "$1" ]; then
- OPTS="--stringparam role $1"
- fi
- ${XSLTPROC} ${OPTS} "${FDPPKGDIR}/doc-version.xsl" "$RPMINFO"
+ # Return latest revision for an optional role argument
+ # Don't gumble if we cannot find ${RPMINF}, because it
+ # may not have been created yet.
+ if [ ! -z "$1" ]; then
+ OPTS="--stringparam role $1"
+ fi
+ if [ -f "${RPMINFO}" ]; then
+ ${XSLTPROC} ${OPTS} "${FDPPKGDIR}/doc-version.xsl" "$RPMINFO"
+ else
+ echo -n XXX
+ fi
+ # The stylesheet doesn't put a NL at the end.
+ echo
+}
+
+iso2date() {
+ # Convert ISO format date (YYYY-MM-DD) to ctime(3)
+ # format, which is needed by the "rpm-info.xml" <revision@date>
+ case "$#" in
+ 0 ) echo -e "usage: iso2date YYYY-MM-DD ..." >&2
+ echo -e "\tiso2date YYYY-MM-DD" >&2
+ echo -e "\tiso2date today" >&2
+ return 1
+ ;;
+ 1 ) multi=0;;
+ * ) multi=1;;
+ esac
+ for x in $@
+ do
+ if [ ${multi} -eq 1 ]; then
+ echo -ne "${x}\t"
+ fi
+ date -d 2006-01-18 +'%a %b %d %Y'
+ done
}