From 1c663e33cdead4bc8cb88eb404df459ad26e51de Mon Sep 17 00:00:00 2001 From: Lorenz Schori Date: Fri, 21 Aug 2009 08:50:45 +0200 Subject: [PATCH] Integrate patch for building dmg on OSX from Lorenz Schori --- bacula/autoconf/bacula-macros/os.m4 | 3 + bacula/autoconf/configure.in | 8 + bacula/configure | 11 ++ bacula/platforms/Makefile.in | 2 +- bacula/platforms/osx/Makefile.in | 149 ++++++++++++++++++ .../osx/files/org.bacula.bacula-fd.plist.in | 25 +++ .../platforms/osx/files/uninstall.command.in | 29 ++++ .../osx/resources/Description.plist.in | 10 ++ bacula/platforms/osx/resources/Info.plist.in | 10 ++ bacula/platforms/osx/resources/ReadMe.html.in | 57 +++++++ bacula/platforms/osx/resources/postflight.in | 35 ++++ bacula/platforms/osx/resources/preupgrade.in | 7 + bacula/technotes | 1 + 13 files changed, 346 insertions(+), 1 deletion(-) create mode 100644 bacula/platforms/osx/Makefile.in create mode 100644 bacula/platforms/osx/files/org.bacula.bacula-fd.plist.in create mode 100644 bacula/platforms/osx/files/uninstall.command.in create mode 100644 bacula/platforms/osx/resources/Description.plist.in create mode 100644 bacula/platforms/osx/resources/Info.plist.in create mode 100644 bacula/platforms/osx/resources/ReadMe.html.in create mode 100644 bacula/platforms/osx/resources/postflight.in create mode 100644 bacula/platforms/osx/resources/preupgrade.in diff --git a/bacula/autoconf/bacula-macros/os.m4 b/bacula/autoconf/bacula-macros/os.m4 index 7fe1a6bf6d..7a3ce55d5a 100644 --- a/bacula/autoconf/bacula-macros/os.m4 +++ b/bacula/autoconf/bacula-macros/os.m4 @@ -207,6 +207,9 @@ then elif test -f /etc/slackware-version then DISTNAME=slackware +elif test x$host_vendor = xapple +then + DISTNAME=osx elif test $HAVE_UNAME=yes -a x`uname -s` = xDarwin then DISTNAME=darwin diff --git a/bacula/autoconf/configure.in b/bacula/autoconf/configure.in index 149f9e7c3e..fb074230d8 100644 --- a/bacula/autoconf/configure.in +++ b/bacula/autoconf/configure.in @@ -2617,6 +2617,14 @@ darwin) PFILES="${PFILES} \ platforms/darwin/Makefile" ;; +osx) + DISTVER=`uname -r` + TAPEDRIVE="/dev/nst0" + PSCMD="ps -e -o pid,command" + MACOSX=macosx + PFILES="${PFILES} \ + platforms/osx/Makefile" + ;; debian) if `test -f /etc/apt/sources.list && grep -q ubuntu /etc/apt/sources.list`; then DISTNAME="ubuntu" diff --git a/bacula/configure b/bacula/configure index 25a0a85cc8..b711d9fc96 100755 --- a/bacula/configure +++ b/bacula/configure @@ -16408,6 +16408,9 @@ then elif test -f /etc/slackware-version then DISTNAME=slackware +elif test x$host_vendor = xapple +then + DISTNAME=osx elif test $HAVE_UNAME=yes -a x`uname -s` = xDarwin then DISTNAME=darwin @@ -42624,6 +42627,14 @@ darwin) PFILES="${PFILES} \ platforms/darwin/Makefile" ;; +osx) + DISTVER=`uname -r` + TAPEDRIVE="/dev/nst0" + PSCMD="ps -e -o pid,command" + MACOSX=macosx + PFILES="${PFILES} \ + platforms/osx/Makefile" + ;; debian) if `test -f /etc/apt/sources.list && grep -q ubuntu /etc/apt/sources.list`; then DISTNAME="ubuntu" diff --git a/bacula/platforms/Makefile.in b/bacula/platforms/Makefile.in index 1a7b89408b..79101b07fd 100644 --- a/bacula/platforms/Makefile.in +++ b/bacula/platforms/Makefile.in @@ -11,7 +11,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL = @INSTALL@ -SUBDIRS = freebsd redhat solaris unknown openbsd irix gentoo \ +SUBDIRS = freebsd redhat solaris unknown openbsd osx irix gentoo \ debian darwin aix bsdi mandrake slackware alpha ubuntu MAKE = make diff --git a/bacula/platforms/osx/Makefile.in b/bacula/platforms/osx/Makefile.in new file mode 100644 index 0000000000..cd483d7ee6 --- /dev/null +++ b/bacula/platforms/osx/Makefile.in @@ -0,0 +1,149 @@ +# +# This is the makefile template for the platform directory +# which contains general platform installation. +# +# 17 August 2009 -- Lorenz Schori +# +# for Bacula release @VERSION@ (@DATE@) -- @DISTNAME@ +# + + +# bacula version and download site +BACULA_VERSION:=@VERSION@ +BACULA_DL_URL:=http://downloads.sourceforge.net/project/bacula/bacula/${BACULA_VERSION}/bacula-${BACULA_VERSION}.tar.gz + +# fakeroot version and download site +FAKEROOT_VERSION:=1.13 +FAKEROOT_DL_URL:=http://ftp.de.debian.org/debian/pool/main/f/fakeroot/fakeroot_${FAKEROOT_VERSION}.tar.gz + +# Build universal binary. Comment out when building versions of bacula < 3.0.0 +ARCHFLAGS:=-arch i386 -arch ppc +MACOSX_SDK_SYSROOT:=/Developer/SDKs/MacOSX10.4u.sdk +MACOSX_VERSION_FLAGS:=-mmacosx-version-min=10.4 + +# Tools +PM:=/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker +MAKE:=/usr/bin/make +CURL:=/usr/bin/curl +TAR:=/usr/bin/tar + +########### you should not have to edit anything beyond this line ########### + +# Build paths +DL_DIR:=dl +BUILD_DIR:=build +PRODUCTS_DIR:=products +TOOLS_DIR:=tools + +WORKING_DIR:=${BUILD_DIR}/${BACULA_VERSION} +BACULA_TAR:=${DL_DIR}/bacula-${BACULA_VERSION}.tar.gz +BACULA_SOURCE:=${WORKING_DIR}/bacula-${BACULA_VERSION} +BACULA_DESTDIR:=${WORKING_DIR}/destdir +BACULA_PREFIX:=/usr/local/bacula-${BACULA_VERSION} + +# Detect whether we sit inside the bacula source tree. In this case we won't +# download the tar from sourceforge but instead work with what its there +# already +CURSUB:=$(CURDIR:%/platforms/osx=%) +ifneq ($(CURDIR),$(CURSUB)) + BACULA_TAR:= + BACULA_SOURCE:=../../ +# BACULA_VERSION:=$(shell sed -n 's,^VERSION=,,p' $(CURSUB)/autoconf/Make.common) +endif + +PACKAGE_TITLE:=Bacula File Daemon ${BACULA_VERSION} +PACKAGE_DIR:=${PRODUCTS_DIR}/${PACKAGE_TITLE} +PACKAGE_BUNDLE:=${PACKAGE_DIR}/${PACKAGE_TITLE}.pkg +PACKAGE_DMG:=${PRODUCTS_DIR}/${PACKAGE_TITLE}.dmg +PACKAGE_RESOURCES:=Description.plist Info.plist ReadMe.html postflight preupgrade +PACKAGE_XRESOURCES:=postflight preupgrade + +FAKEROOT_TAR:=${DL_DIR}/fakeroot-${FAKEROOT_VERSION}.tar.gz +FAKEROOT_SOURCE:=${TOOLS_DIR}/fakeroot-${FAKEROOT_VERSION} +FAKEROOT_DESTDIR:=${FAKEROOT_SOURCE}/destdir +FAKEROOT:=${FAKEROOT_DESTDIR}/bin/fakeroot + +# Flags for the toolchain +CONFIGFLAGS:=--enable-client-only --prefix=${BACULA_PREFIX} \ + --with-dir-password=@DIR_PW@ --with-fd-password=@FD_PW@ \ + --with-sd-password=@SD_PW@ --with-mon-dir-password=@MON_DIR_PW@ \ + --with-mon-fd-password=@MON_FD_PW@ --with-mon-sd-password=@MON_SD_PW@ \ + --with-basename=@BASENAME@ --with-hostname=@HOSTNAME@ +CPPFLAGS:=-isysroot ${MACOSX_SDK_SYSROOT} ${MACOSX_VERSION_FLAGS} +CFLAGS:=-O -g ${ARCHFLAGS} +CXXFLAGS:=${CFLAGS} +LDFLAGS:=${MACOSX_VERSION_FLAGS} ${ARCHFLAGS} + +dmg: pkg + hdiutil create -srcfolder "${PACKAGE_DIR}" "${PACKAGE_DMG}" + +pkg: ${BACULA_DESTDIR} ${WORKING_DIR}/resources ${FAKEROOT_DESTDIR} + mkdir -p "${PACKAGE_DIR}" + + ${FAKEROOT} ${PM} -build -ds -v -f "\"${BACULA_DESTDIR}\"" -p "\"${PACKAGE_BUNDLE}\"" \ + -r "\"${WORKING_DIR}/resources\"" -i "\"${WORKING_DIR}/resources/Info.plist\"" + + cp ${WORKING_DIR}/resources/ReadMe.html "${PACKAGE_DIR}/ReadMe.html" + + sed -e "s,@PREFIX@,${BACULA_PREFIX},g" -e "s,@BACULA_VERSION@,${BACULA_VERSION},g" \ + files/uninstall.command.in > "${PACKAGE_DIR}/uninstall.command"; + chmod 0775 "${PACKAGE_DIR}/uninstall.command" + +${WORKING_DIR}/resources: ${BACULA_DESTDIR} + mkdir -p "${WORKING_DIR}/resources" + + for res in ${PACKAGE_RESOURCES}; do \ + sed -e "s,@PREFIX@,${BACULA_PREFIX},g" -e "s,@BACULA_VERSION@,${BACULA_VERSION},g" \ + resources/$$res.in > "${WORKING_DIR}/resources/$$res"; \ + done + + for xres in ${PACKAGE_XRESOURCES}; do \ + chmod +x "${WORKING_DIR}/resources/$$xres"; \ + done + + cp "${BACULA_SOURCE}/LICENSE" "${WORKING_DIR}/resources/License.txt" + +${BACULA_DESTDIR}: ${BACULA_SOURCE} + (cd ${BACULA_SOURCE} && ./configure ${CONFIGFLAGS} CPPFLAGS="${CPPFLAGS}" CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}" LDFLAGS="${LDFLAGS}") + ${MAKE} -C ${BACULA_SOURCE} LDFLAGS="-Wl,-syslibroot,${MACOSX_SDK_SYSROOT} ${LDFLAGS}" + ${MAKE} -C ${BACULA_SOURCE} install DESTDIR="${CURDIR}/${BACULA_DESTDIR}" + + rm -rf "${BACULA_DESTDIR}/tmp" + + for conffile in ${BACULA_DESTDIR}${BACULA_PREFIX}/etc/*.conf; do \ + mv $$conffile $$conffile.example; \ + done + + mkdir -p "${BACULA_DESTDIR}${BACULA_PREFIX}/Library/LaunchDaemons" + sed "s,@PREFIX@,${BACULA_PREFIX},g" files/org.bacula.bacula-fd.plist.in \ + > "${BACULA_DESTDIR}${BACULA_PREFIX}/Library/LaunchDaemons/org.bacula.bacula-fd.plist" + +${BACULA_SOURCE}: ${BACULA_TAR} + mkdir -p "${WORKING_DIR}" + ${TAR} -xzf "${BACULA_TAR}" -C "${WORKING_DIR}" + +${BACULA_TAR}: + mkdir -p "${DL_DIR}" + ${CURL} -L -o "${BACULA_TAR}" "${BACULA_DL_URL}" + +${FAKEROOT_DESTDIR}: ${FAKEROOT_SOURCE} + (cd ${FAKEROOT_SOURCE} && ./configure --prefix=${CURDIR}/${FAKEROOT_DESTDIR}) + ${MAKE} -C ${FAKEROOT_SOURCE} + ${MAKE} -C ${FAKEROOT_SOURCE} install + +${FAKEROOT_SOURCE}: ${FAKEROOT_TAR} + mkdir -p "${TOOLS_DIR}" + ${TAR} -xzf "${FAKEROOT_TAR}" -C "${TOOLS_DIR}" + +${FAKEROOT_TAR}: + mkdir -p "${DL_DIR}" + ${CURL} -L -o "${FAKEROOT_TAR}" "${FAKEROOT_DL_URL}" + +.PHONY: distclean +distclean: clean + rm -rf "${DL_DIR}" "${PRODUCTS_DIR}" "${TOOLS_DIR}" + +.PHONY: clean +clean: + rm -rf "${BUILD_DIR}" "${PACKAGE_DIR}" "${PACKAGE_DMG}" + diff --git a/bacula/platforms/osx/files/org.bacula.bacula-fd.plist.in b/bacula/platforms/osx/files/org.bacula.bacula-fd.plist.in new file mode 100644 index 0000000000..9952c40216 --- /dev/null +++ b/bacula/platforms/osx/files/org.bacula.bacula-fd.plist.in @@ -0,0 +1,25 @@ + + + + + Label + org.bacula.bacula-fd + ProgramArguments + + @PREFIX@/sbin/bacula-fd + -f + -c + @PREFIX@/etc/bacula-fd.conf + + Sockets + + Listeners + + + SockServiceName + bacula-fd + + + + + diff --git a/bacula/platforms/osx/files/uninstall.command.in b/bacula/platforms/osx/files/uninstall.command.in new file mode 100644 index 0000000000..90b1efaa10 --- /dev/null +++ b/bacula/platforms/osx/files/uninstall.command.in @@ -0,0 +1,29 @@ +#!/bin/sh + +echo "Bacula file daemon @BACULA_VERSION@ uninstaller" + +# Remove startup item +echo "* Bacula startup item... " +if [ -f /Library/LaunchDaemons/org.bacula.bacula-fd.plist ]; then + sudo launchctl unload /Library/LaunchDaemons/org.bacula.bacula-fd.plist + sudo rm /Library/LaunchDaemons/org.bacula.bacula-fd.plist + echo " + removed successfully" +else + echo " - not found, nothing to remove" +fi + +echo "* Bacula file daemon... " +if [ -d "/usr/local/bacula-@BACULA_VERSION@" ]; then + sudo rm -r "/usr/local/bacula-@BACULA_VERSION@" + echo " + removed successfully" +else + echo " - not found, nothing to remove" +fi + +echo "* Installer receipt... " +if [ -d "/Library/Receipts/Bacula File Daemon @BACULA_VERSION@.pkg" ]; then + sudo rm -r "/Library/Receipts/Bacula File Daemon @BACULA_VERSION@.pkg" + echo " + removed successfully" +else + echo " - not found, nothing to remove" +fi diff --git a/bacula/platforms/osx/resources/Description.plist.in b/bacula/platforms/osx/resources/Description.plist.in new file mode 100644 index 0000000000..976546eb92 --- /dev/null +++ b/bacula/platforms/osx/resources/Description.plist.in @@ -0,0 +1,10 @@ + + + + + IFPkgDescriptionDescription + + IFPkgDescriptionTitle + Bacula File Daemon @BACULA_VERSION@ + + diff --git a/bacula/platforms/osx/resources/Info.plist.in b/bacula/platforms/osx/resources/Info.plist.in new file mode 100644 index 0000000000..9d1cd1ce28 --- /dev/null +++ b/bacula/platforms/osx/resources/Info.plist.in @@ -0,0 +1,10 @@ + + + + + CFBundleIdentifier + org.bacula.bacula-fd + CFBundleShortVersionString + @BACULA_VERSION@ + + diff --git a/bacula/platforms/osx/resources/ReadMe.html.in b/bacula/platforms/osx/resources/ReadMe.html.in new file mode 100644 index 0000000000..22914c8dea --- /dev/null +++ b/bacula/platforms/osx/resources/ReadMe.html.in @@ -0,0 +1,57 @@ + + + + + + Bacula File Daemon @BACULA_VERSION@ + + + + + +

