source: trunk/base/src/package1.0/portmpkg.tcl @ 42662

Last change on this file since 42662 was 42662, checked in by raimue@…, 12 years ago

Merged revisions 34469,34852,34854-34855,34900,36952-36956,37507-37508,37511-37512,41040,41042-41046,41138-41139,41142-41143,41145,41151,41403,41458,41462-41463,42575,42626,42640-42641,42659 via svnmerge from
https://svn.macosforge.org/repository/macports/branches/variant-descs-14482/base

........

r34469 | raimue@… | 2008-02-26 07:08:09 +0100 (Tue, 26 Feb 2008) | 3 lines


port/port.tcl:
Reading from .config/variant_descriptions actually works

........

r34852 | raimue@… | 2008-03-09 02:45:22 +0100 (Sun, 09 Mar 2008) | 4 lines


macports1.0/macports.tcl:
New API: macports::getsourceconfigdir
Returns the path to .config for a porturl.

........

r34854 | raimue@… | 2008-03-09 03:11:27 +0100 (Sun, 09 Mar 2008) | 3 lines


port/port.tcl:
Use new API macports::getsourceconfigdir

........

r34855 | raimue@… | 2008-03-09 03:12:54 +0100 (Sun, 09 Mar 2008) | 3 lines


port/port.tcl:
Treat variant descriptions as strings to avoid problems with braces

........

r34900 | raimue@… | 2008-03-10 16:54:25 +0100 (Mon, 10 Mar 2008) | 3 lines


port/port.tcl:
Rename variable

........

r36952 | raimue@… | 2008-05-21 04:20:27 +0200 (Wed, 21 May 2008) | 3 lines


port/port.tcl:
Remove get_variant_desc, this will now be done in port1.0/portutil.tcl instead

........

r36953 | raimue@… | 2008-05-21 04:22:04 +0200 (Wed, 21 May 2008) | 3 lines


macports1.0/macports.tcl:
Give the worker access to variable porturl and proc getsourceconfigdir

........

r36954 | raimue@… | 2008-05-21 04:23:37 +0200 (Wed, 21 May 2008) | 3 lines


port1.0/tests:
Fix the portutil test after r36953

........

r36955 | raimue@… | 2008-05-21 05:01:11 +0200 (Wed, 21 May 2008) | 3 lines


macports1.0/macports.tcl:
Give worker access to getprotocol and getportdir as they are needed for getsourceconfigdir

........

r36956 | raimue@… | 2008-05-21 05:02:23 +0200 (Wed, 21 May 2008) | 3 lines


port1.0/portutil.tcl:
New proc variant_desc, reads global variant description file

........

r37507 | raimue@… | 2008-06-10 16:04:54 +0200 (Tue, 10 Jun 2008) | 4 lines


port1.0/portutil.tcl:
Don't warn about a missing description if it is set global,
but warn if the variant overrides the global description

........

r37508 | raimue@… | 2008-06-10 16:14:03 +0200 (Tue, 10 Jun 2008) | 3 lines


macports1.0/macports.tcl:
Use .resources instead of .config as it is a bit clearer, see #14553

........

r37511 | raimue@… | 2008-06-10 17:22:12 +0200 (Tue, 10 Jun 2008) | 5 lines


port1.0/portutil.tcl:
Switch back to this format:
name {description}
So this could be easily extended if ever needed.

........

r37512 | raimue@… | 2008-06-10 17:27:48 +0200 (Tue, 10 Jun 2008) | 3 lines


port1.0/portutil.tcl:
Add a warning if global variant description file could not be opened

........

r41040 | raimue@… | 2008-10-21 13:06:39 +0200 (Tue, 21 Oct 2008) | 4 lines


macports/macport.tcl:

  • New flag "default" for sources to indicate fallback for resources (group)
  • Add parameter to getsourceconfigdir to get path for a requested file

........

r41042 | raimue@… | 2008-10-21 13:11:44 +0200 (Tue, 21 Oct 2008) | 3 lines


