set lidx [punk::lib::lindex_resolve [llength $l] $last]
switch -exact -- $lidx {
-Inf {
#index below lower bound
set post [lrange $l 0 end]
}
Inf {
#index above upper bound
set post [list]
}
default {
if {$lidx < $fidx} {
#from ledit man page:
#If last is less than first, then any specified elements will be inserted into the list before the element specified by first with no elements being deleted.
set post [lrange $l $fidx end]
} else {
#set post [lrange $l $last+1 end]
if {$lidx < $fidx} {
#from ledit man page:
#If last is less than first, then any specified elements will be inserted into the list before the element specified by first with no elements being deleted.
set post [lrange $l $fidx end]
} else {
#set post [lrange $l $last+1 end]
switch -exact -- $lidx {
-Inf {
#index below lower bound
set post [lrange $l 0 end]
}
Inf {
#index above upper bound
set post [list]
}
default {
set post [lrange $l $lidx+1 end]
}
}
}
#switch -exact -- $lidx {
# -Inf {
# #index below lower bound
# set post [lrange $l 0 end]
# }
# Inf {
# #index above upper bound
# set post [list]
# }
# default {
# if {$lidx < $fidx} {
# #from ledit man page:
# #If last is less than first, then any specified elements will be inserted into the list before the element specified by first with no elements being deleted.
set extractioninfo [punkcheck::recordlist::extract_or_create_fileset_record $o_targets $record_list]
set o_fileset_record [dict get $extractioninfo record]
set record_list [dict get $extractioninfo recordset]
set record_list [dict get $extractioninfo recordset] ;#if fileset wasn't present, same as original record_list, otherwise full recordset with the fileset record removed, ready for reinsertion.
set isnew [dict get $extractioninfo isnew]
set oldposition [dict get $extractioninfo oldposition]
puts stderr "\x1b\[32mNo existing records found in punkcheck file '$o_checkfile' for installer '$installername'. Starting with empty record list.\x1b\[m"
if {![llength $o_record_list] && $o_debugchannel ne ""} {
puts $o_debugchannel "\x1b\[32mNo existing records found in punkcheck file '$o_checkfile' for installer '$installername'. Starting with empty record list.\x1b\[m"
} else {
#verify no duplicate installer records for this installer.
#JMN
@ -565,7 +566,9 @@ namespace eval punkcheck {
set name [dict get $rec -name]
if {[dict exists $sanity_dict $name]} {
#todo - warn - duplicate record for same targetlist - shouldn't happen as we should be using get_file_record to find existing records
puts stderr "\x1b\[31mpunkcheck installtrack - multiple INSTALLER records with same name '$name'\x1b\[m"
if {$o_debugchannel ne ""} {
puts $o_debugchannel "\x1b\[31mpunkcheck installtrack - multiple INSTALLER records with same name '$name'\x1b\[m"
}
set insane "$name"
break
}
@ -576,10 +579,14 @@ namespace eval punkcheck {
set msg "Sanity check: punkcheck file '$o_checkfile' contains multiple records for INSTALLER -name '$insane'."
append msg \n "This may indicate a problem such as multiple concurrent installtrack instances using the same punkcheck file,"
append msg \n " or a previous installtrack instance that did not complete properly."
append msg \n " Please verify that this is expected and safe to proceed before confirming with 'yes'."
append msg \n " Do you want to DELETE the .punkcheck file?"
append msg \n " It is safe to delete .punkcheck files, at the cost of loss of history and checksums used to optimize installs."
append msg \n " They are a record of installation events and checksums used to avoid unnecessary reinstalls."
append msg \n " If not confirmed, an error will be raised - likely aborting the current operation."
append msg \n "confirm deletion and continue by regenerating the file, by typing the 3 letters: 'yes'."
set answer [punk::lib::askuser $msg]
if {$answer ne "yes"} {
error "Aborting due to sanity check failure. User did not confirm with 'yes'."
if {[string tolower $answer] ne "yes"} {
error "Failing due to sanity check failure. User did not confirm with 'yes'."
}
if {[file exists $o_checkfile] && [file isfile $o_checkfile]} {
file delete $o_checkfile
@ -589,7 +596,9 @@ namespace eval punkcheck {
}
set o_record_list [list]
} else {
puts stderr "\x1b\[32mSanity check passed: no duplicate INSTALLER records found for installer '$installername' in punkcheck file '$o_checkfile'.\x1b\[m"
if {$o_debugchannel ne ""} {
puts $o_debugchannel "\x1b\[32mSanity check passed: no duplicate INSTALLER records found for installer '$installername' in punkcheck file '$o_checkfile'.\x1b\[m"
}
}
unset sanity_dict
}
@ -628,6 +637,9 @@ namespace eval punkcheck {
method get_checkfile {} {
return $o_checkfile
}
method get_debugchannel {} {
return $o_debugchannel
}
#call set_source_target before calling start_event/end_event
#each event can have different source->target pairs - but may often have same, so set on installtrack as defaults. Only persisted in event records.
@ -2430,7 +2442,8 @@ namespace eval punkcheck {
set fileset_record [dict create tag FILEINFO -targets $relative_target_paths body {}]
set lidx [punk::lib::lindex_resolve [llength $l] $last]
switch -exact -- $lidx {
-Inf {
#index below lower bound
set post [lrange $l 0 end]
}
Inf {
#index above upper bound
set post [list]
}
default {
if {$lidx < $fidx} {
#from ledit man page:
#If last is less than first, then any specified elements will be inserted into the list before the element specified by first with no elements being deleted.
set post [lrange $l $fidx end]
} else {
#set post [lrange $l $last+1 end]
if {$lidx < $fidx} {
#from ledit man page:
#If last is less than first, then any specified elements will be inserted into the list before the element specified by first with no elements being deleted.
set post [lrange $l $fidx end]
} else {
#set post [lrange $l $last+1 end]
switch -exact -- $lidx {
-Inf {
#index below lower bound
set post [lrange $l 0 end]
}
Inf {
#index above upper bound
set post [list]
}
default {
set post [lrange $l $lidx+1 end]
}
}
}
#switch -exact -- $lidx {
# -Inf {
# #index below lower bound
# set post [lrange $l 0 end]
# }
# Inf {
# #index above upper bound
# set post [list]
# }
# default {
# if {$lidx < $fidx} {
# #from ledit man page:
# #If last is less than first, then any specified elements will be inserted into the list before the element specified by first with no elements being deleted.
set extractioninfo [punkcheck::recordlist::extract_or_create_fileset_record $o_targets $record_list]
set o_fileset_record [dict get $extractioninfo record]
set record_list [dict get $extractioninfo recordset]
set record_list [dict get $extractioninfo recordset] ;#if fileset wasn't present, same as original record_list, otherwise full recordset with the fileset record removed, ready for reinsertion.
set isnew [dict get $extractioninfo isnew]
set oldposition [dict get $extractioninfo oldposition]
puts stderr "\x1b\[32mNo existing records found in punkcheck file '$o_checkfile' for installer '$installername'. Starting with empty record list.\x1b\[m"
if {![llength $o_record_list] && $o_debugchannel ne ""} {
puts $o_debugchannel "\x1b\[32mNo existing records found in punkcheck file '$o_checkfile' for installer '$installername'. Starting with empty record list.\x1b\[m"
} else {
#verify no duplicate installer records for this installer.
#JMN
@ -565,7 +566,9 @@ namespace eval punkcheck {
set name [dict get $rec -name]
if {[dict exists $sanity_dict $name]} {
#todo - warn - duplicate record for same targetlist - shouldn't happen as we should be using get_file_record to find existing records
puts stderr "\x1b\[31mpunkcheck installtrack - multiple INSTALLER records with same name '$name'\x1b\[m"
if {$o_debugchannel ne ""} {
puts $o_debugchannel "\x1b\[31mpunkcheck installtrack - multiple INSTALLER records with same name '$name'\x1b\[m"
}
set insane "$name"
break
}
@ -576,10 +579,14 @@ namespace eval punkcheck {
set msg "Sanity check: punkcheck file '$o_checkfile' contains multiple records for INSTALLER -name '$insane'."
append msg \n "This may indicate a problem such as multiple concurrent installtrack instances using the same punkcheck file,"
append msg \n " or a previous installtrack instance that did not complete properly."
append msg \n " Please verify that this is expected and safe to proceed before confirming with 'yes'."
append msg \n " Do you want to DELETE the .punkcheck file?"
append msg \n " It is safe to delete .punkcheck files, at the cost of loss of history and checksums used to optimize installs."
append msg \n " They are a record of installation events and checksums used to avoid unnecessary reinstalls."
append msg \n " If not confirmed, an error will be raised - likely aborting the current operation."
append msg \n "confirm deletion and continue by regenerating the file, by typing the 3 letters: 'yes'."
set answer [punk::lib::askuser $msg]
if {$answer ne "yes"} {
error "Aborting due to sanity check failure. User did not confirm with 'yes'."
if {[string tolower $answer] ne "yes"} {
error "Failing due to sanity check failure. User did not confirm with 'yes'."
}
if {[file exists $o_checkfile] && [file isfile $o_checkfile]} {
file delete $o_checkfile
@ -589,7 +596,9 @@ namespace eval punkcheck {
}
set o_record_list [list]
} else {
puts stderr "\x1b\[32mSanity check passed: no duplicate INSTALLER records found for installer '$installername' in punkcheck file '$o_checkfile'.\x1b\[m"
if {$o_debugchannel ne ""} {
puts $o_debugchannel "\x1b\[32mSanity check passed: no duplicate INSTALLER records found for installer '$installername' in punkcheck file '$o_checkfile'.\x1b\[m"
}
}
unset sanity_dict
}
@ -628,6 +637,9 @@ namespace eval punkcheck {
method get_checkfile {} {
return $o_checkfile
}
method get_debugchannel {} {
return $o_debugchannel
}
#call set_source_target before calling start_event/end_event
#each event can have different source->target pairs - but may often have same, so set on installtrack as defaults. Only persisted in event records.
@ -2430,7 +2442,8 @@ namespace eval punkcheck {
set fileset_record [dict create tag FILEINFO -targets $relative_target_paths body {}]