Bacula File Daemon @BACULA_VERSION@

+

+ Bacula is on Open Source, enterprise ready, network based backup program. + This installer package contains the bacula file daemon for Mac OS X 10.4 + or later built as an universal binary for PPC and Intel processors. +

+

Requirements

+

+ The bacula file daemon is only the client component of the backup system. + For proper operation the file daemon needs to have access to a bacula + director and storage daemon, typically installed on a server machine in + the local network. +

+

Installation

+

+ Open the Bacula File Daemon @BACULA_VERSION@ installer package and follow the + directions given to you. +

+

Configuration

+

+ After the installation is complete you have to adapt the configuration + file to your needs. Use your favorite command line editor and don't forget + to become root before you try to open the file. E.g: +

sudo vim /usr/local/bacula-@BACULA_VERSION@/etc/bacula-fd.conf
+

+

Operating the File Daemon

+

+ Use launchctl to enable and disable the bacula file daemon. +

sudo launchctl load -w /Library/LaunchDaemons/org.bacula.bacula-fd.plist

+
sudo launchctl unload -w /Library/LaunchDaemons/org.bacula.bacula-fd.plist

+

+

Uninstalling the File Daemon

+

+ Doubleclick the script uninstaller.command to remove the bacula file + daemon completely from your system. +

