run: rename 'check_installed' to 'installed_command'

Also remove 'requires_installation_of', while also checking sbin
directories in 'have_installed'. The run scripts have been adjusted
accordingly.

Fixes #2853
This commit is contained in:
Sebastian Sumpf
2018-06-19 19:55:04 +02:00
committed by Norman Feske
parent 365d0bccd5
commit 10485b0d39
28 changed files with 93 additions and 106 deletions

View File

@@ -15,14 +15,13 @@ proc image_disk_size { } { return [get_cmd_arg --image-disk-size 0] }
#
proc run_image { {unused ""} } {
requires_installation_of sgdisk
requires_installation_of e2cp
set sgdisk [installed_command sgdisk]
# make copy of template grub2 header image
exec cp [get_grub2_dir]/boot/grub2-head.img [run_dir].header
# remove template partition
exec sgdisk --delete=3 [run_dir].header
exec $sgdisk --delete=3 [run_dir].header
# calculate size of grub2 header and the size of Genode scenario
set size_header [expr [regsub {\s.*} [exec du -b [run_dir].header] {}]]
@@ -36,7 +35,7 @@ proc run_image { {unused ""} } {
# setup partition with content
exec dd if=/dev/zero of=[run_dir].partition bs=1k count=$disk_size_kb 2>/dev/null
exec mkfs.ext2 -L GENODE -q -T default [run_dir].partition
exec [installed_command mkfs.ext2] -L GENODE -q -T default [run_dir].partition
# copy content to disk image
foreach file [exec find [run_dir]] {
@@ -46,9 +45,9 @@ proc run_image { {unused ""} } {
}
if {[file isdirectory $file]} {
exec e2mkdir [run_dir].partition:$filename
exec [installed_command e2mkdir] [run_dir].partition:$filename
} else {
exec e2cp $file [run_dir].partition:$filename
exec [installed_command e2cp] $file [run_dir].partition:$filename
}
}
@@ -57,7 +56,7 @@ proc run_image { {unused ""} } {
set last_sector [expr ((($size_header + ($disk_size_kb * 1024)) / 512) - 1)]
# add free space for the backup gpt at the end of disk
set sector_backup [exec sgdisk --info=1 [run_dir].header]
set sector_backup [exec $sgdisk --info=1 [run_dir].header]
set sector_backup [regexp -all -line -inline {First sector: ([0-9]+)} $sector_backup]
set sector_backup [lindex $sector_backup 1]
@@ -72,14 +71,14 @@ proc run_image { {unused ""} } {
exec rm [run_dir].partition
# move backup GPT to the end of the disk
exec sgdisk --move-second-header [run_dir].img
exec $sgdisk --move-second-header [run_dir].img
# create partition table entry pointing to the content
exec sgdisk --new=3:$first_sector:$last_sector [run_dir].img
exec sgdisk --change-name=3:GENODE [run_dir].img
exec $sgdisk --new=3:$first_sector:$last_sector [run_dir].img
exec $sgdisk --change-name=3:GENODE [run_dir].img
# create hybrid MBR
exec sgdisk --hybrid [run_dir].img
exec $sgdisk --hybrid [run_dir].img
set size_image [expr [regsub {\s.*} [exec du -sk [run_dir].img] {}]]
puts "Created image file [run_dir].img (${size_image}kiB)"

View File

@@ -6,8 +6,6 @@ source [genode_dir]/tool/run/iso.inc
#
proc run_image { {unused ""} } {
requires_installation_of xorriso
puts "creating ISO image..."
exec rm -f "[run_dir].iso"
@@ -17,7 +15,7 @@ proc run_image { {unused ""} } {
# 'xorriso' writes diagnostics to stderr, which are interpreted as
# execution failure by expect unless '-ignorestderr' is set on 'exec'.
#
if {[catch {exec -ignorestderr xorriso -out_charset utf-8 -report_about HINT -as mkisofs -f -l -R -hide-rr-moved -graft-points --modification-date=2017101816570300 -b boot/grub/i386-pc/eltorito.img -no-emul-boot -boot-load-size 4 -boot-info-table --embedded-boot $grub2_path/boot/grub2/embedded.img --protective-msdos-label -o [run_dir].iso -r [run_dir] --sort-weight 0 / --sort-weight 1 /boot} ]} {
if {[catch {exec -ignorestderr [installed_command xorriso] -out_charset utf-8 -report_about HINT -as mkisofs -f -l -R -hide-rr-moved -graft-points --modification-date=2017101816570300 -b boot/grub/i386-pc/eltorito.img -no-emul-boot -boot-load-size 4 -boot-info-table --embedded-boot $grub2_path/boot/grub2/embedded.img --protective-msdos-label -o [run_dir].iso -r [run_dir] --sort-weight 0 / --sort-weight 1 /boot} ]} {
puts stderr "Error: ISO image creation failed"
exit -5
}

View File

@@ -14,10 +14,6 @@ proc image_uefi_size { } { return [get_cmd_arg --image-uefi_size 0] }
#
proc run_image { {unused ""} } {
requires_installation_of sgdisk
requires_installation_of mkfs.vfat
requires_installation_of mcopy
set run_size [expr [regsub {\s.*} [exec du -sm [run_dir]] {}]]
if {[image_uefi_size] > 0} {
@@ -30,16 +26,16 @@ proc run_image { {unused ""} } {
exec dd if=/dev/zero of=[run_dir].header count=34 bs=512 2>/dev/null
exec dd if=/dev/zero of=[run_dir].partition bs=1M count=$disk_size 2>/dev/null
exec mkfs.vfat -n GENODE [run_dir].partition
exec [installed_command mkfs.vfat] -n GENODE [run_dir].partition
# copy content to disk image
foreach file [exec ls [run_dir]] {
exec mcopy -i [run_dir].partition -s [run_dir]/$file ::
exec [installed_command mcopy] -i [run_dir].partition -s [run_dir]/$file ::
}
exec cat [run_dir].header [run_dir].partition > [run_dir].img
exec sgdisk --set-alignment=1 --largest-new=1 --typecode=1:EF00 [run_dir].img
exec [installed_command sgdisk] --set-alignment=1 --largest-new=1 --typecode=1:EF00 [run_dir].img
exec rm -f [run_dir].header [run_dir].partition
}

View File

@@ -49,7 +49,7 @@ proc run_power_on { } {
exit -1
}
set telnet [check_installed telnet]
set telnet [installed_command telnet]
spawn $telnet $host $port
set connection_id $spawn_id

View File

@@ -506,18 +506,41 @@ proc have_spec {spec} { global specs; return [expr [lsearch $specs $spec] != -1]
# Return true if specified program is installed
#
proc have_installed {program} {
if {[catch { exec which $program }]} { return false; }
return true
if {[catch { exec which $program }] == 0} { return true; }
if {[catch { exec which "/sbin/$program" }] == 0} { return true; }
if {[catch { exec which "/usr/sbin/$program" }] == 0} { return true; }
if {[catch { exec which "/usr/local/bin/$program" }] == 0} { return true; }
return false;
}
##
# Return true if specified program is installed on the host platform
# Check if a shell command is installed
#
proc requires_installation_of {program} {
if {![have_installed $program]} {
puts "Run script aborted because $program is not installed"; exit 1
# \param command name of the command to search
#
# \return absolute path of command if found, or exists if not
#
proc installed_command {command} {
if { [catch {set path [exec which $command]}] == 0} {
return $path
}
set dir { /sbin /usr/sbin /usr/local/bin }
foreach location $dir {
append location / $command
if { [file exists $location] == 1} {
return $location
}
}
puts stderr "Error: '$command' command could be not found. Please make sure to install the"
puts stderr " packet containing '$command', or make it available in your PATH variable.\n"
exit 1
}
@@ -757,39 +780,7 @@ proc gdb { } {
if {[have_installed "[cross_dev_prefix]gdb"]} {
return "[cross_dev_prefix]gdb" }
if {[have_installed gdb]} {
return "gdb" }
requires_installation_of gdb
}
##
# Check if a shell command is installed
#
# \param command name of the command to search
#
# \return absolute path of command if found, or exists if not
#
proc check_installed {command} {
if { [catch {set path [exec which $command]}] == 0} {
return $path
}
set dir { /sbin /usr/sbin /usr/local/bin }
foreach location $dir {
append location / $command
if { [file exists $location] == 1} {
return $location
}
}
puts stderr "Error: '$command' command could be not found. Please make sure to install the"
puts stderr " packet containing '$command', or make it available in your PATH variable.\n"
exit 1
return [installed_command gdb]
}