source: trunk/base/src/portmgr/mpkgall.tcl @ 2426

Last change on this file since 2426 was 2426, checked in by landonf (Landon Fuller), 18 years ago

Allow DarwinPorts to build out of the box on newer Darwin releases with Tcl 8.4

  • Remove references to 'tclsh8.3', replacing them with 'tclsh'. This will work everywhere except FreeBSD
  • Remove compile.sh, link.sh, and tcldir.sh, replacing them with config.sh. config.sh references the config data provided by TEA and allows us to steer clear of autoconf.
  • Modify all Makefiles to use config.sh
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 7.4 KB
Line 
1#!/usr/bin/env tclsh
2# mpkgall.tcl
3#
4# Copyright (c) 2003 Kevin Van Vechten <kevin@opendarwin.org>
5# Copyright (c) 2002 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
32package require darwinports
33
34# globals
35set portdir .
36
37proc ui_puts {args} {}
38
39# copy binary packages if they've already been built.
40
41proc copy_package_if_available {portname basepath destpath} {
42
43        set dependencies {}
44
45        if {[catch {set res [dportsearch "^$portname\$"]} error]} {
46                puts stderr "Internal error: port search failed: $error"
47                return
48        }
49        foreach {name array} $res {
50                array set portinfo $array
51                if {![info exists portinfo(name)]} { return -1 }
52                if {![info exists portinfo(version)]} { return -1 }
53                if {![info exists portinfo(categories)]} { return -1 }
54               
55                set portname $portinfo(name)
56                set portversion $portinfo(version)
57                set category [lindex $portinfo(categories) 0]
58               
59                set depends {}
60                if {[info exists portinfo(depends_run)]} { eval "lappend depends $portinfo(depends_run)" }
61                if {[info exists portinfo(depends_lib)]} { eval "lappend depends $portinfo(depends_lib)" }
62                #if {[info exists portinfo(depends_build)]} { eval "lappend depends $portinfo(depends_build)" }
63                foreach depspec $depends {
64                        set dep [lindex [split $depspec :] 2]
65                        set result [copy_package_if_available $dep $basepath $destpath]
66                        if {$result == -1} { 
67                                return -1
68                        } else {
69                                eval "lappend dependencies $result"
70                        }
71                }
72               
73                set pkgname "${portname}-${portversion}.pkg"
74                lappend dependencies $pkgname
75                set pkgpath "${basepath}/${category}/${pkgname}"
76                if {[file readable "${pkgpath}/Contents/Info.plist"]} {
77                        puts stderr "copying package: ${pkgpath} to ${destpath}"
78                        if {[catch {system "cp -R ${pkgpath} ${destpath}/"} error]} {
79                                puts stderr "Internal error: $error"
80                        }
81                } else {
82                        puts stderr "package ${pkgname} not found"
83                        return -1
84                }
85        }
86       
87        return $dependencies
88}
89
90
91# Standard procedures
92
93proc fatal args {
94    global argv0
95    puts stderr "$argv0: $args"
96    exit
97}
98
99# Main
100array set options [list]
101array set variations [list]
102#       set ui_options(ports_verbose) yes
103
104if {[catch {dportinit} result]} {
105    puts "Failed to initialize ports system, $result"
106    exit 1
107}
108
109package require Pextlib
110package require portmpkg 1.0
111package require portpackage 1.0
112
113# If no arguments were given, default to all ports.
114if {[llength $argv] == 0} {
115        lappend argv ".*"
116}
117
118foreach pname $argv {
119
120if {[catch {set res [dportsearch "^${pname}\$"]} result]} {
121        puts "port search failed: $result"
122        exit 1
123}
124
125foreach {name array} $res {
126        global prefix
127        array unset portinfo
128        array set portinfo $array
129
130        if ![info exists portinfo(porturl)] {
131                puts stderr "Internal error: no porturl for $name"
132                continue
133        }
134       
135        set pkgbase "/darwinports/pkgs/"
136        set mpkgbase "/darwinports/mpkgs/"
137        set porturl $portinfo(porturl)
138        set prefix "/opt/local"
139
140        # Skip up-to-date packages
141        if {[regsub {^file://} $portinfo(porturl) "" portpath]} {
142                if {[info exists portinfo(name)] &&
143                        [info exists portinfo(version)] &&
144                        [info exists portinfo(categories)]} {
145                        set portname $portinfo(name)
146                        set portversion $portinfo(version)
147                        set category [lindex $portinfo(categories) 0]
148                        set mpkgfile ${mpkgbase}/${category}/${portname}-${portversion}.mpkg/Contents/Info.plist
149                        if {[file readable $mpkgfile] && ([file mtime ${mpkgfile}] > [file mtime ${portpath}/Portfile])} {
150                                puts stderr "Skipping ${portname}-${portversion}; meta-package is up to date."
151                                continue
152                        }
153                }
154        }
155       
156        # Skipt packages which previously failed
157               
158        # Building the mpkg:
159        # - create an mpkg skeleton
160        # - copy dependent pkgs into Contents/Resources directory
161
162        set portname ""
163        set portversion ""
164        set description ""
165        set long_description ""
166        set homepage ""
167        set category ""
168
169        if {[info exists portinfo(name)]} {     set portname $portinfo(name) }
170        if {[info exists portinfo(version)]} { set portversion $portinfo(version) }
171        if {[info exists portinfo(description)]} { set description $portinfo(description) }
172        if {[info exists portinfo(long_description)]} { set long_description $portinfo(long_description) }
173        if {[info exists portinfo(homepage)]} { set homepage $portinfo(homepage) }
174        if {[info exists portinfo(categories)]} { set category [lindex $portinfo(categories) 0] }
175        if {[info exists portinfo(maintainers)]} { set maintainers $portinfo(maintainers) }
176       
177        puts "meta-packaging ${category}/${portname}-${portversion}"
178
179        set mpkgpath "${mpkgbase}/${category}/${portname}-${portversion}.mpkg"
180
181        if {[catch {system "mkdir -p -m 0755 ${mpkgpath}/Contents/Resources"} error]} {
182                puts stderr "Internal error: $error"
183        }
184       
185        # list of .pkg names for dependencies,
186        # built up by copy_package_if_available, and used in the Info.plist
187        set dependencies {}
188        set result [copy_package_if_available ${portname} $pkgbase "${mpkgpath}/Contents/Resources/"]
189        if {$result == -1} {
190                puts stderr "aborting; one or more dependencies was missing."
191                if {[catch {system "rm -R ${mpkgpath}"} error]} {
192                        puts stderr "Internal error: $error"
193                }
194                continue
195        } else {
196                set result [lsort -uniq $result]
197                eval "lappend dependencies $result"
198        }
199       
200        #
201        # Begin quote from portmpkg.tcl
202        #
203    write_PkgInfo ${mpkgpath}/Contents/PkgInfo
204    write_info_file ${mpkgpath}/Contents/Resources/${portname}-${portversion}.info $portname $portversion $description
205    mpkg_write_info_plist ${mpkgpath}/Contents/Info.plist $portname $portversion $prefix $dependencies
206    write_description_plist ${mpkgpath}/Contents/Resources/Description.plist $portname $portversion $description
207    # long_description, description, or homepage may not exist
208    foreach variable {long_description description homepage} {
209        if {![info exists $variable]} {
210            set pkg_$variable ""
211        } else {
212            set pkg_$variable [set $variable]
213        }
214    }
215    write_welcome_html ${mpkgpath}/Contents/Resources/Welcome.rtf $portname $portversion $pkg_long_description $pkg_description $pkg_homepage
216    file copy -force -- /opt/local/share/darwinports/resources/port1.0/package/background.tiff \
217                        ${mpkgpath}/Contents/Resources/background.tiff
218        #
219        # End quote from portmpkg.tcl
220        #
221}
222
223}
224# end foreach pname
Note: See TracBrowser for help on using the repository browser.