From 1f2e192ffab0145a067369eaa02fb4d3b5f0cc1e Mon Sep 17 00:00:00 2001 From: Lorenz Schori Date: Wed, 18 Nov 2009 19:28:41 +0100 Subject: [PATCH] OSX installer: switch to new pmdoc packagemaker format By switching to the new xml based pmdoc format of PackageMaker it is possible to build OSX installer packages without the help of fakeroot (for root/wheel owned files). The downside of this move is that it is no more possible to create the installer on OSX 10.4 (Tiger). --- bacula/platforms/osx/Makefile.in | 25 ++++++--- bacula/platforms/osx/README | 10 ---- bacula/platforms/osx/files/Info.plist.in | 32 ----------- .../files/installer.pmdoc.in/01destdir.xml | 27 +++++++++ .../osx/files/installer.pmdoc.in/index.xml | 30 ++++++++++ bacula/platforms/osx/installer-gencontents.py | 56 +++++++++++++++++++ .../osx/resources/Description.plist.in | 10 ---- 7 files changed, 129 insertions(+), 61 deletions(-) delete mode 100644 bacula/platforms/osx/files/Info.plist.in create mode 100644 bacula/platforms/osx/files/installer.pmdoc.in/01destdir.xml create mode 100644 bacula/platforms/osx/files/installer.pmdoc.in/index.xml create mode 100644 bacula/platforms/osx/installer-gencontents.py delete mode 100644 bacula/platforms/osx/resources/Description.plist.in diff --git a/bacula/platforms/osx/Makefile.in b/bacula/platforms/osx/Makefile.in index 3c7256f2af..12cf18d492 100644 --- a/bacula/platforms/osx/Makefile.in +++ b/bacula/platforms/osx/Makefile.in @@ -22,7 +22,6 @@ PM:=/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMak 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 ########### @@ -38,6 +37,7 @@ 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 +BACULA_PMDOC:=${WORKING_DIR}/installer.pmdoc # 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 @@ -53,7 +53,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 ReadMe.html postflight preupgrade +PACKAGE_RESOURCES:=ReadMe.html postflight preupgrade PACKAGE_XRESOURCES:=postflight preupgrade # Flags for the toolchain @@ -72,19 +72,16 @@ LDFLAGS:=${MACOSX_VERSION_FLAGS} ${ARCHFLAGS} INFILE_SUBST=\ -e "s,@PREFIX@,${BACULA_PREFIX},g" \ -e "s,@BACULA_VERSION@,${BACULA_VERSION},g" \ - -e "s,@FD_CONF@,${BACULA_FD_CONF},g" + -e "s,@FD_CONF@,${BACULA_FD_CONF},g" \ + -e "s,@BACULA_DESTDIR@,${BACULA_DESTDIR},g" dmg: pkg hdiutil create -srcfolder "${PACKAGE_DIR}" "${PACKAGE_DMG}" -pkg: ${BACULA_DESTDIR} ${WORKING_DIR}/resources +pkg: ${BACULA_DESTDIR} ${BACULA_PMDOC} ${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\"" + ${PM} --doc "${BACULA_PMDOC}" --out "${PACKAGE_BUNDLE}" cp ${WORKING_DIR}/resources/ReadMe.html "${PACKAGE_DIR}/ReadMe.html" @@ -92,6 +89,16 @@ pkg: ${BACULA_DESTDIR} ${WORKING_DIR}/resources files/uninstall.command.in > "${PACKAGE_DIR}/uninstall.command"; chmod 0775 "${PACKAGE_DIR}/uninstall.command" +${BACULA_PMDOC}: ${BACULA_DESTDIR} ${WORKING_DIR}/resources + mkdir -p "${BACULA_PMDOC}" + + for f in index.xml 01destdir.xml; do \ + sed ${INFILE_SUBST} \ + files/installer.pmdoc.in/$$f > "${BACULA_PMDOC}/$$f"; \ + done + + python installer-gencontents.py destdir > ${BACULA_PMDOC}/01destdir-contents.xml + ${WORKING_DIR}/resources: ${BACULA_DESTDIR} mkdir -p "${WORKING_DIR}/resources" diff --git a/bacula/platforms/osx/README b/bacula/platforms/osx/README index 6b2a33c173..387f09631e 100644 --- a/bacula/platforms/osx/README +++ b/bacula/platforms/osx/README @@ -13,8 +13,6 @@ 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 @@ -58,11 +56,3 @@ Additional notes on the build-script: 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 deleted file mode 100644 index 48402bfccf..0000000000 --- a/bacula/platforms/osx/files/Info.plist.in +++ /dev/null @@ -1,32 +0,0 @@ - - - - - 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/installer.pmdoc.in/01destdir.xml b/bacula/platforms/osx/files/installer.pmdoc.in/01destdir.xml new file mode 100644 index 0000000000..35c2877e64 --- /dev/null +++ b/bacula/platforms/osx/files/installer.pmdoc.in/01destdir.xml @@ -0,0 +1,27 @@ + + + + org.bacula.bacula-fd.pkg + @BACULA_VERSION@ + + + + destdir + / + + + + + version + identifier + parent + + + resources/postflight + resources/preupgrade + + + 01destdir-contents.xml + /\.DS_Store$ + + diff --git a/bacula/platforms/osx/files/installer.pmdoc.in/index.xml b/bacula/platforms/osx/files/installer.pmdoc.in/index.xml new file mode 100644 index 0000000000..37ac4647db --- /dev/null +++ b/bacula/platforms/osx/files/installer.pmdoc.in/index.xml @@ -0,0 +1,30 @@ + + + + Bacula File Daemon @BACULA_VERSION@ + org.bacula + + + + + + + + + + + + + + + + resources/License.txt + resources/ReadMe.html + + + + 01destdir.xml + properties.title + properties.anywhereDomain + properties.systemDomain + diff --git a/bacula/platforms/osx/installer-gencontents.py b/bacula/platforms/osx/installer-gencontents.py new file mode 100644 index 0000000000..a061946cb7 --- /dev/null +++ b/bacula/platforms/osx/installer-gencontents.py @@ -0,0 +1,56 @@ +import os +import stat +import sys +from xml.dom.minidom import Document + +def createFtags(doc, path, isrootpath=True): + """ + create f-tags for packagemaker's contents.xml files recursively replacing + owner with "root" and group with "wheel" in each entry + """ + + statinfo = os.lstat(path) + isdir = stat.S_ISDIR(statinfo[0]) + + ftag = doc.createElement("f") + ftag.setAttribute("n",os.path.split(path)[1]) + ftag.setAttribute("p","%d" % statinfo[0]) + ftag.setAttribute("o","root") + ftag.setAttribute("g","wheel") + + # we additionally have to create owner and group + # within each f-tag + ftag.appendChild(doc.createElement("mod").appendChild(doc.createTextNode("owner"))) + ftag.appendChild(doc.createElement("mod").appendChild(doc.createTextNode("group"))) + + if isrootpath: + # needs to be the full path + ftag.setAttribute("pt",os.path.abspath(path)) + # no idea what those attributes mean: + ftag.setAttribute("m","false") + ftag.setAttribute("t","file") + + if isdir: + for item in os.listdir(path): + ftag.appendChild(createFtags(doc, os.path.join(path,item), False)) + + return ftag + +def generateContentsDocument(path): + """ + create new minidom document and generate contents by recursively traver- + sing the given path. + """ + + doc = Document() + root = doc.createElement("pkg-contents") + root.setAttribute("spec","1.12") + root.appendChild(createFtags(doc, path)) + doc.appendChild(root) + + return doc + +if __name__ == "__main__": + # construct document + doc = generateContentsDocument(sys.argv[1]) + print doc.toprettyxml(indent=" "), diff --git a/bacula/platforms/osx/resources/Description.plist.in b/bacula/platforms/osx/resources/Description.plist.in deleted file mode 100644 index 976546eb92..0000000000 --- a/bacula/platforms/osx/resources/Description.plist.in +++ /dev/null @@ -1,10 +0,0 @@ - - - - - IFPkgDescriptionDescription - - IFPkgDescriptionTitle - Bacula File Daemon @BACULA_VERSION@ - - -- 2.39.5