source: branches/gsoc08-privileges/base/src/port1.0/portextract.tcl @ 38096

Last change on this file since 38096 was 38096, checked in by pmagrath@…, 11 years ago

Merged revisions 38033,38037-38038,38040 via svnmerge from
https://svn.macosforge.org/repository/macports/trunk/base

........

r38033 | raimue@… | 2008-07-04 00:49:00 +0100 (Fri, 04 Jul 2008) | 3 lines


port/port.tcl:
Document depends: and depends_*: from r37909

........

r38037 | raimue@… | 2008-07-04 03:58:10 +0100 (Fri, 04 Jul 2008) | 3 lines


portmgr/dmg/postflight:
Copy the postflight script from the release_1_6 branch so the changes will not be lost or forgotten

........

r38038 | raimue@… | 2008-07-04 05:30:56 +0100 (Fri, 04 Jul 2008) | 4 lines


port1.0/portextract.tcl:
If the $distfile exists in $filespath, use it from there as it was not fetched
to the distpath in this case.

........

r38040 | raimue@… | 2008-07-04 05:59:54 +0100 (Fri, 04 Jul 2008) | 3 lines


portmgr/dmg/postflight:
Remove old non-compressed man pages on install

........

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 4.7 KB
Line 
1# et:ts=4
2# portextract.tcl
3# $Id: portextract.tcl 38096 2008-07-06 15:21:25Z pmagrath@macports.org $
4#
5# Copyright (c) 2002 - 2003 Apple Computer, Inc.
6# Copyright (c) 2007 Markus W. Weissmann <mww@macports.org>
7# All rights reserved.
8#
9# Redistribution and use in source and binary forms, with or without
10# modification, are permitted provided that the following conditions
11# are met:
12# 1. Redistributions of source code must retain the above copyright
13#    notice, this list of conditions and the following disclaimer.
14# 2. Redistributions in binary form must reproduce the above copyright
15#    notice, this list of conditions and the following disclaimer in the
16#    documentation and/or other materials provided with the distribution.
17# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
18#    may be used to endorse or promote products derived from this software
19#    without specific prior written permission.
20#
21# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31# POSSIBILITY OF SUCH DAMAGE.
32#
33
34package provide portextract 1.0
35package require portutil 1.0
36
37set org.macports.extract [target_new org.macports.extract extract_main]
38target_init ${org.macports.extract} extract_init
39target_provides ${org.macports.extract} extract
40target_requires ${org.macports.extract} fetch checksum
41target_prerun ${org.macports.extract} extract_start
42
43# define options
44options extract.only extract.mkdir
45commands extract
46
47# Set up defaults
48# XXX call out to code in portutil.tcl XXX
49# This cleans the distfiles list of all site tags
50default extract.only {[disttagclean $distfiles]}
51
52default extract.dir {${workpath}}
53default extract.cmd gzip
54default extract.pre_args -dc
55default extract.post_args {"| ${portutil::autoconf::tar_command} -xf -"}
56default extract.mkdir no
57
58set_ui_prefix
59
60proc extract_init {args} {
61    global extract.only extract.dir extract.cmd extract.pre_args extract.post_args extract.mkdir distfiles use_bzip2 use_zip use_dmg workpath
62
63    # should the distfiles be extracted to worksrcpath instead?
64    if {[tbool extract.mkdir]} {
65        global worksrcpath
66        ui_debug "Extracting to subdirectory worksrcdir"
67        file mkdir ${worksrcpath}
68        set extract.dir ${worksrcpath}
69    }
70
71    if {[tbool use_bzip2]} {
72        option extract.cmd [binaryInPath "bzip2"]
73    } elseif {[tbool use_zip]} {
74        option extract.cmd [binaryInPath "unzip"]
75        option extract.pre_args -q
76        option extract.post_args "-d [option extract.dir]"
77    } elseif {[tbool use_dmg]} {
78        global worksrcdir
79        set dmg_tmp_dir [exec mktemp -d -q "/tmp/mports.XXXXXXXX"]
80        set dmg_mount ${dmg_tmp_dir}/${worksrcdir}
81        file mkdir ${dmg_mount}
82        option extract.cmd [binaryInPath "hdiutil"]
83        option extract.pre_args attach
84        option extract.post_args "-private -readonly -nobrowse -mountpoint ${dmg_mount} && [binaryInPath "cp"] -Rp ${dmg_mount} ${extract.dir} && ${extract.cmd} detach ${dmg_mount} && [binaryInPath "rmdir"] ${dmg_mount} ${dmg_tmp_dir}"
85    }
86}
87
88proc extract_start {args} {
89    global UI_PREFIX
90   
91    ui_msg "$UI_PREFIX [format [msgcat::mc "Extracting %s"] [option portname]]"
92}
93
94proc extract_main {args} {
95    global UI_PREFIX euid egid worksrcpath macportsuser
96    global filespath
97   
98    if {![exists distfiles] && ![exists extract.only]} {
99        # nothing to do
100        return 0
101    }
102
103    foreach distfile [option extract.only] {
104        ui_info "$UI_PREFIX [format [msgcat::mc "Extracting %s"] $distfile]"
105        if {[file exists $filespath/$distfile]} {
106                option extract.args "$filespath/$distfile"
107        } else {
108                option extract.args "[option distpath]/$distfile"
109        }
110        if {[catch {command_exec extract} result]} {
111            return -code error "$result"
112        }
113       
114        # start gsoc08-privileges
115        if { [getuid] == 0 && [geteuid] == [name_to_uid "$macportsuser"] } {
116        # if started with sudo but have dropped the privileges
117                seteuid $euid   
118                ui_debug "euid changed to: [geteuid]"
119                file attributes "${worksrcpath}" -owner [name_to_uid "$macportsuser"]
120                ui_debug "chowned $worksrcpath to $macportsuser"
121                seteuid [name_to_uid "$macportsuser"]
122                ui_debug "euid changed to: [geteuid]"
123        }
124        # end gsoc08-privileges
125       
126    }
127    return 0
128}
Note: See TracBrowser for help on using the repository browser.