Skip to content

Commit

Permalink
Introduce extract.rename_filter
Browse files Browse the repository at this point in the history
The idea is allow to use `extract.rename yes` for a `Portfile` which
downloads multiple artifacts from different sources by suggesting the
filter which should be used to detect main artifact name.

Example of Portfile which required it `retdec`.
  • Loading branch information
catap committed Apr 24, 2023
1 parent 5643919 commit b91ce17
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/port1.0/portextract.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace eval portextract {
}

# define options
options extract.only extract.mkdir extract.rename extract.asroot
options extract.only extract.mkdir extract.rename extract.rename_filter extract.asroot
commands extract

# Set up defaults
Expand All @@ -58,6 +58,7 @@ default extract.pre_args -dc
default extract.post_args {| ${portutil::autoconf::tar_command} -xf -}
default extract.mkdir no
default extract.rename no
default extract.rename_filter {*}

set_ui_prefix

Expand Down Expand Up @@ -159,9 +160,10 @@ proc portextract::extract_main {args} {
}

if {[option extract.rename] && ![file exists [option worksrcpath]]} {
global workpath distname
global workpath distname extract.rename_filter
# rename whatever directory exists in $workpath to $distname
set worksubdirs [glob -nocomplain -types d -directory $workpath *]
ui_debug [format [msgcat::mc "extract.rename: using filter '%s'"] ${extract.rename_filter}]
set worksubdirs [glob -nocomplain -types d -directory $workpath ${extract.rename_filter}]
if {[llength $worksubdirs] == 1} {
set origpath [lindex $worksubdirs 0]
set newpath [file join $workpath $distname]
Expand Down

0 comments on commit b91ce17

Please sign in to comment.