From 144f1344adf60815c8c57e93b5ed0acf98bbc40f Mon Sep 17 00:00:00 2001 From: Daniel Joseph Barnhart Clark Date: Thu, 24 Aug 2006 03:21:17 +0000 Subject: EncapPackages: A bunch of changes, including but not limited to: * Cleaner directory structure * Numerous Makefile improvements * Makefile no longer tied to specific versions of encap packages (except in the case of python-apt, which is distro-specific) * Automatic dependancy generation from encap package files * bcfg2-site pretty much done git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@2103 ce84e21b-d406-0410-9b95-82705330c041 --- encap/src/bcfg2-site/Makefile | 26 ++++--- .../bcfg2-site/bcfg2-site-RENAME/encapinfo.tmpl | 2 + .../etc/default/bcfg2-client/.SENTINEL_SITE | 0 .../etc/default/bcfg2-server/.SENTINEL_SITE | 0 .../src/bcfg2-site/bcfg2-site-RENAME/mkinstalldirs | 32 +++++++++ encap/src/bcfg2-site/bcfg2-site-RENAME/postinstall | 81 ++++++++++++++++++++++ encap/src/bcfg2-site/bcfg2-site-RENAME/preinstall | 0 encap/src/bcfg2-site/site-settings.conf | 46 ------------ encap/src/bcfg2-site/site-settings.conf-example | 46 ++++++++++++ 9 files changed, 179 insertions(+), 54 deletions(-) delete mode 100644 encap/src/bcfg2-site/bcfg2-site-RENAME/etc/default/bcfg2-client/.SENTINEL_SITE delete mode 100644 encap/src/bcfg2-site/bcfg2-site-RENAME/etc/default/bcfg2-server/.SENTINEL_SITE create mode 100755 encap/src/bcfg2-site/bcfg2-site-RENAME/mkinstalldirs delete mode 100755 encap/src/bcfg2-site/bcfg2-site-RENAME/preinstall delete mode 100644 encap/src/bcfg2-site/site-settings.conf create mode 100644 encap/src/bcfg2-site/site-settings.conf-example (limited to 'encap/src/bcfg2-site') diff --git a/encap/src/bcfg2-site/Makefile b/encap/src/bcfg2-site/Makefile index e42ff2eb6..1f9063d9e 100644 --- a/encap/src/bcfg2-site/Makefile +++ b/encap/src/bcfg2-site/Makefile @@ -7,7 +7,7 @@ CHEETAH = /usr/local/lib/bcfg2/bin/cheetah # Main -.PHONY : all clean fill copy fix encap test cheetah +.PHONY : all clean distclean fill copy fix encap install test cheetah .SUFFIXES : BD = /usr/local @@ -23,36 +23,46 @@ clean : done; \ done +distclean : clean + -rm *-encap-*.tar.gz + fill : clean $(CHEETAH) fill -R --oext out copy : fill EN=`cat bcfg2-site-RENAME/encapname.out` && \ - ( test ! -d $$ED/bcfg2-site-$${EN} || rm -rf $$ED/bcfg2-site-$${EN} ) && \ + ( test ! -d $(ED)/bcfg2-site-$${EN} || rm -rf $(ED)/bcfg2-site-$${EN} ) && \ for SRC in `find bcfg2-site-RENAME | grep -v svn | grep -v tmpl`; do \ - DEST=$$ED/`printf "$$SRC" | sed s/RENAME/$$EN/g | sed s/\.out//g`; \ + DEST=$(ED)/`printf "$$SRC" | sed s/RENAME/$$EN/g | sed s/\.out//g`; \ if [ -d $$SRC ]; then mkdir $$DEST; else cp $$SRC $$DEST; fi; \ done fix : copy - EN="$$ED/bcfg2-site-`cat bcfg2-site-RENAME/encapname.out`" && \ + EN="$(ED)/bcfg2-site-`cat bcfg2-site-RENAME/encapname.out`" && \ chown -R 0 $$EN && chgrp -R 0 $$EN && \ find $$EN -type d | xargs -n1 chmod 0755 && \ find $$EN -type f | xargs -n1 chmod 0644 && \ chmod 0600 $$EN/etc/ostiary.cfg && \ chmod 0600 $$EN/etc/bcfg2.conf && \ chmod 0755 $$EN/sbin/ost-bcfg2.sh && \ - chmod 0755 $$EN/postinstall && \ - chmod 0755 $$EN/preinstall + chmod 0755 $$EN/postinstall encap : fix EN="bcfg2-site-`cat bcfg2-site-RENAME/encapname.out`" && \ - cd $$ED && \ + cd $(ED) && \ ( test ! -f $${EN}-encap-*.tar.gz || rm $${EN}-encap-*.tar.gz ) && \ mkencap -c $$EN EN="bcfg2-site-`cat bcfg2-site-RENAME/encapname.out`" && \ - mv $$ED/$${EN}-encap-*.tar.gz . + mv $(ED)/$${EN}-encap-*.tar.gz ./ +install : fix + -(EN="bcfg2-site-`cat bcfg2-site-RENAME/encapname.out`" && \ + epkg -q -r $(ED)/$$EN) + EN="bcfg2-site-`cat bcfg2-site-RENAME/encapname.out`" && \ + cd $(ED) && \ + epkg -q -i $(ED)/$$EN && \ + test -h $(BD)/var/encap/$$EN + test : : $(PATH) $(CHEETAH) test diff --git a/encap/src/bcfg2-site/bcfg2-site-RENAME/encapinfo.tmpl b/encap/src/bcfg2-site/bcfg2-site-RENAME/encapinfo.tmpl index e6af738ac..f54cb1e18 100644 --- a/encap/src/bcfg2-site/bcfg2-site-RENAME/encapinfo.tmpl +++ b/encap/src/bcfg2-site/bcfg2-site-RENAME/encapinfo.tmpl @@ -7,3 +7,5 @@ description bcfg2-site-${SITE_SHORTNAME} - bcfg2 configuration for ${SITE_NAME} prereq pkgspec >= bcfg2-0.8.2 prereq pkgspec >= daemontools-0.76 prereq pkgspec >= ostiary-3.4 +exclude etc +exclude sbin diff --git a/encap/src/bcfg2-site/bcfg2-site-RENAME/etc/default/bcfg2-client/.SENTINEL_SITE b/encap/src/bcfg2-site/bcfg2-site-RENAME/etc/default/bcfg2-client/.SENTINEL_SITE deleted file mode 100644 index e69de29bb..000000000 diff --git a/encap/src/bcfg2-site/bcfg2-site-RENAME/etc/default/bcfg2-server/.SENTINEL_SITE b/encap/src/bcfg2-site/bcfg2-site-RENAME/etc/default/bcfg2-server/.SENTINEL_SITE deleted file mode 100644 index e69de29bb..000000000 diff --git a/encap/src/bcfg2-site/bcfg2-site-RENAME/mkinstalldirs b/encap/src/bcfg2-site/bcfg2-site-RENAME/mkinstalldirs new file mode 100755 index 000000000..0801ec2c9 --- /dev/null +++ b/encap/src/bcfg2-site/bcfg2-site-RENAME/mkinstalldirs @@ -0,0 +1,32 @@ +#! /bin/sh +# mkinstalldirs --- make directory hierarchy +# Author: Noah Friedman +# Created: 1993-05-16 +# Last modified: 1994-03-25 +# Public domain + +errstatus=0 + +for file in ${1+"$@"} ; do + set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` + shift + + pathcomp= + for d in ${1+"$@"} ; do + pathcomp="$pathcomp$d" + case "$pathcomp" in + -* ) pathcomp=./$pathcomp ;; + esac + + if test ! -d "$pathcomp"; then + echo "mkdir $pathcomp" 1>&2 + mkdir "$pathcomp" || errstatus=$? + fi + + pathcomp="$pathcomp/" + done +done + +exit $errstatus + +# mkinstalldirs ends here diff --git a/encap/src/bcfg2-site/bcfg2-site-RENAME/postinstall b/encap/src/bcfg2-site/bcfg2-site-RENAME/postinstall index e69de29bb..4ed875e4c 100755 --- a/encap/src/bcfg2-site/bcfg2-site-RENAME/postinstall +++ b/encap/src/bcfg2-site/bcfg2-site-RENAME/postinstall @@ -0,0 +1,81 @@ +#!/bin/sh -e + +umask 002 +BASEDIR="${ENCAP_TARGET}" # Usually /usr/local +PKGDIR="${ENCAP_SOURCE}/${ENCAP_PKGNAME}" # Ususally /usr/local/encap/ +LOG="${PKGDIR}/postinstall.log" +MKINSTALLDIRS="${PKGDIR}/mkinstalldirs" +exec > $LOG 2>&1 + +printf "Running ${ENCAP_PKGNAME} postinstall script...\n" +date + +chmod 755 ${MKINSTALLDIRS} +${MKINSTALLDIRS} "${BASEDIR}/etc/default/bcfg2-client/env" +${MKINSTALLDIRS} "${BASEDIR}/etc/default/bcfg2-server/env" +${MKINSTALLDIRS} "${BASEDIR}/sbin" + +rmcp() { + SRCFILENAME="`basename ${1}`" + if [ -d "${2}" ]; then + DESTDIRNAME="$2" + else + DESTDIRNAME="`dirname ${2}`" + fi + TARGETNAME="$DESTDIRNAME/$SRCFILENAME" + if [ -h "$TARGETNAME" ]; then rm "$TARGETNAME"; fi + if [ -f "$TARGETNAME" ]; then rm "$TARGETNAME"; fi + cp "$1" "$2" +} + +if [ -f ${BASEDIR}/etc/default/bcfg2-client/.SENTINEL_BCFG2 ]; then + printf "INFO: bcfg2 client options have been updated by bcfg2 -\n" + printf "INFO: not replacing that configuration.\n" +elif [ -f ${BASEDIR}/etc/default/bcfg2-client/.SENTINEL_SITE ]; then + printf "INFO: bcfg2 client options have been previously updated -\n" + printf "INFO: not replacing that configuration.\n" +else + DIR="etc/default/bcfg2-client" + rmcp $PKGDIR/$DIR/env/RUN_INTERVAL_SECONDS ${BASEDIR}/$DIR/env/ + rmcp $PKGDIR/$DIR/env/OPTIONS ${BASEDIR}/$DIR/env/ + touch ${BASEDIR}/$DIR/.SENTINEL_SITE +fi + +if [ -f ${BASEDIR}/etc/default/bcfg2-server/.SENTINEL_BCFG2 ]; then + printf "INFO: bcfg2 server options have been updated by bcfg2 -\n" + printf "INFO: not replacing that configuration.\n" +elif [ -f ${BASEDIR}/etc/default/bcfg2-server/.SENTINEL_SITE ]; then + printf "INFO: bcfg2 server options have been previously updated -\n" + printf "INFO: not replacing that configuration.\n" +else + DIR="etc/default/bcfg2-server" + rmcp $PKGDIR/$DIR/env/OPTIONS ${BASEDIR}/$DIR/env/ + touch ${BASEDIR}/$DIR/.SENTINEL_SITE +fi + +if [ -f ${BASEDIR}/etc/.SENTINEL_BCFG2 ]; then + printf "INFO: bcfg2.conf and/or ostiary.cfg may have been updated by\n" + printf "INFO: bcfg2 - not replacing that configuration.\n" +elif [ -f ${BASEDIR}/etc/.SENTINEL_SITE ]; then + printf "INFO: bcfg2.conf and/or ostiary.cfg may have been previously\n" + printf "INFO: updated - not replacing that configuration.\n" +else + rmcp $PKGDIR/etc/bcfg2.conf ${BASEDIR}/etc/ + rmcp $PKGDIR/etc/ostiary.cfg ${BASEDIR}/etc/ + touch ${BASEDIR}/etc/.SENTINEL_SITE +fi + +if [ -f ${BASEDIR}/sbin/.SENTINEL_BCFG2 ]; then + printf "INFO: ost-bcfg2.sh may have been updated by bcfg2 -\n" + printf "INFO: not replacing that configuration with this script.\n" +elif [ -f ${BASEDIR}/sbin/.SENTINEL_SITE ]; then + printf "INFO: ost-bcfg2.sh may have been previously updated -\n" + printf "INFO: not replacing that configuration with this script.\n" +else + rmcp $PKGDIR/sbin/ost-bcfg2.sh ${BASEDIR}/sbin/ + touch ${BASEDIR}/sbin/.SENTINEL_SITE +fi + +printf "Finished ${ENCAP_PKGNAME} postinstall script.\n" + +exit 0 diff --git a/encap/src/bcfg2-site/bcfg2-site-RENAME/preinstall b/encap/src/bcfg2-site/bcfg2-site-RENAME/preinstall deleted file mode 100755 index e69de29bb..000000000 diff --git a/encap/src/bcfg2-site/site-settings.conf b/encap/src/bcfg2-site/site-settings.conf deleted file mode 100644 index c29ab36e2..000000000 --- a/encap/src/bcfg2-site/site-settings.conf +++ /dev/null @@ -1,46 +0,0 @@ -###### -###### Set these variables as appropriate for your site -###### -#### -#### Site Information -#### -#set global $ADMIN_NAME = "Local Admin Contact" -#set global $ADMIN_EMAIL = "tickets@localhost.localdomain.com" -#set global $SITE_NAME = "localdomain.com" -## SITE_SHORTNAME should be a single word with no punctuation -#set global $SITE_SHORTNAME = "localdomain" -## SITE_VERSION should be the version of this file, starting at 1 -#set global $SITE_VERSION = "1" -#### -#### Paths, Variables, and Passwords -#### -#set global $SENDMAILPATH = "/usr/sbin/sendmail" -#set global $BCFG2_SERVER = "config.localdomain.com" -#set global $BCFG2_PORT = "6" -#set global $OSTIARY_PORT = "7" -#set global $BCFG2_CLIENT_RUN_INTERVAL_SECONDS = "3600" -## Initial options for bcfg(1). The bcfg2 client is started with these options -## on installation and periodically based on BCFG2_CLIENT_RUN_INTERVAL_SECONDS, -## so you probably want to include the "-n" (dry-run mode) flag, unless you -## already have a good configuration in place. You can then change the config -## file /usr/local/etc/default/bcfg2-client/env/OPTIONS via the bcfg2 "Cfg" -## functionality (possibly by kicking off a non-dry from the bcfg2 server using -## ostiary, or just by running bcfg2 manually on the client) to run in non-dry- -## run mode. -#set global $BCFG2_CLIENT_OPTIONS = "-q -v -d -n" -## Initial options for bcfg2-server(8). Note that bcfg2-server is not fully -## configured by bcfg2-site; you need to edit /usr/local/etc/bcfg2.conf to -## include the "[server]" stanza and appropriate values, as well as a "key =" -## line in the "[communications]" stanza (see bcfg2 doc for details). -#set global $BCFG2_SERVER_OPTIONS = "-v" -## You can set passwords here, and you will not be prompted for them at -## install time; however you will then have to treat your bcfg2-site -## distribution as equivalent to the bcfg2 server and ostiary passwords. -## To be prompted for passwords at install time, make these empty string ("") -#set global $BCFG2_PASSWORD = "" -#set global $OSTIARY_PASSWORD = "" -###### -###### Automatically-set variables - you shouldn't have to touch these. -###### -#from time import localtime, strftime -#set global $DATE = strftime("%a %b %d %H:%M:%S %Z %Y", localtime()) diff --git a/encap/src/bcfg2-site/site-settings.conf-example b/encap/src/bcfg2-site/site-settings.conf-example new file mode 100644 index 000000000..c29ab36e2 --- /dev/null +++ b/encap/src/bcfg2-site/site-settings.conf-example @@ -0,0 +1,46 @@ +###### +###### Set these variables as appropriate for your site +###### +#### +#### Site Information +#### +#set global $ADMIN_NAME = "Local Admin Contact" +#set global $ADMIN_EMAIL = "tickets@localhost.localdomain.com" +#set global $SITE_NAME = "localdomain.com" +## SITE_SHORTNAME should be a single word with no punctuation +#set global $SITE_SHORTNAME = "localdomain" +## SITE_VERSION should be the version of this file, starting at 1 +#set global $SITE_VERSION = "1" +#### +#### Paths, Variables, and Passwords +#### +#set global $SENDMAILPATH = "/usr/sbin/sendmail" +#set global $BCFG2_SERVER = "config.localdomain.com" +#set global $BCFG2_PORT = "6" +#set global $OSTIARY_PORT = "7" +#set global $BCFG2_CLIENT_RUN_INTERVAL_SECONDS = "3600" +## Initial options for bcfg(1). The bcfg2 client is started with these options +## on installation and periodically based on BCFG2_CLIENT_RUN_INTERVAL_SECONDS, +## so you probably want to include the "-n" (dry-run mode) flag, unless you +## already have a good configuration in place. You can then change the config +## file /usr/local/etc/default/bcfg2-client/env/OPTIONS via the bcfg2 "Cfg" +## functionality (possibly by kicking off a non-dry from the bcfg2 server using +## ostiary, or just by running bcfg2 manually on the client) to run in non-dry- +## run mode. +#set global $BCFG2_CLIENT_OPTIONS = "-q -v -d -n" +## Initial options for bcfg2-server(8). Note that bcfg2-server is not fully +## configured by bcfg2-site; you need to edit /usr/local/etc/bcfg2.conf to +## include the "[server]" stanza and appropriate values, as well as a "key =" +## line in the "[communications]" stanza (see bcfg2 doc for details). +#set global $BCFG2_SERVER_OPTIONS = "-v" +## You can set passwords here, and you will not be prompted for them at +## install time; however you will then have to treat your bcfg2-site +## distribution as equivalent to the bcfg2 server and ostiary passwords. +## To be prompted for passwords at install time, make these empty string ("") +#set global $BCFG2_PASSWORD = "" +#set global $OSTIARY_PASSWORD = "" +###### +###### Automatically-set variables - you shouldn't have to touch these. +###### +#from time import localtime, strftime +#set global $DATE = strftime("%a %b %d %H:%M:%S %Z %Y", localtime()) -- cgit v1.2.3-1-g7c22