Ignore:
Timestamp:
Jun 1, 2013, 8:55:55 AM (7 years ago)
Author:
jmr@…
Message:

bring back clean --archive since files can persist in incoming/ in some circumstances

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/base/src/port1.0/portclean.tcl

    r106614 r106617  
    11# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
    2 # portclean.tcl
    32# $Id$
    43#
    5 # Copyright (c) 2005-2007, 2009-2011 The MacPorts Project
     4# Copyright (c) 2005-2007, 2009-2011, 2013 The MacPorts Project
    65# Copyright (c) 2004 Robert Shaw <rshaw@opendarwin.org>
    76# Copyright (c) 2002 - 2003 Apple Inc.
     
    6261
    6362proc portclean::clean_main {args} {
    64     global UI_PREFIX \
    65            ports_clean_dist ports_clean_work ports_clean_logs \
    66            ports_clean_all keeplogs usealtworkpath
     63    global UI_PREFIX ports_clean_dist ports_clean_work ports_clean_logs \
     64           ports_clean_archive ports_clean_all keeplogs usealtworkpath
    6765
    6866    if {$usealtworkpath} {
     
    7573        clean_dist
    7674    }
     75    if {([info exists ports_clean_all] && $ports_clean_all == "yes" || \
     76        [info exists ports_clean_archive] && $ports_clean_archive == "yes")
     77        && !$usealtworkpath} {
     78        ui_info "$UI_PREFIX [format [msgcat::mc "Removing temporary archives for %s"] [option subport]]"
     79        clean_archive
     80    }
    7781    if {[info exists ports_clean_all] && $ports_clean_all == "yes" || \
    7882        [info exists ports_clean_work] && $ports_clean_work == "yes" || \
     83        [info exists ports_clean_archive] && $ports_clean_archive == "yes" || \
     84        [info exists ports_clean_dist] && $ports_clean_dist == "yes" || \
    7985        !([info exists ports_clean_logs] && $ports_clean_logs == "yes")} {
    8086         ui_info "$UI_PREFIX [format [msgcat::mc "Removing work directory for %s"] [option subport]]"
     
    260266    return 0
    261267}
     268
     269proc portclean::clean_archive {args} {
     270    global subport ports_version_glob portdbpath
     271
     272    # Define archive destination directory, target filename, regex for archive name
     273    set archivepath [file join $portdbpath incoming]
     274
     275    if {[info exists ports_version_glob]} {
     276        # Match all possible archive variants that match the version
     277        # glob specified by the user.
     278        set fileglob "$subport-[option ports_version_glob]*.*.*.*"
     279    } else {
     280        # Match all possible archives for this port.
     281        set fileglob "$subport-*_*.*.*.*"
     282    }
     283
     284    # Remove the archive files
     285    set count 0
     286    foreach dir [list $archivepath ${archivepath}/verified] {
     287        set archivelist [glob -nocomplain -directory $dir $fileglob]
     288        foreach path $archivelist {
     289            # Make sure file is truly an archive file for this port, and not
     290            # an accidental match with some other file that might exist. Also
     291            # delete anything ending in .TMP since those are incomplete and
     292            # thus can't be checked and aren't useful anyway.
     293            set archivetype [string range [file extension $path] 1 end]
     294            if {[file isfile $path] && ($archivetype == "TMP"
     295                || [extract_archive_metadata $path $archivetype portname] == $subport)} {
     296                ui_debug "Removing archive: $path"
     297                if {[catch {delete $path} result]} {
     298                    ui_debug "$::errorInfo"
     299                    ui_error "$result"
     300                }
     301                if {[file isfile ${path}.rmd160]} {
     302                    ui_debug "Removing archive signature: ${path}.rmd160"
     303                    if {[catch {delete ${path}.rmd160} result]} {
     304                        ui_debug "$::errorInfo"
     305                        ui_error "$result"
     306                    }
     307                }
     308                incr count
     309            }
     310        }
     311    }
     312    if {$count > 0} {
     313        ui_debug "$count archive(s) removed."
     314    } else {
     315        ui_debug "No archives found to remove at $archivepath"
     316    }
     317
     318    return 0
     319}
Note: See TracChangeset for help on using the changeset viewer.