diff --git a/src/make.tcl b/src/make.tcl index 1ce41557..1154c2a2 100644 --- a/src/make.tcl +++ b/src/make.tcl @@ -134,6 +134,7 @@ foreach pkg $::punkmake::pkg_requirements { + proc punkmake_gethelp {args} { set scriptname [file tail [info script]] append h "Usage:" \n @@ -305,6 +306,61 @@ if {[file exists $sourcefolder/vendormodules]} { puts stderr "NOTE: No src/vendormodules folder found." } +######################################################## +#templates +#e.g The default project layout is mainly folder structure and readme files - but has some scripts developed under the main src that we want to sync +#src to src/modules/punk/mix/templates/layouts/project/src + + set templatebase $sourcefolder/modules/punk/mix/templates + set config [dict create\ + -make-step sync_templates\ + ] + #---------- + set tpl_installer [punkcheck::installtrack new make.tcl $templatebase/.punkcheck] + $tpl_installer set_source_target $sourcefolder $templatebase + set tpl_event [$tpl_installer start_event $config] + #---------- + set pairs [list] + set pairs [list\ + [list $sourcefolder/build.tcl $templatebase/layouts/project/src/build.tcl]\ + [list $sourcefolder/make.tcl $templatebase/layouts/project/src/make.tcl]\ + ] + + foreach filepair $pairs { + lassign $filepair srcfile tgtfile + #---------- + $tpl_event targetset_init INSTALL $tgtfile + $tpl_event targetset_addsource $srcfile + #---------- + if {\ + [llength [dict get [$tpl_event targetset_source_changes] changed]]\ + || [llength [$tpl_event get_targets_exist]] < [llength [$tpl_event get_targets]]\ + } { + $tpl_event targetset_started + # -- --- --- --- --- --- + puts stdout "punk module templates: Copying from $srcfile to $tgtfile" + if {[catch { + file copy -force $srcfile $tgtfile + } errM]} { + $tpl_event targetset_end FAILED -note "copy failed with err: $errM" + } else { + $tpl_event targetset_end OK -note "test" + } + # -- --- --- --- --- --- + } else { + puts stderr "." + $tpl_event targetset_end SKIPPED + } + } + + $tpl_event end + $tpl_event destroy + $tpl_installer destroy +######################################################## + + + + #default source module folder is at projectroot/src/modules #There may be multiple other src module folders at same level (e.g folder not being other special-purpose folder and not matching name vendor* that contains at least one .tm file in its root) set source_module_folderlist [punk::mix::cli::lib::find_source_module_paths $projectroot] @@ -458,14 +514,17 @@ foreach runtimefile $runtimes { $event targetset_started # -- --- --- --- --- --- puts stdout "Copying runtime from $rtfolder/$runtimefile to $buildfolder/build_$runtimefile" - file copy -force $rtfolder/$runtimefile $buildfolder/build_$runtimefile + if {[catch { + file copy -force $rtfolder/$runtimefile $buildfolder/build_$runtimefile + } errM]} { + $event targetset_end FAILED + } else { + $event targetset_end OK + } # -- --- --- --- --- --- - #set file_record [punkcheck::installfile_finished_install $basedir $file_record] - $event targetset_finished } else { puts stderr "." - #set file_record [punkcheck::installfile_skipped_install $basedir $file_record] - $event targetset_skipped + $event targetset_end SKIPPED } $event end @@ -541,21 +600,20 @@ foreach vfs $vfs_folders { set targetexe ${vfsname}_$rtname } lappend exe_names_seen $targetexe - - lassign [punkcheck::start_installer_event $basedir/.punkcheck $installername $sourcefolder $buildfolder $config] _eventid punkcheck_eventid _recordset record_list - set target_relpath [punkcheck::lib::path_relative $basedir $buildfolder/$targetexe] - set file_record [punkcheck::installfile_begin $basedir $target_relpath $installername -eventid $punkcheck_eventid] - # -- --- --- --- --- --- - set source_relpath [punkcheck::lib::path_relative $basedir $sourcefolder/$vfs] - set file_record [punkcheck::installfile_add_source_and_fetch_metadata $basedir $source_relpath $file_record] - # -- --- --- --- --- --- - set source_relpath [punkcheck::lib::path_relative $basedir $buildfolder/build_$rtname] - set file_record [punkcheck::installfile_add_source_and_fetch_metadata $basedir $source_relpath $file_record] - # -- --- --- --- --- --- - set changed_unchanged [punkcheck::recordlist::file_install_record_source_changes [lindex [dict get $file_record body] end]] - if {[llength [dict get $changed_unchanged changed]] || ![file exists $buildfolder/$targetexe]} { + # -- ---------- + set vfs_installer [punkcheck::installtrack new $installername $basedir/.punkcheck] + $vfs_installer set_source_target $sourcefolder $buildfolder + set vfs_event [$vfs_installer start_event {-make-step build_vfs}] + $vfs_event targetset_init INSTALL $buildfolder/$targetexe + $vfs_event targetset_addsource $sourcefolder/$vfs + $vfs_event targetset_addsource $buildfolder/build_$rtname + # -- ---------- + + set changed_unchanged [$vfs_event targetset_source_changes] + + if {[llength [dict get $changed_unchanged changed]] || [llength [$vfs_event get_targets_exist]] < [llength [$vfs_event get_targets]]} { #source .vfs folder has changes - set file_record [punkcheck::installfile_started_install $basedir $file_record] + $vfs_event targetset_started # -- --- --- --- --- --- #use @@ -580,7 +638,8 @@ foreach vfs $vfs_folders { } if {![file exists $buildfolder/$vfsname.new]} { - puts stderr "|err> build didn't seem to produce output at $sourcefolder/_build/$vfsname.new" + puts stderr "|err> make.tcl build didn't seem to produce output at $sourcefolder/_build/$vfsname.new" + $vfs_event targetset_end FAILED exit 2 } @@ -650,7 +709,7 @@ foreach vfs $vfs_folders { #This is probably harmless - but worth being aware of. file rename $buildfolder/$vfsname.new $buildfolder/$targetexe # -- --- --- --- --- --- - set file_record [punkcheck::installfile_finished_install $basedir $file_record] + $vfs_event targetset_end OK after 200 @@ -658,12 +717,12 @@ foreach vfs $vfs_folders { file mkdir $deployment_folder # -- ---------- - set installer [punkcheck::installtrack new "make.tcl" $deployment_folder/.punkcheck] - $installer set_source_target $buildfolder $deployment_folder - set event [$installer start_event {-make-step final_exe_install}] - $event targetset_init INSTALL $deployment_folder/$targetexe - $event targetset_addsource $buildfolder/$targetexe - $event targetset_started + set bin_installer [punkcheck::installtrack new "make.tcl" $deployment_folder/.punkcheck] + $bin_installer set_source_target $buildfolder $deployment_folder + set bin_event [$bin_installer start_event {-make-step final_exe_install}] + $bin_event targetset_init INSTALL $deployment_folder/$targetexe + $bin_event targetset_addsource $buildfolder/$targetexe + $bin_event targetset_started # -- ---------- @@ -686,19 +745,22 @@ foreach vfs $vfs_folders { after 300 file copy $buildfolder/$targetexe $deployment_folder/$targetexe # -- ---------- - $event targetset_finished + $bin_event targetset_end OK # -- ---------- } else { - #todo - targetset_failed - $event targetset_skipped + $bin_event targetset_end FAILED } + $bin_event destroy + $bin_installer destroy } else { set skipped_vfs_build 1 puts stderr "." puts stdout "Skipping build for vfs $vfs - no change detected" - set file_record [punkcheck::installfile_skipped_install $basedir $file_record] + $vfs_event targetset_end SKIPPED } + $vfs_event destroy + $vfs_installer destroy } ;#end foreach rtname in runtimes # -- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- } diff --git a/src/modules/punkcheck-0.1.0.tm b/src/modules/punkcheck-0.1.0.tm index 80607768..5c9c322d 100644 --- a/src/modules/punkcheck-0.1.0.tm +++ b/src/modules/punkcheck-0.1.0.tm @@ -95,7 +95,7 @@ namespace eval punkcheck { if {$objname ni [info commands $objname]} { package require oolib - #FILEINFO record - target fileset with body records: INSTALLRECORD,INSTALL-INPROGRESS,SKIPPED,DELETERECORD,DELETE-INPROGRESS,MODIFY-INPROGRESS,MODIFYRECORD + #FILEINFO record - target fileset with body records: INSTALL-RECORD,INSTALL-INPROGRESS,INSTALL-SKIPPED,DELETE-RECORD,DELETE-INPROGRESS,MODIFY-INPROGRESS,MODIFY-RECORD #each FILEINFO body being a list of SOURCE records oo::class create targetset { variable o_targets @@ -126,10 +126,10 @@ namespace eval punkcheck { method get_last_record {fileset_record} { set body [dict_getwithdefault $fileset_record body [list]] set previous_records [lrange $body 0 end-1] - #get last previous that is tagged INSTALLRECORD,MODIFYRECORD,DELETERECORD + #get last previous that is tagged INSTALL-RECORD,MODIFY-RECORD,DELETE-RECORD set revlist [lreverse $previous_records] foreach rec $revlist { - if {[dict get $rec tag] in [list "INSTALLRECORD" "MODIFYRECORD" "DELETERECORD"]} { + if {[dict get $rec tag] in [list "INSTALL-RECORD" "MODIFY-RECORD" "DELETE-RECORD" "VIRTUAL-RECORD"]} { return $rec } } @@ -180,7 +180,7 @@ namespace eval punkcheck { set o_rel_targetroot $rel_targetroot } destructor { - puts "[self] destructor called" + #puts "[self] destructor called" } method as_record {} { set begin_seconds [expr {$o_ts_begin / 1000000}] @@ -218,7 +218,7 @@ namespace eval punkcheck { set punkcheck_folder [file dirname [$o_installer get_checkfile]] set existing [list] foreach t $o_targets { - if {[file exists [file join $puncheck_folder $t]]} { + if {[file exists [file join $punkcheck_folder $t]]} { lappend existing $t } } @@ -276,7 +276,7 @@ namespace eval punkcheck { set oldposition [dict get $extractioninfo oldposition] unset extractioninfo - #INSTALL-INPROGRESS will become INSTALLRECORD or INSTALLFAILED or SKIPPED upon finalisation + #INSTALL-INPROGRESS will become INSTALL-RECORD or INSTALL-FAILED or INSTALL-SKIPPED upon finalisation #-installer and -eventid keys are added here set new_inprogress_record [dict create tag [string toupper $operation]-INPROGRESS {*}$fields -tempcontext [my as_record] body {}] #set existing_body [dict_getwithdefault $o_fileset_record body [list]] @@ -298,42 +298,55 @@ namespace eval punkcheck { set punkcheck_folder [file dirname [$o_installer get_checkfile]] set o_fileset_record [punkcheck::installfile_started_install $punkcheck_folder $o_fileset_record] } - method targetset_finished {} { - if {$o_operation_start_ts eq ""} { - error "[self] targetset_finished - no current operation - call targetset_start first" + method targetset_end {status args} { + set defaults [dict create\ + -note \uFFFF\ + ] + set known_opts [dict keys $defaults] + if {[llength $args] % 2 != 0} { + error "targetset_end arguments after status must be in the form of -flag value pairs. known flags: $known_opts" + } + set opts [dict merge $defaults $args] + if {[dict get $opts -note] eq "\uFFFF"} { + dict unset opts -note } - set operation_end_ts [clock microseconds] - set elapsed [expr {$o_operation_start_ts - $operation_end_ts}] - - set punkcheck_file [$o_installer get_checkfile] - set record_list [punkcheck::load_records_from_file $punkcheck_file] - + set status [string toupper $status] + set statusdict [dict create OK RECORD SKIPPED SKIPPED FAILED FAILED] + if {$o_operation_start_ts eq ""} { + error "[self] targetset_end $status - no current operation - call targetset_started first" + } + if {$status ni [dict keys $statusdict]} { + error "[self] targetset_end unrecognized status:$status known values: [dict keys $statusdict]" + } if {![punkcheck::lib::is_file_record_inprogress $o_fileset_record]} { - error "targetset_finished_install error: bad fileset_record - expected FILEINFO with last body element *-INPROGRESS" + error "targetset_end $status error: bad fileset_record - expected FILEINFO with last body element *-INPROGRESS" } - - set file_record_body [dict get $o_fileset_record body] set targetlist [dict get $o_fileset_record -targets] if {$targetlist ne $o_targets} { - error "targetset_finished error. targetlist mismatch between file : $targetlist vs $o_targets" + error "targetset_end $status error. targetlist mismatch between file : $targetlist vs $o_targets" } + set operation_end_ts [clock microseconds] + set elapsed_us [expr {$operation_end_ts - $o_operation_start_ts}] + set file_record_body [dict get $o_fileset_record body] set installing_record [lindex $file_record_body end] + set punkcheck_file [$o_installer get_checkfile] + set record_list [punkcheck::load_records_from_file $punkcheck_file] + if {[dict exists $installing_record -ts_start_transfer]} { + set ts_start_transfer [dict get $installing_record -ts_start_transfer] + set transfer_us [expr {$operation_end_ts - $ts_start_transfer}] + dict set installing_record -transfer_us $transfer_us + } + if {[dict exists $opts -note]} { + dict set installing_record -note [dict get $opts -note] + } - set ts_start [dict get $installing_record -ts] - set ts_start_transfer [dict get $installing_record -ts_start_transfer] - set ts_now [clock microseconds] - set elapsed_us [expr {$ts_now - $ts_start}] - set transfer_us [expr {$ts_now - $ts_start_transfer}] - dict set installing_record -transfer_us $transfer_us dict set installing_record -elapsed_us $elapsed_us dict unset installing_record -tempcontext - dict set installing_record tag "${o_operation}RECORD" - + dict set installing_record tag "${o_operation}-[dict get $statusdict $status]" ;# e.g INSTALL-RECORD, INSTALL-SKIPPED lset file_record_body end $installing_record dict set o_fileset_record body $file_record_body - set o_fileset_record [punkcheck::recordlist::file_record_prune $o_fileset_record] set oldrecordinfo [punkcheck::recordlist::get_file_record $targetlist $record_list] @@ -343,56 +356,10 @@ namespace eval punkcheck { } else { lset record_list $old_posn $o_fileset_record } - punkcheck::save_records_to_file $record_list $punkcheck_file set o_operation_start_ts "" set o_operation "" return $o_fileset_record - - } - method targetset_skipped {} { - if {$o_operation_start_ts eq ""} { - error "[self] targetset_skipped - no current operation - call targetset_start first" - } - set operation_end_ts [clock microseconds] - set elapsed [expr {$o_operation_start_ts - $operation_end_ts}] - set o_operation_start_ts "" - set o_operation "" - if {![punkcheck::lib::is_file_record_inprogress $o_fileset_record]} { - set msg "targetset_skipped_install error: bad fileset_record - expected FILEINFO with last body element *-INPROGRESS" - append msg \n "received:" - append msg \n $o_fileset_record - error $msg - } - set punkcheck_file [$o_installer get_checkfile] - set record_list [punkcheck::load_records_from_file $punkcheck_file] - - set file_record_body [dict get $o_fileset_record body] - set targetlist [dict get $o_fileset_record -targets] - set inprogress_record [lindex $file_record_body end] - - set ts_start [dict get $inprogress_record -ts] - set tsnow [clock microseconds] - set elapsed_us [expr {$tsnow - $ts_start}] - dict set inprogress_record -elapsed_us $elapsed_us - dict set inprogress_record tag "SKIPPED" - - lset file_record_body end $inprogress_record - dict set o_fileset_record body $file_record_body - - set o_fileset_record [punkcheck::recordlist::file_record_prune $o_fileset_record] - - set getresult [punkcheck::recordlist::get_file_record $targetlist $record_list] - set old_posn [dict get $getresult position] - if {$old_posn == -1} { - lappend record_list $o_fileset_record - } else { - lset record_list $old_posn $o_fileset_record - } - - punkcheck::save_records_to_file $record_list $punkcheck_file - return $o_fileset_record - } method targetset_addsource {source_path} { set punkcheck_file [$o_installer get_checkfile] @@ -464,7 +431,7 @@ namespace eval punkcheck { } destructor { - puts "[self] destructor called" + #puts "[self] destructor called" } method test {} { return [self] @@ -701,7 +668,7 @@ namespace eval punkcheck { set oldposition [dict get $extractioninfo oldposition] unset extractioninfo - #INSTALL-INPROGRESS will become INSTALLRECORD or INSTALLFAILED or SKIPPED upon finalisation + #INSTALL-INPROGRESS will become INSTALL-RECORD or INSTALL-FAILED or INSTALL-SKIPPED upon finalisation #-installer and -eventid keys are added here set new_installing_record [dict create tag INSTALL-INPROGRESS {*}$opts -tempcontext $active_event body {}] #set existing_body [dict_getwithdefault $file_record body [list]] @@ -728,6 +695,7 @@ namespace eval punkcheck { set ts_start [clock microseconds] set last_installrecord [lib::file_record_get_last_installrecord $file_record] set prev_ftype "" + set prev_fsize "" set prev_cksum "" set prev_cksum_opts "" if {[llength $last_installrecord]} { @@ -735,6 +703,7 @@ namespace eval punkcheck { if {[llength $src]} { if {[dict_getwithdefault $src -path ""] eq $source_relpath} { set prev_ftype [dict_getwithdefault $src -type ""] + set prev_fsize [dict_getwithdefault $src -size ""] set prev_cksum [dict_getwithdefault $src -cksum ""] set prev_cksum_opts [dict_getwithdefault $src -cksum_all_opts ""] } @@ -753,14 +722,24 @@ namespace eval punkcheck { } else { set cksum_opts "" } - - set ftype [file type [file join $punkcheck_folder/$source_relpath]] - if {$ftype eq "directory"} { + #allow nonexistant as a source + set fpath [file join $punkcheck_folder $source_relpath] + if {![file exists $fpath]} { + set ftype "missing" + set fsize "" + #get_relativecksum_from_base will set cksum to set source_cksum_info [punk::mix::base::lib::get_relativecksum_from_base $punkcheck_folder $source_relpath {*}$cksum_opts] } else { - #todo - optionally use mtime instead of cksum (for files only)? - #mtime is not reliable across platforms and filesystems though.. see article linked at toop. - set source_cksum_info [punk::mix::base::lib::get_relativecksum_from_base $punkcheck_folder $source_relpath {*}$cksum_opts] + set ftype [file type $fpath] + if {$ftype eq "directory"} { + set source_cksum_info [punk::mix::base::lib::get_relativecksum_from_base $punkcheck_folder $source_relpath {*}$cksum_opts] + set fsize "NA" + } else { + #todo - optionally use mtime instead of cksum (for files only)? + #mtime is not reliable across platforms and filesystems though.. see article linked at toop. + set source_cksum_info [punk::mix::base::lib::get_relativecksum_from_base $punkcheck_folder $source_relpath {*}$cksum_opts] + set fsize [file size $fpath] + } } @@ -770,7 +749,7 @@ namespace eval punkcheck { } set cksum [dict get $ckinfo cksum] set cksum_all_opts [dict get $ckinfo cksum_all_opts] - if {$cksum ne $prev_cksum || $ftype ne $prev_ftype} { + if {$cksum ne $prev_cksum || $ftype ne $prev_ftype || $fsize ne $prev_fsize} { set changed 1 } else { set changed 0 @@ -778,7 +757,7 @@ namespace eval punkcheck { set installing_record_sources [dict_getwithdefault $installing_record body [list]] set ts_now [clock microseconds] ;#gathering metadata - especially checsums on folder can take some time - calc and store elapsed us for time taken to gather metadata set metadata_us [expr {$ts_now - $ts_start}] - set this_source_record [dict create tag SOURCE -type $ftype -path $source_relpath -cksum $cksum -cksum_all_opts $cksum_all_opts -changed $changed -metadata_us $metadata_us] + set this_source_record [dict create tag SOURCE -type $ftype -size $fsize -path $source_relpath -cksum $cksum -cksum_all_opts $cksum_all_opts -changed $changed -metadata_us $metadata_us] lappend installing_record_sources $this_source_record dict set installing_record body $installing_record_sources @@ -842,7 +821,7 @@ namespace eval punkcheck { dict set installing_record -transfer_us $transfer_us dict set installing_record -elapsed_us $elapsed_us dict unset installing_record -tempcontext - dict set installing_record tag "INSTALLRECORD" + dict set installing_record tag "INSTALL-RECORD" lset file_record_body end $installing_record dict set file_record body $file_record_body @@ -916,7 +895,7 @@ namespace eval punkcheck { return 0 } set installing_record [lindex [dict_getwithdefault $file_record body [list]] end] - if {[dict_getwithdefault $installing_record tag [list]] ne "INSTALLING"} { + if {[dict_getwithdefault $installing_record tag [list]] ne "INSTALL-INPROGRESS"} { return 0 } return 1 @@ -924,11 +903,11 @@ namespace eval punkcheck { proc file_record_get_last_installrecord {file_record} { set body [dict_getwithdefault $file_record body [list]] set previous_install_records [lrange $body 0 end-1] - #get last previous that is tagged INSTALLRECORD,MODIFYRECORD,VIRTUALRECORD + #get last previous that is tagged INSTALL-RECORD,MODIFY-RECORD,VIRTUAL-RECORD #REVIEW DELETERECORD ??? set revlist [lreverse $previous_install_records] foreach rec $revlist { - if {[dict get $rec tag] in [list "INSTALLRECORD" "MODIFYRECORD" "VIRTUALRECORD"]} { + if {[dict get $rec tag] in [list "INSTALL-RECORD" "MODIFY-RECORD" "VIRTUAL-RECORD"]} { return $rec } } @@ -1328,14 +1307,14 @@ namespace eval punkcheck { #sample .punkcheck file record (raw form) to make the code clearer #punk::tdl converts to dict form e.g: tag FILEINFO -targets filename body sublist - #Valid installrecord types are INSTALLRECORD SKIPPED INSTALL-INPROGRESS, MODIFYRECORD MODIFY-INPROGRESS DELETERECORD DELETE-INPROGRESS + #Valid installrecord types are INSTALL-RECORD SKIPPED INSTALL-INPROGRESS, MODIFY-RECORD MODIFY-INPROGRESS DELETE-RECORD DELETE-INPROGRESS # #FILEINFO -targets jjjetc-0.1.0.tm -keep_installrecords 2 -keep_skipped 1 -keep_inprogress 2 { - # INSTALLRECORD -tsiso 2023-09-20T07:30:30 -ts 1695159030266610 -installer punk::mix::cli::build_modules_from_source_to_base -metadata_us 18426 -ts_start_transfer 1695159030285036 -transfer_us 10194 -elapsed_us 28620 { + # INSTALL-RECORD -tsiso 2023-09-20T07:30:30 -ts 1695159030266610 -installer punk::mix::cli::build_modules_from_source_to_base -metadata_us 18426 -ts_start_transfer 1695159030285036 -transfer_us 10194 -elapsed_us 28620 { # SOURCE -type file -path ../src/modules/jjjetc-buildversion.txt -cksum c7c71839c36b3d21c8370fed106192fcd659eca9 -cksum_all_opts {-cksum_content 1 -cksum_meta 0 -cksum_acls 0 -cksum_usetar 0 -cksum_algorithm sha1} -changed 1 -metadata_us 3423 # SOURCE -type file -path ../src/modules/jjjetc-999999.0a1.0.tm -cksum b646fc2ee88cbd068d2e946fe929b7aea96bd39d -cksum_all_opts {-cksum_content 1 -cksum_meta 0 -cksum_acls 0 -cksum_usetar 0 -cksum_algorithm sha1} -changed 1 -metadata_us 3413 # } - # SKIPPED -tsiso 2023-09-20T08:14:26 -ts 1695161666087880 -installer punk::mix::cli::build_modules_from_source_to_base -elapsed_us 18914 { + # INSTALL-SKIPPED -tsiso 2023-09-20T08:14:26 -ts 1695161666087880 -installer punk::mix::cli::build_modules_from_source_to_base -elapsed_us 18914 { # SOURCE -type file -path ../src/modules/jjjetc-buildversion.txt -cksum c7c71839c36b3d21c8370fed106192fcd659eca9 -cksum_all_opts {-cksum_content 1 -cksum_meta 0 -cksum_acls 0 -cksum_usetar 0 -cksum_algorithm sha1} -changed 0 -metadata_us 3435 # SOURCE -type file -path ../src/modules/jjjetc-999999.0a1.0.tm -cksum b646fc2ee88cbd068d2e946fe929b7aea96bd39d -cksum_all_opts {-cksum_content 1 -cksum_meta 0 -cksum_acls 0 -cksum_usetar 0 -cksum_algorithm sha1} -changed 0 -metadata_us 3338 # } @@ -1444,11 +1423,11 @@ namespace eval punkcheck { set install_records [dict get $filerec body] set current_install_record [lindex $install_records end] - #change the tag from *-INPROGRESS to INSTALLRECORD/SKIPPED + #change the tag from *-INPROGRESS to INSTALL-RECORD/SKIPPED if {$is_skip} { - set tag SKIPPED + set tag INSTALL-SKIPPED } else { - set tag INSTALLRECORD + set tag INSTALL-RECORD } dict set current_install_record tag $tag dict set current_install_record -elapsed_us $elapsed_us @@ -1579,8 +1558,8 @@ namespace eval punkcheck { } proc file_install_record_source_changes {install_record} { #reject INSTALLFAILED items ? - if {[dict get $install_record tag] ni [list "INSTALLRECORD" "SKIPPED" "INSTALL-INPROGRESS" "MODIFY-INPROGRESS" "MODIFYRECORD" "VIRTUAL-INPROGRESS" "VIRTUALRECORD" "DELETERECORD" "DELETE-INPROGRESS"]} { - error "file_install_record_source_changes bad file->install record: tag not INSTALLRECORD|SKIPPED|INSTALL-INPROGRESS|MODIFYRECORD|MODIFY-INPROGRESS|VIRTUALRECORD|VIRTUAL-INPROGRESS|DELETERECORD|DELETE-INPROGRESS" + if {[dict get $install_record tag] ni [list "INSTALL-RECORD" "SKIPPED" "INSTALL-INPROGRESS" "MODIFY-INPROGRESS" "MODIFY-RECORD" "VIRTUAL-INPROGRESS" "VIRTUAL-RECORD" "DELETE-RECORD" "DELETE-INPROGRESS"]} { + error "file_install_record_source_changes bad file->install record: tag not INSTALL-RECORD|SKIPPED|INSTALL-INPROGRESS|MODIFY-RECORD|MODIFY-INPROGRESS|VIRTUAL-RECORD|VIRTUAL-INPROGRESS|DELETE-RECORD|DELETE-INPROGRESS" } set source_list [dict_getwithdefault $install_record body [list]] set changed [list] @@ -1739,19 +1718,22 @@ namespace eval punkcheck { } set body_items [dict get $file_record body] foreach item [lreverse $body_items] { - if {[dict get $item tag] eq "INSTALLRECORD"} { + if {[dict get $item tag] eq "INSTALL-RECORD"} { return $item } } return [list] } - proc file_record_add_installrecord {file_record install_record} { + + + #dead code? + proc file_record_add_installrecordXXX {file_record install_record} { if {[dict get $file_record tag] ne "FILEINFO"} { error "file_record_add_installrecord bad file_record: tag not FILEINFO" } #disallow '-INPROGRESS' as it's not a final tag - if {[dict get $install_record tag] ni [list "INSTALLRECORD" "SKIPPED"]} { - error "file_record_add_installrecord bad install_record: tag not INSTALLRECORD" + if {[dict get $install_record tag] ni [list "INSTALL-RECORD" "SKIPPED"]} { + error "file_record_add_installrecord bad install_record: tag not INSTALL-RECORD" } set keep 3 if {[dict exists $file_record -keep_installrecords]} { @@ -1767,7 +1749,7 @@ namespace eval punkcheck { set kept_body_items [list] set kcount 0 foreach item [lreverse $body_items] { - if {[dict get $item tag] eq "INSTALLRECORD"} { + if {[dict get $item tag] eq "INSTALL-RECORD"} { incr kcount if {$keep < 0 || $kcount <= $keep} { lappend kept_body_items $item @@ -1804,7 +1786,7 @@ namespace eval punkcheck { error "file_record_prune bad file_record: tag not FILEINFO" } set file_record [file_record_set_defaults $file_record] - set kmap [list -keep_installrecords *RECORD -keep_skipped SKIPPED -keep_inprogress *-INPROGRESS] + set kmap [list -keep_installrecords *-RECORD -keep_skipped *-SKIPPED -keep_inprogress *-INPROGRESS] foreach {key rtype} $kmap { set keep [dict get $file_record $key] if {[dict exists $file_record body]} { diff --git a/src/modules/punkcheck/cli-999999.0a1.0.tm b/src/modules/punkcheck/cli-999999.0a1.0.tm index 87a83b30..8a17a6a2 100644 --- a/src/modules/punkcheck/cli-999999.0a1.0.tm +++ b/src/modules/punkcheck/cli-999999.0a1.0.tm @@ -91,7 +91,9 @@ namespace eval punkcheck::cli { set display_records [list] set pcheck \n set latest_install_record [punkcheck::recordlist::file_record_latest_installrecord $filerec] - lappend display_records $latest_install_record + if {[llength $latest_install_record]} { + lappend display_records $latest_install_record + } if {$latest_install_record ne [lindex $records end]} { lappend display_records [lindex $records end] }