Opened 18 years ago

Last modified 8 years ago

#8794 closed enhancement

request for review: adding file autodetection to portextract.tcl — at Initial Version

Reported by: erickt@… Owned by: macports-tickets@…
Priority: Normal Milestone:
Component: base Version: 1.2
Keywords: Cc:
Port:

Description

I ran into a case where a file had both tar.bz2 and tar.gz files (vim 7). I discovered that it's a bit obnoxious trying to get darwinports to extract both types of files at the same time. So, I added file autodetection to the extraction code. Since I'm a new committer, I don't want to go right ahead to make changes. So, could someone check my patch? It should be backwards compatible. Thanks!

-e

Index: portextract.tcl =================================================================== RCS file: /Volumes/src/cvs/od/proj/darwinports/base/src/port1.0/portextract.tcl,v retrieving revision 1.41 diff -r1.41 portextract.tcl 43c43 < options extract.only ---

options extract.only

45a46,47

default extract.autodetect yes

52,54c54 < default extract.cmd gzip < default extract.pre_args -dc < default extract.post_args {"| ${portutil::autoconf::tar_command} -xf -"} ---

default extract.cmd ""

59c59 < global extract.only extract.dir extract.cmd extract.pre_args extract.post_args distfiles use_bzip2 use_zip workpath ---

global extract.autodetect extract.only extract.dir extract.cmd extract.pre_args extract.post_args distfiles use_bzip2 use_zip workpath

61,66c61,75 < if {[tbool use_bzip2]} { < option extract.cmd [binaryInPath "bzip2"] < } elseif {[tbool use_zip]} { < option extract.cmd [binaryInPath "unzip"] < option extract.pre_args -q < option extract.post_args "-d [option extract.dir]" ---

# if we specified an extraction command, assume we don't want autodetection

if {[option extract.autodetect] != "yes"
[option extract.cmd] != ""} {

option extract.autodetect "no"

if {[tbool use_bzip2]} {

option extract.cmd [binaryInPath "bzip2"]

} elseif {[tbool use_zip]} {

option extract.cmd [binaryInPath "unzip"] option extract.pre_args -q option extract.post_args "-d [option extract.dir]"

} else {

option extract.cmd [binaryInPath "gzip"] option extract.pre_args -dc option extract.post_args {"| ${portutil::autoconf::tar_command} -xf -"}

}

77c86 < global UI_PREFIX ---

global UI_PREFIX

85a95,118

if {[option extract.autodetect] == "yes"} {

option extract.pre_args "" option extract.post_args ""

if {[regexp {(\.tgz)|(\.tar\.gz)$} $distfile]} {

option extract.cmd $portutil::autoconf::tar_command option extract.pre_args -zxf

} elseif {[regexp {\.tar\.bz2$} $distfile]} {

option extract.cmd $portutil::autoconf::tar_command option extract.pre_args -jxf

} elseif {[string equal -nocase [file extension $distfile] ".zip"]} {

option extract.cmd [binaryInPath "zip"] option extract.pre_args -q option extract.post_args "-d [option extract.dir]"

} elseif {[string equal -nocase [file extension $distfile] ".gz"]} {

option extract.cmd [binaryInPath "gzip"] option extract.pre_args -dc option extract.post_args " > [option extract.dir]/[string range $distfile 0 end-3]"

} else {

return -code error "unknown file type: $distfile"

}

}

Change History (0)

Note: See TracTickets for help on using tickets.