source: trunk/dports/_resources/port1.0/group/archcheck-1.0.tcl @ 125633

Last change on this file since 125633 was 96776, checked in by blair@…, 7 years ago

group/*: trim trailing whitespace.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 5.6 KB
Line 
1# -*- 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
2# $Id: archcheck-1.0.tcl 96776 2012-08-19 05:52:01Z blair@macports.org $
3#
4# Copyright (c) 2009 The MacPorts Project
5# All rights reserved.
6#
7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions are
9# met:
10#
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 The MacPorts Project nor the names of its
17#    contributors may be used to endorse or promote products derived from
18#    this software without specific prior written permission.
19#
20# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31#
32#
33# This PortGroup checks that the architecture(s) of the given files match
34# the architecture(s) we are trying to install this port as now. This is
35# a crutch to get us by until a proper solution is implemented in base.
36# See #20728.
37#
38# Usage:
39#
40#   PortGroup               archcheck 1.0
41#   archcheck.files         file1 file2 ...
42#
43# Files can (and probably usually should) be specified relative to ${prefix}.
44
45options archcheck.files
46default archcheck.files {}
47
48if {"darwin" == ${os.platform}} {
49pre-configure {
50    if {[variant_exists universal] && [variant_isset universal]} {
51        set requested_archs ${configure.universal_archs}
52    } else {
53        set requested_archs ${configure.build_arch}
54    }
55    foreach file ${archcheck.files} {
56        # Prepend prefix if necessary.
57        if {"/" != [string index ${file} 0]} {
58            set file [file join ${prefix} ${file}]
59        }
60
61        # Make sure the file exists -- there have been cases where dylibs are
62        # inexplicably absent (e.g. #23057).
63        if {![file exists ${file}]} {
64            ui_error "The file ${file} does not exist, though it was"
65            ui_error "expected to have been provided by one of ${name}'s dependencies. Try"
66            ui_error "rebuilding the port that should have provided that file by running"
67            ui_error ""
68            ui_error "    sudo port -n upgrade --force <portname>"
69            ui_error ""
70            return -code error "missing required file"
71        }
72
73        set file_archs [string trim [strsed [exec lipo -info ${file}] {s/.*://}]]
74        set file_archs [string map {ppc7400 ppc ppc7450 ppc} ${file_archs}]
75
76        foreach file_arch ${file_archs} {
77            switch ${file_arch} {
78                i386 -
79                x86_64 -
80                ppc -
81                ppc64 {
82                    # ok
83                }
84                default {
85                    ui_error "File ${file} contains unexpected architecture ${file_arch}."
86                    ui_error "This may be a bug in the archcheck portgroup."
87                    return -code error "unexpected architecture"
88                }
89            }
90        }
91
92        foreach requested_arch ${requested_archs} {
93            if {-1 == [string first " ${requested_arch} " " ${file_archs} "]} {
94                set dependency [strsed [exec ${prefix}/bin/port provides ${file} 2>/dev/null] {s/.*: //}]
95                ui_error "You cannot install ${name} for the architecture(s) ${requested_archs} because"
96                ui_error "its dependency ${dependency} only contains the architecture(s) ${file_archs}."
97                # Dependency is not universal?
98                if {1 == [llength ${file_archs}]} {
99                    # Trying to install this port either universal or for non-default arch?
100                    if {([variant_exists universal] && [variant_isset universal]) || (${build_arch} != ${configure.build_arch})} {
101                        ui_error ""
102                        ui_error "Try rebuilding ${dependency} (and all its dependencies) with"
103                        ui_error "the +universal variant by running"
104                        ui_error ""
105                        ui_error "    sudo port upgrade --enforce-variants ${dependency} +universal"
106                        ui_error ""
107                    # Dependency's arch is not the default arch? User has likely upgraded
108                    # from Leopard to Snow Leopard and has not reinstalled all ports.
109                    } elseif {${file_archs} != ${build_arch}} {
110                        ui_error ""
111                        ui_error "Did you upgrade to a new version of Mac OS X? If so, please see"
112                        ui_error ""
113                        ui_error "    http://trac.macports.org/wiki/Migration"
114                        ui_error ""
115                    }
116                }
117                return -code error "incompatible architectures in dependencies"
118            }
119        }
120    }
121}
122}
Note: See TracBrowser for help on using the repository browser.