source: trunk/base/src/port1.0/portactivate.tcl @ 118304

Last change on this file since 118304 was 118304, checked in by cal@…, 6 years ago

base: Delay displaying notes for installed ports until the end of the current operation

Mostly written by Jeremy Lavergne (snc).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.5 KB
RevLine 
[64638]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
[7622]2# portactivate.tcl
[19376]3# $Id: portactivate.tcl 118304 2014-03-29 19:21:58Z cal@macports.org $
[7622]4#
[79593]5# Copyright (c) 2005, 2007, 2009-2011 The MacPorts Project
[9720]6# Copyright (c) 2004 Robert Shaw <rshaw@opendarwin.org>
[79593]7# Copyright (c) 2002 - 2003 Apple Inc.
[7622]8# All rights reserved.
9#
10# Redistribution and use in source and binary forms, with or without
11# modification, are permitted provided that the following conditions
12# are met:
13# 1. Redistributions of source code must retain the above copyright
14#    notice, this list of conditions and the following disclaimer.
15# 2. Redistributions in binary form must reproduce the above copyright
16#    notice, this list of conditions and the following disclaimer in the
17#    documentation and/or other materials provided with the distribution.
[79593]18# 3. Neither the name of Apple Inc. nor the names of its contributors
[7622]19#    may be used to endorse or promote products derived from this software
20#    without specific prior written permission.
[50562]21#
[7622]22# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32# POSSIBILITY OF SUCH DAMAGE.
33#
34
35# the 'activate' target is provided by this package
36
37package provide portactivate 1.0
38package require portutil 1.0
39
[49087]40set org.macports.activate [target_new org.macports.activate portactivate::activate_main]
[26177]41target_runtype ${org.macports.activate} always
42target_state ${org.macports.activate} no
43target_provides ${org.macports.activate} activate
[77511]44target_requires ${org.macports.activate} main archivefetch fetch checksum extract patch configure build destroot install
[64718]45target_prerun ${org.macports.activate} portactivate::activate_start
[116820]46target_postrun ${org.macports.activate} portactivate::activate_finish
[7622]47
[49087]48namespace eval portactivate {
49}
50
[64638]51options activate.asroot
[64718]52default activate.asroot no
[7622]53
[64718]54proc portactivate::activate_start {args} {
[77511]55    global prefix
56    if {![file writable $prefix] || ([getuid] == 0 && [geteuid] != 0)} {
[64718]57        # if install location is not writable, need root privileges
58        elevateToRoot "activate"
59    }
60}
61
[49087]62proc portactivate::activate_main {args} {
[118304]63    global subport version revision portvariants user_options PortInfo
[46061]64
[79167]65    registry_activate $subport $version $revision $portvariants [array get user_options]
[118304]66    if {[info exists PortInfo(notes)] && [llength $PortInfo(notes)] > 0} {
67        ui_notifications_append $subport $PortInfo(notes)
[46061]68    }
[50562]69
[116820]70    return 0
71}
72
73proc portactivate::activate_finish {args} {
74    global subport startupitem.autostart UI_PREFIX
75
76    # Do this _after_ activate_main, because post-activate hooks might create
77    # the files needed for this
[106810]78    if {[tbool startupitem.autostart]} {
[116820]79        ui_notice "$UI_PREFIX [format [msgcat::mc "Loading %s"] $subport]"
[106810]80        if {[eval_targets "load"]} {
[116820]81            ui_error [format [msgcat::mc "Failed to load %s"] $subport]
[106810]82            return 1
83        }
84    }
85
[7622]86    return 0
87}
Note: See TracBrowser for help on using the repository browser.