[106617] trunk/base
jmr at macports.org
jmr at macports.org
Sat Jun 1 01:55:55 PDT 2013
Revision: 106617
https://trac.macports.org/changeset/106617
Author: jmr at macports.org
Date: 2013-06-01 01:55:55 -0700 (Sat, 01 Jun 2013)
Log Message:
-----------
bring back clean --archive since files can persist in incoming/ in some circumstances
Modified Paths:
--------------
trunk/base/doc/port.1
trunk/base/src/port/port-help.tcl
trunk/base/src/port/port.tcl
trunk/base/src/port1.0/portclean.tcl
trunk/base/src/port1.0/portinstall.tcl
trunk/base/src/port1.0/portutil.tcl
Modified: trunk/base/doc/port.1
===================================================================
--- trunk/base/doc/port.1 2013-06-01 08:06:24 UTC (rev 106616)
+++ trunk/base/doc/port.1 2013-06-01 08:55:55 UTC (rev 106617)
@@ -522,15 +522,27 @@
This is the default when no flag is given.
To remove the distribution files (tarballs, etc), specify
.Fl -dist .
-To remove the work files, distribution files and logs, pass
+To remove any archives of a port that remain in the temporary download directory, pass
+.Fl -archive .
+(This does not remove archives from the installed location.)
+To remove the log files for a port, pass
+.Fl -logs .
+To remove the work files, distribution files, temporary archives and logs, pass
.Fl -all .
-To remove log files for certain port, pass
-.Fl -logs .
For example:
.Pp
.Dl "port clean --dist vim"
.Dl "port clean --logs vim"
.Pp
+To remove only certain version(s) of a port's temporary archives (
+.Ar version
+is any valid UNIX glob pattern), you can use:
+.Pp
+.Dl "port clean --archive vim 6.2.114"
+.Pp
+or:
+.Pp
+.Dl "port clean --archive vim '6.*'"
.Ss log
Parses and shows log files for
.Ar portname .
Modified: trunk/base/src/port/port-help.tcl
===================================================================
--- trunk/base/src/port/port-help.tcl 2013-06-01 08:06:24 UTC (rev 106616)
+++ trunk/base/src/port/port-help.tcl 2013-06-01 08:55:55 UTC (rev 106617)
@@ -42,6 +42,7 @@
set porthelp(clean) {
Removes files associated with the given ports
+--archive Removes temporary archives
--dist Removes downloaded distfiles
--logs Removes log files
--work Removes work directory (default)
Modified: trunk/base/src/port/port.tcl
===================================================================
--- trunk/base/src/port/port.tcl 2013-06-01 08:06:24 UTC (rev 106616)
+++ trunk/base/src/port/port.tcl 2013-06-01 08:55:55 UTC (rev 106617)
@@ -4269,7 +4269,7 @@
install {no-rev-upgrade unrequested}
uninstall {follow-dependents follow-dependencies no-exec}
variants {index}
- clean {all dist work logs}
+ clean {all archive dist work logs}
mirror {new}
lint {nitpick}
select {list set show}
Modified: trunk/base/src/port1.0/portclean.tcl
===================================================================
--- trunk/base/src/port1.0/portclean.tcl 2013-06-01 08:06:24 UTC (rev 106616)
+++ trunk/base/src/port1.0/portclean.tcl 2013-06-01 08:55:55 UTC (rev 106617)
@@ -1,8 +1,7 @@
# -*- 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
-# portclean.tcl
# $Id$
#
-# Copyright (c) 2005-2007, 2009-2011 The MacPorts Project
+# Copyright (c) 2005-2007, 2009-2011, 2013 The MacPorts Project
# Copyright (c) 2004 Robert Shaw <rshaw at opendarwin.org>
# Copyright (c) 2002 - 2003 Apple Inc.
# All rights reserved.
@@ -61,9 +60,8 @@
}
proc portclean::clean_main {args} {
- global UI_PREFIX \
- ports_clean_dist ports_clean_work ports_clean_logs \
- ports_clean_all keeplogs usealtworkpath
+ global UI_PREFIX ports_clean_dist ports_clean_work ports_clean_logs \
+ ports_clean_archive ports_clean_all keeplogs usealtworkpath
if {$usealtworkpath} {
ui_warn "Only cleaning in ~/.macports; insufficient privileges for standard locations"
@@ -74,8 +72,16 @@
ui_info "$UI_PREFIX [format [msgcat::mc "Removing distfiles for %s"] [option subport]]"
clean_dist
}
+ if {([info exists ports_clean_all] && $ports_clean_all == "yes" || \
+ [info exists ports_clean_archive] && $ports_clean_archive == "yes")
+ && !$usealtworkpath} {
+ ui_info "$UI_PREFIX [format [msgcat::mc "Removing temporary archives for %s"] [option subport]]"
+ clean_archive
+ }
if {[info exists ports_clean_all] && $ports_clean_all == "yes" || \
[info exists ports_clean_work] && $ports_clean_work == "yes" || \
+ [info exists ports_clean_archive] && $ports_clean_archive == "yes" || \
+ [info exists ports_clean_dist] && $ports_clean_dist == "yes" || \
!([info exists ports_clean_logs] && $ports_clean_logs == "yes")} {
ui_info "$UI_PREFIX [format [msgcat::mc "Removing work directory for %s"] [option subport]]"
clean_work
@@ -259,3 +265,55 @@
}
return 0
}
+
+proc portclean::clean_archive {args} {
+ global subport ports_version_glob portdbpath
+
+ # Define archive destination directory, target filename, regex for archive name
+ set archivepath [file join $portdbpath incoming]
+
+ if {[info exists ports_version_glob]} {
+ # Match all possible archive variants that match the version
+ # glob specified by the user.
+ set fileglob "$subport-[option ports_version_glob]*.*.*.*"
+ } else {
+ # Match all possible archives for this port.
+ set fileglob "$subport-*_*.*.*.*"
+ }
+
+ # Remove the archive files
+ set count 0
+ foreach dir [list $archivepath ${archivepath}/verified] {
+ set archivelist [glob -nocomplain -directory $dir $fileglob]
+ foreach path $archivelist {
+ # Make sure file is truly an archive file for this port, and not
+ # an accidental match with some other file that might exist. Also
+ # delete anything ending in .TMP since those are incomplete and
+ # thus can't be checked and aren't useful anyway.
+ set archivetype [string range [file extension $path] 1 end]
+ if {[file isfile $path] && ($archivetype == "TMP"
+ || [extract_archive_metadata $path $archivetype portname] == $subport)} {
+ ui_debug "Removing archive: $path"
+ if {[catch {delete $path} result]} {
+ ui_debug "$::errorInfo"
+ ui_error "$result"
+ }
+ if {[file isfile ${path}.rmd160]} {
+ ui_debug "Removing archive signature: ${path}.rmd160"
+ if {[catch {delete ${path}.rmd160} result]} {
+ ui_debug "$::errorInfo"
+ ui_error "$result"
+ }
+ }
+ incr count
+ }
+ }
+ }
+ if {$count > 0} {
+ ui_debug "$count archive(s) removed."
+ } else {
+ ui_debug "No archives found to remove at $archivepath"
+ }
+
+ return 0
+}
Modified: trunk/base/src/port1.0/portinstall.tcl
===================================================================
--- trunk/base/src/port1.0/portinstall.tcl 2013-06-01 08:06:24 UTC (rev 106616)
+++ trunk/base/src/port1.0/portinstall.tcl 2013-06-01 08:55:55 UTC (rev 106617)
@@ -299,60 +299,7 @@
}
proc portinstall::extract_contents {location type} {
- set qflag ${portutil::autoconf::tar_q}
- switch -- $type {
- tbz -
- tbz2 {
- set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xOj${qflag}f $location ./+CONTENTS]
- }
- tgz {
- set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xOz${qflag}f $location ./+CONTENTS]
- }
- tar {
- set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xO${qflag}f $location ./+CONTENTS]
- }
- txz {
- set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xO${qflag}f $location --use-compress-program [findBinary xz ""] ./+CONTENTS]
- }
- tlz {
- set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xO${qflag}f $location --use-compress-program [findBinary lzma ""] ./+CONTENTS]
- }
- xar {
- system "cd ${workpath} && [findBinary xar ${portutil::autoconf::xar_path}] -xf $location +CONTENTS"
- set twostep 1
- }
- zip {
- set raw_contents [exec [findBinary unzip ${portutil::autoconf::unzip_path}] -p $location +CONTENTS]
- }
- cpgz {
- system "cd ${workpath} && [findBinary pax ${portutil::autoconf::pax_path}] -rzf $location +CONTENTS"
- set twostep 1
- }
- cpio {
- system "cd ${workpath} && [findBinary pax ${portutil::autoconf::pax_path}] -rf $location +CONTENTS"
- set twostep 1
- }
- }
- if {[info exists twostep]} {
- set fd [open "${workpath}/+CONTENTS"]
- set raw_contents [read $fd]
- close $fd
- }
- set contents {}
- set ignore 0
- set sep [file separator]
- foreach line [split $raw_contents \n] {
- if {$ignore} {
- set ignore 0
- continue
- }
- if {[string index $line 0] != "@"} {
- lappend contents "${sep}${line}"
- } elseif {$line == "@ignore"} {
- set ignore 1
- }
- }
- return $contents
+ return [extract_archive_metadata $location $type contents]
}
proc portinstall::install_main {args} {
Modified: trunk/base/src/port1.0/portutil.tcl
===================================================================
--- trunk/base/src/port1.0/portutil.tcl 2013-06-01 08:06:24 UTC (rev 106616)
+++ trunk/base/src/port1.0/portutil.tcl 2013-06-01 08:55:55 UTC (rev 106617)
@@ -2531,6 +2531,76 @@
return -code error [format [msgcat::mc "Unsupported port archive type '%s': %s"] $type $errmsg]
}
+# return the specified piece of metadata from the +CONTENTS file in the given archive
+proc extract_archive_metadata {archive_location archive_type metadata_type} {
+ set qflag ${portutil::autoconf::tar_q}
+ set raw_contents ""
+ switch -- $archive_type {
+ tbz -
+ tbz2 {
+ set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xOj${qflag}f $archive_location ./+CONTENTS]
+ }
+ tgz {
+ set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xOz${qflag}f $archive_location ./+CONTENTS]
+ }
+ tar {
+ set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xO${qflag}f $archive_location ./+CONTENTS]
+ }
+ txz {
+ set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xO${qflag}f $archive_location --use-compress-program [findBinary xz ""] ./+CONTENTS]
+ }
+ tlz {
+ set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xO${qflag}f $archive_location --use-compress-program [findBinary lzma ""] ./+CONTENTS]
+ }
+ xar {
+ system "cd ${workpath} && [findBinary xar ${portutil::autoconf::xar_path}] -xf $archive_location +CONTENTS"
+ set twostep 1
+ }
+ zip {
+ set raw_contents [exec [findBinary unzip ${portutil::autoconf::unzip_path}] -p $archive_location +CONTENTS]
+ }
+ cpgz {
+ system "cd ${workpath} && [findBinary pax ${portutil::autoconf::pax_path}] -rzf $archive_location +CONTENTS"
+ set twostep 1
+ }
+ cpio {
+ system "cd ${workpath} && [findBinary pax ${portutil::autoconf::pax_path}] -rf $archive_location +CONTENTS"
+ set twostep 1
+ }
+ }
+ if {[info exists twostep]} {
+ set fd [open "${workpath}/+CONTENTS"]
+ set raw_contents [read $fd]
+ close $fd
+ }
+ if {$metadata_type == "contents"} {
+ set contents {}
+ set ignore 0
+ set sep [file separator]
+ foreach line [split $raw_contents \n] {
+ if {$ignore} {
+ set ignore 0
+ continue
+ }
+ if {[string index $line 0] != "@"} {
+ lappend contents "${sep}${line}"
+ } elseif {$line == "@ignore"} {
+ set ignore 1
+ }
+ }
+ return $contents
+ } elseif {$metadata_type == "portname"} {
+ foreach line [split $raw_contents \n] {
+ if {[lindex $line 0] == "@portname"} {
+ return [lindex $line 1]
+ }
+ }
+ return ""
+ } else {
+ return -code error "unknown metadata_type: $metadata_type"
+ }
+}
+
#
# merge function for universal builds
#
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20130601/cf4835a9/attachment-0001.html>
More information about the macports-changes
mailing list