summaryrefslogtreecommitdiffstats
path: root/osx/Makefile
blob: 174eb53c831b39d7cf356d7681632d123595cf5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
PYVERSION := $(shell /usr/bin/python -c "import sys; print '%s.%s' % (sys.version_info[0], sys.version_info[1])")
PYMAJORVERSION := $(shell /usr/bin/python -c "import sys; print sys.version_info[0]")
PYMINORVERSION := $(shell /usr/bin/python -c "import sys; print sys.version_info[1]")
PREFLIGHT = preflight
POSTFLIGHT = postflight
PKGROOT = bcfg2pkg
PKGTMP = bcfg2tmp
FILTERS = --filter Reports \
--filter Server \
--filter xsd \
--filter xsl \
--filter bcfg2-admin \
--filter bcfg2-build-reports \
--filter bcfg2-info \
--filter bcfg2-ping-sweep \
--filter bcfg2-lint \
--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 = 1.4.0pre1
MAJOR = 1
MINOR = 40

default: clean client

install:
	echo "Installing Bcfg2 to ${PKGROOT}"
	mkdir -p ${PKGROOT}
	cd ../ && /usr/bin/python setup.py install \
	       --root="osx/${PKGROOT}" \
	       --install-lib="${SITELIBDIR}" \
	       --install-data="${DATADIR}"

prepare: install
	mkdir -p ${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 if python version is less than 2.6
	if [[ ${PYMAJORVERSION} == 2 ]]; then if [[ ${PYMINORVERSION} -lt 6 ]]; then cp "M2Crypto-0.20.2-py2.5-macosx-10.5-ppc.egg" "${PKGROOT}/${SITELIBDIR}" && cp "easy-install.pth" "${PKGROOT}/${SITELIBDIR}"; fi ;  fi
	# 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