]> git.sur5r.net Git - bacula/bacula/commitdiff
OSX installer: switch to new pmdoc packagemaker format
authorLorenz Schori <lo@znerol.ch>
Wed, 18 Nov 2009 18:28:41 +0000 (19:28 +0100)
committerEric Bollengier <eric@eb.homelinux.org>
Mon, 23 Nov 2009 22:27:05 +0000 (23:27 +0100)
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
bacula/platforms/osx/README
bacula/platforms/osx/files/Info.plist.in [deleted file]
bacula/platforms/osx/files/installer.pmdoc.in/01destdir.xml [new file with mode: 0644]
bacula/platforms/osx/files/installer.pmdoc.in/index.xml [new file with mode: 0644]
bacula/platforms/osx/installer-gencontents.py [new file with mode: 0644]
bacula/platforms/osx/resources/Description.plist.in [deleted file]

index 3c7256f2af3917066d2a4847b5ae81fa8d34fec3..12cf18d4923c2d4f313a6f6d5ecc8a36078d48e9 100644 (file)
@@ -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"
 
index 6b2a33c173559aca605d2050f83955e09f0086bc..387f09631e6dbfdf736c1591e9a3757c2527c8ba 100644 (file)
@@ -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 (file)
index 48402bf..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-       <key>CFBundleIdentifier</key>
-       <string>org.bacula.bacula-fd</string>
-       <key>CFBundleShortVersionString</key>
-       <string>@BACULA_VERSION@</string>
-       <key>IFPkgFlagAllowBackRev</key>
-       <false/>
-       <key>IFPkgFlagAuthorizationAction</key>
-       <string>RootAuthorization</string>
-       <key>IFPkgFlagDefaultLocation</key>
-       <string>/</string>
-       <key>IFPkgFlagFollowLinks</key>
-       <true/>
-       <key>IFPkgFlagInstallFat</key>
-       <false/>
-       <key>IFPkgFlagIsRequired</key>
-       <false/>
-       <key>IFPkgFlagOverwritePermissions</key>
-       <false/>
-       <key>IFPkgFlagRelocatable</key>
-       <false/>
-       <key>IFPkgFlagRestartAction</key>
-       <string>None</string>
-       <key>IFPkgFlagRootVolumeOnly</key>
-       <false/>
-       <key>IFPkgFlagUpdateInstalledLanguages</key>
-       <false/>
-</dict>
-</plist>
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 (file)
index 0000000..35c2877
--- /dev/null
@@ -0,0 +1,27 @@
+<?xml version="1.0"?>
+<pkgref spec="1.12" uuid="E3A20DCD-888A-4211-8318-BF9CAA10B769">
+  <config>
+    <identifier>org.bacula.bacula-fd.pkg</identifier>
+    <version>@BACULA_VERSION@</version>
+    <description/>
+    <post-install type="none"/>
+    <requireAuthorization/>
+    <installFrom>destdir</installFrom>
+    <installTo>/</installTo>
+    <flags>
+      <followSymbolicLinks/>
+    </flags>
+    <packageStore type="internal"/>
+    <mod>version</mod>
+    <mod>identifier</mod>
+    <mod>parent</mod>
+  </config>
+  <scripts>
+    <postflight relative="true" mod="true">resources/postflight</postflight>
+    <preupgrade relative="true" mod="true">resources/preupgrade</preupgrade>
+  </scripts>
+  <contents>
+    <file-list>01destdir-contents.xml</file-list>
+    <filter>/\.DS_Store$</filter>
+  </contents>
+</pkgref>
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 (file)
index 0000000..37ac464
--- /dev/null
@@ -0,0 +1,30 @@
+<?xml version="1.0"?>
+<pkmkdoc spec="1.12">
+  <properties>
+    <title>Bacula File Daemon @BACULA_VERSION@</title>
+    <organization>org.bacula</organization>
+    <userSees ui="easy"/>
+    <min-target os="2"/>
+    <domain system="true"/>
+  </properties>
+  <distribution>
+    <versions min-spec="1.000000"/>
+    <scripts/>
+  </distribution>
+  <contents>
+    <choice title="destdir" id="choice0" starts_selected="true" starts_enabled="true" starts_hidden="false">
+      <pkgref id="org.bacula.bacula-fd.pkg"/>
+    </choice>
+  </contents>
+  <resources bg-scale="none" bg-align="topleft">
+    <locale lang="en">
+      <resource mod="true" type="license">resources/License.txt</resource>
+      <resource mod="true" type="readme">resources/ReadMe.html</resource>
+    </locale>
+  </resources>
+  <flags/>
+  <item type="file">01destdir.xml</item>
+  <mod>properties.title</mod>
+  <mod>properties.anywhereDomain</mod>
+  <mod>properties.systemDomain</mod>
+</pkmkdoc>
diff --git a/bacula/platforms/osx/installer-gencontents.py b/bacula/platforms/osx/installer-gencontents.py
new file mode 100644 (file)
index 0000000..a061946
--- /dev/null
@@ -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 <mod>owner</mod> and <mod>group</mod>
+    # 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 (file)
index 976546e..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-       <key>IFPkgDescriptionDescription</key>
-       <string></string>
-       <key>IFPkgDescriptionTitle</key>
-       <string>Bacula File Daemon @BACULA_VERSION@</string>
-</dict>
-</plist>