#!/bin/sh # based on http://www.royhooper.ca/blog/articles/2007/07/07/installing-the-darwin-calendar-server-on-freebsd GREP="/usr/bin/grep" PKG_INFO="/usr/sbin/pkg_info" PKG_ADD="/dev/null" #PKG_ADD="/usr/sbin/pkg_add" SRCDIR="/usr/local/src" if [ -x /usr/bin/uname ]; then if [ `/usr/bin/uname` = "FreeBSD" ]; then I_AM_FREEBSD=1 echo "detected FreeBSD, installing from ports" else echo "sorry, don't know how to install on `uname`" exit fi fi if [ ! -f /usr/ports/INDEX ]; then echo "OOPS! Your ports tree is missing, did you install it? Install ports using portsnap: portsnap fetch extract and keep it updated with: portsnap fetch update " exit fi if [ -z "`$GREP PYTHON_DEFAULT_VERSION /etc/make.conf`" ]; then echo 'PYTHON_DEFAULT_VERSION=python2.4' >> /etc/make.conf else echo 'python version set in make.conf' fi install_ports() { echo "installing required FreeBSD ports" if [ -z "`$PKG_INFO | $GREP python24-`" ]; then $PKG_ADD -r python if [ -z "`$PKG_INFO | $GREP python24-`" ]; then echo " installing Python" cd /usr/ports/lang/python && make install clean fi else echo " Python is installed." fi if [ -z "`$PKG_INFO | $GREP zope-`" ]; then echo " installing zope" cd /usr/ports/www/zope3 && make install clean else echo " Zope is installed." fi if [ -z "`$PKG_INFO | $GREP '^py' | $GREP xml`" ]; then echo " installing py-xml" cd /usr/ports/textproc/py-xml && make install clean else echo " py-xml is installed." fi if [ -z "`$PKG_INFO | $GREP '^py' | $GREP openssl`" ]; then echo " installing py-openssl" cd /usr/ports/security/py-openssl && make install clean else echo " py-security is installed." fi if [ -z "`$PKG_INFO | $GREP '^py' | $GREP sqlite`" ]; then if [ -z "`$PKG_INFO | $GREP '^sqlite' `" ]; then echo " installing sqlite3" $PKG_ADD -r sqlite3 fi echo " installing py-pysqlite" cd /usr/ports/databases/py-pysqlite22 && make install clean else echo " py-pysqlite is installed." fi if [ -z "`$PKG_INFO | $GREP '^py' | $GREP twisted`" ]; then echo " installing py-twisted" cd /usr/ports/devel/py-twisted && make install clean else echo " py-twisted is installed." fi if [ -z "`$PKG_INFO | $GREP '^py' | $GREP vobject`" ]; then echo " installing py-vobject" cd /usr/ports/deskutils/py-vobject && make install clean else echo " py-vobject is installed." fi } install_mac_compat_ports() { echo "installing ports for MacOS compatibility" if [ -z "`$PKG_INFO | $GREP '^bash'`" ]; then echo " installing bash" $PKG_ADD -r bash if [ -z "`$PKG_INFO | $GREP '^bash'`" ]; then echo " installing bash" cd /usr/ports/shells/bash && make install clean fi else echo " bash is installed." fi if [ -z "`$PKG_INFO | $GREP '^curl'`" ]; then echo " installing curl" $PKG_ADD -r curl if [ -z "`$PKG_INFO | $GREP '^curl'`" ]; then echo " installing curl" cd /usr/ports/ftp/curl && make install clean fi else echo " curl is installed." fi } install_kerberos() { echo "installing Kerberos (and dependecies)" if [ -z "`$PKG_INFO | $GREP perl-`" ]; then echo " installing perl" $PKG_ADD -r perl # if pkg_add -r fails, try to build from ports if [ -z "`$PKG_INFO | $GREP perl`" ]; then echo " installing Perl" cd /usr/ports/lang/perl5.8 && make install clean fi else echo " Perl is installed." fi if [ -z "`$PKG_INFO | $GREP '^ghostscript'`" ]; then $PKG_ADD -r ghostscript-gpl-nox11 if [ -z "`$PKG_INFO | $GREP '^ghostscript'`" ]; then echo " installing ghostscript" cd /usr/ports/print/ghostscript-gpl-nox11 && make install clean fi else echo " ghostscript is installed." fi if [ -z "`$PKG_INFO | $GREP '^krb5'`" ]; then $PKG_ADD -r krb5 if [ -z "`$PKG_INFO | $GREP '^krb5'`" ]; then echo " installing kerberos" cd /usr/ports/security/krb5 && make install clean fi else echo " kerberos is installed." fi } install_subversion() { echo "installing subversion" if [ -z "`$PKG_INFO | $GREP '^subversion'`" ]; then echo "installing subversion" $PKG_ADD -r subversion if [ -z "`$PKG_INFO | $GREP '^subversion'`" ]; then if [ -z "`$PKG_INFO | $GREP expat`" ]; then echo " installing expat" $PKG_ADD -r expat # if pkg_add -r fails, try to build from ports if [ -z "`$PKG_INFO | $GREP expat`" ]; then echo " installing expat" cd /usr/ports/textproc/expat2 && make install clean fi else echo " expat is installed." fi echo " installing subversion" cd /usr/ports/devel/subversion-perl && make -DWITHOUT_BDB install clean fi else echo " subversion is installed." fi } setup_source() { if [ ! -d $SRCDIR ]; then mkdir -p $SRCDIR fi chdir $SRCDIR } checkout_svn_sources() { SVN="/usr/local/bin/svn" cd $SRCDIR if [ ! -d "CalendarServer" ]; then $SVN co http://svn.calendarserver.org/repository/calendarserver/CalendarServer/trunk CalendarServer else cd $SRCDIR/CalendarServer $SVN update fi cd $SRCDIR if [ ! -d "PyKerberos" ]; then $SVN co http://svn.calendarserver.org/repository/calendarserver/PyKerberos/trunk PyKerberos else cd $SRCDIR/PyKerberos $SVN update fi } install_py-setuptools() { cd /usr/ports/devel/py-setuptools if [ ! -z "`grep 0.6c5 Makefile`" ]; then echo "oops, version is too old" sed -i .bak -e 's/0.6c5/0.6c6/' Makefile echo "MD5 (python/setuptools-0.6c6.tar.gz) = e3d56d4d19776042607cbbecae823c8b SHA256 (python/setuptools-0.6c6.tar.gz) = 075172b39f0933d3fbd1d4e90f29742c1402a29da26db04357eb18fd46ffd6b1 SIZE (python/setuptools-0.6c6.tar.gz) = 248601" >> distinfo make install clean else echo " building py-setuptools" make install clean fi #fetch http://cheeseshop.python.org/packages/2.4/s/setuptools/setuptools-0.6c6-py2.4.egg#md5=3c56af57be3225019260a644430065ab } install_xattr() { cd $SRCDIR if [ ! -d "xattr-0.4" ]; then echo "installing python xattr" fetch http://cheeseshop.python.org/packages/source/x/xattr/xattr-0.4.tar.gz#md5=9820bfdd12a176034c60070657ad3d7c mv xattr-0.4.tar.gz#md5=9820bfdd12a176034c60070657ad3d7c xattr-0.4.tar.gz tar -xzf xattr-0.4.tar.gz cd xattr-0.4 python setup.py install fi echo "python xattr installed" } install_py-kerberos() { if [ ! -d "$SRCDIR/PyKerberos" ]; then echo "ERROR: PyKerberos sources not downloaded. Is subversion installed correctly?" exit fi cd $SRCDIR/PyKerberos if [ -z "`grep include setup.py`" ]; then echo '## # Copyright (c) 2006-2007 Apple Inc. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # DRI: Cyrus Daboo, cdaboo@apple.com ## from distutils.core import setup, Extension import sys import commands setup ( name = "kerberos", version = "1.0", description = "Kerberos high-level interface", ext_modules = [ Extension( "kerberos", extra_link_args = commands.getoutput("krb5-config --libs gssapi").split(), extra_compile_args = commands.getoutput("krb5-config --cflags gssapi").split(), sources = [ "src/kerberos.c", "src/kerberosbasic.c", "src/kerberosgss.c", "src/base64.c" ], library_dirs=["/usr/local/lib"], include_dirs=["/usr/local/include"], ), ], )' > setup.py sed -i .bak -e 's/