tool/run: option to copy tftp served files (x86)

Fixes #4153
This commit is contained in:
Alexander Boettcher 2021-03-23 15:22:52 +01:00 committed by Christian Helmuth
parent a13dee8d19
commit 921a99bb9b

View File

@ -56,24 +56,29 @@ proc generate_tftp_config { } {
if {[string length $tftp_base_dir] > 0 && [string length $tftp_offset_dir] > 0} {
# if the link target exists as directory this leads to bad behavior
if {[file exists $tftp_base_dir$tftp_offset_dir] &&
[string compare [file type $tftp_base_dir$tftp_offset_dir] "directory"] == 0} {
puts stderr "Error: TFTP symlink target $tftp_base_dir$tftp_offset_dir is a directory"
exit -1
}
exec ln -nfs "[pwd]" "$tftp_base_dir$tftp_offset_dir"
set tftp_base ""
if {[load_tftp_use_absolute]} {
set tftp_base $tftp_base_dir
}
set fh [open "$tftp_base_dir$tftp_offset_dir/config-00-00-00-00-00-00" "WRONLY CREAT TRUNC"]
puts $fh " root $tftp_base$tftp_offset_dir/[run_dir]"
puts $fh " config config-52-54-00-12-34-56"
close $fh
if {[load_tftp_copy_files]} {
exec cp -r --dereference "[pwd]/[run_dir]/." $tftp_base_dir$tftp_offset_dir/.
} else {
# if the link target exists as directory this leads to bad behavior
if {[file exists $tftp_base_dir$tftp_offset_dir] &&
[string compare [file type $tftp_base_dir$tftp_offset_dir] "directory"] == 0} {
puts stderr "Error: TFTP symlink target $tftp_base_dir$tftp_offset_dir is a directory"
exit -1
}
exec ln -nfs "[pwd]" "$tftp_base_dir$tftp_offset_dir"
set fh [open "$tftp_base_dir$tftp_offset_dir/config-00-00-00-00-00-00" "WRONLY CREAT TRUNC"]
puts $fh " root $tftp_base$tftp_offset_dir/[run_dir]"
puts $fh " config config-52-54-00-12-34-56"
close $fh
}
} else {
puts "Warning, TFTP base directory or TFTP offset directory not set."
}