Ignore:
Timestamp:
Jun 23, 2011, 4:00:37 AM (9 years ago)
Author:
derek@…
Message:

Merged latest trunk changes to gsoc11-statistics

Location:
branches/gsoc11-statistics/base
Files:
85 edited

Legend:

Unmodified
Added
Removed
  • branches/gsoc11-statistics/base

  • branches/gsoc11-statistics/base/src/cregistry/entry.c

    r78229 r79672  
    33 * $Id$
    44 *
     5 * Copyright (c) 2010-2011 The MacPorts Project
    56 * Copyright (c) 2007 Chris Pickel <sfiera@macports.org>
    67 * All rights reserved.
  • branches/gsoc11-statistics/base/src/darwintracelib1.0/darwintrace.c

    r74369 r79672  
    11/*
    2  * Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
     2 * Copyright (c) 2005 Apple Inc. All rights reserved.
    33 * Copyright (c) 2005-2006 Paul Guyot <pguyot@kallisys.net>,
    44 * All rights reserved.
     
    1717 *     notice, this list of conditions and the following disclaimer in the
    1818 *     documentation and/or other materials provided with the distribution.
    19  * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
     19 * 3.  Neither the name of Apple Inc. ("Apple") nor the names of
    2020 *     its contributors may be used to endorse or promote products derived
    2121 *     from this software without specific prior written permission.
  • branches/gsoc11-statistics/base/src/images_to_archives.tcl

    r78144 r79672  
    99package require macports 1.0
    1010package require registry 1.0
     11package require registry2 2.0
     12package require Pextlib 1.0
     13
     14umask 022
    1115
    1216mportinit
     
    2428
    2529puts "This could take a while..."
     30
     31# list of ports we successfully create an archive of, to be used to update
     32# the registry only after we know all creation attempts were successful.
     33set archived_list {}
    2634
    2735foreach installed $ilist {
     
    8088            set targetdir [file join ${macports::registry.path} software ${iname}]
    8189            file mkdir $targetdir
    82             if {${macports::registry.format} == "receipt_sqlite"} {
    83                 set contents [$iref imagefiles]
    84             } else {
    85                 set contents {}
    86                 set rawcontents [registry::property_retrieve $iref contents]
    87                 foreach entry $rawcontents {
    88                     lappend contents [lindex $entry 0]
    89                 }
    90             }
     90            set contents [$iref imagefiles]
    9191        }
    9292        set newlocation [file join $targetdir $archivename]
     
    110110        }
    111111
     112        lappend archived_list [list $installtype $iref $location $newlocation]
     113    }
     114}
     115
     116registry::write {
     117    foreach archived $archived_list {
     118        set installtype [lindex $archived 0]
     119        set iref [lindex $archived 1]
     120        set newlocation [lindex $archived 3]
     121   
    112122        if {$installtype == "direct"} {
    113123            # change receipt to image
    114             if {${macports::registry.format} == "receipt_sqlite"} {
    115                 $iref installtype image
    116                 $iref state imaged
    117                 $iref activate [$iref imagefiles]
    118                 $iref state installed
    119             } else {
    120                 registry::property_store $iref installtype image
    121                 foreach entry $contents {
    122                     registry::register_file $entry $iname
    123                 }
    124                 registry::property_store $iref active 1
    125             }
     124            $iref installtype image
     125            $iref state imaged
     126            $iref activate [$iref imagefiles]
     127            $iref state installed
    126128        }
     129   
     130        # set the new location in the registry and delete the old dir
     131        $iref location $newlocation
     132    }
     133}
    127134
    128         if {${macports::registry.format} == "flat" && $installtype == "image"} {
    129             # flat receipts also need file paths in contents trimmed to exclude image dir
    130             set loclen [string length $location]
    131             set locend [expr $loclen - 1]
    132             set oldcontents [registry::property_retrieve $iref contents]
    133             set newcontents {}
    134             foreach fe $contents {
    135                 set oldfilepath [lindex $fe 0]
    136                 if {[string range $oldfilepath 0 $locend] == $location} {
    137                     set newfilepath [string range $oldfilepath $loclen end]
    138                     set newentry [list $newfilepath]
    139                     foreach other [lrange $fe 1 end] {
    140                         lappend newentry $other
    141                     }
    142                     lappend newcontents $newentry
    143                 } else {
    144                     lappend newcontents $fe
    145                 }
    146             }
    147             registry::property_store $iref contents $newcontents
    148         }
    149         # set the new location in the registry and delete the old dir
    150         registry::property_store $iref location $newlocation
    151         if {${macports::registry.format} == "flat"} {
    152             registry::write_entry $iref
    153         }
    154         if {$location != "" && [file isdirectory $location]} {
    155             file delete -force $location
     135foreach archived $archived_list {
     136    set location [lindex $archived 2]
     137    if {$location != "" && [file isdirectory $location]} {
     138        if {[catch {file delete -force $location} result]} {
     139            ui_warn "Failed to delete ${location}: $result"
    156140        }
    157141    }
  • branches/gsoc11-statistics/base/src/macports1.0/Makefile

    r67293 r79672  
    3333
    3434        echo "${TCL_PACKAGE_DIR}" > ${DESTDIR}${prefix}/var/macports/.tclpackage
    35         if test -z "${DESTDIR}" && test "${INSTALLPKGLINK}" != "${INSTALLDIR}" && test -w "${TCL_PACKAGE_DIR}"; then \
    36                 if ! test -L "${INSTALLPKGLINK}" && test -d "${INSTALLPKGLINK}"; then \
    37                         rm -rf "${INSTALLPKGLINK}" || true; \
     35        if test -z "${DESTDIR}" -a "${INSTALLPKGLINK}" != "${INSTALLDIR}"; then \
     36                if test ! -d "${TCL_PACKAGE_DIR}"; then \
     37                        $(INSTALL) -d -o ${DSTUSR} -g ${DSTGRP} -m ${DSTMODE} "${TCL_PACKAGE_DIR}" || true; \
    3838                fi; \
    39                 if ! test -e "${INSTALLPKGLINK}"; then \
    40                         ln -s "${INSTALLDIR}" "${INSTALLPKGLINK}" || true; \
     39                if test -w "${TCL_PACKAGE_DIR}"; then \
     40                        if test ! -L "${INSTALLPKGLINK}" && test -d "${INSTALLPKGLINK}"; then \
     41                                rm -rf "${INSTALLPKGLINK}" || true; \
     42                        fi; \
     43                        if test ! -e "${INSTALLPKGLINK}"; then \
     44                                ln -s "${INSTALLDIR}" "${INSTALLPKGLINK}" || true; \
     45                        fi; \
    4146                fi; \
    4247        fi
  • branches/gsoc11-statistics/base/src/macports1.0/macports.tcl

    r79662 r79672  
    33# $Id$
    44#
    5 # Copyright (c) 2002 Apple Computer, Inc.
     5# Copyright (c) 2002 - 2003 Apple Inc.
    66# Copyright (c) 2004 - 2005 Paul Guyot, <pguyot@kallisys.net>.
    77# Copyright (c) 2004 - 2006 Ole Guldberg Jensen <olegb@opendarwin.org>.
    88# Copyright (c) 2004 - 2005 Robert Shaw <rshaw@opendarwin.org>
     9# Copyright (c) 2004 - 2011 The MacPorts Project
    910# All rights reserved.
    1011#
     
    1718#    notice, this list of conditions and the following disclaimer in the
    1819#    documentation and/or other materials provided with the distribution.
    19 # 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
     20# 3. Neither the name of Apple Inc. nor the names of its contributors
    2021#    may be used to endorse or promote products derived from this software
    2122#    without specific prior written permission.
     
    130131    global ::debuglog ::debuglogname
    131132
    132     set portname [_mportkey $mport name]
     133    set portname [_mportkey $mport subport]
    133134    set portpath [_mportkey $mport portpath]
    134135
     
    370371                    set macports::xcodeversion $xcode_v
    371372                } elseif {[regexp "DevToolsCore-(.*);" $xcodebuildversion - devtoolscore_v] == 1} {
    372                     if {$devtoolscore_v >= 921.0} {
     373                    if {$devtoolscore_v >= 1809.0} {
     374                        set macports::xcodeversion "3.2.6"
     375                    } elseif {$devtoolscore_v >= 1204.0} {
     376                        set macports::xcodeversion "3.1.4"
     377                    } elseif {$devtoolscore_v > 921.0} {
     378                        # XXX find actual version corresponding to 3.1
     379                        set macports::xcodeversion "3.1"
     380                    } elseif {$devtoolscore_v >= 921.0} {
    373381                        set macports::xcodeversion "3.0"
    374382                    } elseif {$devtoolscore_v >= 798.0} {
     
    745753    }
    746754    if {![info exists rsync_dir]} {
    747         set macports::rsync_dir release/base/
     755        set macports::rsync_dir release/tarballs/base.tar
    748756        global macports::rsync_dir
    749757    }
     
    981989    }
    982990   
    983     # init registry if needed
    984     if {${registry.format} == "receipt_sqlite"} {
    985         set db_path [file join ${registry.path} registry registry.db]
    986         set db_exists [file exists $db_path]
    987         registry::open $db_path
    988         # for the benefit of the portimage code that is called from multiple interpreters
    989         global registry_open
    990         set registry_open yes
    991         # convert any flat receipts if we just created a new db
    992         if {$db_exists == 0 && [file writable $db_path]} {
    993             ui_warn "Converting your registry to sqlite format, this might take a while..."
    994             if {[catch {registry::convert_to_sqlite}]} {
    995                 ui_debug "$::errorInfo"
    996                 file delete -force $db_path
    997                 error "Failed to convert your registry to sqlite!"
    998             } else {
    999                 ui_warn "Successfully converted your registry to sqlite!"
    1000             }
     991    # init registry
     992    set db_path [file join ${registry.path} registry registry.db]
     993    set db_exists [file exists $db_path]
     994    registry::open $db_path
     995    # for the benefit of the portimage code that is called from multiple interpreters
     996    global registry_open
     997    set registry_open yes
     998    # convert any flat receipts if we just created a new db
     999    if {$db_exists == 0 && [file writable $db_path]} {
     1000        ui_warn "Converting your registry to sqlite format, this might take a while..."
     1001        if {[catch {registry::convert_to_sqlite}]} {
     1002            ui_debug "$::errorInfo"
     1003            file delete -force $db_path
     1004            error "Failed to convert your registry to sqlite!"
     1005        } else {
     1006            ui_warn "Successfully converted your registry to sqlite!"
    10011007        }
    10021008    }
     
    10051011# call this just before you exit
    10061012proc mportshutdown {} {
    1007     global macports::registry.format
    1008     if {${registry.format} == "receipt_sqlite"} {
    1009         # close it down so the cleanup stuff is called, e.g. vacuuming the db
    1010         registry::close
    1011     }
     1013    # close it down so the cleanup stuff is called, e.g. vacuuming the db
     1014    registry::close
    10121015}
    10131016
     
    10821085    $workername alias registry_activate portimage::activate
    10831086    $workername alias registry_deactivate portimage::deactivate
     1087    $workername alias registry_deactivate_composite portimage::deactivate_composite
    10841088    $workername alias registry_uninstall registry_uninstall::uninstall
    10851089    $workername alias registry_register_deps registry::register_dependencies
     
    11651169}
    11661170
    1167 proc macports::fetch_port {url} {
     1171proc macports::get_tar_flags {suffix} {
     1172    switch -- $suffix {
     1173        .tbz -
     1174        .tbz2 {
     1175            return "-j"
     1176        }
     1177        .tgz {
     1178            return "-z"
     1179        }
     1180        .txz {
     1181            return "--use-compress-program [findBinary xz {}] -"
     1182        }
     1183        .tlz {
     1184            return "--use-compress-program [findBinary lzma {}] -"
     1185        }
     1186        default {
     1187            return "-"
     1188        }
     1189    }
     1190}
     1191
     1192proc macports::fetch_port {url {local 0}} {
    11681193    global macports::portdbpath
    11691194    set fetchdir [file join $portdbpath portdirs]
    1170     set fetchfile [file tail $url]
    11711195    file mkdir $fetchdir
    11721196    if {![file writable $fetchdir]} {
    11731197        return -code error "Port remote fetch failed: You do not have permission to write to $fetchdir"
    11741198    }
    1175     if {[catch {curl fetch $url [file join $fetchdir $fetchfile]} result]} {
    1176         return -code error "Port remote fetch failed: $result"
    1177     }
     1199    if {$local} {
     1200        set fetchfile $url
     1201    } else {
     1202        set fetchfile [file tail $url]
     1203        if {[catch {curl fetch $url [file join $fetchdir $fetchfile]} result]} {
     1204            return -code error "Port remote fetch failed: $result"
     1205        }
     1206    }
     1207    set oldpwd [pwd]
    11781208    cd $fetchdir
    1179     if {[catch {exec [findBinary tar $macports::autoconf::tar_path] -zxf $fetchfile} result]} {
     1209    # check if this is a binary archive or just the port dir
     1210    set tarcmd [findBinary tar $macports::autoconf::tar_path]
     1211    set tarflags [get_tar_flags [file extension $fetchfile]]
     1212    set qflag ${macports::autoconf::tar_q}
     1213    set cmdline "$tarcmd ${tarflags}${qflag}xOf {$fetchfile} +CONTENTS"
     1214    ui_debug "$cmdline"
     1215    set contents [eval exec $cmdline]
     1216    if {![catch {set contents [eval exec $cmdline]}]} {
     1217        set binary 1
     1218        ui_debug "getting port name from binary archive"
     1219        # get the portname from the contents file
     1220        foreach line [split $contents "\n"] {
     1221            if {[lindex $line 0] == "@name"} {
     1222                # actually ${name}-${version}_${revision}
     1223                set portname [lindex $line 1]
     1224            }
     1225        }
     1226        ui_debug "port name is '$portname'"
     1227        file mkdir $portname
     1228        cd $portname
     1229    } else {
     1230        set binary 0
     1231        set portname [file rootname $fetchfile]
     1232    }
     1233
     1234    # extract the portfile (and possibly files dir if not a binary archive)
     1235    ui_debug "extracting port archive to [pwd]"
     1236    if {$binary} {
     1237        set cmdline "$tarcmd ${tarflags}${qflag}xOf {$fetchfile} +PORTFILE > Portfile"
     1238    } else {
     1239        set cmdline "$tarcmd ${tarflags}xf {$fetchfile}"
     1240    }
     1241    ui_debug "$cmdline"
     1242    if {[catch {eval exec $cmdline} result]} {
    11801243        return -code error "Port extract failed: $result"
    11811244    }
    1182     if {[regexp {(.+).tgz} $fetchfile match portdir] != 1} {
    1183         return -code error "Can't decipher portdir from $fetchfile"
    1184     }
    1185     return [file join $fetchdir $portdir]
     1245
     1246    cd $oldpwd
     1247    return [file join $fetchdir $portname]
    11861248}
    11871249
     
    11991261# mports:// sources).
    12001262proc macports::getportdir {url {destdir "."}} {
     1263    global macports::extracted_portdirs
    12011264    set protocol [macports::getprotocol $url]
    12021265    switch ${protocol} {
    12031266        file {
    1204             return [file normalize [string range $url [expr [string length $protocol] + 3] end]]
     1267            set path [file normalize [string range $url [expr [string length $protocol] + 3] end]]
     1268            if {[file isdirectory $path]} {
     1269                return $path
     1270            } else {
     1271                # need to create a local dir for the exracted port, but only once
     1272                if {![info exists macports::extracted_portdirs($url)]} {
     1273                    set macports::extracted_portdirs($url) [macports::fetch_port $path 1]
     1274                }
     1275                return $macports::extracted_portdirs($url)
     1276            }
    12051277        }
    12061278        mports {
     
    12101282        http -
    12111283        ftp {
    1212             return [macports::fetch_port $url]
     1284            if {![info exists macports::extracted_portdirs($url)]} {
     1285                set macports::extracted_portdirs($url) [macports::fetch_port $url 0]
     1286            }
     1287            return $macports::extracted_portdirs($url)
    12131288        }
    12141289        default {
     
    13381413    }
    13391414
    1340     ditem_key $mport provides [$workername eval return \$name]
     1415    ditem_key $mport provides [$workername eval return \$subport]
    13411416
    13421417    return $mport
     
    13461421# opens a portfile stored in the registry
    13471422proc mportopen_installed {name version revision variants options} {
    1348     global macports::registry.format macports::registry.path
    1349     if {${registry.format} != "receipt_sqlite"} {
    1350         return -code error "mportopen_installed requires sqlite registry"
    1351     }
     1423    global macports::registry.path
    13521424    set regref [lindex [registry::entry imaged $name $version $revision $variants] 0]
    13531425    set portfile_dir [file join ${registry.path} registry portfiles $name "${version}_${revision}${variants}"]
     
    13751447proc mportclose_installed {mport} {
    13761448    global macports::registry.path
    1377     foreach key {name version revision portvariants} {
     1449    foreach key {subport version revision portvariants} {
    13781450        set $key [_mportkey $mport $key]
    13791451    }
    13801452    mportclose $mport
    1381     set portfiles_dir [file join ${registry.path} registry portfiles $name]
     1453    set portfiles_dir [file join ${registry.path} registry portfiles $subport]
    13821454    set portfile [file join $portfiles_dir "${version}_${revision}${portvariants}" Portfile]
    13831455    file delete -force $portfile [file dirname $portfile]
     
    14741546    # Check for the presence of the port in the registry
    14751547    set workername [ditem_key $mport workername]
    1476     return [$workername eval registry_exists_for_name \${name}]
     1548    return [$workername eval registry_exists_for_name \${subport}]
    14771549}
    14781550
     
    14801552proc _mportactive {mport} {
    14811553    set workername [ditem_key $mport workername]
    1482     if {![catch {set reslist [$workername eval registry_active \${name}]}] && [llength $reslist] > 0} {
     1554    if {![catch {set reslist [$workername eval registry_active \${subport}]}] && [llength $reslist] > 0} {
    14831555        set i [lindex $reslist 0]
    14841556        set name [lindex $i 0]
     
    15451617    set conflictlist {}
    15461618    if {[llength $conflictinfo] > 0} {
    1547         ui_debug "Checking for conflicts against [_mportkey $mport name]"
     1619        ui_debug "Checking for conflicts against [_mportkey $mport subport]"
    15481620        foreach conflictport ${conflictinfo} {
    15491621            if {[_mportispresent $mport port:${conflictport}]} {
     
    15521624        }
    15531625    } else {
    1554         ui_debug "[_mportkey $mport name] has no conflicts"
     1626        ui_debug "[_mportkey $mport subport] has no conflicts"
    15551627    }
    15561628
     
    15621634
    15631635proc _mportexec {target mport} {
    1564     set portname [_mportkey $mport name]
     1636    set portname [_mportkey $mport subport]
    15651637    macports::push_log $mport
    15661638    # xxx: set the work path?
     
    16051677        return 1
    16061678    }
    1607     set portname [_mportkey $mport name]
     1679    set portname [_mportkey $mport subport]
    16081680    if {$target != "clean"} {
    16091681        macports::push_log $mport
     
    16161688        # see if we actually need to build this port
    16171689        if {($target != "activate" && $target != "install") ||
    1618             ![$workername eval registry_exists \$name \$version \$revision \$portvariants]} {
     1690            ![$workername eval registry_exists \$subport \$version \$revision \$portvariants]} {
    16191691            # possibly warn or error out depending on how old xcode is
    16201692            if {[$workername eval _check_xcode_version] != 0} {
     
    16321704        }
    16331705
    1634         ui_msg -nonewline "--->  Computing dependencies for [_mportkey $mport name]"
     1706        ui_msg -nonewline "--->  Computing dependencies for [_mportkey $mport subport]"
    16351707        if {[macports::ui_isset ports_debug]} {
    16361708            # play nice with debug messages
     
    17471819                        array unset dep_portinfo
    17481820                        array set dep_portinfo [lindex $res 1]
     1821                        if {[info exists dep_portinfo(installs_libs)] && !$dep_portinfo(installs_libs)} {
     1822                            set missing {}
     1823                        }
     1824                    }
     1825                    if {[llength $missing] > 0} {
    17491826                        if {[info exists dep_portinfo(variants)] && [lsearch $dep_portinfo(variants) universal] != -1} {
    17501827                            # dep offers a universal variant
     
    17581835                                }
    17591836                                if {[llength $missing] > 0} {
    1760                                     ui_error "Cannot install [_mportkey $mport name] for the arch(s) '$required_archs' because"
     1837                                    ui_error "Cannot install [_mportkey $mport subport] for the arch(s) '$required_archs' because"
    17611838                                    ui_error "its dependency $dep_portname is only installed for the arch '$active_archs'"
    17621839                                    ui_error "and the configured universal_archs '$macports::universal_archs' are not sufficient."
     
    17701847                            } else {
    17711848                                # already universal
    1772                                 ui_error "Cannot install [_mportkey $mport name] for the arch(s) '$required_archs' because"
     1849                                ui_error "Cannot install [_mportkey $mport subport] for the arch(s) '$required_archs' because"
    17731850                                ui_error "its dependency $dep_portname is only installed for the archs '$active_archs'."
    17741851                                return -code error "architecture mismatch"
    17751852                            }
    17761853                        } else {
    1777                             ui_error "Cannot install [_mportkey $mport name] for the arch(s) '$required_archs' because"
     1854                            ui_error "Cannot install [_mportkey $mport subport] for the arch(s) '$required_archs' because"
    17781855                            ui_error "its dependency $dep_portname is only installed for the arch '$active_archs'"
    17791856                            ui_error "and does not have a universal variant."
     
    18281905    upvar $extension myextension
    18291906
    1830     if {[regexp {^(?:https?|ftp)://.+/(.+\.(tar\.gz|tar\.bz2))$} $url -> f e]} {
     1907    if {[regexp {^(?:https?|ftp|rsync)://.+/(.+\.(tar\.gz|tar\.bz2|tar))$} $url -> f e]} {
    18311908        set myfilename $f
    18321909        set myextension $e
     
    18721949    global macports::sources macports::portdbpath macports::rsync_options tcl_platform
    18731950    global macports::portverbose
    1874     global macports::autoconf::rsync_path
     1951    global macports::autoconf::rsync_path macports::autoconf::tar_path macports::autoconf::openssl_path
    18751952    array set options $optionslist
    18761953
     
    19242001                set indexfile [macports::getindex $source]
    19252002                set destdir [file dirname $indexfile]
     2003                set is_tarball [_source_is_snapshot $source]
    19262004                file mkdir $destdir
    1927                 # Keep rsync happy with a trailing slash
    1928                 if {[string index $source end] != "/"} {
    1929                     append source "/"
    1930                 }
    1931                 # don't sync PortIndex yet; we grab the platform specific one afterwards
    1932                 set exclude_option "'--exclude=/PortIndex*'"
     2005
     2006                if {$is_tarball} {
     2007                    set exclude_option ""
     2008                    # need to do a few things before replacing the ports tree in this case
     2009                    set destdir [file dirname $destdir]
     2010                } else {
     2011                    # Keep rsync happy with a trailing slash
     2012                    if {[string index $source end] != "/"} {
     2013                        append source "/"
     2014                    }
     2015                    # don't sync PortIndex yet; we grab the platform specific one afterwards
     2016                    set exclude_option "'--exclude=/PortIndex*'"
     2017                }
    19332018                # Do rsync fetch
    19342019                set rsync_commandline "${macports::autoconf::rsync_path} ${rsync_options} ${exclude_option} ${source} ${destdir}"
     
    19392024                    continue
    19402025                }
     2026
     2027                if {$is_tarball} {
     2028                    # verify signature for tarball
     2029                    global macports::archivefetch_pubkeys
     2030                    set rsync_commandline "${macports::autoconf::rsync_path} ${rsync_options} ${exclude_option} ${source}.rmd160 ${destdir}"
     2031                    ui_debug $rsync_commandline
     2032                    if {[catch {system $rsync_commandline}]} {
     2033                        ui_error "Synchronization of the ports tree signature failed doing rsync"
     2034                        incr numfailed
     2035                        continue
     2036                    }
     2037                    set tarball "${destdir}/[file tail $source]"
     2038                    set signature "${tarball}.rmd160"
     2039                    set openssl [macports::findBinary openssl $macports::autoconf::openssl_path]
     2040                    set verified 0
     2041                    foreach pubkey ${macports::archivefetch_pubkeys} {
     2042                        if {![catch {exec $openssl dgst -ripemd160 -verify $pubkey -signature $signature $tarball} result]} {
     2043                            set verified 1
     2044                            ui_debug "successful verification with key $pubkey"
     2045                            break
     2046                        } else {
     2047                            ui_debug "failed verification with key $pubkey"
     2048                            ui_debug "openssl output: $result"
     2049                        }
     2050                    }
     2051                    if {!$verified} {
     2052                        ui_error "Failed to verify signature for ports tree!"
     2053                        incr numfailed
     2054                        continue
     2055                    }
     2056
     2057                    # extract tarball and move into place
     2058                    set tar [macports::findBinary tar $macports::autoconf::tar_path]
     2059                    file mkdir ${destdir}/tmp
     2060                    set tar_cmd "$tar -C ${destdir}/tmp -xf ${tarball}"
     2061                    ui_debug $tar_cmd
     2062                    if {[catch {system $tar_cmd}]} {
     2063                        ui_error "Failed to extract ports tree from tarball!"
     2064                        incr numfailed
     2065                        continue
     2066                    }
     2067                    # save the local PortIndex data
     2068                    if {[file isfile $indexfile]} {
     2069                        file copy -force $indexfile ${destdir}/
     2070                        file rename -force $indexfile ${destdir}/tmp/ports/
     2071                        if {[file isfile ${indexfile}.quick]} {
     2072                            file rename -force ${indexfile}.quick ${destdir}/tmp/ports/
     2073                        }
     2074                    }
     2075                    file delete -force ${destdir}/ports
     2076                    file rename ${destdir}/tmp/ports ${destdir}/ports
     2077                    file delete -force ${destdir}/tmp
     2078                }
     2079
    19412080                # now sync the index if the local file is missing or older than a day
    19422081                if {![file isfile $indexfile] || [expr [clock seconds] - [file mtime $indexfile]] > 86400} {
    1943                     set remote_indexfile "${source}PortIndex_${macports::os_platform}_${macports::os_major}_${macports::os_arch}/PortIndex"
     2082                    if {$is_tarball} {
     2083                        # chop ports.tar off the end
     2084                        set index_source [string range $source 0 end-[string length [file tail $source]]]
     2085                    } else {
     2086                        set index_source $source
     2087                    }
     2088                    set remote_indexfile "${index_source}PortIndex_${macports::os_platform}_${macports::os_major}_${macports::os_arch}/PortIndex"
    19442089                    set rsync_commandline "${macports::autoconf::rsync_path} ${rsync_options} $remote_indexfile ${destdir}"
    19452090                    ui_debug $rsync_commandline
     
    19472092                        ui_debug "Synchronization of the PortIndex failed doing rsync"
    19482093                    } else {
    1949                         mports_generate_quickindex $indexfile
     2094                        set ok 1
     2095                        if {$is_tarball} {
     2096                            set ok 0
     2097                            # verify signature for PortIndex
     2098                            set rsync_commandline "${macports::autoconf::rsync_path} ${rsync_options} ${remote_indexfile}.rmd160 ${destdir}"
     2099                            ui_debug $rsync_commandline
     2100                            if {![catch {system $rsync_commandline}]} {
     2101                                foreach pubkey ${macports::archivefetch_pubkeys} {
     2102                                    if {![catch {exec $openssl dgst -ripemd160 -verify $pubkey -signature ${destdir}/PortIndex.rmd160 ${destdir}/PortIndex} result]} {
     2103                                        set ok 1
     2104                                        ui_debug "successful verification with key $pubkey"
     2105                                        break
     2106                                    } else {
     2107                                        ui_debug "failed verification with key $pubkey"
     2108                                        ui_debug "openssl output: $result"
     2109                                    }
     2110                                }
     2111                                if {$ok} {
     2112                                    # move PortIndex into place
     2113                                    file rename -force ${destdir}/PortIndex ${destdir}/ports/
     2114                                }
     2115                            }
     2116                        }
     2117                        if {$ok} {
     2118                            mports_generate_quickindex $indexfile
     2119                        }
    19502120                    }
    19512121                }
     
    25332703                    ui_error "Dependency '$dep_portname' not found."
    25342704                    return 1
     2705                } elseif {[info exists dep_portinfo(installs_libs)] && !$dep_portinfo(installs_libs)} {
     2706                    set check_archs 0
    25352707                }
    25362708                lappend options subport $dep_portname
     
    25692741                }
    25702742                if {$arch_mismatch} {
    2571                     macports::_explain_arch_mismatch [_mportkey $mport name] $dep_portname $required_archs $supported_archs $has_universal
     2743                    macports::_explain_arch_mismatch [_mportkey $mport subport] $dep_portname $required_archs $supported_archs $has_universal
    25722744                    return -code error "architecture mismatch"
    25732745                }
     
    27372909        activate    -
    27382910        ""          {
    2739             if {[$workername eval registry_exists \$name \$version \$revision \$portvariants]
     2911            if {[$workername eval registry_exists \$subport \$version \$revision \$portvariants]
    27402912                || [$workername eval _archive_available]} {
    27412913                return "depends_lib depends_run"
     
    27522924    global macports::prefix macports::portdbpath macports::libpath macports::rsync_server macports::rsync_dir macports::rsync_options
    27532925    global macports::autoconf::macports_version macports::autoconf::rsync_path tcl_platform
     2926    global macports::autoconf::openssl_path macports::autoconf::tar_path
    27542927    array set options $optionslist
    27552928   
     
    27682941    }
    27692942
     2943    # are we syncing a tarball? (implies detached signature)
     2944    set is_tarball 0
     2945    if {[string range ${rsync_dir} end-3 end] == ".tar"} {
     2946        set is_tarball 1
     2947        set mp_source_path [file join $portdbpath sources ${rsync_server} [file dirname ${rsync_dir}]]
     2948    } else {
     2949        if {[string index $rsync_dir end] != "/"} {
     2950            append rsync_dir "/"
     2951        }
     2952        set mp_source_path [file join $portdbpath sources ${rsync_server} ${rsync_dir}]
     2953    }
    27702954    # create the path to the to be downloaded sources if it doesn't exist
    2771     set mp_source_path [file join $portdbpath sources ${rsync_server} ${rsync_dir}/]
    27722955    if {![file exists $mp_source_path]} {
    27732956        file mkdir $mp_source_path
     
    27792962    if { [catch { system "$rsync_path $rsync_options rsync://${rsync_server}/${rsync_dir} $mp_source_path" } result ] } {
    27802963       return -code error "Error synchronizing MacPorts sources: $result"
     2964    }
     2965
     2966    if {$is_tarball} {
     2967        # verify signature for tarball
     2968        global macports::archivefetch_pubkeys
     2969        if { [catch { system "$rsync_path $rsync_options rsync://${rsync_server}/${rsync_dir}.rmd160 $mp_source_path" } result ] } {
     2970            return -code error "Error synchronizing MacPorts source signature: $result"
     2971        }
     2972        set openssl [findBinary openssl $macports::autoconf::openssl_path]
     2973        set tarball "${mp_source_path}/[file tail $rsync_dir]"
     2974        set signature "${tarball}.rmd160"
     2975        set verified 0
     2976        foreach pubkey ${macports::archivefetch_pubkeys} {
     2977            if {![catch {exec $openssl dgst -ripemd160 -verify $pubkey -signature $signature $tarball} result]} {
     2978                set verified 1
     2979                ui_debug "successful verification with key $pubkey"
     2980                break
     2981            } else {
     2982                ui_debug "failed verification with key $pubkey"
     2983                ui_debug "openssl output: $result"
     2984            }
     2985        }
     2986        if {!$verified} {
     2987            return -code error "Failed to verify signature for MacPorts source!"
     2988        }
     2989       
     2990        # extract tarball and move into place
     2991        set tar [macports::findBinary tar $macports::autoconf::tar_path]
     2992        file mkdir ${mp_source_path}/tmp
     2993        set tar_cmd "$tar -C ${mp_source_path}/tmp -xf ${tarball}"
     2994        ui_debug $tar_cmd
     2995        if {[catch {system $tar_cmd}]} {
     2996            return -code error "Failed to extract MacPorts sources from tarball!"
     2997        }
     2998        file delete -force ${mp_source_path}/base
     2999        file rename ${mp_source_path}/tmp/base ${mp_source_path}/base
     3000        file delete -force ${mp_source_path}/tmp
     3001        # set the final extracted source path
     3002        set mp_source_path ${mp_source_path}/base
    27813003    }
    27823004
     
    28393061            } else {
    28403062                ui_warn "Disabling readline support due to readline in /usr/local"
     3063            }
     3064
     3065            if {$prefix == "/usr/local"} {
     3066                append configure_args " --with-unsupported-prefix"
    28413067            }
    28423068
     
    32513477    }
    32523478
    3253     global macports::registry.format
    32543479    # are we installing an existing version due to force or epoch override?
    32553480    if {[registry::entry_exists $newname $version_in_tree $revision_in_tree $portinfo(canonical_active_variants)]
     
    32633488        if {$is_dryrun eq "yes"} {
    32643489            ui_msg "Skipping uninstall $newname @${version_in_tree}_${revision_in_tree}$portinfo(canonical_active_variants) (dry run)"
    3265         } elseif {!(${registry.format} == "receipt_sqlite" && [registry::run_target $newregref uninstall [array get options]])
    3266                   && [catch {registry_uninstall::uninstall $newname ${version_in_tree}_${revision_in_tree}$portinfo(canonical_active_variants) [array get options]} result]} {
     3490        } elseif {![registry::run_target $newregref uninstall [array get options]]
     3491                  && [catch {registry_uninstall::uninstall $newname $version_in_tree $revision_in_tree $portinfo(canonical_active_variants) [array get options]} result]} {
    32673492            global errorInfo
    32683493            ui_debug "$errorInfo"
     
    32873512            ui_msg "Skipping deactivate $portname @${version_active}_${revision_active}${variant_active} (dry run)"
    32883513        } elseif {![catch {registry::active $portname}] &&
    3289                   !(${registry.format} == "receipt_sqlite" && [registry::run_target $regref deactivate [array get options]])
    3290                   && [catch {portimage::deactivate $portname ${version_active}_${revision_active}${variant_active} [array get options]} result]} {
     3514                  ![registry::run_target $regref deactivate [array get options]]
     3515                  && [catch {portimage::deactivate $portname $version_active $revision_active $variant_active [array get options]} result]} {
    32913516            global errorInfo
    32923517            ui_debug "$errorInfo"
     
    33633588            if {$is_dryrun eq "yes"} {
    33643589                ui_msg "Skipping uninstall $portname @${version}_${revision}${variant} (dry run)"
    3365             } elseif {!(${registry.format} == "receipt_sqlite" && [registry::run_target $regref uninstall $optionslist])
    3366                       && [catch {registry_uninstall::uninstall $portname ${version}_${revision}${variant} $optionslist} result]} {
     3590            } elseif {![registry::run_target $regref uninstall $optionslist]
     3591                      && [catch {registry_uninstall::uninstall $portname $version $revision $variant $optionslist} result]} {
    33673592                global errorInfo
    33683593                ui_debug "$errorInfo"
  • branches/gsoc11-statistics/base/src/macports1.0/macports_autoconf.tcl.in

    r77511 r79672  
    33# $Id$
    44#
    5 # Copyright (c) 2002 - 2003 Apple Computer, Inc.
     5# Copyright (c) 2006 - 2009, 2011 The MacPorts Project
     6# Copyright (c) 2002 - 2003 Apple Inc.
    67# All rights reserved.
    78#
     
    1415#    notice, this list of conditions and the following disclaimer in the
    1516#    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# 3. Neither the name of Apple Inc. nor the names of its contributors
    1718#    may be used to endorse or promote products derived from this software
    1819#    without specific prior written permission.
     
    4142    variable macportsuser "@RUNUSR@"
    4243    variable open_path "@OPEN@"
     44    variable openssl_path "@OPENSSL@"
    4345    variable pax_path "@PAX@"
    4446    variable rsync_path "@RSYNC@"
    4547    variable tar_command "@TAR_CMD@"
    4648    variable tar_path "@TAR@"
     49    variable tar_q "@TAR_Q@"
    4750    variable unzip_path "@UNZIP@"
    4851    variable xar_path "@XAR@"
  • branches/gsoc11-statistics/base/src/macports1.0/macports_dlist.tcl

    r78396 r79672  
    22# $Id$
    33#
     4# Copyright (c) 2004-2005, 2007, 2009, 2011 The MacPorts Project
    45# Copyright (c) 2003 Kevin Van Vechten <kevin@opendarwin.org>
    5 # Copyright (c) 2002 Apple Computer, Inc.
     6# Copyright (c) 2002 Apple Inc.
    67# All rights reserved.
    78#
     
    1415#    notice, this list of conditions and the following disclaimer in the
    1516#    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# 3. Neither the name of Apple Inc. nor the names of its contributors
    1718#    may be used to endorse or promote products derived from this software
    1819#    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/macports1.0/macports_fastload.tcl.in

    r66607 r79672  
    33# $Id$
    44#
    5 # Copyright (c) 2004 Paul Guyot, The MacPorts Project.
     5# Copyright (c) 2005-2007, 2009-2010 The MacPorts Project
     6# Copyright (c) 2004-2005 Paul Guyot, The MacPorts Project.
    67# All rights reserved.
    78#
     
    1415#    notice, this list of conditions and the following disclaimer in the
    1516#    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# 3. Neither the name of The MacPorts Project nor the names of its contributors
    1718#    may be used to endorse or promote products derived from this software
    1819#    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/macports1.0/macports_index.tcl

    r26177 r79672  
    22# $Id$
    33#
    4 # Copyright (c) 2004 Apple Computer, Inc.
     4# Copyright (c) 2004 Apple Inc.
    55# All rights reserved.
    66#
     
    1313#    notice, this list of conditions and the following disclaimer in the
    1414#    documentation and/or other materials provided with the distribution.
    15 # 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
     15# 3. Neither the name of Apple Inc. nor the names of its contributors
    1616#    may be used to endorse or promote products derived from this software
    1717#    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/macports1.0/macports_util.tcl

    r26177 r79672  
    1313#    notice, this list of conditions and the following disclaimer in the
    1414#    documentation and/or other materials provided with the distribution.
    15 # 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
     15# 3. Neither the name of The MacPorts Project nor the names of its contributors
    1616#    may be used to endorse or promote products derived from this software
    1717#    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/macports1.0/tests/macports_dlist.tcl

    r26721 r79672  
    33# $Id$
    44#
     5# Copyright (c) 2007 The MacPorts Project
    56# Copyright (c) 2003 Kevin Van Vechten <kevin@opendarwin.org>
    67
     
    7172
    7273# Replicate Shantonu's Bug #354 to test dlist functionality.
    73 # http://trac.macports.org/projects/macports/ticket/354
     74# https://trac.macports.org/ticket/354
    7475# A depends on B, C.
    7576# B depends on C.
  • branches/gsoc11-statistics/base/src/package1.0/package.tcl

    r77511 r79672  
    33# $Id$
    44#
    5 # Copyright (c) 2002 Apple Computer, Inc.
     5# Copyright (c) 2004, 2007-2008, 2010 The MacPorts Project
     6# Copyright (c) 2002-2004 Apple Inc.
    67# All rights reserved.
    78#
     
    1415#    notice, this list of conditions and the following disclaimer in the
    1516#    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# 3. Neither the name of Apple Inc. nor the names of its contributors
    1718#    may be used to endorse or promote products derived from this software
    1819#    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/package1.0/portarchivefetch.tcl

    r78062 r79672  
    33#
    44# Copyright (c) 2002 - 2003 Apple Inc.
    5 # Copyright (c) 2004-2010 The MacPorts Project
     5# Copyright (c) 2004 - 2011 The MacPorts Project
    66# All rights reserved.
    77#
     
    6060default archivefetch.pubkeys {$archivefetch_pubkeys}
    6161
    62 default archive_sites macports_archives
     62default archive_sites {[portarchivefetch::filter_sites]}
    6363default archive_sites.listfile {"archive_sites.tcl"}
    6464default archive_sites.listpath {"port1.0/fetch"}
    6565default archive.subdir {${subport}}
     66
     67proc portarchivefetch::filter_sites {} {
     68    global prefix porturl
     69    set ret {}
     70    foreach site [array names portfetch::mirror_sites::archive_prefix] {
     71        if {$portfetch::mirror_sites::archive_prefix($site) == $prefix} {
     72            lappend ret $site
     73        }
     74    }
     75    if {[file rootname [file tail $porturl]] == [file rootname [file tail [get_portimage_path]]]} {
     76        lappend ret [string range $porturl 0 end-[string length [file tail $porturl]]]
     77    }
     78    return $ret
     79}
    6680
    6781set_ui_prefix
     
    205219                    return -code error "Failed to fetch signature for archive: $result"
    206220                }
     221                set openssl [findBinary openssl $portutil::autoconf::openssl_path]
    207222                set verified 0
    208223                foreach pubkey [option archivefetch.pubkeys] {
    209                     set openssl [findBinary openssl $portutil::autoconf::openssl_path]
    210224                    if {![catch {exec $openssl dgst -ripemd160 -verify $pubkey -signature $signature "${incoming_path}/${archive}.TMP"} result]} {
    211225                        set verified 1
     
    247261# Initialize archivefetch target and call checkfiles.
    248262proc portarchivefetch::archivefetch_init {args} {
     263    global porturl portarchivetype
     264    # installing straight from a binary archive
     265    if {[file rootname [file tail $porturl]] == [file rootname [file tail [get_portimage_path]]] && [file extension $porturl] != ""} {
     266        set portarchivetype [string range [file extension $porturl] 1 end]
     267    }
    249268    return 0
    250269}
  • branches/gsoc11-statistics/base/src/package1.0/portdmg.tcl

    r78062 r79672  
    33# $Id$
    44#
    5 # Copyright (c) 2003 Apple Computer, Inc.
     5# Copyright (c) 2007, 2009-2011  The MacPorts Project
     6# Copyright (c) 2003, 2005 Apple Inc.
    67# All rights reserved.
    78#
     
    1415#    notice, this list of conditions and the following disclaimer in the
    1516#    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# 3. Neither the name of Apple Inc. nor the names of its contributors
    1718#    may be used to endorse or promote products derived from this software
    1819#    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/package1.0/portdpkg.tcl

    r78062 r79672  
    33# $Id$
    44#
     5# Copyright (c) 2005, 2007, 2009, 2011 The MacPorts Project
    56# Copyright (c) 2004 Landon Fuller <landonf@macports.org>
    6 # Copyright (c) 2002 - 2003 Apple Computer, Inc.
     7# Copyright (c) 2002 - 2003 Apple Inc.
    78# All rights reserved.
    89#
     
    1516#    notice, this list of conditions and the following disclaimer in the
    1617#    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# 3. Neither the name of Apple Inc. nor the names of its contributors
    1819#    may be used to endorse or promote products derived from this software
    1920#    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/package1.0/portmdmg.tcl

    r78062 r79672  
    33# $Id$
    44#
    5 # Copyright (c) 2003 Apple Computer, Inc.
     5# Copyright (c) 2005, 2007-2011 The MacPorts Project
     6# Copyright (c) 2003-2004 Apple Inc.
    67# All rights reserved.
    78#
     
    1415#    notice, this list of conditions and the following disclaimer in the
    1516#    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# 3. Neither the name of Apple Inc. nor the names of its contributors
    1718#    may be used to endorse or promote products derived from this software
    1819#    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/package1.0/portmpkg.tcl

    r78390 r79672  
    33# $Id$
    44#
    5 # Copyright (c) 2002 - 2003 Apple Computer, Inc.
     5# Copyright (c) 2005, 2007 - 2011 The MacPorts Project
     6# Copyright (c) 2002 - 2004 Apple Inc.
    67# All rights reserved.
    78#
     
    1415#    notice, this list of conditions and the following disclaimer in the
    1516#    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# 3. Neither the name of Apple Inc. nor the names of its contributors
    1718#    may be used to endorse or promote products derived from this software
    1819#    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/package1.0/portpkg.tcl

    r78178 r79672  
    33# $Id$
    44#
    5 # Copyright (c) 2002 - 2003 Apple Computer, Inc.
     5# Copyright (c) 2005, 2007 - 2011 The MacPorts Project
     6# Copyright (c) 2002 - 2003 Apple Inc.
    67# All rights reserved.
    78#
     
    1415#    notice, this list of conditions and the following disclaimer in the
    1516#    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# 3. Neither the name of Apple Inc. nor the names of its contributors
    1718#    may be used to endorse or promote products derived from this software
    1819#    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/package1.0/portportpkg.tcl

    r53280 r79672  
    33# $Id$
    44#
    5 # Copyright (c) 2002 - 2004 Apple Computer, Inc.
     5# Copyright (c) 2002 - 2004 Apple Inc.
    66# All rights reserved.
    77#
     
    1414#    notice, this list of conditions and the following disclaimer in the
    1515#    documentation and/or other materials provided with the distribution.
    16 # 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
     16# 3. Neither the name of Apple Inc. nor the names of its contributors
    1717#    may be used to endorse or promote products derived from this software
    1818#    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/package1.0/portrpm.tcl

    r78062 r79672  
    33# $Id$
    44#
    5 # Copyright (c) 2002 - 2003 Apple Computer, Inc.
     5# Copyright (c) 2005 - 2007, 2009 - 2011 The MacPorts Project
     6# Copyright (c) 2002 - 2003 Apple Inc.
    67# All rights reserved.
    78#
     
    1415#    notice, this list of conditions and the following disclaimer in the
    1516#    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# 3. Neither the name of Apple Inc. nor the names of its contributors
    1718#    may be used to endorse or promote products derived from this software
    1819#    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/package1.0/portsrpm.tcl

    r78062 r79672  
    33# $Id$
    44#
    5 # Copyright (c) 2002 - 2003 Apple Computer, Inc.
     5# Copyright (c) 2007, 2009, 2011 The MacPorts Project
     6# Copyright (c) 2002 - 2003 Apple Inc.
    67# All rights reserved.
    78#
     
    1415#    notice, this list of conditions and the following disclaimer in the
    1516#    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# 3. Neither the name of Apple Inc. nor the names of its contributors
    1718#    may be used to endorse or promote products derived from this software
    1819#    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/package1.0/portunarchive.tcl

    r78660 r79672  
    33# $Id$
    44#
     5# Copyright (c) 2005, 2007-2011 The MacPorts Project
    56# Copyright (c) 2004 Robert Shaw <rshaw@opendarwin.org>
    6 # Copyright (c) 2002 - 2003 Apple Computer, Inc.
     7# Copyright (c) 2002 - 2003 Apple Inc.
    78# All rights reserved.
    89#
     
    1516#    notice, this list of conditions and the following disclaimer in the
    1617#    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# 3. Neither the name of Apple Inc. nor the names of its contributors
    1819#    may be used to endorse or promote products derived from this software
    1920#    without specific prior written permission.
     
    6263
    6364proc portunarchive::unarchive_init {args} {
    64     global target_state_fd unarchive.skip \
     65    global target_state_fd unarchive.skip destroot \
    6566           ports_force ports_source_only ports_binary_only \
    6667           subport version revision portvariants \
     
    7475        ui_debug "Skipping unarchive ($subport) since source-only is set"
    7576        set skipped 1
    76     } elseif {[check_statefile target org.macports.destroot $target_state_fd]} {
     77    } elseif {[check_statefile target org.macports.destroot $target_state_fd]
     78              && [file isdirectory $destroot]} {
    7779        ui_debug "Skipping unarchive ($subport) since destroot completed"
    7880        set skipped 1
  • branches/gsoc11-statistics/base/src/pextlib1.0/Pextlib.c

    r74010 r79672  
    33 * $Id$
    44 *
    5  * Copyright (c) 2002 - 2003 Apple Computer, Inc.
     5 * Copyright (c) 2002 - 2003 Apple Inc.
    66 * Copyright (c) 2004 - 2005 Paul Guyot <pguyot@kallisys.net>
    77 * Copyright (c) 2004 Landon Fuller <landonf@macports.org>
     
    1616 *    notice, this list of conditions and the following disclaimer in the
    1717 *    documentation and/or other materials provided with the distribution.
    18  * 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
     18 * 3. Neither the name of Apple Inc. nor the names of its contributors
    1919 *    may be used to endorse or promote products derived from this software
    2020 *    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/pextlib1.0/base32cmd.c

    r74007 r79672  
    1414 *    notice, this list of conditions and the following disclaimer in the
    1515 *    documentation and/or other materials provided with the distribution.
    16  * 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
     16 * 3. Neither the name of The MacPorts Project nor the names of its contributors
    1717 *    may be used to endorse or promote products derived from this software
    1818 *    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/pextlib1.0/base32cmd.h

    r74001 r79672  
    1414 *    notice, this list of conditions and the following disclaimer in the
    1515 *    documentation and/or other materials provided with the distribution.
    16  * 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
     16 * 3. Neither the name of The MacPorts Project nor the names of its contributors
    1717 *    may be used to endorse or promote products derived from this software
    1818 *    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/pextlib1.0/fs-traverse.c

    r65785 r79672  
    66 * Author: Jordan K. Hubbard, Kevin Ballard, Rainer Mueller
    77 *
    8  * Copyright (c) 2004 Apple Computer, Inc.
     8 * Copyright (c) 2004 Apple Inc.
    99 * Copyright (c) 2010 The MacPorts Project
    1010 * All rights reserved.
     
    1818 *    notice, this list of conditions and the following disclaimer in the
    1919 *    documentation and/or other materials provided with the distribution.
    20  * 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
     20 * 3. Neither the name of Apple Inc. nor the names of its contributors
    2121 *    may be used to endorse or promote products derived from this software
    2222 *    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/pextlib1.0/fs-traverse.h

    r24112 r79672  
    33 * $Id$
    44 *
    5  * Copyright (c) 2002 - 2003 Apple Computer, Inc.
     5 * Copyright (c) 2002 - 2003 Apple Inc.
    66 * All rights reserved.
    77 *
     
    1414 *    notice, this list of conditions and the following disclaimer in the
    1515 *    documentation and/or other materials provided with the distribution.
    16  * 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
     16 * 3. Neither the name of Apple Inc. nor the names of its contributors
    1717 *    may be used to endorse or promote products derived from this software
    1818 *    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/pextlib1.0/md5cmd.c

    r77865 r79672  
    33 * $Id$
    44 *
    5  * Copyright (c) 2002 - 2003 Apple Computer, Inc.
     5 * Copyright (c) 2004 - 2005, 2009, 2011 The MacPorts Project
     6 * Copyright (c) 2002 - 2003 Apple Inc.
    67 * All rights reserved.
    78 *
     
    1415 *    notice, this list of conditions and the following disclaimer in the
    1516 *    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 * 3. Neither the name of Apple Inc. nor the names of its contributors
    1718 *    may be used to endorse or promote products derived from this software
    1819 *    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/pextlib1.0/md5cmd.h

    r19376 r79672  
    33 * $Id$
    44 *
    5  * Copyright (c) 2002 - 2003 Apple Computer, Inc.
     5 * Copyright (c) 2002 - 2003 Apple Inc.
    66 * All rights reserved.
    77 *
     
    1414 *    notice, this list of conditions and the following disclaimer in the
    1515 *    documentation and/or other materials provided with the distribution.
    16  * 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
     16 * 3. Neither the name of Apple Inc. nor the names of its contributors
    1717 *    may be used to endorse or promote products derived from this software
    1818 *    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/pextlib1.0/md_wrappers.h

    r53201 r79672  
    1414 *    notice, this list of conditions and the following disclaimer in the
    1515 *    documentation and/or other materials provided with the distribution.
    16  * 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
     16 * 3. Neither the name of The MacPorts Project nor the names of its contributors
    1717 *    may be used to endorse or promote products derived from this software
    1818 *    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/pextlib1.0/rmd160cmd.c

    r77865 r79672  
    33 * $Id$
    44 *
     5 * Copyright (c) 2006, 2009-2011 The MacPorts Project
    56 * Copyright (c) 2005 Paul Guyot <pguyot@kallisys.net>.
    67 * All rights reserved.
     
    1415 *    notice, this list of conditions and the following disclaimer in the
    1516 *    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 * 3. Neither the name of The MacPorts Project nor the names of its contributors
    1718 *    may be used to endorse or promote products derived from this software
    1819 *    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/pextlib1.0/rmd160cmd.h

    r26177 r79672  
    1414 *    notice, this list of conditions and the following disclaimer in the
    1515 *    documentation and/or other materials provided with the distribution.
    16  * 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
     16 * 3. Neither the name of The MacPorts Project nor the names of its contributors
    1717 *    may be used to endorse or promote products derived from this software
    1818 *    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/pextlib1.0/sha1cmd.c

    r77865 r79672  
    44 * Copied from md5cmd.c 20040903 EH
    55 *
    6  * Copyright (c) 2002 - 2003 Apple Computer, Inc.
     6 * Copyright (c) 2004 - 2005, 2009 - 2011 The MacPorts Project
     7 * Copyright (c) 2002 - 2003 Apple Inc.
    78 * All rights reserved.
    89 *
     
    1516 *    notice, this list of conditions and the following disclaimer in the
    1617 *    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 * 3. Neither the name of Apple Inc. nor the names of its contributors
    1819 *    may be used to endorse or promote products derived from this software
    1920 *    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/pextlib1.0/sha1cmd.h

    r19376 r79672  
    44 * Copied from md5cmd.h 20040903 EH
    55 *
    6  * Copyright (c) 2002 - 2003 Apple Computer, Inc.
     6 * Copyright (c) 2002 - 2003 Apple Inc.
    77 * All rights reserved.
    88 *
     
    1515 *    notice, this list of conditions and the following disclaimer in the
    1616 *    documentation and/or other materials provided with the distribution.
    17  * 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
     17 * 3. Neither the name of Apple Inc. nor the names of its contributors
    1818 *    may be used to endorse or promote products derived from this software
    1919 *    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/pextlib1.0/sha2.c

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/gsoc11-statistics/base/src/pextlib1.0/sha2.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/gsoc11-statistics/base/src/pextlib1.0/sha256cmd.c

    r77865 r79672  
    33 * $Id$
    44 *
    5  * Copyright (c) 2009 The MacPorts Project
     5 * Copyright (c) 2009, 2011 The MacPorts Project
    66 * All rights reserved.
    77 *
     
    1414 *    notice, this list of conditions and the following disclaimer in the
    1515 *    documentation and/or other materials provided with the distribution.
    16  * 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
     16 * 3. Neither the name of The MacPorts Project nor the names of its contributors
    1717 *    may be used to endorse or promote products derived from this software
    1818 *    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/pextlib1.0/sha256cmd.h

    r60372 r79672  
    1414 *    notice, this list of conditions and the following disclaimer in the
    1515 *    documentation and/or other materials provided with the distribution.
    16  * 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
     16 * 3. Neither the name of The MacPorts Project nor the names of its contributors
    1717 *    may be used to endorse or promote products derived from this software
    1818 *    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/pextlib1.0/tty.c

    r61670 r79672  
    66 * Author: Rainer Mueller <raimue@macports.org>
    77 *
     8 * Copyright (c) 2009 The MacPorts Project
    89 * Copyright (c) 2008 Rainer Mueller <raimue@macports.org>
    910 * All rights reserved.
     
    1718 *    notice, this list of conditions and the following disclaimer in the
    1819 *    documentation and/or other materials provided with the distribution.
    19  * 3. Neither the name of Apple Computer, Inc. nor the names of its
     20 * 3. Neither the name of The MacPorts Project nor the names of its
    2021 *    contributors may be used to endorse or promote products derived from
    2122 *    this software without specific prior written permission.
  • branches/gsoc11-statistics/base/src/pextlib1.0/tty.h

    r51280 r79672  
    1717 *    notice, this list of conditions and the following disclaimer in the
    1818 *    documentation and/or other materials provided with the distribution.
    19  * 3. Neither the name of Apple Computer, Inc. nor the names of its
     19 * 3. Neither the name of The MacPorts Project nor the names of its
    2020 *    contributors may be used to endorse or promote products derived from
    2121 *    this software without specific prior written permission.
  • branches/gsoc11-statistics/base/src/pextlib1.0/vercomp.c

    r51280 r79672  
    66 * Author: Landon Fuller <landonf@macports.org>
    77 *
    8  * Copyright (c) 2002 - 2003 Apple Computer, Inc.
     8 * Copyright (c) 2002 - 2003 Apple Inc.
    99 * Copyright (c) 2004 Landon Fuller <landonf@macports.org>
    1010 * All rights reserved.
     
    1818 *    notice, this list of conditions and the following disclaimer in the
    1919 *    documentation and/or other materials provided with the distribution.
    20  * 3. Neither the name of Apple Computer, Inc. nor the names of its
     20 * 3. Neither the name of Apple Inc. nor the names of its
    2121 *    contributors may be used to endorse or promote products derived from
    2222 *    this software without specific prior written permission.
  • branches/gsoc11-statistics/base/src/pextlib1.0/vercomp.h

    r26177 r79672  
    44 * Author: Landon Fuller <landonf@macports.org>
    55 *
    6  * Copyright (c) 2002 - 2003 Apple Computer, Inc.
     6 * Copyright (c) 2002 - 2003 Apple Inc.
    77 * Copyright (c) 2004 Landon Fuller
    88 * All rights reserved.
     
    1616 *    notice, this list of conditions and the following disclaimer in the
    1717 *    documentation and/or other materials provided with the distribution.
    18  * 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
     18 * 3. Neither the name of Apple Inc. nor the names of its contributors
    1919 *    may be used to endorse or promote products derived from this software
    2020 *    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/pkg_mkindex.sh.in

    r77867 r79672  
    1313#    notice, this list of conditions and the following disclaimer in the
    1414#    documentation and/or other materials provided with the distribution.
    15 # 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
     15# 3. Neither the name of The MacPorts Project nor the names of its contributors
    1616#    may be used to endorse or promote products derived from this software
    1717#    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/port/Makefile

    r71035 r79672  
    2323
    2424mkdirs:
    25         <../../doc/prefix.mtree $(MTREE) -U -d -e -p ${INSTALLDIR} > /dev/null
     25        < ../../doc/prefix.mtree $(MTREE) -U -d -e -p ${INSTALLDIR} > /dev/null
     26        < ../../doc/base.mtree $(MTREE) -U -d -e -p ${INSTALLDIR} > /dev/null
    2627
    2728clean:
  • branches/gsoc11-statistics/base/src/port/port-help.tcl

    r78937 r79672  
    278278
    279279One example is the set of python ports, where there are (among others)
    280 python25, python26, and python30.  The select action lets you set which
     280python25, python26, and python31.  The select action lets you set which
    281281of these becomes the version run when you simply use 'python'.
    282282
     
    292292set porthelp(selfupdate) {
    293293Upgrade MacPorts itself and run the sync target
     294}
     295
     296set porthelp(space) {
     297Show the disk space used by the given ports
     298
     299--units <units> Specify units to use. Accepted units are: B, kB, KiB, MB, MiB,
     300                GB, GiB. The 'B' may be omitted.
    294301}
    295302
  • branches/gsoc11-statistics/base/src/port/port.tcl

    r79663 r79672  
    66# $Id$
    77#
    8 # Copyright (c) 2002-2007 The MacPorts Project.
     8# Copyright (c) 2004-2011 The MacPorts Project
    99# Copyright (c) 2004 Robert Shaw <rshaw@opendarwin.org>
    10 # Copyright (c) 2002 Apple Computer, Inc.
     10# Copyright (c) 2002-2003 Apple Inc.
    1111# All rights reserved.
    1212#
     
    1919#    notice, this list of conditions and the following disclaimer in the
    2020#    documentation and/or other materials provided with the distribution.
    21 # 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
     21# 3. Neither the name of Apple Inc. nor the names of its contributors
    2222#    may be used to endorse or promote products derived from this software
    2323#    without specific prior written permission.
     
    8888Pseudo-portnames are words that may be used in place of a portname, and
    8989which expand to some set of ports. The common pseudo-portnames are:
    90 all, current, active, inactive, installed, uninstalled, outdated, obsolete,
    91 requested, unrequested and leaves.
     90all, current, active, inactive, actinact, installed, uninstalled, outdated,
     91obsolete, requested, unrequested and leaves.
    9292These pseudo-portnames expand to the set of ports named.
    9393
     
    155155
    156156
     157# Format an integer representing bytes using given units
     158proc bytesize {siz {unit {}}} {
     159    if {$unit == {}} {
     160        if {$siz > 0x40000000} {
     161            set unit "GiB"
     162        } elseif {$siz > 0x100000} {
     163            set unit "MiB"
     164        } elseif {$siz > 0x400} {
     165            set unit "KiB"
     166        } else {
     167            set unit "B"
     168        }
     169    }
     170    switch -- $unit {
     171        KiB {
     172            set siz [expr $siz / 1024.0]
     173        }
     174        kB {
     175            set siz [expr $siz / 1000.0]
     176        }
     177        MiB {
     178            set siz [expr $siz / 1048576.0]
     179        }
     180        MB {
     181            set siz [expr $siz / 1000000.0]
     182        }
     183        GiB {
     184            set siz [expr $siz / 1073741824.0]
     185        }
     186        GB {
     187            set siz [expr $siz / 1000000000.0]
     188        }
     189        B { }
     190        default {
     191            ui_warn "Unknown file size unit '$unit' specified"
     192            set unit "B"
     193        }
     194    }
     195    if {[expr round($siz)] != $siz} {
     196        set siz [format {%.3f} $siz]
     197    }
     198    return "$siz $unit"
     199}
     200
     201proc filesize {fil {unit {}}} {
     202    set siz {@}
     203    catch {
     204        set siz [bytesize [file size $fil] $unit]
     205    }
     206    return $siz
     207}
    157208
    158209# Produce an error message, and exit, unless
     
    714765}
    715766
     767proc get_actinact_ports {} {
     768    set inactive_ports [get_inactive_ports]
     769    set active_ports [get_active_ports]
     770    set results {}
     771
     772    foreach port $inactive_ports {
     773        array set portspec $port
     774        set portname $portspec(name)
     775        lappend inact($portname) $port
     776    }
     777
     778    foreach port $active_ports {
     779        array set portspec $port
     780        set portname $portspec(name)
     781
     782        if {[info exists inact($portname)]} {
     783            if {![info exists added_inact($portname)]} {
     784                foreach inact_spec $inact($portname) {
     785                    lappend results $inact_spec
     786                }
     787                set added_inact($portname) 1
     788            }
     789            lappend results $port
     790        }
     791    }
     792    return $results
     793}
     794
    716795
    717796proc get_outdated_ports {} {
     
    11641243        ^active(@.*)?$      -
    11651244        ^inactive(@.*)?$    -
     1245        ^actinact(@.*)?$    -
    11661246        ^leaves(@.*)?$      -
    11671247        ^outdated(@.*)?$    -
     
    22182298
    22192299proc action_activate { action portlist opts } {
    2220     global macports::registry.format
    22212300    set status 0
    22222301    if {[require_portlist portlist] || [prefix_unwritable]} {
     
    22252304    foreachport $portlist {
    22262305        set composite_version [composite_version $portversion [array get variations]]
    2227         if {${macports::registry.format} == "receipt_sqlite"
    2228             && ![info exists options(ports_activate_no-exec)]
     2306        if {![info exists options(ports_activate_no-exec)]
    22292307            && ![catch {set ilist [registry::installed $portname $composite_version]}]
    22302308            && [llength $ilist] == 1} {
     
    22372315        }
    22382316        if {![macports::global_option_isset ports_dryrun]} {
    2239             if { [catch {portimage::activate $portname $composite_version [array get options]} result] } {
     2317            if { [catch {portimage::activate_composite $portname $composite_version [array get options]} result] } {
    22402318                global errorInfo
    22412319                ui_debug "$errorInfo"
     
    22522330
    22532331proc action_deactivate { action portlist opts } {
    2254     global macports::registry.format
    22552332    set status 0
    22562333    if {[require_portlist portlist] || [prefix_unwritable]} {
     
    22592336    foreachport $portlist {
    22602337        set composite_version [composite_version $portversion [array get variations]]
    2261         if {${macports::registry.format} == "receipt_sqlite"
    2262             && ![info exists options(ports_deactivate_no-exec)]
     2338        if {![info exists options(ports_deactivate_no-exec)]
    22632339            && ![catch {set ilist [registry::active $portname]}]} {
    22642340
     
    22752351        }
    22762352        if {![macports::global_option_isset ports_dryrun]} {
    2277             if { [catch {portimage::deactivate $portname $composite_version [array get options]} result] } {
     2353            if { [catch {portimage::deactivate_composite $portname $composite_version [array get options]} result] } {
    22782354                global errorInfo
    22792355                ui_debug "$errorInfo"
     
    24132489
    24142490proc action_setrequested { action portlist opts } {
    2415     global macports::registry.format
    24162491    set status 0
    24172492    if {[require_portlist portlist] || [prefix_unwritable]} {
     
    24272502                set regref [registry::open_entry $portname [lindex $i 1] [lindex $i 2] [lindex $i 3] [lindex $i 5]]
    24282503                registry::property_store $regref requested $val
    2429                 if {${macports::registry.format} != "receipt_sqlite"} {
    2430                     registry::write_entry $regref
    2431                 }
    24322504            }
    24332505        } else {
     
    26562728           
    26572729            set json [json_encode_stats ${macports::stats_id} os ports]
    2658             curl post "data=$json" ${macports::stats_url} 
     2730            curl post "submit\[data\]=$json" ${macports::stats_url} 
    26592731        }
    26602732        default {
     
    29973069
    29983070proc action_uninstall { action portlist opts } {
    2999     global macports::registry.format
    30003071    set status 0
    30013072    if {[macports::global_option_isset port_uninstall_old]} {
     
    30193090        }
    30203091        set composite_version [composite_version $portversion [array get variations]]
    3021         if {${macports::registry.format} == "receipt_sqlite"
    3022             && ![info exists options(ports_uninstall_no-exec)]
     3092        if {![info exists options(ports_uninstall_no-exec)]
    30233093            && ![catch {set ilist [registry::installed $portname $composite_version]}]
    30243094            && [llength $ilist] == 1} {
     
    30323102        }
    30333103
    3034         if { [catch {registry_uninstall::uninstall $portname $composite_version [array get options]} result] } {
     3104        if { [catch {registry_uninstall::uninstall_composite $portname $composite_version [array get options]} result] } {
    30353105            global errorInfo
    30363106            ui_debug "$errorInfo"
     
    32563326
    32573327proc action_contents { action portlist opts } {
    3258     set status 0
     3328    global global_options
    32593329    if {[require_portlist portlist]} {
    32603330        return 1
    32613331    }
     3332    if {[info exists global_options(ports_contents_size)]} {
     3333        set units {}
     3334        if {[info exists global_options(ports_contents_units)]} {
     3335            set units [complete_size_units $global_options(ports_contents_units)]
     3336        }
     3337        set outstring {[format "%12s $file" [filesize $file $units]]}
     3338    } else {
     3339        set outstring {  $file}
     3340    }
     3341
    32623342    foreachport $portlist {
    32633343        if { ![catch {set ilist [registry::installed $portname]} result] } {
     
    32703350                ui_notice "Port $portname contains:"
    32713351                foreach file $files {
    3272                     puts "  $file"
     3352                    puts [subst $outstring]
    32733353                }
    32743354            } else {
     
    32813361    registry::close_file_map
    32823362
    3283     return $status
     3363    return 0
     3364}
     3365
     3366# expand abbreviations of size units
     3367proc complete_size_units {units} {
     3368    if {$units == "K" || $units == "Ki"} {
     3369        return "KiB"
     3370    } elseif {$units == "k"} {
     3371        return "kB"
     3372    } elseif {$units == "Mi"} {
     3373        return "MiB"
     3374    } elseif {$units == "M"} {
     3375        return "MB"
     3376    } elseif {$units == "Gi"} {
     3377        return "GiB"
     3378    } elseif {$units == "G"} {
     3379        return "GB"
     3380    } else {
     3381        return $units
     3382    }
     3383}
     3384
     3385# Show space used by the given ports' files
     3386proc action_space {action portlist opts} {
     3387    global global_options
     3388    require_portlist portlist
     3389
     3390    set units {}
     3391    if {[info exists global_options(ports_space_units)]} {
     3392        set units [complete_size_units $global_options(ports_space_units)]
     3393    }
     3394    set spaceall 0.0
     3395    foreachport $portlist {
     3396        set space 0.0
     3397        set files [registry::port_registered $portname]
     3398        if { $files != 0 } {
     3399            if { [llength $files] > 0 } {
     3400                foreach file $files {
     3401                    catch {
     3402                        set space [expr $space + [file size $file] ]
     3403                    }
     3404                }
     3405                set msg "[bytesize $space $units] $portname"
     3406                if { $portversion != {} } {
     3407                    append msg " @$portversion"
     3408                }
     3409                puts $msg
     3410                set spaceall [expr $space + $spaceall]
     3411            } else {
     3412                puts "Port $portname does not contain any file or is not active."
     3413            }
     3414        } else {
     3415            puts "Port $portname is not installed."
     3416        }
     3417    }
     3418    if {[llength $portlist] > 1} {
     3419        puts "[bytesize $spaceall $units] total"
     3420    }
     3421    return 0
    32843422}
    32853423
     
    39774115    outdated    [list action_outdated       [ACTION_ARGS_PORTS]] \
    39784116    contents    [list action_contents       [ACTION_ARGS_PORTS]] \
     4117    space       [list action_space          [ACTION_ARGS_PORTS]] \
    39794118    dependents  [list action_dependents     [ACTION_ARGS_PORTS]] \
    39804119    rdependents [list action_dependents     [ACTION_ARGS_PORTS]] \
     
    40324171]
    40334172
     4173# Expand "action".
     4174# Returns an action proc, or a list of matching action procs, or the action passed in
     4175proc find_action { action } {
     4176    global action_array
     4177   
     4178    if { ! [info exists action_array($action)] } {
     4179        set guess [guess_action $action]
     4180        if { [info exists action_array($guess)] } {
     4181            return $guess
     4182        }
     4183        return $guess
     4184    }
     4185   
     4186    return $action
     4187}
     4188
     4189# Expand action
     4190# If there's more than one match, return the next possibility
    40344191proc find_action_proc { action } {
     4192    global action_array
     4193   
     4194    set action_proc ""
     4195    if { [info exists action_array($action)] } {
     4196        set action_proc [lindex $action_array($action) 0]
     4197    } else {
     4198        set action [complete_action $action]
     4199        if { [info exists action_array($action)] } {
     4200            set action_proc [lindex $action_array($action) 0]
     4201        }
     4202    }
     4203   
     4204    return $action_proc
     4205}
     4206
     4207proc get_action_proc { action } {
    40354208    global action_array
    40364209   
     
    40754248                 maintainer maintainers name platform platforms portdir pretty
    40764249                 replaced_by revision variant variants version}
     4250    contents    {size {units 1}}
    40774251    deps        {index no-build}
    40784252    rdeps       {index no-build full}
     
    40844258                 platforms portdir regex revision variant variants version}
    40854259    selfupdate  {nosync}
     4260    space       {{units 1}}
    40864261    activate    {no-exec}
    40874262    deactivate  {no-exec}
     
    43194494       
    43204495        # Find an action to execute
    4321         set action_proc [find_action_proc $action]
    4322         if { $action_proc == "" } {
    4323             puts "Unrecognized action \"$action\""
     4496        set actions [find_action $action]
     4497        if {[llength $actions] == 1} {
     4498            set action [lindex $actions 0]
     4499            set action_proc [get_action_proc $action]
     4500        } else {
     4501            if {[llength $actions] > 1} {
     4502                puts "Ambiguous action \"$action\": could be any of {$actions}."
     4503            } else {
     4504                puts "Unrecognized action \"$action\""
     4505            }
    43244506            set action_status 1
    43254507            break
     
    44114593
    44124594
     4595# return text action beginning with $text
    44134596proc complete_action { text state } {   
    44144597    global action_array
     
    44264609}
    44274610
     4611# return all actions beginning with $text
     4612proc guess_action { text } {   
     4613    global action_array
     4614
     4615    return [array names action_array "[string tolower $text]*"]
     4616
     4617    if { [llength $complete_choices ] == 1 } {
     4618        return [lindex $complete_choices 0]
     4619    }
     4620
     4621    return {}
     4622}
    44284623
    44294624proc attempt_completion { text word start end } {
  • branches/gsoc11-statistics/base/src/port/portindex.tcl

    r78062 r79672  
    260260             depends_lib depends_run description epoch homepage \
    261261             long_description maintainers name platforms revision variants \
    262              version portdir portarchive replaced_by license} {
     262             version portdir portarchive replaced_by license installs_libs} {
    263263    set keepkeys($key) 1
    264264}
  • branches/gsoc11-statistics/base/src/port1.0/fetch_common.tcl

    r69471 r79672  
    33#
    44# Copyright (c) 2002 - 2003 Apple Inc.
    5 # Copyright (c) 2004-2010 The MacPorts Project
     5# Copyright (c) 2004 - 2011 The MacPorts Project
    66# All rights reserved.
    77#
     
    242242
    243243        foreach site $urllist {
     244            if {[string range $site 0 6] == "file://"} {
     245                set pingtimes(localhost) 0
     246                continue
     247            }
     248           
    244249            regexp $hostregex $site -> host
    245 
     250           
    246251            if { [info exists seen($host)] } {
    247252                continue
     
    285290        set pinglist {}
    286291        foreach site $urllist {
    287             regexp $hostregex $site -> host
     292            if {[string range $site 0 6] == "file://"} {
     293                set host localhost
     294            } else {
     295                regexp $hostregex $site -> host
     296            }
    288297            lappend pinglist [ list $site $pingtimes($host) ]
    289298        }
  • branches/gsoc11-statistics/base/src/port1.0/port.tcl

    r64638 r79672  
    33# $Id$
    44#
    5 # Copyright (c) 2002 Apple Computer, Inc.
     5# Copyright (c) 2002 Apple Inc.
    66# All rights reserved.
    77#
     
    1414#    notice, this list of conditions and the following disclaimer in the
    1515#    documentation and/or other materials provided with the distribution.
    16 # 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
     16# 3. Neither the name of Apple Inc. nor the names of its contributors
    1717#    may be used to endorse or promote products derived from this software
    1818#    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/port1.0/port_autoconf.tcl.in

    r77749 r79672  
    22# $Id$
    33#
    4 # Copyright (c) 2002 - 2004 Apple Computer, Inc.
     4# Copyright (c) 2005 - 2011 The MacPorts Project
     5# Copyright (c) 2002 - 2004 Apple Inc.
    56# All rights reserved.
    67#
     
    1314#    notice, this list of conditions and the following disclaimer in the
    1415#    documentation and/or other materials provided with the distribution.
    15 # 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
     16# 3. Neither the name of Apple Inc. nor the names of its contributors
    1617#    may be used to endorse or promote products derived from this software
    1718#    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/port1.0/portactivate.tcl

    r78062 r79672  
    33# $Id$
    44#
    5 # Copyright (c) 2002 - 2003 Apple Computer, Inc.
     5# Copyright (c) 2005, 2007, 2009-2011 The MacPorts Project
    66# Copyright (c) 2004 Robert Shaw <rshaw@opendarwin.org>
     7# Copyright (c) 2002 - 2003 Apple Inc.
    78# All rights reserved.
    89#
     
    1516#    notice, this list of conditions and the following disclaimer in the
    1617#    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# 3. Neither the name of Apple Inc. nor the names of its contributors
    1819#    may be used to endorse or promote products derived from this software
    1920#    without specific prior written permission.
     
    6162    global env subport version revision portvariants user_options PortInfo
    6263
    63     registry_activate $subport "${version}_${revision}${portvariants}" [array get user_options]
     64    registry_activate $subport $version $revision $portvariants [array get user_options]
    6465
    6566    # Display notes at the end of the activation phase.
  • branches/gsoc11-statistics/base/src/port1.0/portbuild.tcl

    r78062 r79672  
    33# $Id$
    44#
    5 # Copyright (c) 2002 - 2003 Apple Computer, Inc.
     5# Copyright (c) 2007 - 2011 The MacPorts Project
     6# Copyright (c) 2002 - 2004 Apple Inc.
    67# All rights reserved.
    78#
     
    1415#    notice, this list of conditions and the following disclaimer in the
    1516#    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# 3. Neither the name of Apple Inc. nor the names of its contributors
    1718#    may be used to endorse or promote products derived from this software
    1819#    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/port1.0/portchecksum.tcl

    r78062 r79672  
    33# $Id$
    44#
    5 # Copyright (c) 2002 - 2004 Apple Computer, Inc.
     5# Copyright (c) 2002 - 2004 Apple Inc.
    66# Copyright (c) 2004 - 2005 Paul Guyot <pguyot@kallisys.net>
     7# Copyright (c) 2006-2011 The MacPorts Project
    78# All rights reserved.
    89#
     
    1516#    notice, this list of conditions and the following disclaimer in the
    1617#    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# 3. Neither the name of Apple Inc. nor the names of its contributors
    1819#    may be used to endorse or promote products derived from this software
    1920#    without specific prior written permission.
     
    5960
    6061# types to recommend if none are specified in the portfile
    61 set default_checksum_types {sha1 rmd160}
     62set default_checksum_types {rmd160 sha256}
    6263
    6364# Using global all_dist_files, parse the checksums and store them into the
     
    311312            ui_notice "The non-matching file appears to be HTML. See this page for possible reasons"
    312313            ui_notice "for the checksum mismatch:"
    313             ui_notice "<http://trac.macports.org/wiki/MisbehavingServers>"
     314            ui_notice "<https://trac.macports.org/wiki/MisbehavingServers>"
    314315            ui_notice "***"
    315316        }
  • branches/gsoc11-statistics/base/src/port1.0/portclean.tcl

    r78179 r79672  
    33# $Id$
    44#
     5# Copyright (c) 2005-2007, 2009-2011 The MacPorts Project
    56# Copyright (c) 2004 Robert Shaw <rshaw@opendarwin.org>
    6 # Copyright (c) 2002 - 2003 Apple Computer, Inc.
     7# Copyright (c) 2002 - 2003 Apple Inc.
    78# All rights reserved.
    89#
     
    1516#    notice, this list of conditions and the following disclaimer in the
    1617#    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# 3. Neither the name of Apple Inc. nor the names of its contributors
    1819#    may be used to endorse or promote products derived from this software
    1920#    without specific prior written permission.
     
    5152
    5253proc portclean::clean_start {args} {
    53     global UI_PREFIX
     54    global UI_PREFIX prefix
    5455
    5556    ui_notice "$UI_PREFIX [format [msgcat::mc "Cleaning %s"] [option subport]]"
     57
     58    if {![file writable $prefix] || ([getuid] == 0 && [geteuid] != 0)} {
     59        elevateToRoot "clean"
     60    }
    5661}
    5762
  • branches/gsoc11-statistics/base/src/port1.0/portconfigure.tcl

    r78062 r79672  
    33# $Id$
    44#
    5 # Copyright (c) 2002 - 2003 Apple Computer, Inc.
     5# Copyright (c) 2007 - 2011 The MacPorts Project
    66# Copyright (c) 2007 Markus W. Weissmann <mww@macports.org>
     7# Copyright (c) 2002 - 2003 Apple Inc.
    78# All rights reserved.
    89#
     
    1516#    notice, this list of conditions and the following disclaimer in the
    1617#    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# 3. Neither the name of Apple Inc. nor the names of its contributors
    1819#    may be used to endorse or promote products derived from this software
    1920#    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/port1.0/portdeactivate.tcl

    r78062 r79672  
    33# $Id$
    44#
    5 # Copyright (c) 2010 The MacPorts Project
     5# Copyright (c) 2010-2011 The MacPorts Project
    66# All rights reserved.
    77#
     
    5959proc portdeactivate::deactivate_main {args} {
    6060    global subport version revision portvariants user_options
    61     registry_deactivate $subport "${version}_${revision}${portvariants}" [array get user_options]
     61    registry_deactivate $subport $version $revision $portvariants [array get user_options]
    6262    return 0
    6363}
  • branches/gsoc11-statistics/base/src/port1.0/portdepends.tcl

    r51780 r79672  
    33# $Id$
    44#
    5 # Copyright (c) 2002 - 2003 Apple Computer, Inc.
     5# Copyright (c) 2005, 2007-2009 The MacPorts Project
     6# Copyright (c) 2002 - 2003 Apple Inc.
    67# All rights reserved.
    78#
     
    1415#    notice, this list of conditions and the following disclaimer in the
    1516#    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# 3. Neither the name of Apple Inc. nor the names of its contributors
    1718#    may be used to endorse or promote products derived from this software
    1819#    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/port1.0/portdestroot.tcl

    r78062 r79672  
    33# $Id$
    44#
    5 # Copyright (c) 2002 - 2003 Apple Computer, Inc.
     5# Copyright (c) 2002 - 2003 Apple Inc.
    66# Copyright (c) 2004 - 2005 Robert Shaw <rshaw@opendarwin.org>
     7# Copyright (c) 2004-2005, 2007-2011 The MacPorts Project
    78# All rights reserved.
    89#
     
    1516#    notice, this list of conditions and the following disclaimer in the
    1617#    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# 3. Neither the name of Apple Inc. nor the names of its contributors
    1819#    may be used to endorse or promote products derived from this software
    1920#    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/port1.0/portdistcheck.tcl

    r78062 r79672  
    44# $Id$
    55#
     6# Copyright (c) 2007-2011 The MacPorts Project
    67# Copyright (c) 2005-2006 Paul Guyot <pguyot@kallisys.net>,
    78# All rights reserved.
     
    1617#    notice, this list of conditions and the following disclaimer in the
    1718#    documentation and/or other materials provided with the distribution.
    18 # 3. Neither the name of Apple Computer, Inc. nor the names of its
     19# 3. Neither the name of The MacPorts Project nor the names of its
    1920#    contributors may be used to endorse or promote products derived from
    2021#    this software without specific prior written permission.
  • branches/gsoc11-statistics/base/src/port1.0/portdistfiles.tcl

    r78062 r79672  
    33# $Id$
    44#
    5 # Copyright (c) 2008 MacPorts Project
     5# Copyright (c) 2008-2011 The MacPorts Project
    66# All rights reserved.
    77#
     
    1414#    notice, this list of conditions and the following disclaimer in the
    1515#    documentation and/or other materials provided with the distribution.
    16 # 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
     16# 3. Neither the name of The MacPorts Project nor the names of its contributors
    1717#    may be used to endorse or promote products derived from this software
    1818#    without specific prior written permission.
     
    5454
    5555proc portdistfiles::distfiles_main {args} {
    56     global UI_PREFIX master_sites checksums_array portdbpath dist_subdir
     56    global UI_PREFIX master_sites checksums_array portdbpath dist_subdir all_dist_files
    5757   
    5858    # give up on ports that do not provide URLs
     
    6464    set fetch_urls {}
    6565    portfetch::checkfiles fetch_urls
     66
     67    # also give up on ports that don't have any distfiles
     68    if {![info exists all_dist_files]} {
     69        return 0
     70    }
    6671
    6772    # get checksum data from the portfile and parse it
  • branches/gsoc11-statistics/base/src/port1.0/portextract.tcl

    r78660 r79672  
    33# $Id$
    44#
    5 # Copyright (c) 2002 - 2003 Apple Computer, Inc.
     5# Copyright (c) 2005, 2007-2011 The MacPorts Project
     6# Copyright (c) 2002 - 2003 Apple Inc.
    67# Copyright (c) 2007 Markus W. Weissmann <mww@macports.org>
    78# All rights reserved.
     
    1516#    notice, this list of conditions and the following disclaimer in the
    1617#    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# 3. Neither the name of Apple Inc. nor the names of its contributors
    1819#    may be used to endorse or promote products derived from this software
    1920#    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/port1.0/portfetch.tcl

    r78062 r79672  
    33# $Id$
    44#
    5 # Copyright (c) 2002 - 2003 Apple Computer, Inc.
     5# Copyright (c) 2004 - 2011 The MacPorts Project
     6# Copyright (c) 2002 - 2003 Apple Inc.
    67# All rights reserved.
    78#
     
    1415#    notice, this list of conditions and the following disclaimer in the
    1516#    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# 3. Neither the name of Apple Inc. nor the names of its contributors
    1718#    may be used to endorse or promote products derived from this software
    1819#    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/port1.0/portinstall.tcl

    r78660 r79672  
    33# $Id$
    44#
    5 # Copyright (c) 2002 - 2003 Apple Computer, Inc.
     5# Copyright (c) 2002 - 2004 Apple Inc.
    66# Copyright (c) 2004 Robert Shaw <rshaw@opendarwin.org>
     7# Copyright (c) 2005, 2007 - 2011 The MacPorts Project
    78# All rights reserved.
    89#
     
    1516#    notice, this list of conditions and the following disclaimer in the
    1617#    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# 3. Neither the name of Apple Inc. nor the names of its contributors
    1819#    may be used to endorse or promote products derived from this software
    1920#    without specific prior written permission.
     
    5556proc portinstall::install_start {args} {
    5657    global UI_PREFIX subport version revision portvariants
    57     global prefix registry_open registry.format registry.path
     58    global prefix registry_open registry.path
    5859    ui_notice "$UI_PREFIX [format [msgcat::mc "Installing %s @%s_%s%s"] $subport $version $revision $portvariants]"
    5960   
     
    6768    # end gsoc08-privileges
    6869   
    69     if {${registry.format} == "receipt_sqlite" && ![info exists registry_open]} {
     70    if {![info exists registry_open]} {
    7071        registry::open [file join ${registry.path} registry registry.db]
    7172        set registry_open yes
     
    484485    worksrcdir UI_PREFIX destroot revision maintainers user_options \
    485486    portvariants negated_variants targets depends_lib PortInfo epoch license \
    486     registry.format os.platform os.major portarchivetype installPlist
     487    os.platform os.major portarchivetype installPlist
    487488
    488489    set oldpwd [pwd]
     
    504505    }
    505506
    506     if {[string equal ${registry.format} "receipt_sqlite"]} {
    507         # registry2.0
    508 
    509         # can't do this inside the write transaction due to deadlock issues with _get_dep_port
    510         set dep_portnames [list]
    511         foreach deplist {depends_lib depends_run} {
    512             if {[info exists $deplist]} {
    513                 foreach dep [set $deplist] {
    514                     set dep_portname [_get_dep_port $dep]
    515                     if {$dep_portname != ""} {
    516                         lappend dep_portnames $dep_portname
    517                     }
     507    # can't do this inside the write transaction due to deadlock issues with _get_dep_port
     508    set dep_portnames [list]
     509    foreach deplist {depends_lib depends_run} {
     510        if {[info exists $deplist]} {
     511            foreach dep [set $deplist] {
     512                set dep_portname [_get_dep_port $dep]
     513                if {$dep_portname != ""} {
     514                    lappend dep_portnames $dep_portname
    518515                }
    519516            }
    520517        }
    521 
    522         registry::write {
    523 
    524             set regref [registry::entry create $subport $version $revision $portvariants $epoch]
    525 
    526             if {[info exists user_options(ports_requested)]} {
    527                 $regref requested $user_options(ports_requested)
    528             } else {
    529                 $regref requested 0
    530             }
    531             $regref os_platform ${os.platform}
    532             $regref os_major ${os.major}
    533             $regref archs [get_canonical_archs]
    534             # Trick to have a portable GMT-POSIX epoch-based time.
    535             $regref date [expr [clock scan now -gmt true] - [clock scan "1970-1-1 00:00:00" -gmt true]]
    536             if {[info exists negated_variants]} {
    537                 $regref negated_variants $negated_variants
    538             }
    539 
    540             foreach dep_portname $dep_portnames {
    541                 $regref depends $dep_portname
    542             }
    543 
    544             $regref installtype image
    545             $regref state imaged
    546             $regref location $location
    547 
    548             if {[info exists installPlist]} {
    549                 # register files
    550                 $regref map $installPlist
    551             }
    552            
    553             # store portfile
    554             set fd [open [file join ${portpath} Portfile]]
    555             $regref portfile [read $fd]
    556             close $fd
    557         }
    558     } else {
    559         # Begin the registry entry
    560         set regref [registry_new $subport $version $revision $portvariants $epoch]
     518    }
     519
     520    registry::write {
     521
     522        set regref [registry::entry create $subport $version $revision $portvariants $epoch]
     523
     524        if {[info exists user_options(ports_requested)]} {
     525            $regref requested $user_options(ports_requested)
     526        } else {
     527            $regref requested 0
     528        }
     529        $regref os_platform ${os.platform}
     530        $regref os_major ${os.major}
     531        $regref archs [get_canonical_archs]
     532        # Trick to have a portable GMT-POSIX epoch-based time.
     533        $regref date [expr [clock scan now -gmt true] - [clock scan "1970-1-1 00:00:00" -gmt true]]
    561534        if {[info exists negated_variants]} {
    562             registry_prop_store $regref negated_variants $negated_variants
    563         }
    564 
    565         registry_prop_store $regref location $location
    566 
    567         if {[info exists user_options(ports_requested)]} {
    568             registry_prop_store $regref requested $user_options(ports_requested)
    569         } else {
    570             registry_prop_store $regref requested 0
    571         }
    572         registry_prop_store $regref categories $categories
    573 
    574         registry_prop_store $regref os_platform ${os.platform}
    575         registry_prop_store $regref os_major ${os.major}
    576         registry_prop_store $regref archs [get_canonical_archs]
    577 
    578         if {[info exists description]} {
    579             registry_prop_store $regref description [string map {\n \\n} ${description}]
    580         }
    581         if {[info exists long_description]} {
    582             registry_prop_store $regref long_description [string map {\n \\n} ${long_description}]
    583         }
    584         if {[info exists license]} {
    585             registry_prop_store $regref license ${license}
    586         }
    587         if {[info exists homepage]} {
    588             registry_prop_store $regref homepage ${homepage}
    589         }
    590         if {[info exists maintainers]} {
    591             registry_prop_store $regref maintainers ${maintainers}
    592         }
    593         if {[info exists depends_run]} {
    594             registry_prop_store $regref depends_run $depends_run
    595             registry_register_deps $depends_run $subport
    596         }
    597         if {[info exists depends_lib]} {
    598             registry_prop_store $regref depends_lib $depends_lib
    599             registry_register_deps $depends_lib $subport
    600         }
     535            $regref negated_variants $negated_variants
     536        }
     537
     538        foreach dep_portname $dep_portnames {
     539            $regref depends $dep_portname
     540        }
     541
     542        $regref installtype image
     543        $regref state imaged
     544        $regref location $location
     545
    601546        if {[info exists installPlist]} {
    602             registry_prop_store $regref contents [_fake_fileinfo_for_index $installPlist]
    603         }
    604         if {[info exists package-install]} {
    605             registry_prop_store $regref package-install ${package-install}
    606         }
    607         if {[info proc pkg_uninstall] == "pkg_uninstall"} {
    608             registry_prop_store $regref pkg_uninstall [proc_disasm pkg_uninstall]
    609         }
    610 
    611         registry_write $regref
     547            # register files
     548            $regref map $installPlist
     549        }
     550       
     551        # store portfile
     552        set fd [open [file join ${portpath} Portfile]]
     553        $regref portfile [read $fd]
     554        close $fd
    612555    }
    613556
  • branches/gsoc11-statistics/base/src/port1.0/portlivecheck.tcl

    r78071 r79672  
    44# $Id$
    55#
    6 # Copyright (c) 2005-2006 Paul Guyot <pguyot@kallisys.net>,
     6# Copyright (c) 2007-2011 The MacPorts Project
     7# Copyright (c) 2005-2007 Paul Guyot <pguyot@kallisys.net>,
    78# All rights reserved.
    89#
     
    1617#    notice, this list of conditions and the following disclaimer in the
    1718#    documentation and/or other materials provided with the distribution.
    18 # 3. Neither the name of Apple Computer, Inc. nor the names of its
     19# 3. Neither the name of The MacPorts Project nor the names of its
    1920#    contributors may be used to endorse or promote products derived from
    2021#    this software without specific prior written permission.
  • branches/gsoc11-statistics/base/src/port1.0/portload.tcl

    r75534 r79672  
    33# $Id$
    44#
    5 # Copyright (c) 2007 MacPorts Project
     5# Copyright (c) 2007, 2009, 2011 The MacPorts Project
    66# Copyright (c) 2007 James D. Berry
    77# All rights reserved.
     
    1515#    notice, this list of conditions and the following disclaimer in the
    1616#    documentation and/or other materials provided with the distribution.
    17 # 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
     17# 3. Neither the name of The MacPorts Project nor the names of its contributors
    1818#    may be used to endorse or promote products derived from this software
    1919#    without specific prior written permission.
     
    3737set org.macports.load [target_new org.macports.load portload::load_main]
    3838target_runtype ${org.macports.load} always
     39target_state ${org.macports.load} no
    3940target_provides ${org.macports.load} load
    4041target_requires ${org.macports.load} main
  • branches/gsoc11-statistics/base/src/port1.0/portmain.tcl

    r78660 r79672  
    33# $Id$
    44#
    5 # Copyright (c) 2002 - 2003 Apple Computer, Inc.
     5# Copyright (c) 2004 - 2005, 2007 - 2011 The MacPorts Project
     6# Copyright (c) 2002 - 2003 Apple Inc.
    67# All rights reserved.
    78#
     
    1415#    notice, this list of conditions and the following disclaimer in the
    1516#    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# 3. Neither the name of Apple Inc. nor the names of its contributors
    1718#    may be used to endorse or promote products derived from this software
    1819#    without specific prior written permission.
     
    5253        platforms default_variants install.user install.group \
    5354        macosx_deployment_target universal_variant os.universal_supported \
    54         supported_archs depends_skip_archcheck \
     55        supported_archs depends_skip_archcheck installs_libs \
    5556        copy_log_files \
    5657        compiler.cpath compiler.library_path \
     
    6566
    6667# Export options via PortInfo
    67 options_export name version revision epoch categories maintainers platforms description long_description notes homepage license provides conflicts replaced_by
     68options_export name version revision epoch categories maintainers platforms description long_description notes homepage license provides conflicts replaced_by installs_libs
    6869
    6970default subport {[portmain::get_default_subport]}
  • branches/gsoc11-statistics/base/src/port1.0/portmirror.tcl

    r78062 r79672  
    44# $Id$
    55#
     6# Copyright (c) 2007-2011 The MacPorts Project
    67# Copyright (c) 2006 Paul Guyot <pguyot@kallisys.net>,
    78# All rights reserved.
     
    1617#    notice, this list of conditions and the following disclaimer in the
    1718#    documentation and/or other materials provided with the distribution.
    18 # 3. Neither the name of Apple Computer, Inc. nor the names of its
     19# 3. Neither the name of The MacPorts Project nor the names of its
    1920#    contributors may be used to endorse or promote products derived from
    2021#    this software without specific prior written permission.
  • branches/gsoc11-statistics/base/src/port1.0/portpatch.tcl

    r78062 r79672  
    33# $Id$
    44#
    5 # Copyright (c) 2002 - 2003 Apple Computer, Inc.
     5# Copyright (c) 2004, 2006-2007, 2009-2011 The MacPorts Project
     6# Copyright (c) 2002 - 2003 Apple Inc.
    67# All rights reserved.
    78#
     
    1415#    notice, this list of conditions and the following disclaimer in the
    1516#    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# 3. Neither the name of Apple Inc. nor the names of its contributors
    1718#    may be used to endorse or promote products derived from this software
    1819#    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/port1.0/portstartupitem.tcl

    r78062 r79672  
    44# $Id$
    55#
    6 # Copyright (c) 2004-2007 MacPorts Project
     6# Copyright (c) 2004-2011 The MacPorts Project
    77# Copyright (c) 2006-2007 James D. Berry
    88# Copyright (c) 2004,2005 Markus W. Weissman <mww@macports.org>
     
    1818#    notice, this list of conditions and the following disclaimer in the
    1919#    documentation and/or other materials provided with the distribution.
    20 # 3. Neither the name of Apple Computer, Inc. nor the names of its
     20# 3. Neither the name of The MacPorts Project nor the names of its
    2121#    contributors may be used to endorse or promote products derived from
    2222#    this software without specific prior written permission.
  • branches/gsoc11-statistics/base/src/port1.0/portsubmit.tcl

    r78174 r79672  
    33# $Id$
    44#
    5 # Copyright (c) 2002 - 2004 Apple Computer, Inc.
     5# Copyright (c) 2007 - 2011 The MacPorts Project
     6# Copyright (c) 2002 - 2004 Apple Inc.
    67# All rights reserved.
    78#
     
    1415#    notice, this list of conditions and the following disclaimer in the
    1516#    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# 3. Neither the name of Apple Inc. nor the names of its contributors
    1718#    may be used to endorse or promote products derived from this software
    1819#    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/port1.0/porttrace.tcl

    r70001 r79672  
    1616#    notice, this list of conditions and the following disclaimer in the
    1717#    documentation and/or other materials provided with the distribution.
    18 # 3. Neither the name of Apple Computer, Inc. nor the names of its
     18# 3. Neither the name of The MacPorts Project nor the names of its
    1919#    contributors may be used to endorse or promote products derived from
    2020#    this software without specific prior written permission.
  • branches/gsoc11-statistics/base/src/port1.0/portuninstall.tcl

    r78062 r79672  
    33# $Id$
    44#
    5 # Copyright (c) 2010 The MacPorts Project
     5# Copyright (c) 2010-2011 The MacPorts Project
    66# All rights reserved.
    77#
     
    5151proc portuninstall::uninstall_start {args} {
    5252    global prefix
    53     if { ![file writable $prefix] } {
     53    if {![file writable $prefix] || ([getuid] == 0 && [geteuid] != 0)} {
    5454        # if install location is not writable, need root privileges
    5555        elevateToRoot "uninstall"
     
    5959proc portuninstall::uninstall_main {args} {
    6060    global subport version revision portvariants user_options
    61     registry_uninstall $subport "${version}_${revision}${portvariants}" [array get user_options]
     61    registry_uninstall $subport $version $revision $portvariants [array get user_options]
    6262    return 0
    6363}
  • branches/gsoc11-statistics/base/src/port1.0/portunload.tcl

    r75534 r79672  
    33# $Id$
    44#
    5 # Copyright (c) 2007 MacPorts Project
     5# Copyright (c) 2007, 2009, 2011 The MacPorts Project
    66# Copyright (c) 2007 James D. Berry
    77# All rights reserved.
     
    1515#    notice, this list of conditions and the following disclaimer in the
    1616#    documentation and/or other materials provided with the distribution.
    17 # 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
     17# 3. Neither the name of The MacPorts Project nor the names of its contributors
    1818#    may be used to endorse or promote products derived from this software
    1919#    without specific prior written permission.
     
    3737set org.macports.unload [target_new org.macports.unload portunload::unload_main]
    3838target_runtype ${org.macports.unload} always
     39target_state ${org.macports.unload} no
    3940target_provides ${org.macports.unload} unload
    4041target_requires ${org.macports.unload} main
  • branches/gsoc11-statistics/base/src/port1.0/portutil.tcl

    r78660 r79672  
    33# $Id$
    44#
     5# Copyright (c) 2002-2003 Apple Inc.
    56# Copyright (c) 2004 Robert Shaw <rshaw@opendarwin.org>
    6 # Copyright (c) 2002 Apple Computer, Inc.
    7 # Copyright (c) 2006, 2007 Markus W. Weissmann <mww@macports.org>
     7# Copyright (c) 2006-2007 Markus W. Weissmann <mww@macports.org>
     8# Copyright (c) 2004-2011 The MacPorts Project
    89# All rights reserved.
    910#
     
    1617#    notice, this list of conditions and the following disclaimer in the
    1718#    documentation and/or other materials provided with the distribution.
    18 # 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
     19# 3. Neither the name of Apple Inc. nor the names of its contributors
    1920#    may be used to endorse or promote products derived from this software
    2021#    without specific prior written permission.
     
    12741275            # otherwise execute the task.
    12751276            if {$skipped == 0} {
    1276                 set target [ditem_key $ditem provides]
     1277                # change current phase shown in log
     1278                set_phase $target
    12771279
    12781280                # Execute pre-run procedure
     
    12801282                    set result [catch {[ditem_key $ditem prerun] $targetname} errstr]
    12811283                }
    1282                 set_phase  $target
     1284
    12831285                #start tracelib
    12841286                if {($result ==0
     
    15771579            return -code error "$statefile is not writable - check permission on port directory"
    15781580        }
    1579         if {[file mtime ${portpath}/Portfile] >= [clock seconds]} {
     1581        if {[file mtime ${portpath}/Portfile] > [clock seconds]} {
    15801582            return -code error "Portfile is from the future - check date and time of your system"
    15811583        }
     
    26722674                set min 3.2
    26732675                set ok 3.2
    2674                 set rec 3.2.4
     2676                set rec 3.2.6
    26752677            }
    26762678        }
     
    26902692proc _archive_available {} {
    26912693    global subport version revision portvariants ports_source_only workpath \
    2692            registry.path os.platform os.major
     2694           registry.path os.platform os.major porturl
    26932695
    26942696    if {[tbool ports_source_only]} {
     
    27042706        }
    27052707    }
    2706    
    2707     # TODO: also check if porturl points to an archive
    2708     # maybe check if there's an archive available on the server too - this
    2709     # is kind of useless otherwise now that archive == installed image
     2708
     2709    if {!$found && [file rootname [file tail $porturl]] == [file rootname [file tail [get_portimage_path]]] && [file extension $porturl] != ""} {
     2710        set found 1
     2711    }
     2712
     2713    # TODO: maybe check if there's an archive available on the server - this
     2714    # is much less useful otherwise now that archive == installed image
    27102715
    27112716    return $found
  • branches/gsoc11-statistics/base/src/portindex/portregister.pl

    r19376 r79672  
    11#!/usr/bin/perl -w
    22#
    3 # Copyright (c) 2003-2004 Apple Computer, Inc.
     3# Copyright (c) 2003-2004 Apple Inc.
    44# All rights reserved.
    55#
     
    1212#    notice, this list of conditions and the following disclaimer in the
    1313#    documentation and/or other materials provided with the distribution.
    14 # 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
     14# 3. Neither the name of Apple Inc. nor the names of its contributors
    1515#    may be used to endorse or promote products derived from this software
    1616#    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/portindex/portsubmit.pl

    r19376 r79672  
    11#!/usr/bin/perl -w
    22#
    3 # Copyright (c) 2003-2004 Apple Computer, Inc.
     3# Copyright (c) 2003-2004 Apple Inc.
    44# All rights reserved.
    55#
     
    1212#    notice, this list of conditions and the following disclaimer in the
    1313#    documentation and/or other materials provided with the distribution.
    14 # 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
     14# 3. Neither the name of Apple Inc. nor the names of its contributors
    1515#    may be used to endorse or promote products derived from this software
    1616#    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/registry2.0/portimage.tcl

    r78180 r79672  
    33# $Id$
    44#
     5# Copyright (c) 2004-2005, 2007-2011 The MacPorts Project
    56# Copyright (c) 2004 Will Barton <wbb4@opendarwin.org>
    67# Copyright (c) 2002 Apple Inc.
     
    6263
    6364variable force 0
    64 variable use_reg2 0
    6565variable noexec 0
    6666
     67# takes a composite version spec rather than separate version,revision,variants
     68proc activate_composite {name {v ""} {optionslist ""}} {
     69    if {$v == ""} {
     70        return [activate $name "" "" 0 $optionslist]
     71    } elseif {[registry::decode_spec $v version revision variants]} {
     72        return [activate $name $version $revision $variants $optionslist]
     73    }
     74    throw registry::invalid "Registry error: Invalid version '$v' specified for ${name}. Please specify a version as recorded in the port registry."
     75}
     76
    6777# Activate a "Port Image"
    68 proc activate {name v optionslist} {
    69     global macports::prefix macports::registry.format macports::registry.path registry_open UI_PREFIX
     78proc activate {name {version ""} {revision ""} {variants 0} {optionslist ""}} {
     79    global macports::prefix macports::registry.path registry_open UI_PREFIX
    7080    array set options $optionslist
    7181    variable force
    72     variable use_reg2
    7382    variable noexec
    7483
     
    7988        set noexec $options(ports_activate_no-exec)
    8089    }
    81     if {[string equal ${macports::registry.format} "receipt_sqlite"]} {
    82         set use_reg2 1
    83         if {![info exists registry_open]} {
    84             registry::open [file join ${macports::registry.path} registry registry.db]
    85             set registry_open yes
    86         }
     90    if {![info exists registry_open]} {
     91        registry::open [file join ${macports::registry.path} registry registry.db]
     92        set registry_open yes
    8793    }
    8894    set todeactivate [list]
    8995
    90     if {$use_reg2} {
    91         registry::read {
    92 
    93             set requested [_check_registry $name $v]
    94             # set name again since the one we were passed may not have had the correct case
    95             set name [$requested name]
    96             set version [$requested version]
    97             set revision [$requested revision]
    98             set variants [$requested variants]
    99             set specifier "${version}_${revision}${variants}"
    100             set location [$requested location]
    101 
    102             # if another version of this port is active, deactivate it first
    103             set current [registry::entry installed $name]
    104             foreach i $current {
    105                 if { ![string equal $specifier "[$i version]_[$i revision][$i variants]"] } {
    106                     lappend todeactivate $i
    107                 }
    108             }
    109 
    110             # this shouldn't be possible
    111             if { ![string equal [$requested installtype] "image"] } {
    112                 return -code error "Image error: ${name} @${version}_${revision}${variants} not installed as an image."
    113             }
    114             if {![file isfile $location]} {
    115                 return -code error "Image error: Can't find image file $location"
    116             }
    117             if { [string equal [$requested state] "installed"] } {
    118                 return -code error "Image error: ${name} @${version}_${revision}${variants} is already active."
    119             }
    120         }
    121         foreach a $todeactivate {
    122             if {$noexec || ![registry::run_target $a deactivate [list ports_nodepcheck 1]]} {
    123                 deactivate $name "[$a version]_[$a revision][$a variants]" [list ports_nodepcheck 1]
    124             }
    125         }
    126     } else {
    127         # registry1.0
    128         set ilist [_check_registry $name $v]
     96    registry::read {
     97
     98        set requested [_check_registry $name $version $revision $variants]
    12999        # set name again since the one we were passed may not have had the correct case
    130         set name [lindex $ilist 0]
    131         set version [lindex $ilist 1]
    132         set revision [lindex $ilist 2]
    133         set variants [lindex $ilist 3]
     100        set name [$requested name]
     101        set version [$requested version]
     102        set revision [$requested revision]
     103        set variants [$requested variants]
     104        set specifier "${version}_${revision}${variants}"
     105        set location [$requested location]
    134106
    135107        # if another version of this port is active, deactivate it first
    136         set ilist [registry::installed $name]
    137         if { [llength $ilist] > 1 } {
    138             foreach i $ilist {
    139                 set iversion [lindex $i 1]
    140                 set irevision [lindex $i 2]
    141                 set ivariants [lindex $i 3]
    142                 set iactive [lindex $i 4]
    143                 if { ![string equal "${iversion}_${irevision}${ivariants}" "${version}_${revision}${variants}"] && $iactive == 1 } {
    144                     lappend todeactivate "${iversion}_${irevision}${ivariants}"
    145                 }
    146             }
    147         }
    148 
    149         set ref [registry::open_entry $name $version $revision $variants]
    150 
    151         if { ![string equal [registry::property_retrieve $ref installtype] "image"] } {
    152             return -code error "Image error: ${name} @${version}_${revision}${variants} not installed as an image."
    153         }
    154         set location [registry::property_retrieve $ref location]
     108        set current [registry::entry installed $name]
     109        foreach i $current {
     110            if { ![string equal $specifier "[$i version]_[$i revision][$i variants]"] } {
     111                lappend todeactivate $i
     112            }
     113        }
     114
     115        # this shouldn't be possible
     116        if { ![string equal [$requested installtype] "image"] } {
     117            return -code error "Image error: ${name} @${specifier} not installed as an image."
     118        }
    155119        if {![file isfile $location]} {
    156120            return -code error "Image error: Can't find image file $location"
    157121        }
    158         if { [registry::property_retrieve $ref active] != 0 } {
    159             return -code error "Image error: ${name} @${version}_${revision}${variants} is already active."
    160         }
    161 
    162         foreach a $todeactivate {
    163             deactivate $name $a [list ports_nodepcheck 1]
    164         }
    165     }
    166 
    167     if {$v != ""} {
    168         ui_msg "$UI_PREFIX [format [msgcat::mc "Activating %s @%s"] $name $v]"
    169     } else {
    170         ui_msg "$UI_PREFIX [format [msgcat::mc "Activating %s"] $name]"
    171     }
    172 
    173     if {$use_reg2} {
    174         _activate_contents $requested
    175         $requested state installed
    176     } else {
    177         set contents [registry::property_retrieve $ref contents]
    178 
    179         set imagefiles {}
    180         foreach content_element $contents {
    181             lappend imagefiles [lindex $content_element 0]
    182         }
    183 
    184         registry::open_file_map
    185         _activate_contents $name $imagefiles $location
    186 
    187         registry::property_store $ref active 1
    188 
    189         registry::write_entry $ref
    190 
    191         foreach file $imagefiles {
    192             registry::register_file $file $name
    193         }
    194         registry::write_file_map
    195         registry::close_file_map
    196     }
    197 }
    198 
    199 proc deactivate {name v optionslist} {
    200     global UI_PREFIX macports::registry.format macports::registry.path registry_open
     122        if { [string equal [$requested state] "installed"] } {
     123            return -code error "Image error: ${name} @${specifier} is already active."
     124        }
     125    }
     126    foreach a $todeactivate {
     127        if {$noexec || ![registry::run_target $a deactivate [list ports_nodepcheck 1]]} {
     128            deactivate $name [$a version] [$a revision] [$a variants] [list ports_nodepcheck 1]
     129        }
     130    }
     131
     132    ui_msg "$UI_PREFIX [format [msgcat::mc "Activating %s @%s"] $name $specifier]"
     133
     134    _activate_contents $requested
     135    $requested state installed
     136}
     137
     138# takes a composite version spec rather than separate version,revision,variants
     139proc deactivate_composite {name {v ""} {optionslist ""}} {
     140    if {$v == ""} {
     141        return [deactivate $name "" "" 0 $optionslist]
     142    } elseif {[registry::decode_spec $v version revision variants]} {
     143        return [deactivate $name $version $revision $variants $optionslist]
     144    }
     145    throw registry::invalid "Registry error: Invalid version '$v' specified for ${name}. Please specify a version as recorded in the port registry."
     146}
     147
     148proc deactivate {name {version ""} {revision ""} {variants 0} {optionslist ""}} {
     149    global UI_PREFIX macports::registry.path registry_open
    201150    array set options $optionslist
    202     variable use_reg2
    203151
    204152    if {[info exists options(ports_force)] && [string is true -strict $options(ports_force)] } {
     
    210158        set force 0
    211159    }
    212     if {[string equal ${macports::registry.format} "receipt_sqlite"]} {
    213         set use_reg2 1
    214         if {![info exists registry_open]} {
    215             registry::open [file join ${macports::registry.path} registry registry.db]
    216             set registry_open yes
    217         }
    218     }
    219 
    220     if {$use_reg2} {
    221         if { [string equal $name ""] } {
    222             throw registry::image-error "Registry error: Please specify the name of the port."
    223         }
    224         set ilist [registry::entry installed $name]
    225         if { [llength $ilist] == 1 } {
    226             set requested [lindex $ilist 0]
    227         } else {
    228             throw registry::image-error "Image error: port ${name} is not active."
    229         }
    230         # set name again since the one we were passed may not have had the correct case
    231         set name [$requested name]
    232         set version [$requested version]
    233         set revision [$requested revision]
    234         set variants [$requested variants]
    235         set specifier "${version}_${revision}${variants}"
     160    if {![info exists registry_open]} {
     161        registry::open [file join ${macports::registry.path} registry registry.db]
     162        set registry_open yes
     163    }
     164
     165    if { [string equal $name ""] } {
     166        throw registry::image-error "Registry error: Please specify the name of the port."
     167    }
     168    set ilist [registry::entry installed $name]
     169    if { [llength $ilist] == 1 } {
     170        set requested [lindex $ilist 0]
    236171    } else {
    237         set ilist [registry::active $name]
    238         if { [llength $ilist] > 1 } {
    239             return -code error "Registry error: Please specify the name of the port."
    240         } else {
    241             set ilist [lindex $ilist 0]
    242         }
    243         # set name again since the one we were passed may not have had the correct case
    244         set name [lindex $ilist 0]
    245         set version [lindex $ilist 1]
    246         set revision [lindex $ilist 2]
    247         set variants [lindex $ilist 3]
    248         set specifier "${version}_${revision}${variants}"
    249     }
    250 
    251     if { $v != "" && ![string equal $specifier $v] } {
     172        throw registry::image-error "Image error: port ${name} is not active."
     173    }
     174    # set name again since the one we were passed may not have had the correct case
     175    set name [$requested name]
     176    set specifier "[$requested version]_[$requested revision][$requested variants]"
     177
     178    if {$version != "" && ($version != [$requested version] ||
     179        ($revision != "" && ($revision != [$requested revision] || $variants != [$requested variants])))} {
     180        set v $version
     181        if {$revision != ""} {
     182            append v _${revision}${variants}
     183        }
    252184        return -code error "Active version of $name is not $v but ${specifier}."
    253185    }
    254186
    255     if {$v != ""} {
    256         ui_msg "$UI_PREFIX [format [msgcat::mc "Deactivating %s @%s"] $name $v]"
    257     } else {
    258         ui_msg "$UI_PREFIX [format [msgcat::mc "Deactivating %s"] $name]"
    259     }
    260 
    261     if {$use_reg2} {
    262         if { ![string equal [$requested installtype] "image"] } {
    263             return -code error "Image error: ${name} @${specifier} not installed as an image."
    264         }
    265         # this shouldn't be possible
    266         if { [$requested state] != "installed" } {
    267             return -code error "Image error: ${name} @${specifier} is not active."
    268         }
    269 
    270         if {![info exists options(ports_nodepcheck)] || ![string is true -strict $options(ports_nodepcheck)]} {
    271             registry::check_dependents $requested $force "deactivate"
    272         }
    273 
    274         _deactivate_contents $requested [$requested files] $force
    275         $requested state imaged
    276     } else {
    277         set ref [registry::open_entry $name $version $revision $variants]
    278 
    279         if { ![string equal [registry::property_retrieve $ref installtype] "image"] } {
    280             return -code error "Image error: ${name} @${specifier} not installed as an image."
    281         }
    282         if { [registry::property_retrieve $ref active] != 1 } {
    283             return -code error "Image error: ${name} @${specifier} is not active."
    284         }
    285 
    286         registry::open_file_map
    287         set imagefiles [registry::port_registered $name]
    288 
    289         _deactivate_contents $name $imagefiles
    290 
    291         foreach file $imagefiles {
    292             registry::unregister_file $file
    293         }
    294         registry::write_file_map
    295         registry::close_file_map
    296 
    297         registry::property_store $ref active 0
    298 
    299         registry::write_entry $ref
    300     }
    301 }
    302 
    303 proc _check_registry {name v} {
     187    ui_msg "$UI_PREFIX [format [msgcat::mc "Deactivating %s @%s"] $name $specifier]"
     188
     189    if { ![string equal [$requested installtype] "image"] } {
     190        return -code error "Image error: ${name} @${specifier} not installed as an image."
     191    }
     192    # this shouldn't be possible
     193    if { [$requested state] != "installed" } {
     194        return -code error "Image error: ${name} @${specifier} is not active."
     195    }
     196
     197    if {![info exists options(ports_nodepcheck)] || ![string is true -strict $options(ports_nodepcheck)]} {
     198        registry::check_dependents $requested $force "deactivate"
     199    }
     200
     201    _deactivate_contents $requested [$requested files] $force
     202    $requested state imaged
     203}
     204
     205proc _check_registry {name version revision variants} {
    304206    global UI_PREFIX
    305     variable use_reg2
    306 
    307     if {$use_reg2} {
    308         if { [registry::decode_spec $v version revision variants] } {
    309             set ilist [registry::entry imaged $name $version $revision $variants]
    310             set valid 1
    311         } else {
    312             set valid [string equal $v {}]
    313             set ilist [registry::entry imaged $name]
    314         }
    315 
    316         if { [llength $ilist] > 1 || (!$valid && [llength $ilist] == 1) } {
    317             ui_msg "$UI_PREFIX [msgcat::mc "The following versions of $name are currently installed:"]"
    318             foreach i $ilist {
    319                 set iname [$i name]
    320                 set iversion [$i version]
    321                 set irevision [$i revision]
    322                 set ivariants [$i variants]
    323                 if { [$i state] == "installed" } {
    324                     ui_msg "$UI_PREFIX [format [msgcat::mc "    %s @%s_%s%s (active)"] $iname $iversion $irevision $ivariants]"
    325                 } else {
    326                     ui_msg "$UI_PREFIX [format [msgcat::mc "    %s @%s_%s%s"] $iname $iversion $irevision $ivariants]"
    327                 }
    328             }
    329             if { $valid } {
    330                 throw registry::invalid "Registry error: Please specify the full version as recorded in the port registry."
     207
     208    set searchkeys $name
     209    set composite_spec ""
     210    if {$version != ""} {
     211        lappend searchkeys $version
     212        set composite_spec $version
     213        # restriction imposed by underlying registry API (see entry.c):
     214        # if a revision is specified, so must variants be
     215        if {$revision != ""} {
     216            lappend searchkeys $revision $variants
     217            append composite_spec _${revision}${variants}
     218        }
     219    }
     220    set ilist [eval registry::entry imaged $searchkeys]
     221
     222    if { [llength $ilist] > 1 } {
     223        ui_msg "$UI_PREFIX [msgcat::mc "The following versions of $name are currently installed:"]"
     224        foreach i $ilist {
     225            set iname [$i name]
     226            set iversion [$i version]
     227            set irevision [$i revision]
     228            set ivariants [$i variants]
     229            if { [$i state] == "installed" } {
     230                ui_msg "$UI_PREFIX [format [msgcat::mc "    %s @%s_%s%s (active)"] $iname $iversion $irevision $ivariants]"
    331231            } else {
    332                 throw registry::invalid "Registry error: Invalid version specified. Please specify a version as recorded in the port registry."
    333             }
    334         } elseif { [llength $ilist] == 1 } {
    335             return [lindex $ilist 0]
    336         }
    337         throw registry::invalid "Registry error: No port of $name installed."
    338     } else {
    339         # registry1.0
    340         set ilist [registry::installed $name $v]
    341         if { [string equal $v ""] && [llength $ilist] > 1 } {
    342             # set name again since the one we were passed may not have had the correct case
    343             set name [lindex [lindex $ilist 0] 0]
    344             ui_msg "$UI_PREFIX [msgcat::mc "The following versions of $name are currently installed:"]"
    345             foreach i $ilist {
    346                 set iname [lindex $i 0]
    347                 set iversion [lindex $i 1]
    348                 set irevision [lindex $i 2]
    349                 set ivariants [lindex $i 3]
    350                 set iactive [lindex $i 4]
    351                 if { $iactive == 0 } {
    352                     ui_msg "$UI_PREFIX [format [msgcat::mc "    %s @%s_%s%s"] $iname $iversion $irevision $ivariants]"
    353                 } elseif { $iactive == 1 } {
    354                     ui_msg "$UI_PREFIX [format [msgcat::mc "    %s @%s_%s%s (active)"] $iname $iversion $irevision $ivariants]"
    355                 }
    356             }
    357             return -code error "Registry error: Please specify the full version as recorded in the port registry."
    358         } elseif {[llength $ilist] == 1} {
    359             return [lindex $ilist 0]
    360         }
    361         return -code error "Registry error: No port of $name installed."
    362     }
     232                ui_msg "$UI_PREFIX [format [msgcat::mc "    %s @%s_%s%s"] $iname $iversion $irevision $ivariants]"
     233            }
     234        }
     235        throw registry::invalid "Registry error: Please specify the full version as recorded in the port registry."
     236    } elseif { [llength $ilist] == 1 } {
     237        return [lindex $ilist 0]
     238    }
     239    if {$composite_spec != ""} {
     240        set composite_spec " @${composite_spec}"
     241    }
     242    throw registry::invalid "Registry error: ${name}${composite_spec} is not installed."
    363243}
    364244
     
    382262                } else {
    383263                    # not root, so can't set owner/group
    384                     eval file attributes {$dstfile} -permissions [file attributes -permissions $srcfile]
     264                    eval file attributes {$dstfile} -permissions [file attributes $srcfile -permissions]
    385265                }
    386266                # set mtime on installed element
     
    535415proc _activate_contents {port {imagefiles {}} {location {}}} {
    536416    variable force
    537     variable use_reg2
    538417    variable noexec
    539418    global macports::prefix
     
    541420    set files [list]
    542421    set baksuffix .mp_[clock seconds]
    543     if {$use_reg2} {
    544         set location [$port location]
    545         set imagefiles [$port imagefiles]
    546     } else {
    547         set name $port
    548     }
     422    set location [$port location]
     423    set imagefiles [$port imagefiles]
    549424    set extracted_dir [extract_archive_to_tmpdir $location]
    550425
     
    557432    #  we remove the file from the file_map, take ownership of it, and
    558433    #  clobber it
    559     if {$use_reg2} {
    560         array set todeactivate {}
    561         try {
    562             registry::write {
    563                 foreach file $imagefiles {
    564                     set srcfile "${extracted_dir}${file}"
    565 
    566                     # To be able to install links, we test if we can lstat the file to
    567                     # figure out if the source file exists (file exists will return
    568                     # false for symlinks on files that do not exist)
    569                     if { [catch {file lstat $srcfile dummystatvar}] } {
    570                         throw registry::image-error "Image error: Source file $srcfile does not appear to exist (cannot lstat it).  Unable to activate port [$port name]."
     434    array set todeactivate {}
     435    try {
     436        registry::write {
     437            foreach file $imagefiles {
     438                set srcfile "${extracted_dir}${file}"
     439
     440                # To be able to install links, we test if we can lstat the file to
     441                # figure out if the source file exists (file exists will return
     442                # false for symlinks on files that do not exist)
     443                if { [catch {file lstat $srcfile dummystatvar}] } {
     444                    throw registry::image-error "Image error: Source file $srcfile does not appear to exist (cannot lstat it).  Unable to activate port [$port name]."
     445                }
     446
     447                set owner [registry::entry owner $file]
     448
     449                if {$owner != {} && $owner != $port} {
     450                    # deactivate conflicting port if it is replaced_by this one
     451                    set result [mportlookup [$owner name]]
     452                    array unset portinfo
     453                    array set portinfo [lindex $result 1]
     454                    if {[info exists portinfo(replaced_by)] && [lsearch -regexp $portinfo(replaced_by) "(?i)^[$port name]\$"] != -1} {
     455                        # we'll deactivate the owner later, but before activating our files
     456                        set todeactivate($owner) yes
     457                        set owner "replaced"
    571458                    }
    572 
    573                     set owner [registry::entry owner $file]
    574 
    575                     if {$owner != {} && $owner != $port} {
    576                         # deactivate conflicting port if it is replaced_by this one
    577                         set result [mportlookup [$owner name]]
    578                         array unset portinfo
    579                         array set portinfo [lindex $result 1]
    580                         if {[info exists portinfo(replaced_by)] && [lsearch -regexp $portinfo(replaced_by) "(?i)^[$port name]\$"] != -1} {
    581                             # we'll deactivate the owner later, but before activating our files
    582                             set todeactivate($owner) yes
    583                             set owner "replaced"
     459                }
     460
     461                if {$owner != "replaced"} {
     462                    if { [string is true -strict $force] } {
     463                        # if we're forcing the activation, then we move any existing
     464                        # files to a backup file, both in the filesystem and in the
     465                        # registry
     466                        if { [file exists $file] } {
     467                            set bakfile "${file}${baksuffix}"
     468                            ui_warn "File $file already exists.  Moving to: $bakfile."
     469                            file rename -force -- $file $bakfile
     470                            lappend backups $file
     471                        }
     472                        if { $owner != {} } {
     473                            $owner deactivate [list $file]
     474                            $owner activate [list $file] [list "${file}${baksuffix}"]
     475                        }
     476                    } else {
     477                        # if we're not forcing the activation, then we bail out if
     478                        # we find any files that already exist, or have entries in
     479                        # the registry
     480                        if { $owner != {} && $owner != $port } {
     481                            throw registry::image-error "Image error: $file is being used by the active [$owner name] port.  Please deactivate this port first, or use 'port -f activate [$port name]' to force the activation."
     482                        } elseif { $owner == {} && ![catch {file type $file}] } {
     483                            throw registry::image-error "Image error: $file already exists and does not belong to a registered port.  Unable to activate port [$port name]. Use 'port -f activate [$port name]' to force the activation."
    584484                        }
    585485                    }
    586 
    587                     if {$owner != "replaced"} {
    588                         if { [string is true -strict $force] } {
    589                             # if we're forcing the activation, then we move any existing
    590                             # files to a backup file, both in the filesystem and in the
    591                             # registry
    592                             if { [file exists $file] } {
    593                                 set bakfile "${file}${baksuffix}"
    594                                 ui_warn "File $file already exists.  Moving to: $bakfile."
    595                                 file rename -force -- $file $bakfile
    596                                 lappend backups $file
    597                             }
    598                             if { $owner != {} } {
    599                                 $owner deactivate [list $file]
    600                                 $owner activate [list $file] [list "${file}${baksuffix}"]
    601                             }
    602                         } else {
    603                             # if we're not forcing the activation, then we bail out if
    604                             # we find any files that already exist, or have entries in
    605                             # the registry
    606                             if { $owner != {} && $owner != $port } {
    607                                 throw registry::image-error "Image error: $file is being used by the active [$owner name] port.  Please deactivate this port first, or use 'port -f activate [$port name]' to force the activation."
    608                             } elseif { $owner == {} && ![catch {file type $file}] } {
    609                                 throw registry::image-error "Image error: $file already exists and does not belong to a registered port.  Unable to activate port [$port name]. Use 'port -f activate [$port name]' to force the activation."
    610                             }
    611                         }
    612                     }
    613 
    614                     # Split out the filename's subpaths and add them to the
    615                     # imagefile list.
    616                     # We need directories first to make sure they will be there
    617                     # before links. However, because file mkdir creates all parent
    618                     # directories, we don't need to have them sorted from root to
    619                     # subpaths. We do need, nevertheless, all sub paths to make sure
    620                     # we'll set the directory attributes properly for all
    621                     # directories.
    622                     set directory [file dirname $file]
    623                     while { [lsearch -exact $files $directory] == -1 } {
    624                         lappend files $directory
    625                         set directory [file dirname $directory]
    626                     }
    627 
    628                     # Also add the filename to the imagefile list.
    629                     lappend files $file
    630                 }
    631             }
    632 
    633             # deactivate ports replaced_by this one
    634             foreach owner [array names todeactivate] {
    635                 if {$noexec || ![registry::run_target $owner deactivate [list ports_nodepcheck 1]]} {
    636                     deactivate [$owner name] "" [list ports_nodepcheck 1]
    637                 }
    638             }
    639 
    640             # Sort the list in forward order, removing duplicates.
    641             # Since the list is sorted in forward order, we're sure that
    642             # directories are before their elements.
    643             # We don't have to do this as mentioned above, but it makes the
    644             # debug output of activate make more sense.
    645             set files [lsort -increasing -unique $files]
    646             set rollback_filelist {}
    647 
    648             registry::write {
    649                 # Activate it, and catch errors so we can roll-back
    650                 try {
    651                     $port activate $imagefiles
    652                     foreach file $files {
    653                         if {[_activate_file "${extracted_dir}${file}" $file] == 1} {
    654                             lappend rollback_filelist $file
    655                         }
    656                     }
    657                 } catch {*} {
    658                     ui_debug "Activation failed, rolling back."
    659                     # can't do it here since we're already inside a transaction
    660                     set deactivate_this yes
    661                     throw
    662                 }
    663             }
    664         } catch {*} {
    665             # roll back activation of this port
    666             if {[info exists deactivate_this]} {
    667                 _deactivate_contents $port $rollback_filelist yes yes
    668             }
    669             # if any errors occurred, move backed-up files back to their original
    670             # locations, then rethrow the error. Transaction rollback will take care
    671             # of this in the registry.
    672             foreach file $backups {
    673                 file rename -force -- "${file}${baksuffix}" $file
    674             }
    675             # reactivate deactivated ports
    676             foreach entry [array names todeactivate] {
    677                 if {[$entry state] == "imaged" && ($noexec || ![registry::run_target $entry activate ""])} {
    678                     set pvers "[$entry version]_[$entry revision][$entry variants]"
    679                     activate [$entry name] $pvers [list ports_activate_no-exec $noexec]
    680                 }
    681             }
    682             # remove temp image dir
    683             file delete -force $extracted_dir
    684             throw
    685         }
    686     } else {
    687         # registry1.0
    688         set deactivated [list]
    689         foreach file $imagefiles {
    690             set srcfile "${extracted_dir}${file}"
    691 
    692             # To be able to install links, we test if we can lstat the file to
    693             # figure out if the source file exists (file exists will return
    694             # false for symlinks on files that do not exist)
    695             if { [catch {file lstat $srcfile dummystatvar}] } {
    696                 file delete -force $extracted_dir
    697                 return -code error "Image error: Source file $srcfile does not appear to exist (cannot lstat it).  Unable to activate port $name."
    698             }
    699 
    700             set port [registry::file_registered $file]
    701            
    702             if {$port != 0  && $port != $name} {
    703                 # deactivate conflicting port if it is replaced_by this one
    704                 if {[catch {mportlookup $port} result]} {
    705                     global errorInfo
    706                     ui_debug "$errorInfo"
    707                     file delete -force $extracted_dir
    708                     return -code error "port lookup failed: $result"
    709                 }
    710                 array unset portinfo
    711                 array set portinfo [lindex $result 1]
    712                 if {[info exists portinfo(replaced_by)] && [lsearch -regexp $portinfo(replaced_by) "(?i)^${name}\$"] != -1} {
    713                     lappend deactivated [lindex [registry::active $port] 0]
    714                     deactivate $port "" ""
    715                     set port 0
    716                 }
    717             }
    718    
    719             if { $port != 0  && $force != 1 && $port != $name } {
    720                 file delete -force $extracted_dir
    721                 return -code error "Image error: $file is being used by the active $port port.  Please deactivate this port first, or use 'port -f activate $name' to force the activation."
    722             } elseif { [file exists $file] && $force != 1 } {
    723                 file delete -force $extracted_dir
    724                 return -code error "Image error: $file already exists and does not belong to a registered port.  Unable to activate port $name. Use 'port -f activate $name' to force the activation."
    725             } elseif { $force == 1 && [file exists $file] || $port != 0 } {
    726                 set bakfile "${file}${baksuffix}"
    727 
    728                 if {[file exists $file]} {
    729                     ui_warn "File $file already exists.  Moving to: $bakfile."
    730                     file rename -force -- $file $bakfile
    731                     lappend backups $file
    732                 }
    733 
    734                 if { $port != 0 } {
    735                     set bakport [registry::file_registered $file]
    736                     registry::unregister_file $file
    737                     if {[file exists $bakfile]} {
    738                         registry::register_file $bakfile $bakport
    739                     }
    740                 }
    741             }
    742 
    743             # Split out the filename's subpaths and add them to the imagefile list.
    744             # We need directories first to make sure they will be there before
    745             # links. However, because file mkdir creates all parent directories,
    746             # we don't need to have them sorted from root to subpaths. We do need,
    747             # nevertheless, all sub paths to make sure we'll set the directory
    748             # attributes properly for all directories.
    749             set directory [file dirname $file]
    750             while { [lsearch -exact $files $directory] == -1 } {
    751                 lappend files $directory
    752                 set directory [file dirname $directory]
    753             }
    754 
    755             # Also add the filename to the imagefile list.
    756             lappend files $file
    757         }
    758         registry::write_file_map
     486                }
     487
     488                # Split out the filename's subpaths and add them to the
     489                # imagefile list.
     490                # We need directories first to make sure they will be there
     491                # before links. However, because file mkdir creates all parent
     492                # directories, we don't need to have them sorted from root to
     493                # subpaths. We do need, nevertheless, all sub paths to make sure
     494                # we'll set the directory attributes properly for all
     495                # directories.
     496                set directory [file dirname $file]
     497                while { [lsearch -exact $files $directory] == -1 } {
     498                    lappend files $directory
     499                    set directory [file dirname $directory]
     500                }
     501
     502                # Also add the filename to the imagefile list.
     503                lappend files $file
     504            }
     505        }
     506
     507        # deactivate ports replaced_by this one
     508        foreach owner [array names todeactivate] {
     509            if {$noexec || ![registry::run_target $owner deactivate [list ports_nodepcheck 1]]} {
     510                deactivate [$owner name] "" "" 0 [list ports_nodepcheck 1]
     511            }
     512        }
    759513
    760514        # Sort the list in forward order, removing duplicates.
    761         # Since the list is sorted in forward order, we're sure that directories
    762         # are before their elements.
     515        # Since the list is sorted in forward order, we're sure that
     516        # directories are before their elements.
    763517        # We don't have to do this as mentioned above, but it makes the
    764518        # debug output of activate make more sense.
     
    766520        set rollback_filelist {}
    767521
    768         # Activate it, and catch errors so we can roll-back
    769         if { [catch { foreach file $files {
    770                         if {[_activate_file "${extracted_dir}${file}" $file] == 1} {
    771                             lappend rollback_filelist $file
    772                         }
    773                     }} result]} {
    774             ui_debug "Activation failed, rolling back."
    775             _deactivate_contents $name $rollback_filelist yes yes
    776             # return backed up files to their old locations
    777             foreach f $backups {
    778                 set bakfile "${f}${baksuffix}"
    779                 set bakport [registry::file_registered $bakfile]
    780                 if {$bakport != 0} {
    781                     registry::unregister_file $bakfile
    782                     registry::register_file $f $bakport
    783                 }
    784                 file rename -force -- $bakfile $file
    785             }
    786             # reactivate deactivated ports
    787             foreach entry $deactivated {
    788                 set pname [lindex $entry 0]
    789                 set pvers "[lindex $entry 1]_[lindex $entry 2][lindex $entry 3]"
    790                 activate $pname $pvers ""
    791             }
    792             registry::write_file_map
    793 
    794             file delete -force $extracted_dir
    795             return -code error $result
    796         }
     522        registry::write {
     523            # Activate it, and catch errors so we can roll-back
     524            try {
     525                $port activate $imagefiles
     526                foreach file $files {
     527                    if {[_activate_file "${extracted_dir}${file}" $file] == 1} {
     528                        lappend rollback_filelist $file
     529                    }
     530                }
     531            } catch {*} {
     532                ui_debug "Activation failed, rolling back."
     533                # can't do it here since we're already inside a transaction
     534                set deactivate_this yes
     535                throw
     536            }
     537        }
     538    } catch {*} {
     539        # roll back activation of this port
     540        if {[info exists deactivate_this]} {
     541            _deactivate_contents $port $rollback_filelist yes yes
     542        }
     543        # if any errors occurred, move backed-up files back to their original
     544        # locations, then rethrow the error. Transaction rollback will take care
     545        # of this in the registry.
     546        foreach file $backups {
     547            file rename -force -- "${file}${baksuffix}" $file
     548        }
     549        # reactivate deactivated ports
     550        foreach entry [array names todeactivate] {
     551            if {[$entry state] == "imaged" && ($noexec || ![registry::run_target $entry activate ""])} {
     552                activate [$entry name] [$entry version] [$entry revision] [$entry variants] [list ports_activate_no-exec $noexec]
     553            }
     554        }
     555        # remove temp image dir
     556        file delete -force $extracted_dir
     557        throw
    797558    }
    798559    file delete -force $extracted_dir
    799560}
     561
     562# These directories should not be removed during deactivation even if they are empty.
     563# TODO: look into what other dirs should go here
     564variable precious_dirs
     565array set precious_dirs { /Library/LaunchDaemons 1 /Library/LaunchAgents 1 }
    800566
    801567proc _deactivate_file {dstfile} {
     
    806572        # 0 item means empty.
    807573        if { [llength [readdir $dstfile]] == 0 } {
    808             ui_debug "deactivating directory: $dstfile"
    809             file delete -- $dstfile
     574            variable precious_dirs
     575            if {![info exists precious_dirs($dstfile)]} {
     576                ui_debug "deactivating directory: $dstfile"
     577                file delete -- $dstfile
     578            } else {
     579                ui_debug "directory $dstfile does not belong to us"
     580            }
    810581        } else {
    811582            ui_debug "$dstfile is not empty"
     
    818589
    819590proc _deactivate_contents {port imagefiles {force 0} {rollback 0}} {
    820     variable use_reg2
    821591    set files [list]
    822592
     
    853623
    854624    # Remove all elements.
    855     if {$use_reg2 && !$rollback} {
     625    if {!$rollback} {
    856626        registry::write {
    857627            $port deactivate $imagefiles
  • branches/gsoc11-statistics/base/src/registry2.0/portuninstall.tcl

    r78086 r79672  
    33# $Id$
    44#
     5# Copyright (c) 2004-2005, 2008-2011 The MacPorts Project
    56# Copyright (c) 2002 - 2003 Apple Inc.
    67# All rights reserved.
     
    4142namespace eval registry_uninstall {
    4243
    43 proc uninstall {portname {v ""} optionslist} {
     44# takes a composite version spec rather than separate version,revision,variants
     45proc uninstall_composite {portname {v ""} {optionslist ""}} {
     46    if {$v == ""} {
     47        return [uninstall $portname "" "" 0 $optionslist]
     48    } elseif {[registry::decode_spec $v version revision variants]} {
     49        return [uninstall $portname $version $revision $variants $optionslist]
     50    }
     51    throw registry::invalid "Registry error: Invalid version '$v' specified for ${portname}. Please specify a version as recorded in the port registry."
     52}
     53
     54proc uninstall {portname {version ""} {revision ""} {variants 0} {optionslist ""}} {
    4455    global uninstall.force uninstall.nochecksum UI_PREFIX \
    45            macports::registry.format macports::portimagefilepath
     56           macports::portimagefilepath
    4657    array set options $optionslist
     58    if {[info exists options(subport)]} {
     59        # don't want this set when calling registry::run_target
     60        unset options(subport)
     61        set optionslist [array get options]
     62    }
    4763
    4864    if {![info exists uninstall.force]} {
     
    5773        set options(ports_deactivate_no-exec) $options(ports_uninstall_no-exec)
    5874    }
    59     # check which registry API to use
    60     set use_reg2 [string equal ${macports::registry.format} "receipt_sqlite"]
    61 
    62     if {$use_reg2} {
    63         if { [registry::decode_spec $v version revision variants] } {
    64             set ilist [registry::entry imaged $portname $version $revision $variants]
    65             set valid 1
    66         } else {
    67             set valid [string equal $v {}]
    68             set ilist [registry::entry imaged $portname]
    69         }
    70     } else {
    71         set ilist [registry::installed $portname $v]
    72         set valid 1
    73     }
     75
     76    set searchkeys $portname
     77    set composite_spec ""
     78    if {$version != ""} {
     79        lappend searchkeys $version
     80        set composite_spec $version
     81        # restriction imposed by underlying registry API (see entry.c):
     82        # if a revision is specified, so must variants be
     83        if {$revision != ""} {
     84            lappend searchkeys $revision $variants
     85            append composite_spec _${revision}${variants}
     86        }
     87    }
     88    set ilist [eval registry::entry imaged $searchkeys]
    7489    if { [llength $ilist] > 1 } {
    7590        # set portname again since the one we were passed may not have had the correct case
    76         if {$use_reg2} {
    77             set portname [[lindex $ilist 0] name]
    78         } else {
    79             set portname [lindex [lindex $ilist 0] 0]
    80         }
     91        set portname [[lindex $ilist 0] name]
    8192        ui_msg "$UI_PREFIX [msgcat::mc "The following versions of $portname are currently installed:"]"
    8293        foreach i [portlist_sortint $ilist] {
    83             if {$use_reg2} {
    84                 set ispec "[$i version]_[$i revision][$i variants]"
    85                 if { [string equal [$i state] installed] } {
    86                     ui_msg "$UI_PREFIX [format [msgcat::mc "    %s @%s (active)"] [$i name] $ispec]"
    87                 } else {
    88                     ui_msg "$UI_PREFIX [format [msgcat::mc "    %s @%s"] [$i name] $ispec]"
    89                 }
     94            set ispec "[$i version]_[$i revision][$i variants]"
     95            if { [string equal [$i state] installed] } {
     96                ui_msg "$UI_PREFIX [format [msgcat::mc "    %s @%s (active)"] [$i name] $ispec]"
    9097            } else {
    91                 set iname [lindex $i 0]
    92                 set iversion [lindex $i 1]
    93                 set irevision [lindex $i 2]
    94                 set ivariants [lindex $i 3]
    95                 set iactive [lindex $i 4]
    96                 if { $iactive == 1 } {
    97                     ui_msg "$UI_PREFIX [format [msgcat::mc "    %s @%s_%s%s (active)"] $iname $iversion $irevision $ivariants]"
    98                 } else {
    99                     ui_msg "$UI_PREFIX [format [msgcat::mc "    %s @%s_%s%s"] $iname $iversion $irevision $ivariants]"
    100                 }
    101             }
    102         }
    103         if { $valid } {
    104             throw registry::invalid "Registry error: Please specify the full version as recorded in the port registry."
     98                ui_msg "$UI_PREFIX [format [msgcat::mc "    %s @%s"] [$i name] $ispec]"
     99            }
     100        }
     101        throw registry::invalid "Registry error: Please specify the full version as recorded in the port registry."
     102    } elseif { [llength $ilist] == 1 } {
     103        set port [lindex $ilist 0]
     104        set version [$port version]
     105        set revision [$port revision]
     106        set variants [$port variants]
     107        set composite_spec "${version}_${revision}${variants}"
     108    } else {
     109        if {$composite_spec != ""} {
     110            set composite_spec " @${composite_spec}"
     111        }
     112        throw registry::invalid "Registry error: ${portname}${composite_spec} not registered as installed"
     113    }
     114
     115    # uninstall dependents if requested
     116    if {[info exists options(ports_uninstall_follow-dependents)] && $options(ports_uninstall_follow-dependents) eq "yes"} {
     117        # don't uninstall dependents' dependencies
     118        if {[info exists options(ports_uninstall_follow-dependencies)]} {
     119            set orig_follow_dependencies $options(ports_uninstall_follow-dependencies)
     120            unset options(ports_uninstall_follow-dependencies)
     121            set optionslist [array get options]
     122        }
     123        foreach depport [$port dependents] {
     124            # make sure it's still installed, since a previous dep uninstall may have removed it
     125            if {[registry::entry exists $depport] && ([$depport state] == "imaged" || [$depport state] == "installed")} {
     126                if {[info exists options(ports_uninstall_no-exec)] || ![registry::run_target $depport uninstall $optionslist]} {
     127                    registry_uninstall::uninstall [$depport name] [$depport version] [$depport revision] [$depport variants] $optionslist
     128                }
     129            }
     130        }
     131        if {[info exists orig_follow_dependencies]} {
     132            set options(ports_uninstall_follow-dependencies) $orig_follow_dependencies
     133            set optionslist [array get options]
     134        }
     135    } else {
     136        # check its dependents
     137        registry::check_dependents $port ${uninstall.force} "uninstall"
     138    }
     139    # if it's active, deactivate it
     140    if { [string equal [$port state] installed] } {
     141        if {[info exists options(ports_dryrun)] && [string is true -strict $options(ports_dryrun)]} {
     142            ui_msg "For $portname @${composite_spec}: skipping deactivate (dry run)"
    105143        } else {
    106             throw registry::invalid "Registry error: Invalid version specified. Please specify a version as recorded in the port registry."
    107         }
    108     } elseif { [llength $ilist] == 1 } {
    109         if {$use_reg2} {
    110             set port [lindex $ilist 0]
    111             set version [$port version]
    112             set revision [$port revision]
    113             set variants [$port variants]
    114         } else {
    115             set version [lindex [lindex $ilist 0] 1]
    116             set revision [lindex [lindex $ilist 0] 2]
    117             set variants [lindex [lindex $ilist 0] 3]
    118             set active [lindex [lindex $ilist 0] 4]
    119         }
    120         if {$v == ""} {
    121             set v "${version}_${revision}${variants}"
    122         }
    123     } else {
    124         throw registry::invalid "Registry error: $portname not registered as installed"
    125     }
    126 
    127     if {$use_reg2} {
    128         # uninstall dependents if requested
    129         if {[info exists options(ports_uninstall_follow-dependents)] && $options(ports_uninstall_follow-dependents) eq "yes"} {
    130             foreach depport [$port dependents] {
    131                 # make sure it's still installed, since a previous dep uninstall may have removed it
    132                 if {[registry::entry exists $depport] && ([$depport state] == "imaged" || [$depport state] == "installed")} {
    133                     if {[info exists options(ports_uninstall_no-exec)] || ![registry::run_target $depport uninstall $optionslist]} {
    134                         set depname [$depport name]
    135                         set depver "[$depport version]_[$depport revision][$depport variants]"
    136                         registry_uninstall::uninstall $depname $depver $optionslist
    137                     }
    138                 }
    139             }
    140         } else {
    141             # check its dependents
    142             registry::check_dependents $port ${uninstall.force} "uninstall"
    143         }
    144         # if it's active, deactivate it
    145         if { [string equal [$port state] installed] } {
    146             if {[info exists options(ports_dryrun)] && [string is true -strict $options(ports_dryrun)]} {
    147                 ui_msg "For $portname @${v}: skipping deactivate (dry run)"
    148             } else {
    149                 if {[info exists options(ports_uninstall_no-exec)] || ![registry::run_target $port deactivate $optionslist]} {
    150                     portimage::deactivate $portname $v [array get options]
    151                 }
    152             }
    153         }
    154     } else {
    155         # registry1.0
    156        
    157         # determine if it's the only installed port with that name or not.
    158         if {$v == ""} {
    159             set nb_versions_installed 1
    160         } else {
    161             set ilist [registry::installed $portname ""]
    162             set nb_versions_installed [llength $ilist]
    163         }
    164    
    165         set ref [registry::open_entry $portname $version $revision $variants]
    166    
    167         # Check and make sure no ports depend on this one
    168         registry::open_dep_map 
    169         set deplist [registry::list_dependents $portname $version $revision $variants]
    170         if { [llength $deplist] > 0 } {
    171             set dl [list]
    172             # Check the deps first
    173             foreach dep $deplist {
    174                 set depport [lindex $dep 2]
    175                 ui_debug "$depport depends on this port"
    176                 if {[registry::entry_exists_for_name $depport]} {
    177                     lappend dl $depport
    178                 }
    179             }
    180             # Now see if we need to error
    181             if { [llength $dl] > 0 } {
    182                 if {[info exists options(ports_uninstall_follow-dependents)] && $options(ports_uninstall_follow-dependents) eq "yes"} {
    183                     foreach depport $dl {
    184                         # make sure it's still installed, since a previous dep uninstall may have removed it
    185                         if {[registry::entry_exists_for_name $depport]} {
    186                             registry_uninstall::uninstall $depport "" $optionslist
    187                         }
    188                     }
    189                 } else {
    190                     # will need to change this when we get version/variant dependencies
    191                     if {$nb_versions_installed == 1 || $active == 1} {
    192                         ui_msg "$UI_PREFIX [format [msgcat::mc "Unable to uninstall %s %s_%s%s, the following ports depend on it:"] $portname $version $revision $variants]"
    193                         foreach depport $dl {
    194                             ui_msg "$UI_PREFIX [format [msgcat::mc "    %s"] $depport]"
    195                         }
    196                         if { [string is true -strict ${uninstall.force}] } {
    197                             ui_warn "Uninstall forced.  Proceeding despite dependencies."
    198                         } else {
    199                             return -code error "Please uninstall the ports that depend on $portname first."
    200                         }
    201                     }
    202                 }
    203             }
    204         }
    205    
    206         if { [registry::property_retrieve $ref active] == 1} {
    207             if {[info exists options(ports_dryrun)] && [string is true -strict $options(ports_dryrun)]} {
    208                 ui_msg "For $portname @${version}_${revision}${variants}: skipping deactivate (dry run)"
    209             } else {
    210                 portimage::deactivate $portname ${version}_${revision}${variants} $optionslist
    211             }
    212         }
    213     }
    214 
    215     if {$use_reg2} {
    216         set ref $port
    217     }
     144            if {[info exists options(ports_uninstall_no-exec)] || ![registry::run_target $port deactivate $optionslist]} {
     145                portimage::deactivate $portname $version $revision $variants [array get options]
     146            }
     147        }
     148    }
     149
     150    set ref $port
    218151
    219152    # note deps before we uninstall if we're going to uninstall them too
     
    222155        set all_dependencies {}
    223156        # look up deps from the saved portfile if possible
    224         if {$use_reg2 && ![catch {set mport [mportopen_installed [$port name] [$port version] [$port revision] [$port variants] $optionslist]}]} {
     157        if {![catch {set mport [mportopen_installed [$port name] [$port version] [$port revision] [$port variants] $optionslist]}]} {
    225158            array set depportinfo [mportinfo $mport]
    226159            mportclose_installed $mport
     
    274207
    275208    if {[info exists options(ports_dryrun)] && [string is true -strict $options(ports_dryrun)]} {
    276         ui_msg "For $portname @${v}: skipping uninstall (dry run)"
     209        ui_msg "For $portname @${composite_spec}: skipping uninstall (dry run)"
    277210    } else {
    278         ui_msg "$UI_PREFIX [format [msgcat::mc "Uninstalling %s @%s"] $portname $v]"
    279    
    280         if {!$use_reg2} {
    281             # Look to see if the port has registered an uninstall procedure
    282             set uninstall [registry::property_retrieve $ref pkg_uninstall]
    283             if { $uninstall != 0 } {
    284                 if {![catch {eval [string map { \\n \n } $uninstall]} err]} {
    285                     ui_info "Executing pkg_uninstall procedure"
    286                     if {[catch {pkg_uninstall $portname "${version}_${revision}${variants}" } err]} {
    287                         ui_error [format [msgcat::mc "Error executing pkg_uninstall procedure: %s"] $err]
    288                     }
    289                 } else {
    290                     global errorInfo
    291                     ui_debug "$errorInfo"
    292                     ui_error [format [msgcat::mc "Could not evaluate pkg_uninstall procedure: %s"] $err]
    293                 }
    294             }
    295        
    296             # Remove the port from the dep_map if only one version was installed.
    297             # This is a temporary fix for a deeper problem that is that the dependency
    298             # map doesn't take the port version into account (but should).
    299             # Fixing it means transitioning to a new dependency map format.
    300             if {$nb_versions_installed == 1} {
    301                 registry::unregister_dependencies $portname
    302             }
    303         }
    304    
     211        ui_msg "$UI_PREFIX [format [msgcat::mc "Uninstalling %s @%s"] $portname $composite_spec]"
     212
    305213        # Get the full path to the image file
    306214        set imagefile [registry::property_retrieve $ref location]
     
    310218        catch {file delete [file dirname $imagefile]}
    311219
    312         if {$use_reg2} {
    313             registry::entry delete $port
    314         } else {
    315             ui_info "$UI_PREFIX [format [msgcat::mc "Uninstall is removing %s from the port registry."] $portname]"
    316             registry::delete_entry $ref
    317         }
     220        registry::entry delete $port
    318221    }
    319222   
    320223    # uninstall dependencies if requested
    321224    if {[info exists options(ports_uninstall_follow-dependencies)] && [string is true -strict $options(ports_uninstall_follow-dependencies)]} {
     225        # don't uninstall dependencies' dependents
     226        if {[info exists options(ports_uninstall_follow-dependents)]} {
     227            unset options(ports_uninstall_follow-dependents)
     228            set optionslist [array get options]
     229        }
    322230        while 1 {
    323231            set remaining_list {}
     
    331239                        if {[llength [registry::list_dependents $dep $iversion $irevision $ivariants]] == 0} {
    332240                            set regref [registry::open_entry $dep $iversion $irevision $ivariants [lindex $i 5]]
    333                             if {![registry::property_retrieve $regref requested] && (!$use_reg2 || [info exists options(ports_uninstall_no-exec)] || ![registry::run_target $regref uninstall $optionslist])} {
    334                                 set depver "${iversion}_${irevision}${ivariants}"
    335                                 registry_uninstall::uninstall $dep $depver $optionslist
     241                            if {![registry::property_retrieve $regref requested] && ([info exists options(ports_uninstall_no-exec)] || ![registry::run_target $regref uninstall $optionslist])} {
     242                                registry_uninstall::uninstall $dep $iversion $irevision $ivariants $optionslist
    336243                            }
    337244                        } else {
  • branches/gsoc11-statistics/base/src/registry2.0/receipt_flat.tcl

    r77511 r79672  
    22# $Id$
    33#
     4# Copyright (c) 2005, 2007-2009 The MacPorts Project
    45# Copyright (c) 2004 Will Barton <wbb4@opendarwin.org>
    56# Copyright (c) 2004 Paul Guyot, The MacPorts Project.
    6 # Copyright (c) 2002 Apple Computer, Inc.
     7# Copyright (c) 2002 Apple Inc.
    78# All rights reserved.
    89#
     
    1516#    notice, this list of conditions and the following disclaimer in the
    1617#    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# 3. Neither the name of Apple Inc. nor the names of its contributors
    1819#    may be used to endorse or promote products derived from this software
    1920#    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/registry2.0/receipt_sqlite.tcl

    r77511 r79672  
    22# $Id$
    33#
    4 # Copyright (c) 2010 The MacPorts Project
     4# Copyright (c) 2010-2011 The MacPorts Project
    55# Copyright (c) 2004 Will Barton <wbb4@opendarwin.org>
    66# Copyright (c) 2002 Apple Inc.
     
    161161# Otherwise, return only ports that exactly match this version.
    162162# What we call version here is version_revision+variants.
     163# The syntax for that can be ambiguous if there's an underscore and dash in
     164# version for example, so we don't attempt to split up the composite version
     165# into its components, we just compare the whole thing.
    163166proc installed {{name ""} {version ""}} {
    164167        if { $name == "" && $version == "" } {
     
    167170            set ports [registry::entry imaged $name]
    168171        } else {
    169             set cmd "registry::entry imaged $name"
    170             registry::decode_spec $version version revision variants
    171             if {[info exists version] && $version != ""} {
    172                 append cmd " $version"
    173                 if {[info exists revision] && $revision != ""} {
    174                     append cmd " $revision"
    175                     if {![info exists variants]} {
    176                         set variants ""
    177                     }
    178                     append cmd " {$variants}"
    179                 }
    180         }
    181             if {[catch {set ports [eval $cmd]}]} {
    182                 set ports [list]
     172            set ports {}
     173            set possible_ports [registry::entry imaged $name]
     174            foreach p $possible_ports {
     175                if {"[$p version]_[$p revision][$p variants]" == $version
     176                    || [$p version] == $version} {
     177                    lappend ports $p
     178                }
    183179            }
    184180        }
  • branches/gsoc11-statistics/base/src/registry2.0/registry.tcl

    r77511 r79672  
    11# registry.tcl
    22#
     3# Copyright (c) 2004-2005, 2007-2010 The MacPorts Project
    34# Copyright (c) 2004 Will Barton <wbb4@opendarwin.org>
    4 # Copyright (c) 2002 Apple Computer, Inc.
     5# Copyright (c) 2002 Apple Inc.
    56# All rights reserved.
    67#
     
    1314#    notice, this list of conditions and the following disclaimer in the
    1415#    documentation and/or other materials provided with the distribution.
    15 # 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
     16# 3. Neither the name of Apple Inc. nor the names of its contributors
    1617#    may be used to endorse or promote products derived from this software
    1718#    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/registry2.0/registry_autoconf.tcl.in

    r63398 r79672  
    1313#    notice, this list of conditions and the following disclaimer in the
    1414#    documentation and/or other materials provided with the distribution.
    15 # 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
     15# 3. Neither the name of The MacPorts Project nor the names of its contributors
    1616#    may be used to endorse or promote products derived from this software
    1717#    without specific prior written permission.
  • branches/gsoc11-statistics/base/src/registry2.0/registry_util.tcl

    r78086 r79672  
    44#
    55# Copyright (c) 2007 Chris Pickel
     6# Copyright (c) 2010-2011 The MacPorts Project
    67# All rights reserved.
    78#
  • branches/gsoc11-statistics/base/src/upgrade_sources_conf_default.tcl

    r74011 r79672  
    6969                  }
    7070                  if {[catch {close $svnChannel} err]} {
    71                      if {![string match "*This client is too old to work with working copy*" $err]} {
    72                         return -code error $err
    73                      } else {
    74                         puts $err
    75                         puts "WARNING: Unable to check svn URL for '$filepath' as it has been checked out with a newer Subversion client; please manually verify $sourcesConf!"
    76                      }
     71                     puts $err
     72                     puts "WARNING: Unable to check svn URL for '$filepath'; please manually verify $sourcesConf!"
    7773                  }
    7874                  if {[regexp {^https?://svn\.(macports|macosforge)\.org/repository/macports/trunk/dports} $svnURL]} {
     
    8076                  }
    8177               } else {
    82                   return -code error $err
     78                  puts $err
     79                  puts "WARNING: Unable to check svn URL for '$filepath'; please manually verify $sourcesConf!"
    8380               }
    8481            }
Note: See TracChangeset for help on using the changeset viewer.