Skip to content

Commit

Permalink
record applied patchfiles in the statefile
Browse files Browse the repository at this point in the history
Adds a "patch: <patchfile>" line to the statefile and verify this record
before applying each subsequent patch. This is a very useful mechanism
during port maintenance when some patches have to be rebased; it allows
repeated application of `port patch` (or "higher") where only the
failing patch has to be reverted and already applied patches are skipped
automatically.
  • Loading branch information
RJVB committed Aug 13, 2024
1 parent b2e06d5 commit 48fc655
Showing 1 changed file with 19 additions and 13 deletions.
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

0 comments on commit 48fc655

Please sign in to comment.