docs-common/bin fdp-functions,1.2,1.3
Tommy Reynolds (jtr)
fedora-docs-commits at redhat.com
Wed Jan 18 06:41:41 UTC 2006
Author: jtr
Update of /cvs/docs/docs-common/bin
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv22922
Modified Files:
fdp-functions
Log Message:
Added helper function 'iso2date' to convert YYYY-MM-DD into ctime(3)
format, as neded by the <revision at date> attributes.
Also added more error checking and usage hints.
Index: fdp-functions
===================================================================
RCS file: /cvs/docs/docs-common/bin/fdp-functions,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- fdp-functions 15 Jan 2006 23:26:25 -0000 1.2
+++ fdp-functions 18 Jan 2006 06:41:34 -0000 1.3
@@ -1,7 +1,8 @@
-#!/bin/sh
+########################################################################
#
# Some common functions for use in other FDP scripts
#
+########################################################################
FDPDIR=${FDPDIR:-".."}
@@ -15,26 +16,63 @@
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 at 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
}
More information about the Fedora-docs-commits
mailing list