Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 19 additions & 13 deletions src/port1.0/portpatch.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ proc portpatch::build_getpatchtype {args} {
}

proc portpatch::patch_main {args} {
global UI_PREFIX
global UI_PREFIX target_state_fd

# First make sure that patchfiles exists and isn't stubbed out.
if {![exists patchfiles] || [option patchfiles] eq ""} {
Expand Down Expand Up @@ -96,18 +96,24 @@ proc portpatch::patch_main {args} {
catch {set xzcat "[findBinary xz $portutil::autoconf::xz_path] -dc"}

foreach patch $patchlist {
ui_info "$UI_PREFIX [format [msgcat::mc "Applying %s"] [file tail $patch]]"
switch -- [file extension $patch] {
.Z -
.gz {command_exec patch "$gzcat \"$patch\" | (" ")"}
.bz2 {command_exec patch "$bzcat \"$patch\" | (" ")"}
.xz {
if {[info exists xzcat]} {
command_exec patch "$xzcat \"$patch\" | (" ")"
} else {
return -code error [msgcat::mc "xz binary not found; port needs to add 'depends_patch bin:xz:xz'"]
}}
default {command_exec patch "" "< '$patch'"}
set pfile [file tail $patch]
if {![check_statefile patch $pfile $target_state_fd]} {
ui_info "$UI_PREFIX [format [msgcat::mc "Applying %s"] [file tail $patch]]"
switch -- [file extension $patch] {
.Z -
.gz {command_exec patch "$gzcat \"$patch\" | (" ")"}
.bz2 {command_exec patch "$bzcat \"$patch\" | (" ")"}
.xz {
if {[info exists xzcat]} {
command_exec patch "$xzcat \"$patch\" | (" ")"
} else {
return -code error [msgcat::mc "xz binary not found; port needs to add 'depends_patch bin:xz:xz'"]
}}
default {command_exec patch "" "< '$patch'"}
}
write_statefile patch $pfile $target_state_fd
} else {
ui_info "$UI_PREFIX [format [msgcat::mc "Skipping already applied %s"] $pfile]"
}
}
return 0
Expand Down
12 changes: 10 additions & 2 deletions src/port1.0/portutil.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -1878,7 +1878,11 @@ proc get_statefile_value {class fd result} {

# check_statefile
# Check completed/selected state of target/variant $name
proc check_statefile {class name fd} {
proc check_statefile {class name {fd {}}} {
global target_state_fd
if {$fd eq {} && [info exists target_state_fd]} {
set fd $target_state_fd
}
seek $fd 0
while {[gets $fd line] >= 0} {
if {$line eq "$class: $name"} {
Expand All @@ -1890,7 +1894,11 @@ proc check_statefile {class name fd} {

# write_statefile
# Set target $name completed in the state file
proc write_statefile {class name fd} {
proc write_statefile {class name {fd {}}} {
global target_state_fd
if {$fd eq {} && [info exists target_state_fd]} {
set fd $target_state_fd
}
if {[check_statefile $class $name $fd]} {
return 0
}
Expand Down