Ticket #46927: patch-record-patches-in-statefile.diff

File patch-record-patches-in-statefile.diff, 2.4 KB (added by RJVB (René Bertin), 3 months ago)

current version of the portpatch:patch_main patch

  • src/port1.0/portpatch.tcl

    commit 2036c7c65856f491cdfbad89dad18a3ee57ad8a8
    Author: René Bertin <rjvbertin@gmail.com>
    Date:   Tue May 28 19:38:47 2024 +0200
    
        patch-record-patches-in-statefile.diff
    
    diff --git a/src/port1.0/portpatch.tcl b/src/port1.0/portpatch.tcl
    index 42dbbd227..3e61a230f 100644
    a b proc portpatch::build_getpatchtype {args} { 
    6868}
    6969
    7070proc portpatch::patch_main {args} {
    71     global UI_PREFIX
     71    global UI_PREFIX target_state_fd
    7272
    7373    # First make sure that patchfiles exists and isn't stubbed out.
    7474    if {![exists patchfiles] || [option patchfiles] eq ""} {
    proc portpatch::patch_main {args} { 
    9696    catch {set xzcat "[findBinary xz $portutil::autoconf::xz_path] -dc"}
    9797
    9898    foreach patch $patchlist {
    99         ui_info "$UI_PREFIX [format [msgcat::mc "Applying %s"] [file tail $patch]]"
    100         switch -- [file extension $patch] {
    101             .Z -
    102             .gz {command_exec patch "$gzcat \"$patch\" | (" ")"}
    103             .bz2 {command_exec patch "$bzcat \"$patch\" | (" ")"}
    104             .xz {
    105                 if {[info exists xzcat]} {
    106                     command_exec patch "$xzcat \"$patch\" | (" ")"
    107                 } else {
    108                     return -code error [msgcat::mc "xz binary not found; port needs to add 'depends_patch bin:xz:xz'"]
    109                 }}
    110             default {command_exec patch "" "< '$patch'"}
     99        set pfile [file tail $patch]
     100        if {![check_statefile patch $pfile $target_state_fd]} {
     101            ui_info "$UI_PREFIX [format [msgcat::mc "Applying %s"] [file tail $patch]]"
     102            switch -- [file extension $patch] {
     103                .Z -
     104                .gz {command_exec patch "$gzcat \"$patch\" | (" ")"}
     105                .bz2 {command_exec patch "$bzcat \"$patch\" | (" ")"}
     106                .xz {
     107                    if {[info exists xzcat]} {
     108                        command_exec patch "$xzcat \"$patch\" | (" ")"
     109                    } else {
     110                        return -code error [msgcat::mc "xz binary not found; port needs to add 'depends_patch bin:xz:xz'"]
     111                    }}
     112                default {command_exec patch "" "< '$patch'"}
     113            }
     114            write_statefile patch $pfile $target_state_fd
     115        } else {
     116            ui_info "$UI_PREFIX [format [msgcat::mc "Skipping already applied %s"] $pfile]"
    111117        }
    112118    }
    113119    return 0