source: trunk/base/src/package1.0/portrpm.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: 8.5 KB
Line 
1# et:ts=4
2# portrpm.tcl
3# $Id: portrpm.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 portrpm 1.0
34package require portutil 1.0
35
36set org.macports.rpm [target_new org.macports.rpm rpm_main]
37target_runtype ${org.macports.rpm} always
38target_provides ${org.macports.rpm} rpm
39target_requires ${org.macports.rpm} destroot
40
41options package.destpath
42
43set_ui_prefix
44
45proc rpm_main {args} {
46    global portname portversion portrevision UI_PREFIX
47   
48    ui_msg "$UI_PREFIX [format [msgcat::mc "Creating RPM package for %s-%s"] ${portname} ${portversion}]"
49   
50    return [rpm_pkg $portname $portversion $portrevision]
51}
52
53proc rpm_pkg {portname portversion portrevision} {
54    global UI_PREFIX package.destpath portdbpath destpath workpath prefix categories maintainers description long_description homepage epoch portpath
55        global os.platform os.arch os.version os.major
56   
57    set rpmdestpath ""
58    if {![string equal ${package.destpath} ${workpath}] && ![string equal ${package.destpath} ""]} {
59        set pkgpath ${package.destpath}
60        system "mkdir -p ${pkgpath}/BUILD"
61        system "mkdir -p ${pkgpath}/RPMS"
62        system "mkdir -p ${pkgpath}/SOURCES"
63        system "mkdir -p ${pkgpath}/SPECS"
64        system "mkdir -p ${pkgpath}/SRPMS"
65        set rpmdestpath "--define '_topdir ${pkgpath}'"
66    }
67   
68    set rpmbuildarch ""
69    if {[variant_isset "universal"]} {
70        set rpmbuildarch "--target fat"
71    }
72    if {false} {
73        set rpmbuildarch "--target noarch"
74    }
75   
76    foreach dir [list "${prefix}/src/macports/RPMS" "${prefix}/src/apple/RPMS" "/usr/src/apple/RPMS" "/macports/rpms/RPMS"] {
77        foreach arch {"ppc" "i386" "fat" "noarch"} {
78            set rpmpath "$dir/${arch}/${portname}-${portversion}-${portrevision}.${arch}.rpm"
79            if {[file readable $rpmpath] && ([file mtime ${rpmpath}] >= [file mtime ${portpath}/Portfile])} {
80                ui_debug "$rpmpath"
81                ui_msg "$UI_PREFIX [format [msgcat::mc "RPM package for %s-%s is up-to-date"] ${portname} ${portversion}]"
82                return 0
83            }
84        }
85    }
86   
87    set specpath ${workpath}/${portname}.spec
88    # long_description, description, or homepage may not exist
89    foreach variable {long_description description homepage categories maintainers} {
90        if {![info exists $variable]} {
91            set pkg_$variable ""
92        } else {
93            set pkg_$variable [set $variable]
94        }
95    }
96    set category   [lindex [split $categories " "] 0]
97    set license    "Unknown"
98    set maintainer $maintainers
99   
100    set dependencies {}
101    # get deplist
102    set deps [make_dependency_list $portname]
103    set deps [lsort -unique $deps]
104    foreach dep $deps {
105        set name [lindex [split $dep /] 0]
106        set vers [lindex [split $dep /] 1]
107        # don't re-package ourself
108        if {$name != $portname} {
109            lappend dependencies "${name} >= ${vers}"
110        }
111    }
112
113        # depend on system (virtual packages for apple stuff)
114        lappend dependencies "org.macports.${os.platform}${os.major}"
115   
116    set listpath ${workpath}/${portname}.filelist
117    system "rm -f '${workpath}/${portname}.filelist' && touch '${workpath}/${portname}.filelist'"
118    #system "cd '${destpath}' && find . -type d | grep -v -E '^.$' | sed -e 's/\"/\\\"/g' -e 's/^./%dir \"/' -e 's/$/\"/' > '${workpath}/${portname}.filelist'"
119    system "cd '${destpath}' && find . ! -type d | grep -v /etc/ | sed -e 's/\"/\\\"/g' -e 's/^./\"/' -e 's/$/\"/' >> '${workpath}/${portname}.filelist'"
120    system "cd '${destpath}' && find . ! -type d | grep /etc/ | sed -e 's/\"/\\\"/g' -e 's/^./%config \"/' -e 's/$/\"/' >> '${workpath}/${portname}.filelist'"
121    write_spec ${specpath} ${destpath} ${listpath} $portname $portversion $portrevision $pkg_description $pkg_long_description $pkg_homepage $category $license $maintainer $dependencies $epoch
122    system "MP_USERECEIPTS='${portdbpath}/receipts' rpmbuild -bb -v ${rpmbuildarch} ${rpmdestpath} ${specpath}"
123   
124    return 0
125}
126
127proc make_dependency_list {portname} {
128    set result {}
129    if {[catch {set res [mport_search "^$portname\$"]} error]} {
130                global errorInfo
131                ui_debug "$errorInfo"
132        ui_error "port search failed: $error"
133        return 1
134    }
135    foreach {name array} $res {
136        array set portinfo $array
137       
138        if {[info exists portinfo(depends_run)] || [info exists portinfo(depends_lib)]} {
139            # get the union of depends_run and depends_lib
140            # xxx: only examines the portfile component of the depspec
141            set depends {}
142            if {[info exists portinfo(depends_run)]} { eval "lappend depends $portinfo(depends_run)" }
143            if {[info exists portinfo(depends_lib)]} { eval "lappend depends $portinfo(depends_lib)" }
144           
145            foreach depspec $depends {
146                set dep [lindex [split $depspec :] end]
147               
148                # xxx: nasty hack
149                if {$dep != "XFree86"} {
150                    eval "lappend result [make_dependency_list $dep]"
151                }
152            }
153        }
154        lappend result $portinfo(name)/$portinfo(version)
155        unset portinfo
156    }
157    ui_debug "dependencies for ${portname}: $result"
158    return $result
159}
160
161proc word_wrap {orig Length} {
162    set pos 0
163    set line ""
164    set text ""
165
166    set words [split $orig]
167    set numWords [llength $words]
168    for {set cnt 0} {$cnt < $numWords} {incr cnt} {
169        set w [lindex $words $cnt]
170        set wLen [string length $w]
171
172        if {($pos+$wLen < $Length)} {
173            # append word to current line
174            if {$pos} {append line " "; incr pos}
175            append line $w
176            incr pos $wLen
177        } else {
178            # line full => write buffer and  begin a new line
179            if {[string length $text]} {append text "\n"}
180            append text $line
181            set line $w
182            set pos $wLen
183        }
184    }
185
186    if {[string length $text]} {append text "\n"}
187    if {[string length $line]} {append text $line}
188    return $text
189}
190
191proc write_spec {specfile destroot filelist portname portversion portrevision description long_description homepage category license maintainer dependencies epoch} {
192    set specfd [open ${specfile} w+]
193    set origportname ${portname}
194    regsub -all -- "\-" $portversion "_" portversion
195    regsub -all -- "\-" $portname "_" portname
196    puts $specfd "\#Spec file generated by MacPorts
197%define distribution MacPorts
198%define vendor MacPorts
199%define packager ${maintainer}
200
201%define buildroot ${destroot}
202# Avoid cleaning BuildRoot in the pre-install:
203%define __spec_install_pre     %{___build_pre}
204%define __spec_clean_body      %{nil}
205
206Summary: ${description}
207Name: ${portname}
208Version: ${portversion}
209Release: ${portrevision}
210Group: ${category}
211License: ${license}
212URL: ${homepage}
213BuildRoot: ${destroot}
214AutoReq: no"
215    if {[expr ${epoch} != 0]} {
216            puts $specfd "Epoch: ${epoch}"
217    }
218    if {[llength ${dependencies}] != 0} {
219        foreach require ${dependencies} {
220            puts $specfd "Requires: [regsub -all -- "\-" $require "_"]"
221        }
222    }
223    set wrap_description [word_wrap ${long_description} 72]
224    puts $specfd "
225%description
226$wrap_description
227
228%prep
229%build
230%install
231%clean
232
233%files -f ${filelist}"
234    close $specfd
235}
Note: See TracBrowser for help on using the repository browser.