Browse Source

attempt to fix make.tcl for use with tcl8.6 (no zipfs available)

master
Julian Noble 3 weeks ago
parent
commit
4fa6d67e3d
  1. 91
      src/make.tcl

91
src/make.tcl

@ -2839,56 +2839,65 @@ foreach vfstail $vfs_tails {
#zipfs mkimg replaces the entire zipped vfs in the runtime - so we need the original data to be part of our targetvfs. #zipfs mkimg replaces the entire zipped vfs in the runtime - so we need the original data to be part of our targetvfs.
puts stdout "building $vfsname.new with zipfs vfsdir:$vfstail cwd: [pwd]" puts stdout "building $vfsname.new with zipfs vfsdir:$vfstail cwd: [pwd]"
file mkdir $targetvfs file mkdir $targetvfs
set rtmountpoint //zipfs:/rtmounts/$runtime_fullname
if {![file exists $rtmountpoint]} { if {[info commands ::tcl::zipfs::mount] ne ""} {
if {[catch {
tcl::zipfs::mount $building_runtime rtmounts/$runtime_fullname set rtmountpoint //zipfs:/rtmounts/$runtime_fullname
} errM]} {
puts stderr "Failed to mount $building_runtime using standard api. Err:$errM\n trying reverse args on tcl::zipfs::mount..." if {![file exists $rtmountpoint]} {
if {[catch { if {[catch {
tcl::zipfs::mount rtmounts/$runtime_fullname $building_runtime tcl::zipfs::mount $building_runtime rtmounts/$runtime_fullname
} errM]} { } errM]} {
puts stderr "ALSO Failed to mount $building_runtime using reverse args to api. Err:$errM - no mountable zipfs on runtime?" puts stderr "Failed to mount $building_runtime using standard api. Err:$errM\n trying reverse args on tcl::zipfs::mount..."
if {[catch {
tcl::zipfs::mount rtmounts/$runtime_fullname $building_runtime
} errM]} {
puts stderr "ALSO Failed to mount $building_runtime using reverse args to api. Err:$errM - no mountable zipfs on runtime?"
}
} }
} }
}
#strip any existing zipfs on the runtime.. #strip any existing zipfs on the runtime..
#2024 - 'zipfs info //zipfs:/mountpoint' is supposed to give us the offset - but it doesn't if the exe has been 'adjusted' to use file offsets. #2024 - 'zipfs info //zipfs:/mountpoint' is supposed to give us the offset - but it doesn't if the exe has been 'adjusted' to use file offsets.
#which unfortunately Tcl does by default after the 2021 'fix' :( #which unfortunately Tcl does by default after the 2021 'fix' :(
#https://core.tcl-lang.org/tcl/tktview/aaa84fbbc5 #https://core.tcl-lang.org/tcl/tktview/aaa84fbbc5
set raw_runtime $buildfolder/raw_$runtime_fullname set raw_runtime $buildfolder/raw_$runtime_fullname
if {[file exists $rtmountpoint]} { if {[file exists $rtmountpoint]} {
merge_over $rtmountpoint $targetvfs merge_over $rtmountpoint $targetvfs
#see if we can extract the exe part #see if we can extract the exe part
set baseoffset [lindex [tcl::zipfs::info $rtmountpoint] 3] set baseoffset [lindex [tcl::zipfs::info $rtmountpoint] 3]
if {$baseoffset != 0} { if {$baseoffset != 0} {
#tcl was able to determine the compressed-data offset #tcl was able to determine the compressed-data offset
#either because runtime is a basic catted exe+zip, or Tcl fixed 'zipfs info' #either because runtime is a basic catted exe+zip, or Tcl fixed 'zipfs info'
set fdrt [open $building_runtime r] set fdrt [open $building_runtime r]
chan configure $fdrt -translation binary chan configure $fdrt -translation binary
set exedata [read $fdrt $baseoffset] ;#may include stored password and ending header // REVIEW - strip it? set exedata [read $fdrt $baseoffset] ;#may include stored password and ending header // REVIEW - strip it?
close $fdrt close $fdrt
set fdraw [open $raw_runtime w] set fdraw [open $raw_runtime w]
chan configure $fdraw -translation binary chan configure $fdraw -translation binary
puts -nonewline $fdraw $exedata puts -nonewline $fdraw $exedata
close $fdraw close $fdraw
} else {
#presumably the supplied building_runtime has had its offsets adjusted so that it all appears within offsets off the zip. (file relative offsets)
#due to zipfs info bug - zipfs now can't tell us the offset of the compressed data.
#we need to use a similarly assumptive method as tclZipfs.c uses to determine the start of the compressed contents
package require punk::zip
#we don't technically need to extract the raw exe for 'zip' - as zipfs mkimg can work on the combined file (ignores zip)
# - but for consistency we want raw_runtime to be emitted in the filesystem.
punk::zip::extract_preamble $building_runtime $raw_runtime
}
} else { } else {
#presumably the supplied building_runtime has had its offsets adjusted so that it all appears within offsets off the zip. (file relative offsets) #the input building_runtime wasn't mountable as a zip - so presumably a plain executable
#due to zipfs info bug - zipfs now can't tell us the offset of the compressed data. #set building_runtime $buildfolder/build_$runtime_fullname ;#working copy of runtime executable - (possibly with kit/zipfs/cookfs etc attached!)
#we need to use a similarly assumptive method as tclZipfs.c uses to determine the start of the compressed contents #set raw_runtime $buildfolder/raw_$runtime_fullname
package require punk::zip file copy -force $building_runtime $raw_runtime
#we don't technically need to extract the raw exe for 'zip' - as zipfs mkimg can work on the combined file (ignores zip)
# - but for consistency we want raw_runtime to be emitted in the filesystem.
punk::zip::extract_preamble $building_runtime $raw_runtime
} }
} else { } else {
#the input building_runtime wasn't mountable - so presumably a plain executable #tcl we are calling with doesn't have zipfs - can't mount
#set building_runtime $buildfolder/build_$runtime_fullname ;#working copy of runtime executable - (possibly with kit/zipfs/cookfs etc attached!) puts stderr "WARNING: tcl shell '[info nameofexecutable]' being used to build doesn't have zipfs - falling back to punk::zip::extract_preamble"
#set raw_runtime $buildfolder/raw_$runtime_fullname punk::zip::extract_preamble $building_runtime $raw_runtime $buildfolder/extracted_$runtime_fullname.zip
file copy -force $building_runtime $raw_runtime merge_over $buildfolder/extracted_$runtime_fullname.zip $targetvfs
} }
merge_over $sourcefolder/vfs/_vfscommon.vfs $targetvfs merge_over $sourcefolder/vfs/_vfscommon.vfs $targetvfs

Loading…
Cancel
Save