macports1.0/macports.tcl:
Rename getsourceconfigdir to getportresourcepath

........

r41043 | raimue@… | 2008-10-21 13:15:16 +0200 (Tue, 21 Oct 2008) | 3 lines


port1.0/portutil.tcl:
Use getportresourcepath for the group files

........

r41044 | raimue@… | 2008-10-21 13:19:47 +0200 (Tue, 21 Oct 2008) | 3 lines


port1.0/portlint.tcl:
Use getresourcepath for group files

........

r41045 | raimue@… | 2008-10-21 13:20:36 +0200 (Tue, 21 Oct 2008) | 3 lines


port1.0/portmain.tcl:
Add a note that we should get rid of $portresourcepath in favor of [getportresourcepath]

........

r41046 | raimue@… | 2008-10-21 13:40:29 +0200 (Tue, 21 Oct 2008) | 3 lines


port1.0/portutil.tcl:
Missed one instance of getsourceconfigdir

........

r41138 | raimue@… | 2008-10-25 20:52:50 +0200 (Sat, 25 Oct 2008) | 3 lines


port1.0/portutil.tcl:
Use getportresourcepath for global variant descriptions

........

r41139 | raimue@… | 2008-10-25 21:23:15 +0200 (Sat, 25 Oct 2008) | 3 lines


port1.0/portmain.tcl:
Correct XXX tag

........

r41142 | raimue@… | 2008-10-25 23:11:30 +0200 (Sat, 25 Oct 2008) | 3 lines


port1.0/portfetch.tcl:
Use getportresourcepath

........

r41143 | raimue@… | 2008-10-25 23:12:04 +0200 (Sat, 25 Oct 2008) | 3 lines


port1.0/portdestroot.tcl:
Use getportresourcepath

........

r41145 | raimue@… | 2008-10-26 00:04:15 +0200 (Sun, 26 Oct 2008) | 3 lines


macports1.0/macports.tcl:
Fix a problem with URLs not using the file protocol

........

r41151 | raimue@… | 2008-10-26 03:09:54 +0100 (Sun, 26 Oct 2008) | 3 lines


macports1.0/macports.tcl:
Fix issues introduced in r41145, the file exists check was wrong

........

r41403 | raimue@… | 2008-11-01 22:59:21 +0100 (Sat, 01 Nov 2008) | 3 lines


port1.0/portutil.tcl:
Add a debug output which group files are used

........

r41458 | blb@… | 2008-11-03 22:58:28 +0100 (Mon, 03 Nov 2008) | 2 lines


Add [default] tag and description to sources.conf

........

r41462 | blb@… | 2008-11-04 02:12:28 +0100 (Tue, 04 Nov 2008) | 2 lines


No longer need to install resources with base

........

r41463 | blb@… | 2008-11-04 02:14:49 +0100 (Tue, 04 Nov 2008) | 4 lines


