From 69c0088e8d8d7e70323adb075afcee4eaf4c5d98 Mon Sep 17 00:00:00 2001 From: Lorenz Schori Date: Mon, 24 Aug 2009 18:29:27 +0200 Subject: [PATCH] Apply Lorenz' OSX patch --- bacula/.gitignore | 4 ++ bacula/platforms/osx/Makefile.in | 20 ++++-- bacula/platforms/osx/README | 66 +++++++++++++++++++ bacula/platforms/osx/files/Info.plist.in | 32 +++++++++ .../osx/files/org.bacula.bacula-fd.plist.in | 2 +- bacula/platforms/osx/resources/Info.plist.in | 10 --- bacula/platforms/osx/resources/ReadMe.html.in | 15 +++-- bacula/platforms/osx/resources/postflight.in | 7 +- 8 files changed, 132 insertions(+), 24 deletions(-) create mode 100644 bacula/platforms/osx/README create mode 100644 bacula/platforms/osx/files/Info.plist.in delete mode 100644 bacula/platforms/osx/resources/Info.plist.in diff --git a/bacula/.gitignore b/bacula/.gitignore index 5d0f544b58..1a47809201 100644 --- a/bacula/.gitignore +++ b/bacula/.gitignore @@ -1329,3 +1329,7 @@ updatedb/update_sqlite_tables_9_to_10 /rescue/solaris/1 /rescue/solaris/bacula-fd /rescue/solaris/bacula-fd.conf +platforms/osx/build +platforms/osx/dl +platforms/osx/products +platforms/osx/tools diff --git a/bacula/platforms/osx/Makefile.in b/bacula/platforms/osx/Makefile.in index cd483d7ee6..8be1b78fb6 100644 --- a/bacula/platforms/osx/Makefile.in +++ b/bacula/platforms/osx/Makefile.in @@ -40,6 +40,7 @@ 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 # 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 @@ -55,7 +56,7 @@ 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_RESOURCES:=Description.plist ReadMe.html postflight preupgrade PACKAGE_XRESOURCES:=postflight preupgrade FAKEROOT_TAR:=${DL_DIR}/fakeroot-${FAKEROOT_VERSION}.tar.gz @@ -74,18 +75,27 @@ 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 ${FAKEROOT_DESTDIR} 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}/resources/Info.plist\"" + -r "\"${WORKING_DIR}/resources\"" -i "\"${WORKING_DIR}/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" \ + sed ${INFILE_SUBST} \ files/uninstall.command.in > "${PACKAGE_DIR}/uninstall.command"; chmod 0775 "${PACKAGE_DIR}/uninstall.command" @@ -93,7 +103,7 @@ ${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" \ + sed ${INFILE_SUBST} \ resources/$$res.in > "${WORKING_DIR}/resources/$$res"; \ done @@ -115,7 +125,7 @@ ${BACULA_DESTDIR}: ${BACULA_SOURCE} done mkdir -p "${BACULA_DESTDIR}${BACULA_PREFIX}/Library/LaunchDaemons" - sed "s,@PREFIX@,${BACULA_PREFIX},g" files/org.bacula.bacula-fd.plist.in \ + 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} diff --git a/bacula/platforms/osx/README b/bacula/platforms/osx/README new file mode 100644 index 0000000000..a5ffaafa43 --- /dev/null +++ b/bacula/platforms/osx/README @@ -0,0 +1,66 @@ +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 + +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 gets built and used during the packaging process 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..142da56e33 --- /dev/null +++ b/bacula/platforms/osx/files/Info.plist.in @@ -0,0 +1,32 @@ + + + + + CFBundleIdentifier + org.bacula.bacula-fd + CFBundleShortVersionString + @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 index 9952c40216..1432d08156 100644 --- a/bacula/platforms/osx/files/org.bacula.bacula-fd.plist.in +++ b/bacula/platforms/osx/files/org.bacula.bacula-fd.plist.in @@ -9,7 +9,7 @@ @PREFIX@/sbin/bacula-fd -f -c - @PREFIX@/etc/bacula-fd.conf + @FD_CONF@ Sockets diff --git a/bacula/platforms/osx/resources/Info.plist.in b/bacula/platforms/osx/resources/Info.plist.in deleted file mode 100644 index 9d1cd1ce28..0000000000 --- a/bacula/platforms/osx/resources/Info.plist.in +++ /dev/null @@ -1,10 +0,0 @@ - - - - - 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 index 22914c8dea..41b396fe93 100644 --- a/bacula/platforms/osx/resources/ReadMe.html.in +++ b/bacula/platforms/osx/resources/ReadMe.html.in @@ -27,15 +27,20 @@

Installation

- Open the Bacula File Daemon @BACULA_VERSION@ installer package and follow the - directions given to you. + 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
+ 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

diff --git a/bacula/platforms/osx/resources/postflight.in b/bacula/platforms/osx/resources/postflight.in index d0e4bee93f..f0d18ef27f 100644 --- a/bacula/platforms/osx/resources/postflight.in +++ b/bacula/platforms/osx/resources/postflight.in @@ -5,7 +5,7 @@ function genpw() { } # copy example config files and fix permissions -if [ ! -f $3@PREFIX@/etc/bacula-fd.conf ]; then +if [ ! -f $3@FD_CONF@ ]; then DIR_PW=$(genpw) FD_PW=$(genpw) SD_PW=$(genpw) @@ -13,6 +13,7 @@ if [ ! -f $3@PREFIX@/etc/bacula-fd.conf ]; then 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" \ @@ -22,9 +23,9 @@ if [ ! -f $3@PREFIX@/etc/bacula-fd.conf ]; then -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" + "$3@PREFIX@/etc/bacula-fd.conf.example" > "$3@FD_CONF@" fi -chmod 0640 "$3@PREFIX@/etc/bacula-fd.conf" +chmod 0600 "$3@FD_CONF@" # install startup item mkdir -p -m 0755 "$3/Library/LaunchDaemons" -- 2.39.5