diff options
Diffstat (limited to 'bin/build-docs')
-rw-r--r-- | bin/build-docs/Makefile | 69 | ||||
-rw-r--r-- | bin/build-docs/README | 95 | ||||
-rw-r--r-- | bin/build-docs/build-docs | 173 | ||||
-rw-r--r-- | bin/build-docs/build-docs.conf | 26 | ||||
-rw-r--r-- | bin/build-docs/build-docs.cron | 10 | ||||
-rw-r--r-- | bin/build-docs/build-docs.spec | 65 |
6 files changed, 438 insertions, 0 deletions
diff --git a/bin/build-docs/Makefile b/bin/build-docs/Makefile new file mode 100644 index 0000000..10ee145 --- /dev/null +++ b/bin/build-docs/Makefile @@ -0,0 +1,69 @@ +VERSION=$(shell awk '/Version:/ { print $$2 }' build-docs.spec) +RELEASE=$(shell awk '/Release:/ { print $$2 }' build-docs.spec) +CVSTAG=r$(subst .,-,$(VERSION)) + +PREFIX=/usr +BINDIR=$(PREFIX)/bin +DATADIR=$(PREFIX)/share +LOCALSTATEPREFIX=/var +LOCALSTATEDIR=$(LOCALSTATEPREFIX)/lib +DOCDIR=$(DATADIR)/doc +PKGNAME=build-docs +PKGLOCALSTATEDIR=$(LOCALSTATEDIR)/$(PKGNAME) +PKGDOCDIR=$(DOCDIR)/$(PKGNAME)-$(VERSION) + +SOURCEDIR := $(shell pwd) + +default: +.PHONY: default + +.PHONY: tarball +tarball: clean + rm -rf /tmp/$(PKGNAME)-$(VERSION) + mkdir -p /tmp/$(PKGNAME)-$(VERSION) + cp -a * /tmp/$(PKGNAME)-$(VERSION) + tar -C /tmp --exclude CVS --bzip2 -cSpf $(PKGNAME)-$(VERSION).tar.bz2 $(PKGNAME)-$(VERSION) + rm -rf /tmp/$(PKGNAME)-$(VERSION) + +srpm: tarball + rpmbuild --define "_srcrpmdir $(SOURCEDIR)" -ts $(PKGNAME)-$(VERSION).tar.bz2 + +install: + @[ "x$(INSTROOT)" != "x" ] || echo -e "\nWARNING\nWARNING: Installation using make is discouraged, try RPMs instead!\nWARNING\n" + mkdir -p $(INSTROOT) + mkdir -p $(INSTROOT)$(BINDIR) + mkdir -p $(INSTROOT)$(PKGLOCALSTATEDIR) + @if [ "$(DISABLECRON)" != "1" ]; then \ + mkdir -p $(INSTROOT)/etc/cron.hourly ; \ + install -b $(PKGNAME).conf $(INSTROOT)/etc/$(PKGNAME).conf ; \ + install $(PKGNAME).cron $(INSTROOT)/etc/cron.hourly/$(PKGNAME).cron ; \ + fi + install -m755 $(PKGNAME) $(INSTROOT)$(BINDIR)/$(PKGNAME) + +install-docs: + @[ "x$(INSTROOT)" != "x" ] || echo -e "\nWARNING\nWARNING: Installation using make is discouraged, try RPMs instead!\nWARNING\n" + mkdir -p $(INSTROOT)$(DOCDIR) + install README $(INSTROO)$(DOCDIR)/README + +uninstall: + @rm -fv $(INSTROOT)/etc/cron.hourly/$(PKGNAME).cron + @rm -fv $(INSTROOT)$(BINDIR)/$(PKGNAME) + @-rmdir -v --ignore-fail-on-non-empty $(INSTROOT)/etc/cron.hourly + @-rmdir -v --ignore-fail-on-non-empty $(INSTROOT)/etc + @-rmdir -v --ignore-fail-on-non-empty $(INSTROOT)$(PKGLOCALSTATEDIR) + @-rmdir -v --ignore-fail-on-non-empty $(INSTROOT)$(LOCALSTATEDIR) + @-rmdir -v --ignore-fail-on-non-empty $(INSTROOT)$(LOCALSTATEPREFIX) + @-rmdir -v --ignore-fail-on-non-empty $(INSTROOT)$(DATADIR) + @-rmdir -v --ignore-fail-on-non-empty $(INSTROOT)$(BINDIR) + @-rmdir -v --ignore-fail-on-non-empty $(INSTROOT)$(PREFIX) + +uninstall-docs: + @rm -fv $(INSTROOT)$(DOCDIR)/README + @-rmdir -v --ignore-fail-on-non-empty $(INSTROOT)$(DOCDIR) + @-rmdir -v --ignore-fail-on-non-empty $(INSTROOT)$(DATADIR) + @-rmdir -v --ignore-fail-on-non-empty $(INSTROOT)$(PREFIX) + +.PHONY: clean +clean: + @rm -fv $(PKGNAME)-$(VERSION)-$(RELEASE).src.rpm + @rm -fv $(PKGNAME)-$(VERSION).tar.bz2 diff --git a/bin/build-docs/README b/bin/build-docs/README new file mode 100644 index 0000000..f0c9e24 --- /dev/null +++ b/bin/build-docs/README @@ -0,0 +1,95 @@ +build-docs - Fedora Documentation builder script +Main script written by Paul W. Frields <stickster@gmail.com> +Packaged by Patrick Barnes <nman64@n-man.com> + +== About == + +The build-docs script is used by the Fedora Documentation Project to +build the latest documents in CVS for viewing by others without a testing +sandbox. It is intended to build HTML (and potentially other) documents for +presentation on a local web server. + +This package also includes a cron job that can run the build process once each +hour. This requires the crontabs package to be installed. The cron job is +normally installed but disabled by default. You can disable it's installation +when building the RPM -- see below. To enable the cron job after installation, +see the file /etc/build-docs.conf for instructions. + +== Installation == + +The recommended method for installing this package is using RPM. + +Note that this document demonstrates using 'sudo' to gain root privileges. You +may need or want to use another method, such as 'su'. + +=== Using RPM & yum === + +If you already have an RPM package, you can use yum to install it. + + sudo yum localinstall build-docs-<version>.noarch.rpm + +==== Building Your Own RPM ==== + +If you are working from a source directory or tarball, you can make an RPM +to install easily. You will need rpmbuild (found in the rpm-build package) +installed on the system. Note that it is considered poor practice to build +packages as root. Dag Wieers has an excellent HOWTO for creating a non-root +RPM-building environment: http://dag.wieers.com/howto/bits/rpm-build-user.php + +First build an SRPM: + + make srpm + +Next, build the RPM from the SRPM: + + rpmbuild --rebuild build-docs-<version>.src.rpm + + Where <version> is replaced by the version of the package you are building. + * If you do not want to use the cron job, you can disable its installation + and the dependency on crontabs: + + rpmbuild --rebuild --define "_without_cron 1" build-docs-... + +Finally, install the package: + + cd /path/to/your/rpm + sudo yum localinstall build-docs-<version>.noarch.rpm + + If you don't know where the RPM was built, look at the output from rpmbuild. + +=== Using make === + +Installing the package using make is not recommended. See the +'Using RPM & yum' section above. To install the package using make: + + make install + + * If you do not want to use the cron job, you can disable its installation: + + make DISABLECRON=1 install + +Uninstallation is also available: + + make uninstall + +== Usage == + + build-docs [options...] + +Where options can be one or more of: + + -h : print usage + -m WORKDIR : set home directory, default '~' + -f FDPDIR : set d/l dir for CVS, default '~/fdpdocs-cvs<datetag>' + -D TARGETDIR : set target dir for built files, + default '/var/www/webtest/docs' + -a ANONCVS : set CVS repo location (cvs -d), default + ':pserver:anonymous@cvs.fedora.redhat.com:/cvs/docs' + -r REV : checkout REV from CVS (global), default 'HEAD' + -Q : make CVS checkout less quiet + -c : build chunked HTML + -n : build HTML nochunks + -p : build PDF (not working currently) + -t : build tarball + -k : continue building in face of errors + diff --git a/bin/build-docs/build-docs b/bin/build-docs/build-docs new file mode 100644 index 0000000..c460c98 --- /dev/null +++ b/bin/build-docs/build-docs @@ -0,0 +1,173 @@ +#!/bin/bash +# +# Written by stickster :) +# Mangled by megacoder ;-P +# Further editing and packaging by nman64 +# +# Dedicated to the lazy Fedora Docs heroes. ;-) +# +# Pull all active FDP docs from CVS, build and install HTML in +# TARGETDIR folder. +# + +MYSELF="$(basename "$0")" +NOW="$(date +%Y%m%d%H%M%S)" + +print_usage() { + echo "$MYSELF: Usage: $MYSELF [options...]" + echo " -h : print usage (this message)" + echo " -m WORKDIR : set home directory, default $HOME" + echo " -f FDPDIR : set d/l dir for CVS, default $FDPDIR" + echo " -D TARGETDIR : set target dir for built files, default $TARGETDIR" + echo " -a ANONCVS : set CVS repo location (cvs -d), default $ANONCVS" + echo " -r REV : checkout REV from CVS (global), default $REV" + echo " -Q : make CVS checkout less quiet" + echo " -c : build chunked HTML" + echo " -n : build HTML nochunks" + echo " -p : build PDF (not working currently)" + echo " -t : build tarball" + echo " -k : continue building in face of errors" +} + + +set_vars() { + [ -z "$WORKDIR" ] && WORKDIR="${HOME}" + [ -z "$FDPDIR" ] && FDPDIR="${WORKDIR}/fdpdocs-cvs${NOW}" + [ -z "$TARGETDIR" ] && TARGETDIR="/var/www/webtest/docs" + # Do this anonymously for now + [ -z "$ANONCVS" ] && ANONCVS=":pserver:anonymous@cvs.fedora.redhat.com:/cvs/docs" + [ -z "$REV" ] && REV="HEAD" + [ -z "$REDIR" ] && REDIR="/dev/null" + [ -z "$QUIET" ] && QUIET="-Q" +} + + +# just to make sure defaults are read +unset FDPDIR HTMLDIR ANONCVS TAG CHUNKS NOCHUNKS PDF TARBALL VERBOSE +unset KEEPON +BUILDS=0 + +while getopts "m:f:D:a:r:Qcnpthvk" OPT; do + case $OPT in + m ) + WORKDIR="$OPTARG" + ;; + f ) + FDPDIR="$OPTARG" + ;; + D ) + TARGETDIR="$OPTARG" + ;; + a ) + ANONCVS="$OPTARG" + ;; + r ) + REV="$OPTARG" + ;; + Q ) + QUIET="-q" + ;; + c ) + CHUNKS="yes" + BUILDS=$(($BUILDS+1)) + ;; + n ) + NOCHUNKS="yes" + BUILDS=$(($BUILDS+1)) + ;; + p ) + PDF="yes" # But PDF doesn't work yet, don't do this! + BUILDS=$(($BUILDS+1)) + ;; + t ) + TARBALL="yes" + BUILDS=$(($BUILDS+1)) + ;; + h ) + set_vars + print_usage + exit 0 + ;; + v ) + REDIR="/dev/stdout" + ;; + k ) + KEEPON="-k" + ;; + * ) + echo "$MYSELF: invalid option: $OPT" + print_usage + exit 10 + ;; + esac +done +shift $(($OPTIND - 1)) + + +if [ $BUILDS -lt 1 ]; then + echo "$MYSELF: nothing to do, try selecting one of [-c|-n|-p|-t]" + exit 20 +fi + + +set_vars +mkdir "${FDPDIR}" || ( echo "Could not mkdir ${FDPDIR}" ; exit 254 ) +mkdir -p "${TARGETDIR}" || ( echo "Could not mkdir ${FDPDIR}" ; exit 254 ) +pushd "${FDPDIR}" >/dev/null || ( echo "Could not pushd ${FDPDIR}" ; exit 253 ) + + +echo "Checking out docs-common from Fedora Docs CVS" +#cvs -d $ANONCVS login +cvs "$QUIET" -z3 -d $ANONCVS co docs-common + +# for DOC in `cat docs-common/bin/active`; do +xargs -n1 echo <docs-common/bin/active | +while read DOC; +do + DONE="" + echo "Checking out module $DOC from Fedora Docs CVS" + cvs "$QUIET" -z3 -d $ANONCVS co $DOC 2>&1 > $REDIR + pushd "$DOC" >/dev/null || (echo "Couldn't cd to $DOCDIR" ; exit 252 ) + make showvars > tmpvars + . tmpvars + rm -f tmpvars + if [ "$CHUNKS" = "yes" ]; then + echo "Making chunked HTML for ${DOCBASE}" + make ${KEEPON} html 2>&1 > $REDIR || ( echo "$MYSELF: CHUNKS failed" ;\ + exit 251 ) + for LANG in $LANGUAGES ; do + DESTDIR="${TARGETDIR}/${DOCBASE}/${LANG}" + [ ! -d "$DESTDIR" ] && mkdir -p $DESTDIR + cp -r "${DOCBASE}-${LANG}/"* "${DESTDIR}" + done + fi + if [ "$NOCHUNKS" = "yes" ]; then + echo "Making nochunks HTML for ${DOCBASE}" + make ${KEEPON} html-nochunks 2>&1 > $REDIR || + ( echo "$MYSELF: NOCHUNKS failed" ; exit 251 ) + for LANG in $LANGUAGES ; do + DESTDIR="${TARGETDIR}/${DOCBASE}/" # add $LANG if desired + [ ! -d "$DESTDIR" ] && mkdir -p $DESTDIR + cp -r "${DOCBASE}-${LANG}.html" "${DESTDIR}" + done + fi + if [ "$TARBALL" = "yes" ]; then + echo "Making tarball for ${DOCBASE}" + make tarball 2>&1 > $REDIR || ( echo "$MYSELF: TARBALL failed" ;\ + exit 251 ) + for LANG in $LANGUAGES ; do + DESTDIR="${TARGETDIR}/${DOCBASE}/" # add $LANG if desired + [ ! -d "$DESTDIR" ] && mkdir -p $DESTDIR + cp -r "${DOCBASE}-${LANG}.tar.gz" "${DESTDIR}" + done + fi + + popd >/dev/null + +done + + +popd >/dev/null +[ "$FDPDIR" != "/" ] && [ "$FDPDIR" != "$HOME" ] && rm -rf "${FDPDIR}" +exit 0 + diff --git a/bin/build-docs/build-docs.conf b/bin/build-docs/build-docs.conf new file mode 100644 index 0000000..f2fce89 --- /dev/null +++ b/bin/build-docs/build-docs.conf @@ -0,0 +1,26 @@ +## Configuration for build-docs cron job + +# +# ENABLE_HOURLY_BUILD, if set to 'yes', will enable the hourly cron +# job that runs the build-docs script. +# +#ENABLE_HOURLY_BUILD=yes + +# +# BDR, if set, should point to the absolute path where the main +# build-docs script is located. +# +#BDR="build-docs" + +# +# BDRFLAGS, if set, should contain the desired flags to be passed +# to the build-docs script. +# +#BDRFLAGS="-c -m /var/lib/build-docs" + +# +# LOGFILE, if set, should point to the location where you want the +# build-docs script output to be written. +# +#LOGFILE="/var/log/build-docs.log" + diff --git a/bin/build-docs/build-docs.cron b/bin/build-docs/build-docs.cron new file mode 100644 index 0000000..6c45ce1 --- /dev/null +++ b/bin/build-docs/build-docs.cron @@ -0,0 +1,10 @@ +#!/bin/sh +. /etc/build-docs.conf +[ "${ENABLE_HOURLY_BUILD}" == "yes" ] || exit 0 +[ "x" == "x${BDR}" ] && BDR="build-docs" +[ "x" == "x${BDRFLAGS}" ] && BDRFLAGS="-c -m /var/lib/build-docs" +[ "x" == "x${LOGFILE}" ] && LOGFILE="/var/log/build-docs.log" +echo "Starting build-docs at `date -uR`..." >> $LOGFILE +$BDR $BDRFLAGS &> $LOGFILE 2>&1 +echo "Finished build-docs at `date -uR`..." >> $LOGFILE +exit 0 diff --git a/bin/build-docs/build-docs.spec b/bin/build-docs/build-docs.spec new file mode 100644 index 0000000..008b64a --- /dev/null +++ b/bin/build-docs/build-docs.spec @@ -0,0 +1,65 @@ +Summary: A simple script and cron job to build Fedora Documentation +Name: build-docs +Version: 0.0.3 +Release: 1 +URL: http://fedoraproject.org/wiki/DocsProject +License: GPL +ExclusiveOS: Linux +Group: Applications/Publishing +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root +BuildArch: noarch +Source0: %{name}-%{version}.tar.bz2 +Requires: xmlto docbook-utils docbook-utils-pdf cvs +%{!?_without_cron:Requires: crontabs} + +%description +build-docs is a script that builds Fedora Documentation. +rpmbuild options: + --define "_without_cron 1" Disables installation of hourly cron job + (default: cron job is installed but disabled) + +%prep +%setup -q + +%build +make + +%install +make INSTROOT=$RPM_BUILD_ROOT %{?_without_cron:DISABLECRON=1} install + +%clean +rm -rf $RPM_BUILD_ROOT + +%post + +%preun + +%postun + +%files +%defattr(-,root,root) +%doc README +%dir /var/lib/%{name} +%attr(0744,root,root) /usr/bin/%{name} +%if 0%{!?_without_cron:1} +%attr(0744,root,root) /etc/cron.hourly/%{name}.cron +%attr(0644,root,root) %config /etc/%{name}.conf +%endif + +%changelog +* Sat Dec 17 2005 Patrick Barnes <nman64@n-man.com> +- Renamed package to build-docs +- Updated script now allows -k flag +- Incremented version to 0.0.3 + +* Fri Dec 02 2005 Patrick Barnes <nman64@n-man.com> +- Added last Requires +- Allowed disabling of cron job +- Incremented version to 0.0.2 + +* Fri Dec 2 2005 Paul W. Frields <stickster@gmail.com> +- Added Requires and changed to valid Group + +* Thu Dec 01 2005 Patrick Barnes <nman64@n-man.com> +- Initial packaging + |