+

Resources

+

+ Refer to the bacula website for more information. +

+ http://bacula.org + + diff --git a/bacula/platforms/osx/resources/postflight.in b/bacula/platforms/osx/resources/postflight.in new file mode 100644 index 0000000000..d0e4bee93f --- /dev/null +++ b/bacula/platforms/osx/resources/postflight.in @@ -0,0 +1,35 @@ +#!/bin/sh + +function genpw() { + openssl rand -base64 33 +} + +# copy example config files and fix permissions +if [ ! -f $3@PREFIX@/etc/bacula-fd.conf ]; then + DIR_PW=$(genpw) + FD_PW=$(genpw) + SD_PW=$(genpw) + MON_DIR_PW=$(genpw) + MON_FD_PW=$(genpw) + MON_SD_PW=$(genpw) + HOSTNAME=$(hostname -s) + sed \ + -e "s,@DIR_PW@,$DIR_PW,g" \ + -e "s,@FD_PW@,$FD_PW,g" \ + -e "s,@SD_PW@,$SD_PW,g" \ + -e "s,@MON_DIR_PW@,$MON_DIR_PW,g" \ + -e "s,@MON_FD_PW@,$MON_FD_PW,g" \ + -e "s,@MON_SD_PW@,$MON_SD_PW,g" \ + -e "s,@BASENAME@,$HOSTNAME,g" \ + -e "s,@HOSTNAME@,$HOSTNAME,g" \ + "$3@PREFIX@/etc/bacula-fd.conf.example" > "$3@PREFIX@/etc/bacula-fd.conf" +fi +chmod 0640 "$3@PREFIX@/etc/bacula-fd.conf" + +# install startup item +mkdir -p -m 0755 "$3/Library/LaunchDaemons" +chmod 0644 "$3@PREFIX@/Library/LaunchDaemons/org.bacula.bacula-fd.plist" +ln -fs "$3@PREFIX@/Library/LaunchDaemons/org.bacula.bacula-fd.plist" "$3/Library/LaunchDaemons/org.bacula.bacula-fd.plist" + +# Load startup item +/bin/launchctl load "$3/Library/LaunchDaemons/org.bacula.bacula-fd.plist" diff --git a/bacula/platforms/osx/resources/preupgrade.in b/bacula/platforms/osx/resources/preupgrade.in new file mode 100644 index 0000000000..99f8d30d2c --- /dev/null +++ b/bacula/platforms/osx/resources/preupgrade.in @@ -0,0 +1,7 @@ +#!/bin/sh +# unload bacula file daemon before upgrading + +if [ -f "$3/Library/LaunchDaemons/org.bacula.bacula-fd.plist" ]; then + /bin/launchctl unload "$3/Library/LaunchDaemons/org.bacula.bacula-fd.plist" +fi + diff --git a/bacula/technotes b/bacula/technotes index 246115310b..047d39520b 100644 --- a/bacula/technotes +++ b/bacula/technotes @@ -3,6 +3,7 @@ General: 21Aug09 +kes Integrate patch for building dmg on OSX from Lorenz Schori kes Add commas in num files for estimate command 19Aug09 kes Fix bat crash due to alignment diff in bat and core code -- 2.39.5