From: Kern Sibbald
Date: Fri, 16 Oct 2009 16:13:19 +0000 (+0200)
Subject: Get osx files from master
X-Git-Tag: Release-3.0.3~8^2
X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=c42ba2947ac813825e031058e38935f487a32971;p=bacula%2Fbacula
Get osx files from master
---
diff --git a/bacula/autoconf/configure.in b/bacula/autoconf/configure.in
index 886f4088b8..6172758557 100644
--- a/bacula/autoconf/configure.in
+++ b/bacula/autoconf/configure.in
@@ -2551,6 +2551,7 @@ PFILES="platforms/Makefile"
PSCMD="ps -e"
WIN32=
MACOSX=
+
hostname=`uname -n | cut -d '.' -f 1`
if test x${hostname} = x ; then
hostname="localhost"
@@ -2605,6 +2606,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)
dnl Make sure hostname is resolved
ping -c 1 $hostname 2>&1 1>/dev/null
diff --git a/bacula/configure b/bacula/configure
index 4caae70a98..c6b311ffbd 100755
--- a/bacula/configure
+++ b/bacula/configure
@@ -42559,6 +42559,7 @@ PFILES="platforms/Makefile"
PSCMD="ps -e"
WIN32=
MACOSX=
+
hostname=`uname -n | cut -d '.' -f 1`
if test x${hostname} = x ; then
hostname="localhost"
@@ -42613,6 +42614,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)
ping -c 1 $hostname 2>&1 1>/dev/null
if test ! $? = 0; then
diff --git a/bacula/platforms/osx/Makefile.in b/bacula/platforms/osx/Makefile.in
new file mode 100644
index 0000000000..3c7256f2af
--- /dev/null
+++ b/bacula/platforms/osx/Makefile.in
@@ -0,0 +1,139 @@
+#
+# 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
+
+# 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
+FAKEROOT:=/usr/local/bin/fakeroot
+
+########### you should not have to edit anything beyond this line ###########
+
+# Build paths
+DL_DIR:=dl
+BUILD_DIR:=build
+PRODUCTS_DIR:=products
+
+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}
+BACULA_FD_CONF:=/Library/Preferences/bacula/bacula-fd.conf
+BACULA_WORKING_DIR:=/private/var/bacula/working
+
+# 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 ReadMe.html postflight preupgrade
+PACKAGE_XRESOURCES:=postflight preupgrade
+
+# 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@ \
+ --with-working-dir=${BACULA_WORKING_DIR}
+CPPFLAGS:=-isysroot ${MACOSX_SDK_SYSROOT} ${MACOSX_VERSION_FLAGS}
+CFLAGS:=-O -g ${ARCHFLAGS}
+CXXFLAGS:=${CFLAGS}
+LDFLAGS:=${MACOSX_VERSION_FLAGS} ${ARCHFLAGS}
+
+# Placeholders for *.in files
+INFILE_SUBST=\
+ -e "s,@PREFIX@,${BACULA_PREFIX},g" \
+ -e "s,@BACULA_VERSION@,${BACULA_VERSION},g" \
+ -e "s,@FD_CONF@,${BACULA_FD_CONF},g"
+
+dmg: pkg
+ hdiutil create -srcfolder "${PACKAGE_DIR}" "${PACKAGE_DMG}"
+
+pkg: ${BACULA_DESTDIR} ${WORKING_DIR}/resources
+ mkdir -p "${PACKAGE_DIR}"
+
+ sed ${INFILE_SUBST} \
+ files/Info.plist.in > "${WORKING_DIR}/Info.plist";
+
+ ${FAKEROOT} ${PM} -build -ds -v -f "\"${BACULA_DESTDIR}\"" -p "\"${PACKAGE_BUNDLE}\"" \
+ -r "\"${WORKING_DIR}/resources\"" -i "\"${WORKING_DIR}/Info.plist\""
+
+ cp ${WORKING_DIR}/resources/ReadMe.html "${PACKAGE_DIR}/ReadMe.html"
+
+ sed ${INFILE_SUBST} \
+ 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 ${INFILE_SUBST} \
+ 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 ${INFILE_SUBST} 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}"
+
+.PHONY: distclean
+distclean: clean
+ rm -rf "${DL_DIR}" "${PRODUCTS_DIR}"
+
+.PHONY: clean
+clean:
+ rm -rf "${BUILD_DIR}" "${PACKAGE_DIR}" "${PACKAGE_DMG}"
+
diff --git a/bacula/platforms/osx/README b/bacula/platforms/osx/README
new file mode 100644
index 0000000000..6b2a33c173
--- /dev/null
+++ b/bacula/platforms/osx/README
@@ -0,0 +1,68 @@
+Bacula file daemon package builder for Mac OS X
+===============================================
+
+This package build script lets you download, compile and package the bacula
+file daemon easily with a single command line. Beside the bacula file daemon
+the resulting installer package contains a short ReadMe file with instructions
+on how to install and use the software. Also a basic launchd property list is
+included along with preugrade and postflight installer scripts to stop and
+restart the daemon while upgrading. To ensure the security of the users the
+passwords in the configuration files are generated during a first time
+installation and file permissions are checked and corrected on upgrades.
+
+Requirements:
+* Mac OS X 10.4 or later
+* Mac OS X developer tools installed
+* fakeroot >= 1.13 (http://ftp.debian.org/debian/pool/main/f/fakeroot/)
+ The makefile expects the compiled binary at /usr/local/bin/fakeroot.
+
+Example (compile and create package from within bacula source tree):
+$ ./configure --enable-client-only
+$ make -C platforms/osx
+
+By moving the contents of platforms/osx to some other directory (e.g.
+~/bacula-standalone-bulder), it is possible to create installer packages from
+older bacula versions and for specific platforms.
+
+Examples (standalone mode):
+ 1. Create an installer package from the newest supported bacula source
+ containing the bacula file daemon as a PPC/Intel universal binary.
+ $ make dmg
+
+ 2. Create an installer package from a specified version of the bacula source
+ containing the bacula file daemon as a PPC/Intel universal binary.
+ $ make dmg BACULA_VERSION=3.0.0
+
+ 3. Create an installer package from the newest supported bacula source
+ containing the bacula file daemon for PPC architecture only.
+ $ make dmg ARCHFLAGS="-arch ppc" PACKAGE_TITLE="Bacula File Daemon PPC x.y.z"
+
+ 4. Create an installer package from a specified version of the bacula source
+ containing the bacula file daemon for the current architecture.
+ $ make dmg BACULA_VERSION=2.4.4 ARCHFLAGS=""
+
+You find the built disk images in the products folder.
+
+Misc commands:
+ 1. Cleanup the build directory
+ $ make clean
+ 2. Additionally remove the downloads and products:
+ $ make distclean
+
+Additional notes on the build-script:
+ * The following *FLAGS are used tu build universal binary with 10.4 SDK:
+ CPPFLAGS=-isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4
+ CFLAGS=-O -g -arch i386 -arch ppc
+ CXXFLAGS=${CFLAGS}
+ LDFLAGS=-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4 -arch i386 -arch ppc
+
+ Because the configure-scripts fails on 10.4 when -syslibroot is specified,
+ this option is supplied to make only.
+
+ * In order to build Mac OS X installer packages in a repeatable manner with
+ the correct owner/group and permissions, PackageMakers's cheap and broken
+ mechanism of applying recommended permissions is not used. Instead
+ Debian's fakeroot tool is used during package building phase to ensure
+ that the ownership of the files in the installer's Archive.pax.gz is set
+ to root and that permissions are kept exactly like "make install" set them
+ before.
diff --git a/bacula/platforms/osx/files/Info.plist.in b/bacula/platforms/osx/files/Info.plist.in
new file mode 100644
index 0000000000..48402bfccf
--- /dev/null
+++ b/bacula/platforms/osx/files/Info.plist.in
@@ -0,0 +1,32 @@
+
+
+
+
+ CFBundleIdentifier
+ org.bacula.bacula-fd
+ CFBundleShortVersionString
+ @BACULA_VERSION@
+ IFPkgFlagAllowBackRev
+
+ IFPkgFlagAuthorizationAction
+ RootAuthorization
+ IFPkgFlagDefaultLocation
+ /
+ IFPkgFlagFollowLinks
+
+ IFPkgFlagInstallFat
+
+ IFPkgFlagIsRequired
+
+ IFPkgFlagOverwritePermissions
+
+ IFPkgFlagRelocatable
+
+ IFPkgFlagRestartAction
+ None
+ IFPkgFlagRootVolumeOnly
+
+ IFPkgFlagUpdateInstalledLanguages
+
+
+
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..1432d08156
--- /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
+ @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/ReadMe.html.in b/bacula/platforms/osx/resources/ReadMe.html.in
new file mode 100644
index 0000000000..41b396fe93
--- /dev/null
+++ b/bacula/platforms/osx/resources/ReadMe.html.in
@@ -0,0 +1,62 @@
+
+
+
+
+
+ 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. The file is located in system-wide Preferences folder:
+
/Library/Preferences/bacula/bacula-fd.conf
+
+
+ Note: The configuration file contains passwords and
+ therefore must not be accessible for any users except root. Use the
+ following command line to edit the file as root-user:
+
sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit /Library/Preferences/bacula/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..f0d18ef27f
--- /dev/null
+++ b/bacula/platforms/osx/resources/postflight.in
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+function genpw() {
+ openssl rand -base64 33
+}
+
+# copy example config files and fix permissions
+if [ ! -f $3@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)
+ mkdir -p "$(dirname $3@FD_CONF@)"
+ 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@FD_CONF@"
+fi
+chmod 0600 "$3@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
+