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

@ -4,7 +4,7 @@ assert_spec x86
# Check used commands
#
set wget [check_installed wget]
set wget [installed_command wget]
#
# Configure

View File

@ -1,7 +1,7 @@
set use_usb_driver [expr [have_spec omap4] || [have_spec arndale] || [have_spec rpi]]
set use_nic_driver [expr [have_spec linux] || [expr !$use_usb_driver && ![have_spec imx53] && ![have_spec odroid_xu] && ![have_spec linux] && ![have_spec wand_quad]]]
requires_installation_of lynx
set lynx [installed_command lynx]
#
# Build
@ -139,7 +139,7 @@ if {[have_include "power_on/qemu"]} {
puts "http server is up, try to query website $uri"
set website [exec lynx -dump $uri]
set website [exec $lynx -dump $uri]
puts "response:\n$website"

View File

@ -19,7 +19,7 @@ create_boot_directory
catch { exec dd if=/dev/zero of=bin/ext2.img bs=1024 count=8192 }
set mkfs_cmd [check_installed mkfs.ext2]
set mkfs_cmd [installed_command mkfs.ext2]
catch { exec $mkfs_cmd -F bin/ext2.img }
@ -131,6 +131,7 @@ set boot_modules {
rump.lib.so
timer
vfs
vfs.lib.so
vfs_rump.lib.so
}

View File

@ -1,4 +1,4 @@
set mkfs_cmd [check_installed mke2fs]
set mkfs_cmd [installed_command mke2fs]
set mkfs_opts "-F"
set test_build_components "lib/vfs/rump"

View File

@ -1,4 +1,4 @@
set mkfs_cmd [check_installed mke2fs]
set mkfs_cmd [installed_command mke2fs]
set mkfs_opts "-F"
set test_build_components "lib/vfs/rump"

View File

@ -5,8 +5,8 @@ if {[have_spec arm]} {
#
# Check used commands
#
set mke2fs [check_installed mke2fs]
set dd [check_installed dd]
set mke2fs [installed_command mke2fs]
set dd [installed_command dd]
#
# Build

View File

@ -5,8 +5,8 @@ if {[have_spec arm]} {
#
# Check used commands
#
set mkfs [check_installed mkfs.vfat]
set dd [check_installed dd]
set mkfs [installed_command mkfs.vfat]
set dd [installed_command dd]
#
# Build
@ -58,7 +58,7 @@ append config {
<config file="fs.raw" block_size="512"/>
</start>
<start name="rump_fs" caps="200">
<resource name="RAM" quantum="8M" />
<resource name="RAM" quantum="10M" />
<provides><service name="File_system"/></provides>
<config fs="msdos"><default-policy root="/" writeable="yes"/></config>
</start>

View File

@ -5,7 +5,7 @@ if {[have_spec arm]} {
#
# Check used commands
#
set mkisofs [check_installed mkisofs]
set mkisofs [installed_command mkisofs]
#
# Build
@ -51,7 +51,7 @@ append config {
<config file="fs.iso" block_size="2048"/>
</start>
<start name="rump_fs" caps="200">
<resource name="RAM" quantum="8M" />
<resource name="RAM" quantum="10M" />
<provides><service name="File_system"/></provides>
<config fs="cd9660"><policy label_prefix="fs_rom" root="/" writeable="no"/></config>
</start>

View File

@ -7,8 +7,8 @@
#
# Check used commands
#
set mke2fs [check_installed mke2fs]
set dd [check_installed dd]
set mke2fs [installed_command mke2fs]
set dd [installed_command dd]
build "core init drivers/timer test/vfs_stress server/ram_blk lib/vfs/rump"
@ -55,7 +55,8 @@ install_config {
set boot_modules {
core init ld.lib.so timer vfs_stress
rump.lib.so rump_fs.lib.so vfs_rump.lib.so
rump.lib.so rump_fs.lib.so
vfs.lib.so vfs_rump.lib.so
ram_blk ext2.raw
}

View File

@ -7,8 +7,8 @@
#
# Check used commands
#
set mke2fs [check_installed mke2fs]
set dd [check_installed dd]
set mke2fs [installed_command mke2fs]
set dd [installed_command dd]
build "core init drivers/timer test/vfs_stress server/ram_blk server/rump_fs"
@ -63,7 +63,7 @@ install_config {
set boot_modules {
core init ld.lib.so timer vfs_stress
rump.lib.so rump_fs.lib.so rump_fs
ram_blk ext2.raw
ram_blk ext2.raw vfs.lib.so
}
build_boot_image $boot_modules

View File

@ -134,8 +134,8 @@ build_boot_image { driver_manager test-driver_manager ld.lib.so }
#
if {[have_include "power_on/qemu"]} {
set mke2fs [check_installed mke2fs]
set dd [check_installed dd]
set mke2fs [installed_command mke2fs]
set dd [installed_command dd]
catch { exec $dd if=/dev/zero of=bin/hdd_disk.raw bs=1M count=32 }
catch { exec $mke2fs -F bin/hdd_disk.raw }

View File

@ -17,7 +17,7 @@ build $build_components
create_boot_directory
set mkfs_cmd [check_installed mkfs.vfat]
set mkfs_cmd [installed_command mkfs.vfat]
catch { exec $mkfs_cmd -C bin/fat.img -n "ROM_UPDATE" 64 }
@ -127,6 +127,7 @@ set boot_modules {
rom_to_file
timer
vfs
vfs.lib.so
vfs_fatfs.lib.so
}

View File

@ -1,4 +1,4 @@
set mkfs_cmd [check_installed mkfs.vfat]
set mkfs_cmd [installed_command mkfs.vfat]
set mkfs_opts "-F32"
set filesystem fatfs

View File

@ -1,4 +1,4 @@
set mkfs_cmd [check_installed mkfs.vfat]
set mkfs_cmd [installed_command mkfs.vfat]
set mkfs_opts "-F32 -nlibc_vfs"
set test_build_components lib/vfs/fatfs

View File

@ -1,4 +1,4 @@
set mkfs_cmd [check_installed mkfs.vfat]
set mkfs_cmd [installed_command mkfs.vfat]
set mkfs_opts "-F32 -nlibc_vfs"
set test_build_components lib/vfs/fatfs

View File

@ -7,7 +7,7 @@
set use_sd_card_drv [expr [have_spec omap4] || [have_spec arndale] || [have_spec pl180]]
set use_ahci_drv [expr [have_spec x86] && ![have_spec linux]]
set use_ram_blk [have_spec linux]
set mkfs [check_installed $mkfs_cmd]
set mkfs [installed_command $mkfs_cmd]
if {[have_spec odroid_xu]} {
puts "Run script does not support this platform"; exit }

View File

@ -27,7 +27,7 @@ if {[expr !$use_usb_driver && !$use_nic_driver] ||
[expr [have_spec imx53] && [have_spec trustzone]]} {
puts "\n Run script is not supported on this platform. \n"; exit 0 }
requires_installation_of lynx
set lynx [installed_command lynx]
#
# Build
@ -163,7 +163,7 @@ if {[have_include "power_on/qemu"]} {
puts "http server is up, try to query website $uri"
set website [exec lynx -dump $uri]
set website [exec $lynx -dump $uri]
puts "response:\n$website"

View File

@ -1,6 +1,6 @@
set mke2fs [check_installed mke2fs]
set dd [check_installed dd]
set mke2fs [installed_command mke2fs]
set dd [installed_command dd]
#
# Build

View File

@ -1,6 +1,6 @@
set mke2fs [check_installed mke2fs]
set dd [check_installed dd]
set mke2fs [installed_command mke2fs]
set dd [installed_command dd]
#
# Build

View File

@ -3,7 +3,7 @@ set use_linux [have_spec linux]
#
# Check used commands
#
set dd [check_installed dd]
set dd [installed_command dd]
#
# Build

View File

@ -27,7 +27,7 @@ set small_test [expr $is_qemu || [have_spec foc] || [have_spec sel4]]
#
# Check used commands
#
set dd [check_installed dd]
set dd [installed_command dd]
#
# Build

View File

@ -2,7 +2,7 @@
# \brief Test of Block session interface provided by server/part_blk
#
requires_installation_of parted
set parted [installed_command parted]
#
# Build
@ -30,15 +30,15 @@ if { ![file exists $img_path] } then {
puts "using parted to partition disk image"
if { $mode == "mbr" } {
exec parted -s $img_path mklabel msdos
exec parted -s $img_path mkpart primary fat32 2048s 4095s
exec parted -s $img_path mkpart extended 4096s 20479s
exec parted -s $img_path mkpart logical fat32 6144s 10239s
exec parted -s $img_path mkpart logical fat32 12288s 20479s
exec $parted -s $img_path mklabel msdos
exec $parted -s $img_path mkpart primary fat32 2048s 4095s
exec $parted -s $img_path mkpart extended 4096s 20479s
exec $parted -s $img_path mkpart logical fat32 6144s 10239s
exec $parted -s $img_path mkpart logical fat32 12288s 20479s
} else {
exec parted -s $img_path mklabel gpt
exec parted -s $img_path mkpart one fat32 2048s 4095s
exec parted -s $img_path mkpart two fat32 4096s 20446s
exec $parted -s $img_path mklabel gpt
exec $parted -s $img_path mkpart one fat32 2048s 4095s
exec $parted -s $img_path mkpart two fat32 4096s 20446s
}
}

View File

@ -1,5 +1,5 @@
set genext2fs [check_installed genext2fs]
set e2fsck [check_installed e2fsck]
set genext2fs [installed_command genext2fs]
set e2fsck [installed_command e2fsck]
create_boot_directory

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]
}