@ -3287,6 +3287,60 @@ proc ::punkboot::get_src_provenance_warnings {projectroot label} {
set checked_vcs_roots [ dict create]
return [ list 1 [ : : punkboot : : utils::vcs_dirty_warnings $projectroot checked_vcs_roots $label src] ]
}
# R e p l a c e a f i l e t h a t m a y b e M E M O R Y - M A P P E D b y a n o t h e r p r o c e s s ( o r b y t h i s o n e ) .
#
# O n w i n d o w s a n o r d i n a r y ' f i l e c o p y - f o r c e ' o n t o a m a p p e d f i l e i s r e f u s e d : a z i p f s m o u n t
# m a p s i t s a r c h i v e ( t c l Z i p f s . c C r e a t e F i l e M a p p i n g W + M a p V i e w O f F i l e ) , s o a z i p - b a s e d . t m
# m o d p o d t h a t a n y r u n n i n g s h e l l - i n c l u d i n g t h i s b u i l d - h a s m o u n t e d c a n n o t b e o v e r w r i t t e n
# i n p l a c e . W i n d o w s r e p o r t s E R R O R _ U S E R _ M A P P E D _ F I L E ( 1 2 2 4 ) ; T c l ' s T c l _ W i n C o n v e r t E r r o r m a p s
# o n l y W i n 3 2 c o d e s 0 . . 2 6 7 a n d s e n d s e v e r y t h i n g a b o v e t h e m t o E I N V A L , s o i t s u r f a c e s a s t h e
# u n i n f o r m a t i v e " i n v a l i d a r g u m e n t " ( s a m e c o d e i n 8 . 6 a n d 9 . x ) .
#
# U N L I N K I N G a m a p p e d f i l e I S a l l o w e d - t h e h o l d e r k e e p s r e a d i n g i t s o w n m a p p i n g a n d n e w
# c o n t e n t l a n d s a t t h e n a m e - s o d e l e t e - t h e n - p l a c e s u c c e e d s w h e r e o v e r w r i t e c a n n o t . T h e n e w
# c o n t e n t g o e s t o a s i b l i n g t e m p F I R S T s o a m i d - s e q u e n c e f a i l u r e c a n n e v e r l e a v e t h e t a r g e t
# m i s s i n g .
#
# R e t u r n s o n e o f : o k ( p l a i n c o p y w o r k e d ) , r e p l a c e d ( n e e d e d t h e d e l e t e - t h e n - p l a c e p a t h ) ,
# f a i l e d ( t a r g e t u n t o u c h e d ) , b r o k e n ( t a r g e t w a s u n l i n k e d a n d c o u l d n o t b e r e s t o r e d - t h e
# c a l l e r m u s t t r e a t t h i s a s s e r i o u s ) . T h e f i r s t c o p y ' s e r r o r m e s s a g e i s w r i t t e n t o t h e
# v a r i a b l e n a m e d b y f i r s t e r r v a r .
proc : : punkboot::replace_possibly_mapped_file { srcfile tgtfile firsterrvar} {
upvar 1 $firsterrvar firsterr
set firsterr " "
if { ! [ catch { file copy - force $srcfile $tgtfile } firsterr] } {
return ok
}
if { ! [ file exists $tgtfile ] } {
# n o t h i n g t o u n l i n k - w h a t e v e r f a i l e d , i t w a s n o t a n i n - p l a c e o v e r w r i t e
return failed
}
set tmpfile $tgtfile.punkboot-new
catch { file delete - force - - $tmpfile }
if { [ catch { file copy - - $srcfile $tmpfile } ] } {
catch { file delete - force - - $tmpfile }
return failed
}
if { [ catch { file delete - - $tgtfile } ] } {
catch { file delete - force - - $tmpfile }
return failed
}
if { [ catch { file rename - - $tmpfile $tgtfile } ] } {
return broken
}
return replaced
}
# A c t i o n a b l e t e x t f o r a f i l e - o p e r a t i o n f a i l u r e w h o s e m e s s a g e i s w i n d o w s ' c a t c h - a l l .
# R e t u r n s " " w h e n t h e e r r o r d o e s n o t l o o k l i k e t h a t c a s e .
proc : : punkboot::mapped_file_hint { errmsg tgtfile} {
if { ! [ string match - nocase " * i n v a l i d a r g u m e n t * " $errmsg ] } {
return " "
}
return " ' i n v a l i d a r g u m e n t ' i s T c l ' s c a t c h - a l l f o r a n y w i n d o w s e r r o r a b o v e 2 6 7 ( T c l _ W i n C o n v e r t E r r o r ) , n o t a b a d a r g u m e n t . \
For a file replace the usual cause is ERROR_USER_MAPPED_FILE: ' $tgtfile ' is memory-mapped by a process that has it mounted - \
a zipfs/ modpod mount does this, so a running punk shell ( or this build) holding that .tm blocks an in - place overwrite.\
Close shells holding it, or rerun - the update now replaces such files by delete-then-place rather than overwrite."
}
# A v a i l a b i l i t y p r o b e + b o o t - p r e c o n d i t i o n c h e c k o f a n a s s e m b l e d k i t v f s ( G - 1 2 5 ) , s h a r e d b y t h e
# k i t g a t e i n t h e b a k e l o o p a n d t h e ' c h e c k ' c o m m a n d r e p o r t . S a m e g u a r d e d - r e q u i r e t r e a t m e n t a s
# t h e p r o v e n a n c e c h e c k a b o v e : a s t a l e o r m i s s i n g p u n k b o o t : : u t i l s s n a p s h o t m u s t n o t b r i c k t h e
@ -4370,31 +4424,47 @@ if {$::punkboot::command eq "bootsupport"} {
$boot_event targetset_started
# - - - - - - - - - - - - - - - - -
puts " \n B O O T S U P P O R T m o d u l e $ w h i c h u p d a t e : $ s r c f i l e - > $ t g t f i l e "
if { [ catch {
file copy - force $srcfile $tgtfile
} errM ] } {
# a c o p y o n t o a m o d p o d t h i s m a k e . t c l p r o c e s s h a s m o u n t e d ( e . g p u n k : : m i x : : t e m p l a t e s )
# f a i l s o n w i n d o w s e v e n w h e n t h e t a r g e t c o n t e n t i s a l r e a d y c u r r e n t ( a p r i o r f a i l e d
# r e c o r d f o r c e s a r e t r y ) . I f c o n t e n t i s a l r e a d y i d e n t i c a l , r e c o r d O K s o t h e r e c o r d
# c o n v e r g e s i n s t e a d o f c h u r n i n g F A I L E D f o r e v e r .
set already_current 0
if { [ file exists $tgtfile ] && [ file size $tgtfile ] == [ file size $srcfile ] } {
catch {
set src_ck [ dict get [ punk : : mix::base::lib::cksum_path $srcfile ] cksum]
set tgt_ck [ dict get [ punk : : mix::base::lib::cksum_path $tgtfile ] cksum]
if { $src_ck ne " " && $src_ck eq $tgt_ck } {
set already_current 1
}
}
# A n i n - p l a c e o v e r w r i t e i s r e f u s e d w h e n t h e t a r g e t i s m e m o r y - m a p p e d -
# w h i c h i s w h a t a m o u n t e d z i p - b a s e d . t m m o d p o d ( e . g p u n k : : m i x : : t e m p l a t e s )
# i s . r e p l a c e _ p o s s i b l y _ m a p p e d _ f i l e f a l l s b a c k t o d e l e t e - t h e n - p l a c e , w h i c h
# w i n d o w s d o e s a l l o w . S e e i t s c o m m e n t f o r w h y t h e e r r o r r e a d s " i n v a l i d
# a r g u m e n t " a n d w h y u n l i n k i n g i s s a f e f o r t h e p r o c e s s h o l d i n g t h e m a p p i n g .
switch - - [ : : punkboot : : replace_possibly_mapped_file $srcfile $tgtfile errM] {
ok {
$boot_event targetset_end OK
}
replaced {
puts stdout " ( i n - p l a c e o v e r w r i t e r e f u s e d - r e p l a c e d b y d e l e t e - t h e n - p l a c e ; t a r g e t w a s m e m o r y - m a p p e d , e . g a m o u n t e d m o d p o d ) "
$boot_event targetset_end OK - note " o v e r w r i t e r e f u s e d ( $ e r r M ) - r e p l a c e d v i a d e l e t e - t h e n - p l a c e ( t a r g e t m e m o r y - m a p p e d ) "
}
if { $already_current } {
$boot_event targetset_end OK - note " c o p y f a i l e d ( $ e r r M ) b u t t a r g e t c o n t e n t a l r e a d y i d e n t i c a l ( s e l f - m o u n t e d m o d p o d ? ) "
} else {
puts stderr " B O O T S U P P O R T m o d u l e $ w h i c h u p d a t e F A I L E D : $ t g t f i l e ( $ e r r M ) "
broken {
puts stderr " B O O T S U P P O R T m o d u l e $ w h i c h u p d a t e F A I L E D : $ t g t f i l e w a s u n l i n k e d a n d c o u l d n o t b e r e p l a c e d - r e s t o r e i t f r o m $ s r c f i l e b y h a n d ( $ e r r M ) "
$boot_event targetset_end FAILED
}
} else {
$boot_event targetset_end OK
default {
# t a r g e t u n t o u c h e d . I f i t s c o n t e n t i s a l r e a d y i d e n t i c a l , r e c o r d O K s o a
# p r i o r f a i l e d r e c o r d c o n v e r g e s i n s t e a d o f c h u r n i n g F A I L E D f o r e v e r .
set already_current 0
if { [ file exists $tgtfile ] && [ file size $tgtfile ] == [ file size $srcfile ] } {
catch {
set src_ck [ dict get [ punk : : mix::base::lib::cksum_path $srcfile ] cksum]
set tgt_ck [ dict get [ punk : : mix::base::lib::cksum_path $tgtfile ] cksum]
if { $src_ck ne " " && $src_ck eq $tgt_ck } {
set already_current 1
}
}
}
if { $already_current } {
$boot_event targetset_end OK - note " c o p y f a i l e d ( $ e r r M ) b u t t a r g e t c o n t e n t a l r e a d y i d e n t i c a l "
} else {
puts stderr " B O O T S U P P O R T m o d u l e $ w h i c h u p d a t e F A I L E D : $ t g t f i l e ( $ e r r M ) "
set _hint [ : : punkboot : : mapped_file_hint $errM $tgtfile ]
if { $_hint ne " " } {
puts stderr " $ _ h i n t "
}
$boot_event targetset_end FAILED
}
}
}
# - - - - - - - - - - - - - - - - -
} else {