Changeset 106617


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

Location:
trunk/base
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/base/doc/port.1

    r98190 r106617  
    523523To remove the distribution files (tarballs, etc), specify
    524524.Fl -dist .
    525 To remove the work files, distribution files and logs, pass
     525To remove any archives of a port that remain in the temporary download directory, pass
     526.Fl -archive .
     527(This does not remove archives from the installed location.)
     528To remove the log files for a port, pass
     529.Fl -logs .
     530To remove the work files, distribution files, temporary archives and logs, pass
    526531.Fl -all .
    527 To remove log files for certain port, pass
    528 .Fl -logs .
    529532For example:
    530533.Pp
     
    532535.Dl "port clean --logs vim"
    533536.Pp
     537To remove only certain version(s) of a port's temporary archives (
     538.Ar version
     539is any valid UNIX glob pattern), you can use:
     540.Pp
     541.Dl "port clean --archive vim 6.2.114"
     542.Pp
     543or:
     544.Pp
     545.Dl "port clean --archive vim '6.*'"
    534546.Ss log
    535547Parses and shows log files for
  • trunk/base/src/port/port-help.tcl

    r103400 r106617  
    4343Removes files associated with the given ports
    4444
     45--archive     Removes temporary archives
    4546--dist        Removes downloaded distfiles
    4647--logs        Removes log files
  • trunk/base/src/port/port.tcl

    r106614 r106617  
    42704270    uninstall   {follow-dependents follow-dependencies no-exec}
    42714271    variants    {index}
    4272     clean       {all dist work logs}
     4272    clean       {all archive dist work logs}
    42734273    mirror      {new}
    42744274    lint        {nitpick}
  • 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}
  • trunk/base/src/port1.0/portinstall.tcl

    r106615 r106617  
    300300
    301301proc portinstall::extract_contents {location type} {
    302     set qflag ${portutil::autoconf::tar_q}
    303     switch -- $type {
    304         tbz -
    305         tbz2 {
    306             set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xOj${qflag}f $location ./+CONTENTS]
    307         }
    308         tgz {
    309             set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xOz${qflag}f $location ./+CONTENTS]
    310         }
    311         tar {
    312             set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xO${qflag}f $location ./+CONTENTS]
    313         }
    314         txz {
    315             set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xO${qflag}f $location --use-compress-program [findBinary xz ""] ./+CONTENTS]
    316         }
    317         tlz {
    318             set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xO${qflag}f $location --use-compress-program [findBinary lzma ""] ./+CONTENTS]
    319         }
    320         xar {
    321             system "cd ${workpath} && [findBinary xar ${portutil::autoconf::xar_path}] -xf $location +CONTENTS"
    322             set twostep 1
    323         }
    324         zip {
    325             set raw_contents [exec [findBinary unzip ${portutil::autoconf::unzip_path}] -p $location +CONTENTS]
    326         }
    327         cpgz {
    328             system "cd ${workpath} && [findBinary pax ${portutil::autoconf::pax_path}] -rzf $location +CONTENTS"
    329             set twostep 1
    330         }
    331         cpio {
    332             system "cd ${workpath} && [findBinary pax ${portutil::autoconf::pax_path}] -rf $location +CONTENTS"
    333             set twostep 1
    334         }
    335     }
    336     if {[info exists twostep]} {
    337         set fd [open "${workpath}/+CONTENTS"]
    338         set raw_contents [read $fd]
    339         close $fd
    340     }
    341     set contents {}
    342     set ignore 0
    343     set sep [file separator]
    344     foreach line [split $raw_contents \n] {
    345         if {$ignore} {
    346             set ignore 0
    347             continue
    348         }
    349         if {[string index $line 0] != "@"} {
    350             lappend contents "${sep}${line}"
    351         } elseif {$line == "@ignore"} {
    352             set ignore 1
    353         }
    354     }
    355     return $contents
     302    return [extract_archive_metadata $location $type contents]
    356303}
    357304
  • trunk/base/src/port1.0/portutil.tcl

    r106614 r106617  
    25322532}
    25332533
     2534# return the specified piece of metadata from the +CONTENTS file in the given archive
     2535proc extract_archive_metadata {archive_location archive_type metadata_type} {
     2536    set qflag ${portutil::autoconf::tar_q}
     2537    set raw_contents ""
     2538    switch -- $archive_type {
     2539        tbz -
     2540        tbz2 {
     2541            set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xOj${qflag}f $archive_location ./+CONTENTS]
     2542        }
     2543        tgz {
     2544            set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xOz${qflag}f $archive_location ./+CONTENTS]
     2545        }
     2546        tar {
     2547            set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xO${qflag}f $archive_location ./+CONTENTS]
     2548        }
     2549        txz {
     2550            set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xO${qflag}f $archive_location --use-compress-program [findBinary xz ""] ./+CONTENTS]
     2551        }
     2552        tlz {
     2553            set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xO${qflag}f $archive_location --use-compress-program [findBinary lzma ""] ./+CONTENTS]
     2554        }
     2555        xar {
     2556            system "cd ${workpath} && [findBinary xar ${portutil::autoconf::xar_path}] -xf $archive_location +CONTENTS"
     2557            set twostep 1
     2558        }
     2559        zip {
     2560            set raw_contents [exec [findBinary unzip ${portutil::autoconf::unzip_path}] -p $archive_location +CONTENTS]
     2561        }
     2562        cpgz {
     2563            system "cd ${workpath} && [findBinary pax ${portutil::autoconf::pax_path}] -rzf $archive_location +CONTENTS"
     2564            set twostep 1
     2565        }
     2566        cpio {
     2567            system "cd ${workpath} && [findBinary pax ${portutil::autoconf::pax_path}] -rf $archive_location +CONTENTS"
     2568            set twostep 1
     2569        }
     2570    }
     2571    if {[info exists twostep]} {
     2572        set fd [open "${workpath}/+CONTENTS"]
     2573        set raw_contents [read $fd]
     2574        close $fd
     2575    }
     2576    if {$metadata_type == "contents"} {
     2577        set contents {}
     2578        set ignore 0
     2579        set sep [file separator]
     2580        foreach line [split $raw_contents \n] {
     2581            if {$ignore} {
     2582                set ignore 0
     2583                continue
     2584            }
     2585            if {[string index $line 0] != "@"} {
     2586                lappend contents "${sep}${line}"
     2587            } elseif {$line == "@ignore"} {
     2588                set ignore 1
     2589            }
     2590        }
     2591        return $contents
     2592    } elseif {$metadata_type == "portname"} {
     2593        foreach line [split $raw_contents \n] {
     2594            if {[lindex $line 0] == "@portname"} {
     2595                return [lindex $line 1]
     2596            }
     2597        }
     2598        return ""
     2599    } else {
     2600        return -code error "unknown metadata_type: $metadata_type"
     2601    }
     2602}
     2603
    25342604#
    25352605# merge function for universal builds
Note: See TracChangeset for help on using the changeset viewer.