From 769e648d243223613d008276bcac18a164302ba8 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sun, 8 Aug 2021 16:59:24 +0000 Subject: spectrumPackages: update execline backtick uses execline 2.8.0.0 changed how backtick's options work: * -i (exit with the program's error code on failure) and -n (chomp off a trailing newline from the captured output) are now the defaults. * -E has been introduced, which does importas automatically. -E is fantastic, because we followed every single use of backtick with importas. Even we didn't have -n before, it's okay that chomping will now be enabled from the default, because in all those cases, there won't be a trailing newline anyway. Message-Id: <20210808170439.1372425-1-hi@alyssa.is> Reviewed-by: sterni --- pkgs/os-specific/linux/spectrum/testhost/default.nix | 14 ++++---------- pkgs/os-specific/linux/spectrum/vm/app/default.nix | 3 +-- pkgs/os-specific/linux/spectrum/vm/net/default.nix | 6 ++---- 3 files changed, 7 insertions(+), 16 deletions(-) (limited to 'pkgs/os-specific/linux') diff --git a/pkgs/os-specific/linux/spectrum/testhost/default.nix b/pkgs/os-specific/linux/spectrum/testhost/default.nix index de62f0add67..d81ff8b826e 100644 --- a/pkgs/os-specific/linux/spectrum/testhost/default.nix +++ b/pkgs/os-specific/linux/spectrum/testhost/default.nix @@ -52,18 +52,14 @@ let # routers from clients. Other bits are reserved. # 5-6 Last two octets of client's IP (in 100.64.0.0/16). # - backtick -i router_mac { + backtick -E router_mac { pipeline { printf %.4x ${toString sys-vms.app.vmID} } sed s/^\\(..\\)\\(..\\)$/0A:B3:EC:80:\\1:\\2/ } - backtick -i client_mac { + backtick -E client_mac { pipeline { printf %.4x ${toString sys-vms.app.vmID} } sed s/^\\(..\\)\\(..\\)$/0A:B3:EC:00:\\1:\\2/ } - multisubstitute { - importas -iu router_mac router_mac - importas -iu client_mac client_mac - } # Create the net VM end, and attach it to the net VM. # @@ -143,12 +139,11 @@ let # is allowed to fail because it might already know that, in # which case it'll return EEXIST. if { modprobe vfio-pci } - backtick -in device_id { + backtick -E device_id { if { dd bs=2 skip=1 count=2 status=none if=''${PCI_PATH}/vendor } if { printf " " } dd bs=2 skip=1 count=2 status=none if=''${PCI_PATH}/device } - importas -iu device_id device_id foreground { redirfd -w 1 /sys/bus/pci/drivers/vfio-pci/new_id printf "%s" $device_id @@ -205,8 +200,7 @@ writeScriptBin "spectrum-testhost" '' if { redirfd -w 1 /proc/sys/net/ipv4/ip_forward echo 1 } importas -iu runtime_dir XDG_RUNTIME_DIR - backtick -in TOP { mktemp -dp $runtime_dir spectrum.XXXXXXXXXX } - importas -iu top TOP + backtick -E top { mktemp -dp $runtime_dir spectrum.XXXXXXXXXX } if { echo $top } if { rsync -r --chmod=Du+w ${servicesDir}/ ''${top}/service } background { diff --git a/pkgs/os-specific/linux/spectrum/vm/app/default.nix b/pkgs/os-specific/linux/spectrum/vm/app/default.nix index f8ff480932c..9ffed7e5b13 100644 --- a/pkgs/os-specific/linux/spectrum/vm/app/default.nix +++ b/pkgs/os-specific/linux/spectrum/vm/app/default.nix @@ -26,12 +26,11 @@ runCommand "vm-app" rec { oneshot ''; up = writeText "net-up" '' - backtick -i LOCAL_IP { + backtick -E LOCAL_IP { pipeline { ip -j link show eth0 } pipeline { jq -r ".[0].address | split(\":\") | .[4:6] | \"0x\" + .[]" } xargs printf "100.64.%d.%d" } - importas -iu LOCAL_IP LOCAL_IP if { ip address add ''${LOCAL_IP}/32 dev eth0 } if { ip link set eth0 up } diff --git a/pkgs/os-specific/linux/spectrum/vm/net/default.nix b/pkgs/os-specific/linux/spectrum/vm/net/default.nix index 5921b62fcf7..75c86b8f92c 100644 --- a/pkgs/os-specific/linux/spectrum/vm/net/default.nix +++ b/pkgs/os-specific/linux/spectrum/vm/net/default.nix @@ -54,12 +54,11 @@ runCommand "vm-net" rec { # Our IP is encoded in the NIC-specific portion of the # interface's MAC address. - backtick -i CLIENT_IP { + backtick -E CLIENT_IP { pipeline { ip -j link show $INTERFACE } pipeline { jq -r ".[0].address | split(\":\") | .[4:6] | \"0x\" + .[]" } xargs printf "100.64.%d.%d" } - importas -iu CLIENT_IP CLIENT_IP if { ip address add 169.254.0.1/32 dev $INTERFACE } if { ip link set $INTERFACE up } @@ -121,7 +120,7 @@ runCommand "vm-net" rec { ''; run = writeScript "connman-run" '' #! ${execline}/bin/execlineb -S0 - backtick -in HARDWARE_INTERFACES { + backtick -E HARDWARE_INTERFACES { pipeline { find -L /sys/class/net -mindepth 2 -maxdepth 2 -name address -print0 } @@ -132,7 +131,6 @@ runCommand "vm-net" rec { # Extract the interface names from the address file paths. awk -F/ "{if (NR > 1) printf \",\"; printf \"%s\", $5}" } - importas -iu HARDWARE_INTERFACES HARDWARE_INTERFACES ${connman}/bin/connmand -ni $HARDWARE_INTERFACES ''; -- cgit 1.4.1