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

Last change on this file was 140035, checked in by raimue@…, 5 years ago

port1.0/portactivate.tcl:
Save notes after finishing the activation, which allows to append notes in the post-activate phase

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.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# portactivate.tcl
3# $Id: portactivate.tcl 140035 2015-09-07 16:09:03Z raimue@macports.org $
4#
5# Copyright (c) 2005, 2007, 2009-2011 The MacPorts Project
6# Copyright (c) 2004 Robert Shaw <rshaw@opendarwin.org>
7# Copyright (c) 2002 - 2003 Apple Inc.
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.
18# 3. Neither the name of Apple Inc. nor the names of its contributors
19#    may be used to endorse or promote products derived from this software
20#    without specific prior written permission.
21#
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
40set org.macports.activate [target_new org.macports.activate portactivate::activate_main]
41target_runtype ${org.macports.activate} always
42target_state ${org.macports.activate} no
43target_provides ${org.macports.activate} activate
44target_requires ${org.macports.activate} main archivefetch fetch checksum extract patch configure build destroot install
45target_prerun ${org.macports.activate} portactivate::activate_start
46target_postrun ${org.macports.activate} portactivate::activate_finish
47
48namespace eval portactivate {
49}
50
51options activate.asroot
52default activate.asroot no
53
54proc portactivate::activate_start {args} {
55    global prefix
56    if {![file writable $prefix] || ([getuid] == 0 && [geteuid] != 0)} {
57        # if install location is not writable, need root privileges
58        elevateToRoot "activate"
59    }
60}
61
62proc portactivate::activate_main {args} {
63    global subport version revision portvariants user_options PortInfo
64
65    registry_activate $subport $version $revision $portvariants [array get user_options]
66
67    return 0
68}
69
70proc portactivate::activate_finish {args} {
71    global subport startupitem.autostart PortInfo UI_PREFIX
72
73    # Do this _after_ activate_main, because post-activate hooks might create
74    # the files needed for this
75    if {[tbool startupitem.autostart]} {
76        ui_notice "$UI_PREFIX [format [msgcat::mc "Loading %s"] $subport]"
77        if {[eval_targets "load"]} {
78            ui_error [format [msgcat::mc "Failed to load %s"] $subport]
79            return 1
80        }
81    }
82
83    # Save notes for display by the port client
84    if {[info exists PortInfo(notes)] && [llength $PortInfo(notes)] > 0} {
85        ui_notifications_append $subport $PortInfo(notes)
86    }
87
88    return 0
89}
Note: See TracBrowser for help on using the repository browser.