[MacPorts] #8794: request for review: adding file autodetection to portextract.tcl

MacPorts noreply at macports.org
Thu Mar 24 06:14:42 PDT 2016


#8794: request for review: adding file autodetection to portextract.tcl
--------------------------+--------------------------------
  Reporter:  erickt@…     |      Owner:  macports-tickets@…
      Type:  enhancement  |     Status:  closed
  Priority:  Normal       |  Milestone:
 Component:  base         |    Version:  1.2
Resolution:  wontfix      |   Keywords:
      Port:               |
--------------------------+--------------------------------
Description changed by ryandesign@…:

Old 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"
> >           }
> >       }
> >

New 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"
 >           }
 >       }
 >
 }}}

--

-- 
Ticket URL: <https://trac.macports.org/ticket/8794#comment:6>
MacPorts <https://www.macports.org/>
Ports system for OS X


More information about the macports-tickets mailing list