From 0f07fb09115d71990bcf3844782ce4174f2158ff Mon Sep 17 00:00:00 2001 From: Sol Jerome Date: Fri, 20 Nov 2009 15:31:30 +0000 Subject: OSX: New packaging framework This commit allows you to build both client/server packages for OS X by changing to the osx directory and running make client/server, respectively. Hopefully make it easier to setup bcfg2 clients on OS X since the most current packages I could find were still 0.9.4. Signed-off-by: Sol Jerome git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5584 ce84e21b-d406-0410-9b95-82705330c041 --- osx/M2Crypto-0.20.2-py2.5-macosx-10.5-ppc.egg | Bin 0 -> 417080 bytes osx/Makefile | 114 ++++++++++++++++++++++++++ osx/PackageInfo.plist | 36 ++++++++ osx/bcfg2.conf | 8 ++ osx/easy-install.pth | 3 + osx/gov.anl.mcs.bcfg2-daily.plist | 24 ++++++ osx/postflight | 14 ++++ osx/preflight | 11 +++ 8 files changed, 210 insertions(+) create mode 100644 osx/M2Crypto-0.20.2-py2.5-macosx-10.5-ppc.egg create mode 100644 osx/Makefile create mode 100644 osx/PackageInfo.plist create mode 100644 osx/bcfg2.conf create mode 100644 osx/easy-install.pth create mode 100644 osx/gov.anl.mcs.bcfg2-daily.plist create mode 100644 osx/postflight create mode 100644 osx/preflight (limited to 'osx') diff --git a/osx/M2Crypto-0.20.2-py2.5-macosx-10.5-ppc.egg b/osx/M2Crypto-0.20.2-py2.5-macosx-10.5-ppc.egg new file mode 100644 index 000000000..3e07b92dd Binary files /dev/null and b/osx/M2Crypto-0.20.2-py2.5-macosx-10.5-ppc.egg differ diff --git a/osx/Makefile b/osx/Makefile new file mode 100644 index 000000000..698d060ab --- /dev/null +++ b/osx/Makefile @@ -0,0 +1,114 @@ +PYVERSION := $(shell /usr/bin/python -c "import sys; print sys.version[0:3]") +PREFLIGHT = preflight +POSTFLIGHT = postflight +PKGROOT = bcfg2pkg +PKGTMP = bcfg2tmp +FILTERS = --filter Hostbase \ +--filter Reports \ +--filter Server \ +--filter xsd \ +--filter xsl \ +--filter bcfg2-admin \ +--filter bcfg2-build-reports \ +--filter bcfg2-info \ +--filter bcfg2-ping-sweep \ +--filter bcfg2-repo-validate \ +--filter bcfg2-reports \ +--filter bcfg2-server + +CONF = bcfg2.conf +DATADIR = /Library/Frameworks/Python.framework/Versions/Current +LAUNCHD = gov.anl.mcs.bcfg2-daily.plist +PACKAGEMAKER = /Developer/usr/bin/packagemaker +PROTO_PLIST = PackageInfo.plist +SITELIBDIR = /Library/Python/${PYVERSION}/site-packages + +# Symlinks cannot be specified on the command line, therefore, we create +# an Info.plist file for packagemaker to look at for package creation +# and substitute the version strings. Major/Minor versions can only be +# integers (e.g. "1" and "00" for bcfg2 version 1.0.0. +BCFGVER = $(shell /usr/bin/grep version ../setup.py | cut -d\" -f2) +BCFGVER1 = $(shell /bin/echo ${BCFGVER} | /usr/bin/cut -d"." -f1) +BCFGVER2 = $(shell /bin/echo ${BCFGVER} | /usr/bin/cut -d"." -f2) +BCFGVER3 = $(shell /bin/echo ${BCFGVER} | /usr/bin/cut -d"." -f3) +MAJOR = ${BCFGVER1} +MINOR = ${BCFGVER2}${BCFGVER3} + +default: clean client + +install: + echo "Installing Bcfg2 to ${PKGROOT}" + mkdir ${PKGROOT} + cd ../ && /usr/bin/python setup.py install \ + --root="osx/${PKGROOT}" \ + --install-lib="${SITELIBDIR}" \ + --install-data="${DATADIR}" + /usr/sbin/chown -R root:admin "${PKGROOT}" + +prepare: install + mkdir ${PKGTMP} + cp ${PROTO_PLIST} ${PKGTMP} + sed -i '' "s/{SHORTVERSION}/${BCFGVER}/g" "${PKGTMP}/${PROTO_PLIST}" + sed -i '' "s/{MAJORVERSION}/${MAJOR}/g" "${PKGTMP}/${PROTO_PLIST}" + sed -i '' "s/{MINORVERSION}/${MINOR}/g" "${PKGTMP}/${PROTO_PLIST}" + + # create a preflight script to remove traces of previous + # bcfg2 installs due to limitations in Apple's pkg format + mkdir -p "${PKGTMP}/scripts" + cp "${PREFLIGHT}" "${PKGTMP}/scripts" + cp "${POSTFLIGHT}" "${PKGTMP}/scripts" + + # substitute in the {sitelib,data}dir specified above on the assumption that + # this is where any previous bcfg2 install exists that should be cleaned out. + sed -i '' "s|{SITELIBDIR}|${SITELIBDIR}|g" "${PKGTMP}/scripts/${PREFLIGHT}" + sed -i '' "s|{SITELIBDIR}|${SITELIBDIR}|g" "${PKGTMP}/scripts/${POSTFLIGHT}" + sed -i '' "s|{DATADIR}|${DATADIR}|g" "${PKGTMP}/scripts/${PREFLIGHT}" + sed -i '' "s|{DATADIR}|${DATADIR}|g" "${PKGTMP}/scripts/${POSTFLIGHT}" + # substitute in the bindir specified on the assumption that this is where + # any old executables that have moved from bindir->sbindir should be + # cleaned out from. + sed -i '' "s|{BINDIR}|${BINDIR}|g" "${PKGTMP}/scripts/${PREFLIGHT}" + sed -i '' "s|{BINDIR}|${BINDIR}|g" "${PKGTMP}/scripts/${POSTFLIGHT}" + sed -i '' "s|{LAUNCHD}|${LAUNCHD}|g" "${PKGTMP}/scripts/${POSTFLIGHT}" + # {pre,post}flight scripts must be 770 to execute + chmod 0770 "${PKGTMP}/scripts/${PREFLIGHT}" + chmod 0770 "${PKGTMP}/scripts/${POSTFLIGHT}" + + # add in M2Crypto + /bin/expr ${PYVERSION} \< 2.6 && \ + cp "M2Crypto-0.20.2-py2.5-macosx-10.5-ppc.egg" "${PKGROOT}/${SITELIBDIR}" && \ + cp "easy-install.pth" "${PKGROOT}/${SITELIBDIR}" + + # add default bcfg2.conf + mkdir -p "${PKGROOT}/etc" + cp "${CONF}" "${PKGROOT}/etc/${CONF}" + + # add default launchd cron job + mkdir -p "${PKGROOT}/Library/LaunchDaemons" + cp "${LAUNCHD}" "${PKGROOT}/Library/LaunchDaemons/${LAUNCHD}" + +client: prepare + rm -rf `pwd`/bcfg2-${BCFGVER}.pkg + echo "Building package" + echo "Note that packagemaker is reknowned for spurious errors. Don't panic." + "${PACKAGEMAKER}" --root "${PKGROOT}" \ + --info "${PKGTMP}/${PROTO_PLIST}" \ + --scripts "${PKGTMP}/scripts" \ + ${FILTERS} \ + --verbose \ + --title "bcfg2" \ + --out `pwd`/bcfg2-${BCFGVER}.pkg + +server: prepare + rm -rf `pwd`/bcfg2-${BCFGVER}.pkg + echo "Building package" + echo "Note that packagemaker is reknowned for spurious errors. Don't panic." + "${PACKAGEMAKER}" --root "${PKGROOT}" \ + --info "${PKGTMP}/${PROTO_PLIST}" \ + --scripts "${PKGTMP}/scripts" \ + --verbose \ + --title "bcfg2" \ + --out `pwd`/bcfg2-${BCFGVER}.pkg + +clean: + rm -rf bcfg2tmp bcfg2pkg diff --git a/osx/PackageInfo.plist b/osx/PackageInfo.plist new file mode 100644 index 000000000..cb553576c --- /dev/null +++ b/osx/PackageInfo.plist @@ -0,0 +1,36 @@ + + + + + CFBundleIdentifier + gov.anl.mcs + CFBundleShortVersionString + {SHORTVERSION} + IFMajorVersion + {MAJORVERSION} + IFMinorVersion + {MINORVERSION} + IFPkgFlagAllowBackRev + + IFPkgFlagAuthorizationAction + RootAuthorization + IFPkgFlagDefaultLocation + / + IFPkgFlagFollowLinks + + IFPkgFlagInstallFat + + IFPkgFlagIsRequired + + IFPkgFlagOverwritePermissions + + IFPkgFlagRelocatable + + IFPkgFlagRestartAction + None + IFPkgFlagRootVolumeOnly + + IFPkgFlagUpdateInstalledLanguages + + + diff --git a/osx/bcfg2.conf b/osx/bcfg2.conf new file mode 100644 index 000000000..cac424576 --- /dev/null +++ b/osx/bcfg2.conf @@ -0,0 +1,8 @@ +[communication] +protocol = xmlrpc/ssl +password = foobat +# certificate = /etc/bcfg2.key +# key = /etc/bcfg2.key + +[components] +bcfg2 = https://localhost:6789 diff --git a/osx/easy-install.pth b/osx/easy-install.pth new file mode 100644 index 000000000..c0c4d11e5 --- /dev/null +++ b/osx/easy-install.pth @@ -0,0 +1,3 @@ +import sys; sys.__plen = len(sys.path) +./M2Crypto-0.20.2-py2.5-macosx-10.5-ppc.egg +import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; p=getattr(sys,'__egginsert',0); sys.path[p:p]=new; sys.__egginsert = p+len(new) diff --git a/osx/gov.anl.mcs.bcfg2-daily.plist b/osx/gov.anl.mcs.bcfg2-daily.plist new file mode 100644 index 000000000..8c2d07d24 --- /dev/null +++ b/osx/gov.anl.mcs.bcfg2-daily.plist @@ -0,0 +1,24 @@ + + + + + Label + gov.anl.mcs.bcfg2-daily + ProgramArguments + + /usr/local/bin/bcfg2 + -n + + LowPriorityIO + + Nice + 1 + StartCalendarInterval + + Hour + 3 + Minute + 15 + + + diff --git a/osx/postflight b/osx/postflight new file mode 100644 index 000000000..52a948a2a --- /dev/null +++ b/osx/postflight @@ -0,0 +1,14 @@ +#!/bin/bash +# +# ${3} is the destination volume so that this works correctly +# when being installed to volumes other than the current OS. + +# set proper perms +/usr/bin/find "${3}"{SITELIBDIR}/Bcfg2* -type f -exec chmod 0644 {} \; +chmod 0644 "${3}"{DATADIR}/share/man/man1/bcfg2.1 +chmod 0644 "${3}"{DATADIR}/share/man/man5/bcfg2.conf.5 +chmod 0644 "${3}"/Library/LaunchDaemons/{LAUNCHD} +chmod 0755 "${3}"/usr/local/bin/bcfg2 + +# add the launchd script +/bin/launchctl load -w "${3}"/Library/LaunchDaemons/{LAUNCHD} diff --git a/osx/preflight b/osx/preflight new file mode 100644 index 000000000..169551b35 --- /dev/null +++ b/osx/preflight @@ -0,0 +1,11 @@ +#!/bin/bash +# +# Remove old bcfg2 cruft +# +# ${3} is the destination volume so that this works correctly +# when being installed to volumes other than the current OS. + +/bin/rm -Rvf "${3}"{SITELIBDIR}/Bcfg2* +/bin/rm -Rvf "${3}"/usr/local/bin/bcfg2* +/bin/rm -Rvf "${3}{DATADIR}/share/bcfg2" +/bin/rm -Rvf "${3}{DATADIR}/share/man/man8/bcfg2*" -- cgit v1.2.3-1-g7c22