Move the install/ subdir (containing the mtree files) into .../share/macports
from the resources dir (the mtree contains a bit of install-time info, so it
shouldn't be with the resources stuff in the port tree)

........

r42575 | blb@… | 2008-11-25 01:53:05 +0100 (Tue, 25 Nov 2008) | 3 lines


Add script to handle upgrades through configure/make/make install and
the package, so [default] is added as appropriate to sources.conf

........

r42626 | raimue@… | 2008-11-27 02:21:15 +0100 (Thu, 27 Nov 2008) | 3 lines


package1.0/portpkg.tcl, package1.0/portmpkg.tcl:
Remove portresourcepath and use [getportresourcepath] instead

........

r42640 | raimue@… | 2008-11-27 11:49:32 +0100 (Thu, 27 Nov 2008) | 3 lines


package1.0/portrpm.tcl, package1.0/portsrpm.tcl:
Remove reference to portresurcepath which is not used at all

........

r42641 | raimue@… | 2008-11-27 11:52:12 +0100 (Thu, 27 Nov 2008) | 3 lines


port1.0/portmain.tcl:
Remove definition of portresourcepath as it is not used any more

........

r42659 | raimue@… | 2008-11-28 16:44:30 +0100 (Fri, 28 Nov 2008) | 3 lines


macports1.0/macports.tcl:
Rename portresourcepath from .resources to _resources

........

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 7.2 KB
Line 
1# et:ts=4
2# portmpkg.tcl
3# $Id: portmpkg.tcl 42662 2008-11-28 23:18:50Z raimue@macports.org $
4#
5# Copyright (c) 2002 - 2003 Apple Computer, Inc.
6# All rights reserved.
7#
8# Redistribution and use in source and binary forms, with or without
9# modification, are permitted provided that the following conditions
10# are met:
11# 1. Redistributions of source code must retain the above copyright
12#    notice, this list of conditions and the following disclaimer.
13# 2. Redistributions in binary form must reproduce the above copyright
14#    notice, this list of conditions and the following disclaimer in the
15#    documentation and/or other materials provided with the distribution.
16# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
17#    may be used to endorse or promote products derived from this software
18#    without specific prior written permission.
19#
20# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30# POSSIBILITY OF SUCH DAMAGE.
31#
32
33package provide portmpkg 1.0
34package require portutil 1.0
35
36set org.macports.mpkg [target_new org.macports.mpkg mpkg_main]
37target_runtype ${org.macports.mpkg} always
38target_provides ${org.macports.mpkg} mpkg
39target_requires ${org.macports.mpkg} pkg
40
41# define options
42options package.destpath package.flat
43
44set_ui_prefix
45
46proc mpkg_main {args} {
47    global portname portversion portrevision package.destpath package.flat UI_PREFIX
48
49    # Make sure the destination path exists.
50    system "mkdir -p ${package.destpath}"
51
52    return [package_mpkg $portname $portversion $portrevision]
53}
54
55proc make_dependency_list {portname} {
56        set result {}
57        if {[catch {set res [mport_search "^$portname\$"]} error]} {
58                global errorInfo
59                ui_debug "$errorInfo"
60                ui_error "port search failed: $error"
61                return 1
62        }
63        foreach {name array} $res {
64                array set portinfo $array
65
66                if {[info exists portinfo(depends_run)] || [info exists portinfo(depends_lib)]} {
67                        # get the union of depends_run and depends_lib
68                        # xxx: only examines the portfile component of the depspec
69                        set depends {}
70                        if {[info exists portinfo(depends_run)]} { eval "lappend depends $portinfo(depends_run)" }
71                        if {[info exists portinfo(depends_lib)]} { eval "lappend depends $portinfo(depends_lib)" }
72
73                        foreach depspec $depends {
74                                set dep [lindex [split $depspec :] end]
75       
76                                # xxx: nasty hack
77                                if {$dep != "XFree86"} {
78                                        eval "lappend result [make_dependency_list $dep]"
79                                }
80                        }
81                }
82                lappend result $portinfo(name)/$portinfo(version)
83                unset portinfo
84        }
85        ui_debug "dependencies for ${portname}: $result"
86        return $result
87}
88
89proc make_one_package {portname portversion destination} {
90        global prefix package.destpath package.flat
91        if {[catch {set res [mport_search "^$portname\$"]} result]} {
92                global errorInfo
93                ui_debug "$errorInfo"
94                ui_error "port search failed: $result"
95                return 1
96        }
97        foreach {name array} $res {
98                array set portinfo $array
99               
100                if {[info exists portinfo(porturl)] && [info exists portinfo(version)] && $portinfo(version) == $portversion} {
101                        # only the prefix gets passed to the worker.
102                        ui_debug "building dependency package: $portname"
103                        set worker [mport_open $portinfo(porturl) [list prefix $prefix package.destpath ${destination} package.flat ${package.flat}] {} yes]
104                        mport_exec $worker pkg
105                        mport_close $worker
106                }
107                unset portinfo
108        }
109}
110
111proc package_mpkg {portname portversion portrevision} {
112    global portdbpath destpath workpath prefix porturl description package.destpath package.flat long_description homepage depends_run depends_lib
113
114        set pkgpath ${package.destpath}/${portname}-${portversion}.pkg
115        set mpkgpath ${package.destpath}/${portname}-${portversion}.mpkg
116        system "mkdir -p -m 0755 ${mpkgpath}/Contents/Resources"
117        system "mkdir -p -m 0755 ${mpkgpath}/Contents/Packages"
118
119        set dependencies {}
120        # get deplist
121        set deps [make_dependency_list $portname]
122        set deps [lsort -unique $deps]
123        foreach dep $deps {
124                set name [lindex [split $dep /] 0]
125                set vers [lindex [split $dep /] 1]
126                # don't re-package ourself
127                if {$name != $portname} {
128                        make_one_package $name $vers $mpkgpath/Contents/Packages
129                        lappend dependencies ${name}-${vers}.pkg
130                }
131        }
132       
133        # copy our own pkg into the mpkg
134        system "cp -PR ${pkgpath} ${mpkgpath}/Contents/Packages/"
135        lappend dependencies ${portname}-${portversion}.pkg
136       
137    write_PkgInfo ${mpkgpath}/Contents/PkgInfo
138    mpkg_write_info_plist ${mpkgpath}/Contents/Info.plist $portname $portversion $portrevision $prefix $dependencies
139    write_description_plist ${mpkgpath}/Contents/Resources/Description.plist $portname $portversion $description
140    # long_description, description, or homepage may not exist
141    foreach variable {long_description description homepage} {
142        if {![info exists $variable]} {
143            set pkg_$variable ""
144        } else {
145            set pkg_$variable [set $variable]
146        }
147    }
148    write_welcome_html ${mpkgpath}/Contents/Resources/Welcome.html $portname $portversion $pkg_long_description $pkg_description $pkg_homepage
149    file copy -force -- [getportresourcepath $porturl "port1.0/package/background.tiff"] ${mpkgpath}/Contents/Resources/background.tiff
150
151        return 0
152}
153
154proc xml_escape {s} {
155        regsub -all {&} $s {\&} s
156        regsub -all {<} $s {\&lt;} s
157        regsub -all {>} $s {\&gt;} s
158        return $s
159}
160
161proc mpkg_write_info_plist {infofile portname portversion portrevision destination dependencies} {
162        set vers [split $portversion "."]
163       
164        if {[string index $destination end] != "/"} {
165                append destination /
166        }
167       
168        set depxml ""
169        foreach dep $dependencies {
170                set dep [xml_escape $dep]
171                append depxml "<dict>
172                        <key>IFPkgFlagPackageLocation</key>
173                        <string>${dep}</string>
174                        <key>IFPkgFlagPackageSelection</key>
175                        <string>selected</string>
176                </dict>
177                "
178        }
179
180        set portname [xml_escape $portname]
181        set portversion [xml_escape $portversion]
182        set portrevision [xml_escape $portrevision]
183
184        set infofd [open ${infofile} w+]
185        puts $infofd {<?xml version="1.0" encoding="UTF-8"?>
186<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
187<plist version="1.0">
188}
189        puts $infofd "<dict>
190        <key>CFBundleGetInfoString</key>
191        <string>${portname} ${portversion}</string>
192        <key>CFBundleIdentifier</key>
193        <string>org.macports.mpkg.${portname}</string>
194        <key>CFBundleName</key>
195        <string>${portname}</string>
196        <key>CFBundleShortVersionString</key>
197        <string>${portversion}</string>
198        <key>IFMajorVersion</key>
199        <integer>${portrevision}</integer>
200        <key>IFMinorVersion</key>
201        <integer>0</integer>
202        <key>IFPkgFlagComponentDirectory</key>
203        <string>./Contents/Packages</string>
204        <key>IFPkgFlagPackageList</key>
205        <array>
206                ${depxml}</array>
207        <key>IFPkgFormatVersion</key>
208        <real>0.10000000149011612</real>
209</dict>
210</plist>"
211        close $infofd
212}
Note: See TracBrowser for help on using the repository browser.