[82534] trunk/dports/_resources/port1.0/group/app-1.0.tcl

ryandesign at macports.org ryandesign at macports.org
Mon Aug 15 05:41:04 PDT 2011


Revision: 82534
          http://trac.macports.org/changeset/82534
Author:   ryandesign at macports.org
Date:     2011-08-15 05:41:03 -0700 (Mon, 15 Aug 2011)
Log Message:
-----------
app-1.0.tcl: new portgroup; see #14557

Added Paths:
-----------
    trunk/dports/_resources/port1.0/group/app-1.0.tcl

Added: trunk/dports/_resources/port1.0/group/app-1.0.tcl
===================================================================
--- trunk/dports/_resources/port1.0/group/app-1.0.tcl	                        (rev 0)
+++ trunk/dports/_resources/port1.0/group/app-1.0.tcl	2011-08-15 12:41:03 UTC (rev 82534)
@@ -0,0 +1,252 @@
+# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
+# $Id$
+# 
+# Copyright (c) 2011 The MacPorts Project
+# All rights reserved.
+# 
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+# 
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+# 3. Neither the name of The MacPorts Project nor the names of its
+#    contributors may be used to endorse or promote products derived from
+#    this software without specific prior written permission.
+# 
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# 
+# 
+# This PortGroup helps create an application bundle the user can open from the
+# Finder or the Dock. This is useful for ports that install a program built
+# with an SDK like SDL or Qt that, when launched, causes an icon to appear in
+# the Dock and opens a proper Mac OS X GUI, but that do not build their own
+# app bundle to easily launch it.
+
+
+# app.create: whether to create the app bundle at all.
+#
+# The default is yes.
+
+options app.create
+default app.create yes
+
+
+# app.name: the name of the app that users will see in the Finder.
+#
+# The default is based on ${name}: if ${name} contains any uppercase letters,
+# ${name} is used, otherwise the first character of ${name} is uppercased.
+#
+# Info.plist key CFBundleName.
+
+options app.name
+default app.name {[app.get_default_name]}
+
+proc app.get_default_name {} {
+    global name
+    if {[regexp {[A-Z]} ${name}]} {
+        return ${name}
+    }
+    return [string totitle ${name}]
+}
+
+
+# app.executable: the program the app will run.
+#
+# The default is ${name}; relative paths are relative to ${prefix}/bin. If you
+# specify a relative or absolute path to a program that exists in ${destroot},
+# the app will contain a symlink to that program. If you specify an absolute
+# path in ${workpath} or ${filespath} it will be copied into the app. This is
+# useful if you need to write a wrapper script, for example to set environment
+# variables. If your wrapper script can be used as is, leave it in ${filespath}
+# and let it be copied from there. If the wrapper needs placeholders to be
+# reinplaced first, copy it into ${workpath}, do your reinplacing, then let it
+# be copied from there.
+#
+# Relates to Info.plist key CFBundleExecutable.
+
+options app.executable
+default app.executable {${name}}
+
+
+# app.icon: the icon the app will have.
+#
+# The default is empty; if no icon graphic is available for this software, this
+# is fine. You can specify an absolute or relative path to an existing .icns
+# file, or the path to a .png or other graphic file that the makeicns program
+# can convert. Relative paths are relative to ${worksrcpath}.
+#
+# Relates to Info.plist key CFBundleIconFile.
+
+options app.icon
+default app.icon ""
+
+
+# app.short_version_string: the version number.
+#
+# The default is ${version}. This is fine for most ports, but ports that list
+# both version and build number in ${version} may wish to separate these here.
+#
+# Info.plist key CFBundleShortVersionString.
+
+options app.short_version_string
+default app.short_version_string {${version}}
+
+
+# app.version: the build number.
+#
+# The default is ${version}. This is fine for most ports, but ports that list
+# both version and build number in ${version} may wish to separate these here.
+#
+# Info.plist key CFBundleVersion.
+
+options app.version
+default app.version {${version}}
+
+
+# app.identifier: the app's unique bundle identifier.
+#
+# The default is computed based on ${homepage} and ${app.name}. For almost all
+# ports this does not need to be overridden.
+#
+# Info.plist key CFBundleIdentifier.
+
+options app.identifier
+default app.identifier {[app.get_default_identifier]}
+
+proc app.get_default_identifier {} {
+    global app.name homepage
+    set identifier [split [lindex [split ${homepage} "/"] 2] .]
+    if {[lindex ${identifier} 0] == "www"} {
+        set identifier [lrange ${identifier} 1 end]
+    }
+    set identifier [lreverse ${identifier}]
+    lappend identifier [regsub -all -nocase {[^a-z0-9.-]} ${app.name} "-"]
+    return [join ${identifier} .]
+}
+
+
+platform macosx {
+    post-destroot {
+        if {[tbool app.create]} {
+            # Ensure app.name is valid.
+            if {[regexp {[/]} ${app.name}]} {
+                return -code error "app.name ${app.name} contains illegal characters"
+            }
+            
+            # Make the app bundle directories.
+            xinstall -d ${destroot}${applications_dir}/${app.name}.app/Contents/MacOS \
+                        ${destroot}${applications_dir}/${app.name}.app/Contents/Resources
+            
+            # Ensure app.identifier is valid.
+            if {[regexp -nocase {[^a-z0-9.-]} ${app.identifier}]} {
+                return -code error "app.identifier ${app.identifier} contains illegal characters"
+            }
+            if {[llength [split ${app.identifier} "."]] < 3} {
+                return -code error "app.identifier ${app.identifier} does not look like a valid CFBundleIdentifier"
+            }
+            
+            if {${app.icon} != ""} {
+                # Turn relative app.icon paths into absolute ones.
+                set icon ${app.icon}
+                if {[string index ${icon} 0] != "/"} {
+                    set icon ${worksrcpath}/${icon}
+                }
+                
+                # Ensure app.icon exists.
+                if {![file exists ${icon}]} {
+                    return -code error "app.icon ${app.icon} does not exist"
+                }
+                
+                # If app.icon is an .icns file, copy it.
+                if {[file extension ${icon}] == ".icns"} {
+                    xinstall -m 644 ${icon} ${destroot}${applications_dir}/${app.name}.app/Contents/Resources/${app.name}.icns
+                
+                # If app.icon is another type of image file, convert it.
+                } else {
+                    if {[catch {exec ${prefix}/bin/makeicns -in ${icon} -out ${destroot}${applications_dir}/${app.name}.app/Contents/Resources/${app.name}.icns 2>@1}]} {
+                        return -code error "app.icon ${app.icon} could not be converted to ${app.name}.icns: $::errorInfo"
+                    }
+                }
+            }
+            
+            # Turn relative app.executable paths into absolute ones.
+            set executable ${app.executable}
+            if {[string index ${executable} 0] != "/"} {
+                set executable ${prefix}/bin/${executable}
+            }
+            
+            # Check for a possible maintainer error.
+            if {[string first ${destroot} ${executable}] == 0} {
+                return -code error "app.executable ${app.executable} should not start with \${destroot}"
+            }
+            
+            # If app.executable is in the destroot, link to it.
+            if {[file exists ${destroot}${executable}]} {
+                ln -s ${executable} ${destroot}${applications_dir}/${app.name}.app/Contents/MacOS/${app.name}
+            } elseif {[file exists ${executable}]} {
+                # If app.executable starts with ${workpath} or ${filespath}, copy it.
+                if {[string first ${workpath} ${executable}] == 0 || [string first ${filespath} ${executable}] == 0} {
+                    xinstall ${executable} ${destroot}${applications_dir}/${app.name}.app/Contents/MacOS/${app.name}
+                } else {
+                    return -code error "app.executable ${app.executable} does not belong to this port"
+                }
+            } else {
+                return -code error "app.executable ${app.executable} does not exist"
+            }
+            
+            # Build the Info.plist.
+            set fp [open ${destroot}${applications_dir}/${app.name}.app/Contents/Info.plist w]
+            puts ${fp} "<?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>CFBundleDevelopmentRegion</key>
+    <string>English</string>
+    <key>CFBundleExecutable</key>
+    <string>${app.name}</string>"
+            if {${app.icon} != ""} {
+                puts ${fp} "    <key>CFBundleIconFile</key>
+    <string>${app.name}.icns</string>"
+            }
+            puts ${fp} "    <key>CFBundleIdentifier</key>
+    <string>${app.identifier}</string>
+    <key>CFBundleInfoDictionaryVersion</key>
+    <string>6.0</string>
+    <key>CFBundleName</key>
+    <string>${app.name}</string>
+    <key>CFBundlePackageType</key>
+    <string>APPL</string>
+    <key>CFBundleShortVersionString</key>
+    <string>${app.short_version_string}</string>
+    <key>CFBundleSignature</key>
+    <string>????</string>
+    <key>CFBundleVersion</key>
+    <string>${app.version}</string>
+</dict>
+</plist>"
+            close ${fp}
+            
+            # Build the PkgInfo file.
+            set fp [open ${destroot}${applications_dir}/${app.name}.app/Contents/PkgInfo w]
+            puts -nonewline ${fp} "APPL????"
+            close ${fp}
+        }
+    }
+}
+
+# TODO: automatically add depends_build-append port:makeicns
+# TODO: for Tiger we probably need our own lreverse implementation e.g. http://wiki.tcl.tk/17188


Property changes on: trunk/dports/_resources/port1.0/group/app-1.0.tcl
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20110815/4857ccff/attachment.html>


More information about the macports-changes mailing list