source: trunk/base/src/port1.0/portpatch.tcl @ 17792

Last change on this file since 17792 was 17792, checked in by pguyot (Paul Guyot), 14 years ago

Suffixes are supported in patchfiles specifications, but the patch command
actually didn't parse the filename and didn't even warn when the patch is not
applied because it cannot be found.

This change fixes that by:

  • moving the distname and disttag-related functions to portutil.tcl
  • fixing portfetch.tcl to actually end up with an error if a patch file cannot

be found (instead of silently ignoring it)

  • fixing portfetch.tcl to actually consider the distname part of the patch files

instead of the whole entry with the optional tag.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 3.2 KB
Line 
1# et:ts=4
2# portpatch.tcl
3# $Id: portpatch.tcl,v 1.30 2006/04/30 05:32:52 pguyot Exp $
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 portpatch 1.0
34package require portutil 1.0
35
36set com.apple.patch [target_new com.apple.patch patch_main]
37target_provides ${com.apple.patch} patch
38target_requires ${com.apple.patch} main fetch checksum extract
39
40set_ui_prefix
41
42# Add command patch
43commands patch
44# Set up defaults
45default patch.dir {${worksrcpath}}
46default patch.cmd patch
47default patch.pre_args -p0
48
49proc patch_main {args} {
50    global UI_PREFIX
51   
52    # First make sure that patchfiles exists and isn't stubbed out.
53    if {![exists patchfiles]} {
54        return 0
55    }
56   
57        ui_msg "$UI_PREFIX [format [msgcat::mc "Applying patches to %s"] [option portname]]"
58
59    foreach patch [option patchfiles] {
60    set patch_file [getdistname $patch]
61        if {[file exists [option filespath]/$patch_file]} {
62            lappend patchlist [option filespath]/$patch_file
63        } elseif {[file exists [option distpath]/$patch_file]} {
64            lappend patchlist [option distpath]/$patch_file
65        } else {
66                return -code error [format [msgcat::mc "Patch file %s is missing"] $patch]
67        }
68    }
69    if {![info exists patchlist]} {
70        return -code error [msgcat::mc "Patch files missing"]
71    }
72    cd [option worksrcpath]
73    foreach patch $patchlist {
74        ui_info "$UI_PREFIX [format [msgcat::mc "Applying %s"] $patch]"
75        if {[option os.platform] == "linux"} {
76            set gzcat "zcat"
77        } else {
78            set gzcat "gzcat"
79        }
80        switch -glob -- [file tail $patch] {
81            *.Z -
82            *.gz {system "$gzcat \"$patch\" | ([command patch])"}
83            *.bz2 {system "bzcat \"$patch\" | ([command patch])"}
84            default {system "[command patch] < \"$patch\""}
85        }
86    }
87    return 0
88}
Note: See TracBrowser for help on using the repository browser.