Permalink
Browse files

Adds a new script to build MacOS X binary packages (.dmg). Both this

script and the Windows one have been relocated to the /packages
directory.


git-svn-id: svn://cherokee-project.com/cherokee/trunk@3527 5dc97367-97f1-0310-9951-d761b3857238
  • Loading branch information...
1 parent 0b78500 commit 39986480962347d3fb48c9a1d0f7dbd50c8e4d10 @alobbs alobbs committed Aug 10, 2009
View
@@ -1,6 +1,6 @@
## Cherokee: Makefile.am -*- makefile -*-
-SUBDIRS = po m4 www icons themes qa doc . admin contrib cherokee cget windows dbslayer
+SUBDIRS = po m4 www icons themes qa doc . admin contrib cherokee cget packages dbslayer
SUFFIXES = .sample.pre .sample .h.pre .h .xml.pre .xml
ACLOCAL_AMFLAGS = -I m4
View
@@ -320,3 +320,5 @@ mime!video/x-msvideo!extensions = avi
mime!video/x-sgi-movie!extensions = movie
mime!x-conference/x-cooltalk!extensions = ice
mime!x-world/x-vrml!extensions = vrm,vrml,wrl
+server!user = www
+server!group = www
View
@@ -25,7 +25,7 @@ AC_PREREQ([2.60])
dnl Version
m4_define([cherokee_major_version], [0])
m4_define([cherokee_minor_version], [99])
-m4_define([cherokee_micro_version], [22])
+m4_define([cherokee_micro_version], [23])
m4_define([cherokee_version], m4_format('%s.%s.%s', cherokee_major_version, cherokee_minor_version, cherokee_micro_version))
dnl Init autoconf and automake
@@ -1450,8 +1450,12 @@ themes/Makefile
themes/default/Makefile
themes/firefox3/Makefile
themes/plain/Makefile
-windows/Makefile
-windows/cherokee.nsi
+packages/Makefile
+packages/osx/Makefile
+packages/osx/Info.plist
+packages/osx/Description.plist
+packages/windows/Makefile
+packages/windows/cherokee.nsi
www/Makefile
dbslayer/Makefile
admin/Makefile
View
@@ -0,0 +1,3 @@
+## Cherokee: Makefile.am -*- makefile -*-
+
+SUBDIRS = windows osx
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+
+<plist version="1.0">
+<dict>
+ <key>IFPkgDescriptionTitle</key>
+ <string>cherokee</string>
+
+ <key>IFPkgDescriptionVersion</key>
+ <string>@VERSION@</string>
+</dict>
+</plist>
View
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+
+<plist version="1.0">
+<dict>
+ <!-- Provides information for the Finder to display about the package -->
+ <key>CFBundleGetInfoString</key>
+ <string>Cherokee Web Server @VERSION@</string>
+
+ <!-- Provides information for the Finder to display about the package. -->
+ <key>CFBundleName</key>
+ <string>cherokee</string>
+
+ <!-- Provides information for the Finder to display about the package. -->
+ <key>CFBundleShortVersionString</key>
+ <string>@VERSION@</string>
+
+ <!-- A unique identifier string for the bundle. It should be in the form of a Java-style package name. -->
+ <key>CFBundleIdentifier</key>
+ <string>org.cherokeeproject.cherokee</string>
+
+ <!-- Should Installer require authorization (and prompt the user to authenticate)? -->
+ <key>IFPkgFlagAuthorizationAction</key>
+ <string>AdminAuthorization</string>
+
+ <key>IFPkgFlagDefaultLocation</key>
+ <string>/usr/local</string>
+
+ <key>IFPkgFlagRelocatable</key>
+ <false/>
+
+ <!-- Weird, standard version string to indicate the package format -->
+ <key>IFPkgFormatVersion</key>
+ <real>0.10000000149011612</real>
+</dict>
+</plist>
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -0,0 +1,18 @@
+## Cherokee: Makefile.am -*- makefile -*-
+
+BINARIES = \
+License.rtf \
+background.tiff.gz
+
+PYTHON = \
+utils.py \
+build.py
+
+EXTRA_DIST = \
+$(PYTHON) \
+$(BINARIES) \
+Info.plist \
+Info.plist.in \
+Description.plist \
+Description.plist.in
+
Binary file not shown.
View
@@ -0,0 +1,108 @@
+#!/usr/bin/env python
+
+import os
+import re
+from utils import *
+
+TMP = "/var/tmp"
+SVN_URL = "svn://cherokee-project.com/cherokee/trunk"
+DIR = "cherokee-trunk"
+CONFIGURE_PARAMS = "--prefix=/usr/local --enable-static-module=all --enable-static --enable-shared=no --with-mysql=no --with-ldap=no"
+MAKE_PARAMS = "-j4"
+DESTDIR = "%s/cherokee-destdir" % (TMP)
+DESTDIR_ROOT = "%s/cherokee-destdir/root" % (TMP)
+DESTDIR_RESOURCES = "%s/cherokee-destdir/resouces" % (TMP)
+PKG_MAKER = "/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker"
+
+
+def _figure_version (path):
+ info = open (os.path.join (path, "Info.plist"), 'r').read()
+ regex = r"<key>CFBundleShortVersionString</key>[ \n\r]*<string>(.+)</string>"
+ return re.findall(regex, info, re.MULTILINE)[0]
+
+def _perform():
+ dmg_fullpath = "%s/Cherokee-%s.dmg" % (osx_dir, version)
+
+ # Clean up
+ exe ("sudo rm -rfv %s %s %s" % (DIR, DESTDIR, dmg_fullpath), colorer=red)
+ exe ("mkdir -p %s %s" % (DESTDIR_ROOT, DESTDIR_RESOURCES), colorer=blue)
+
+ # Set the www user
+ cfg = '%s/cherokee.conf.sample.pre' % (src_topdir)
+ if not "server!user = www" in open(cfg, 'r').read():
+ f = open (cfg, 'a')
+ f.write ('server!user = www\n')
+ f.write ('server!group = www\n')
+ f.close()
+
+ # Ensure it's compiled
+ chdir (src_topdir)
+ exe ("make %s" % (MAKE_PARAMS))
+
+ # Install it
+ exe ("sudo make install DESTDIR=%s" % (DESTDIR_ROOT))
+ exe ("sudo mv %s/usr/local/etc/cherokee/cherokee.conf %s/usr/local/etc/cherokee/cherokee.conf.example" % (DESTDIR_ROOT, DESTDIR_ROOT), colorer=red)
+
+ # Fix permissions (TODO)
+ None
+
+ # Copy resources
+ exe ("cp -v %s/Info.plist %s" % (osx_dir, DESTDIR_RESOURCES), colorer=green)
+ exe ("cp -v %s/Description.plist %s" % (osx_dir, DESTDIR_RESOURCES), colorer=green)
+ exe ("cp -v %s/License.rtf %s" % (osx_dir, DESTDIR_RESOURCES), colorer=green)
+ exe ("gunzip --stdout %s/background.tiff.gz > %s/background.tiff" % (osx_dir, DESTDIR_RESOURCES), colorer=green)
+
+ # Clean up
+ exe ("rm -rfv %s/cherokee-%s.pkg" %(TMP, version), colorer=red)
+ exe ("rm -rfv %s/Cherokee-%s.dmg" %(TMP, version), colorer=red)
+
+ # Build package and image
+ chdir ('%s/usr/local' %(DESTDIR_ROOT))
+ exe ("%s -build -v " % (PKG_MAKER) +
+ "-p %s/cherokee-%s.pkg " % (TMP, version) +
+ "-f %s/usr/local " % (DESTDIR_ROOT) +
+ "-r %s " % (DESTDIR_RESOURCES) +
+ "-i %s/Info.plist " % (DESTDIR_RESOURCES) +
+ "-d %s/Description.plist " % (DESTDIR_RESOURCES))
+
+ chdir (TMP)
+ exe ("hdiutil create -volname Cherokee-%s -srcfolder cherokee-%s.pkg %s" % (version, version, dmg_fullpath), colorer=green)
+ exe ("ls -l %s" % (dmg_fullpath))
+
+
+def perform():
+ # Get the srcdir
+ global osx_dir
+ global src_topdir
+ global version
+
+ osx_dir = os.path.abspath (os.path.dirname(__file__))
+ src_topdir = os.path.abspath ("../..")
+ version = _figure_version (osx_dir)
+
+ # Change the current directory
+ prev_dir = chdir (TMP)
+
+ # Perform
+ try:
+ _perform()
+ except:
+ chdir (prev_dir)
+ raise
+
+ # Done and dusted
+ chdir (prev_dir)
+ print yellow("Done and dusted!")
+
+
+def check_preconditions():
+ assert "prefix = /usr/local" in open("Makefile").read(), "Wrong configuration"
+ assert os.access (TMP, os.W_OK), "Cannot compile in: %s" %(TMP)
+ assert which("svn"), "SVN is required"
+ assert which("gunzip"), "gunzip is required"
+ assert which("hdiutil"), "hdiutil is required"
+
+
+if __name__ == "__main__":
+ check_preconditions()
+ perform()
View
@@ -0,0 +1,73 @@
+import os
+import subprocess
+
+
+# Colors
+#
+ESC = chr(27) + '['
+RESET = '%s0m' % (ESC)
+
+def green (s):
+ return ESC + '0;32m' + s + RESET
+
+def red (s):
+ return ESC + '0;31m' + s + RESET
+
+def yellow (s):
+ return ESC + '1;33m' + s + RESET
+
+def blue (s):
+ return ESC + '0;34m' + s + RESET
+
+
+# Utilies
+#
+def prepend_env (var, value):
+ prev = os.getenv(var)
+ os.putenv(var, "%s:%s"%(value, prev))
+ return prev
+
+def chdir (dir):
+ if '*' in dir or '?' in dir:
+ tmp = exe_output ("ls -1d %s" %(dir))
+ dir = tmp.split('\n')[0]
+ current = os.getcwd()
+ os.chdir (dir)
+ return current
+
+def exe_output (cmd):
+ p = subprocess.Popen (cmd, shell=True, stdout=subprocess.PIPE)
+ return p.stdout.read()
+
+def exe (cmd, colorer=lambda x: x, return_fatal=True):
+ p = subprocess.Popen (cmd, shell=True, stdout=subprocess.PIPE)
+ while True:
+ line = p.stdout.readline()
+ if not line:
+ break
+ print colorer(line.rstrip('\n\r'))
+
+ p.wait()
+ if return_fatal:
+ if p.returncode != 0:
+ print '\n%s: Could execute: %s' %(red('ERROR'), cmd)
+
+ assert p.returncode == 0, "Execution failed"
+
+ return p.returncode
+
+def which (program):
+ def is_exe(fpath):
+ return os.path.exists(fpath) and os.access(fpath, os.X_OK)
+
+ fpath, fname = os.path.split(program)
+ if fpath:
+ if is_exe(program):
+ return program
+ else:
+ for path in os.environ["PATH"].split(os.pathsep):
+ exe_file = os.path.join(path, program)
+ if is_exe(exe_file):
+ return exe_file
+
+ return None
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 3998648

Please sign in to comment.