Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1From 4893cc08acc81bfc2f8730ea108574aedae909aa Mon Sep 17 00:00:00 2001 2From: Fernando Rodrigues <alpha@sigmasquadron.net> 3Date: Fri, 4 Jul 2025 20:09:06 +0000 4Subject: [PATCH 2/2] xen/tools/hotplug/Linux: patch external binary calls 5 6This patch replaces all instances of executable calls and static FHS 7paths in the hotplug scripts with at-padded variables that can be 8replaced by replaceVars during a Nix build. 9 10Signed-off-by: Fernando Rodrigues <alpha@sigmasquadron.net> 11 12diff --git a/tools/hotplug/Linux/block b/tools/hotplug/Linux/block 13index 2691b56951..bd41313bf8 100644 14--- a/tools/hotplug/Linux/block 15+++ b/tools/hotplug/Linux/block 16@@ -1,5 +1,5 @@ 17 #!/bin/bash 18 19-dir=$(dirname "$0") 20+dir=$(@dirname@ "$0") 21 . "$dir/block-common.sh" 22 23@@ -32,5 +32,5 @@ find_free_loopback_helper() { 24 find_free_loopback_dev() { 25 local loopdev 26- loopdev=$(losetup -a | sed -e 's+^/dev/loop++' -e 's/:.*//' | find_free_loopback_helper) 27+ loopdev=$(@losetup@ -a | @sed@ -e 's+^/dev/loop++' -e 's/:.*//' | find_free_loopback_helper) 28 if [ -n "$loopdev" ] && [ -b "$loopdev" ]; then 29 echo "$loopdev" 30@@ -67,6 +67,6 @@ check_sharing() 31 local inode="$4" 32 33- shared_list=$(losetup -a | 34- sed -n -e "s@^\([^:]\+\)\(:[[:blank:]]\[0*${dev}\]:${inode}[[:blank:]](.*)\)@\1@p" ) 35+ shared_list=$(@losetup@ -a | 36+ @sed@ -n -e "s@^\([^:]\+\)\(:[[:blank:]]\[0*${dev}\]:${inode}[[:blank:]](.*)\)@\1@p" ) 37 for dev in $shared_list 38 do 39@@ -95,5 +95,5 @@ check_sharing() 40 fi 41 42- for file in $(cat /proc/mounts | grep -v "$toskip" | cut -f 1 -d ' ') 43+ for file in $(@cat@ /proc/mounts | @grep@ -v "$toskip" | @cut@ -f 1 -d ' ') 44 do 45 if [ -e "$file" ] 46@@ -268,5 +268,5 @@ case "$command" in 47 if [ -L "$dev" ] 48 then 49- dev=$(readlink -f "$dev") || fatal "$dev link does not exist." 50+ dev=$(@readlink@ -f "$dev") || fatal "$dev link does not exist." 51 fi 52 test -e "$dev" || fatal "$dev does not exist." 53@@ -283,5 +283,5 @@ case "$command" in 54 # Canonicalise the file, for sharing check comparison, and the mode 55 # for ease of use here. 56- file=$(readlink -f "$p") || fatal "$p does not exist." 57+ file=$(@readlink@ -f "$p") || fatal "$p does not exist." 58 test -f "$file" || fatal "$file does not exist." 59 mode=$(canonicalise_mode "$mode") 60@@ -298,5 +298,5 @@ case "$command" in 61 fi 62 63- if [ "$mode" = 'w' ] && ! stat "$file" -c %A | grep -q w 64+ if [ "$mode" = 'w' ] && ! @stat@ "$file" -c %A | @grep@ -q w 65 then 66 release_lock "block" 67@@ -308,6 +308,6 @@ mount it read-write in a guest domain." 68 if [ "x$mode" != 'x!' ] 69 then 70- inode=$(stat -c '%i' "$file") 71- dev=$(stat -c '%D' "$file") 72+ inode=$(@stat@ -c '%i' "$file") 73+ dev=$(@stat@ -c '%D' "$file") 74 if [ -z "$inode" ] || [ -z "$dev" ] 75 then 76@@ -318,5 +318,5 @@ mount it read-write in a guest domain." 77 fi 78 79- loopdev=$(losetup -f 2>/dev/null || find_free_loopback_dev) 80+ loopdev=$(@losetup@ -f 2>/dev/null || find_free_loopback_dev) 81 if [ "$loopdev" = '' ] 82 then 83@@ -325,5 +325,5 @@ mount it read-write in a guest domain." 84 fi 85 86- if LANG=C losetup -h 2>&1 | grep read-only >/dev/null 87+ if LANG=C @losetup@ -h 2>&1 | @grep@ read-only >/dev/null 88 then 89 roflag="-$mode"; roflag="${roflag#-w}"; roflag="${roflag#-!}" 90@@ -331,5 +331,5 @@ mount it read-write in a guest domain." 91 roflag='' 92 fi 93- do_or_die losetup $roflag "$loopdev" "$file" 94+ do_or_die @losetup@ $roflag "$loopdev" "$file" 95 xenstore_write "$XENBUS_PATH/node" "$loopdev" 96 write_dev "$loopdev" 97@@ -355,5 +355,5 @@ mount it read-write in a guest domain." 98 claim_lock "block" 99 node=$(xenstore_read "$XENBUS_PATH/node") 100- losetup -d "$node" 101+ @losetup@ -d "$node" 102 release_lock "block" 103 exit 0 104diff --git a/tools/hotplug/Linux/block-common.sh b/tools/hotplug/Linux/block-common.sh 105index 5c80237d99..5e1c350555 100644 106--- a/tools/hotplug/Linux/block-common.sh 107+++ b/tools/hotplug/Linux/block-common.sh 108@@ -16,5 +16,5 @@ 109 110 111-dir=$(dirname "$0") 112+dir=$(@dirname@ "$0") 113 . "$dir/xen-hotplug-common.sh" 114 115@@ -46,5 +46,5 @@ ebusy() 116 device_major_minor() 117 { 118- stat -L -c %t:%T "$1" 119+ @stat@ -L -c %t:%T "$1" 120 } 121 122diff --git a/tools/hotplug/Linux/block-drbd-probe b/tools/hotplug/Linux/block-drbd-probe 123index 7b2968b6d9..ba246cd132 100755 124--- a/tools/hotplug/Linux/block-drbd-probe 125+++ b/tools/hotplug/Linux/block-drbd-probe 126@@ -32,6 +32,6 @@ function get_res_name() 127 { 128 local drbd_dev=$1 129- local drbd_dev_list=($(drbdadm sh-dev all)) 130- local drbd_res_list=($(drbdadm sh-resource all)) 131+ local drbd_dev_list=($(@drbdadm@ sh-dev all)) 132+ local drbd_res_list=($(@drbdadm@ sh-resource all)) 133 local temp_drbd_dev temp_drbd_res 134 local found=0 135@@ -49,5 +49,5 @@ function get_res_name() 136 137 for temp_drbd_res in ${drbd_res_list[@]}; do 138- temp_drbd_dev=$(drbdadm sh-dev $temp_drbd_res) 139+ temp_drbd_dev=$(@drbdadm@ sh-dev $temp_drbd_res) 140 if [[ "$temp_drbd_dev" == "$drbd_dev" ]]; then 141 drbd_res="$temp_drbd_res" 142@@ -67,5 +67,5 @@ fi 143 144 # check protocol 145-drbdsetup $1 show | grep -q "protocol D;" 146+@drbdsetup@ $1 show | @grep@ -q "protocol D;" 147 if [[ $? -ne 0 ]]; then 148 exit 3 149@@ -73,5 +73,5 @@ fi 150 151 # check connect status 152-state=$(drbdadm cstate "$drbd_res") 153+state=$(@drbdadm@ cstate "$drbd_res") 154 if [[ "$state" != "Connected" ]]; then 155 exit 4 156@@ -79,5 +79,5 @@ fi 157 158 # check role 159-role=$(drbdadm role "$drbd_res") 160+role=$(@drbdadm@ role "$drbd_res") 161 if [[ "$role" != "Primary/Secondary" ]]; then 162 exit 4 163diff --git a/tools/hotplug/Linux/block-dummy b/tools/hotplug/Linux/block-dummy 164index 57d40b5fce..50bbf09bb6 100644 165--- a/tools/hotplug/Linux/block-dummy 166+++ b/tools/hotplug/Linux/block-dummy 167@@ -23,10 +23,10 @@ 168 # script=block-dummy,vdev=xvda,target=dummy:<file> 169 170-dir=$(dirname "$0") 171+dir=$(@dirname@ "$0") 172 . "$dir/block-common.sh" 173 174 check_tools() 175 { 176- if ! command -v losetup > /dev/null 2>&1; then 177+ if ! command -v @losetup@ > /dev/null 2>&1; then 178 fatal "Unable to find losetup" 179 fi 180@@ -56,5 +56,5 @@ add() 181 test -f "$file" || fatal "$file does not exist." 182 183- loopdev=$(losetup -f 2>/dev/null || find_free_loopback_dev) 184+ loopdev=$(@losetup@ -f 2>/dev/null || find_free_loopback_dev) 185 if [ "$loopdev" = '' ] 186 then 187@@ -62,5 +62,5 @@ add() 188 fi 189 190- if LANG=C losetup -h 2>&1 | grep read-only >/dev/null 191+ if LANG=C @losetup@ -h 2>&1 | @grep@ read-only >/dev/null 192 then 193 roflag="-$mode"; roflag="${roflag#-w}"; roflag="${roflag#-!}" 194@@ -69,5 +69,5 @@ add() 195 fi 196 197- do_or_die losetup $roflag "$loopdev" "$file" 198+ do_or_die @losetup@ $roflag "$loopdev" "$file" 199 # FIXME Is this OK? 200 xenstore_write "$XENBUS_PATH/node" "$loopdev" 201@@ -79,5 +79,5 @@ remove() 202 { 203 node=$(xenstore_read "$XENBUS_PATH/node") 204- losetup -d "$node" 205+ @losetup@ -d "$node" 206 } 207 208diff --git a/tools/hotplug/Linux/block-enbd b/tools/hotplug/Linux/block-enbd 209index 67faa84268..77599ff6df 100644 210--- a/tools/hotplug/Linux/block-enbd 211+++ b/tools/hotplug/Linux/block-enbd 212@@ -8,5 +8,5 @@ 213 # This assumes you're running a correctly configured server at the other end! 214 215-dir=$(dirname "$0") 216+dir=$(@dirname@ "$0") 217 . "$dir/block-common.sh" 218 219@@ -14,5 +14,5 @@ case "$command" in 220 add) 221 for dev in /dev/nd*; do 222- if nbd-client $2:$3 $dev; then 223+ if @nbd-client@ $2:$3 $dev; then 224 write_dev $dev 225 exit 0 226@@ -22,5 +22,5 @@ case "$command" in 227 ;; 228 remove) 229- nbd-client -d $2 230+ @nbd-client@ -d $2 231 exit 0 232 ;; 233diff --git a/tools/hotplug/Linux/block-iscsi b/tools/hotplug/Linux/block-iscsi 234index 3615905252..ad45a3685b 100644 235--- a/tools/hotplug/Linux/block-iscsi 236+++ b/tools/hotplug/Linux/block-iscsi 237@@ -24,18 +24,18 @@ 238 # 239 240-dir=$(dirname "$0") 241+dir=$(@dirname@ "$0") 242 . "$dir/block-common.sh" 243 244 remove_label() 245 { 246- echo $1 | sed "s/^\("$2"\)//" 247+ echo $1 | @sed@ "s/^\("$2"\)//" 248 } 249 250 check_tools() 251 { 252- if ! command -v iscsiadm > /dev/null 2>&1; then 253+ if ! command -v @iscsiadm@ > /dev/null 2>&1; then 254 fatal "Unable to find iscsiadm tool" 255 fi 256- if [ "$multipath" = "y" ] && ! command -v multipath > /dev/null 2>&1; then 257+ if [ "$multipath" = "y" ] && ! command -v @multipath@ > /dev/null 2>&1; then 258 fatal "Unable to find multipath" 259 fi 260@@ -75,5 +75,5 @@ find_device() 261 count=0 262 while [ ! -e /dev/disk/by-path/*"$iqn"-lun-0 ]; do 263- sleep 1 264+ @sleep@ 1 265 count=`expr $count + 1` 266 if [ count = 100 ]; then 267@@ -82,10 +82,10 @@ find_device() 268 fi 269 done 270- sddev=$(readlink -f /dev/disk/by-path/*"$iqn"-lun-0 || true) 271+ sddev=$(@readlink@ -f /dev/disk/by-path/*"$iqn"-lun-0 || true) 272 if [ ! -b "$sddev" ]; then 273 fatal "Unable to find attached device path" 274 fi 275 if [ "$multipath" = "y" ]; then 276- mdev=$(multipath -ll "$sddev" | head -1 | awk '{ print $1}') 277+ mdev=$(@multipath@ -ll "$sddev" | @head@ -1 | @awk@ '{ print $1}') 278 if [ ! -b /dev/mapper/"$mdev" ]; then 279 fatal "Unable to find attached device multipath" 280@@ -101,5 +101,5 @@ find_device() 281 attach() 282 { 283- do_or_die iscsiadm -m node --targetname "$iqn" -p "$portal" --login > /dev/null 284+ do_or_die @iscsiadm@ -m node --targetname "$iqn" -p "$portal" --login > /dev/null 285 find_device 286 } 287@@ -110,7 +110,7 @@ prepare() 288 { 289 # Check if target is already opened 290- iscsiadm -m session 2>&1 | grep -q "$iqn" && fatal "Device already opened" 291+ @iscsiadm@ -m session 2>&1 | @grep@ -q "$iqn" && fatal "Device already opened" 292 # Discover portal targets 293- iscsiadm -m discovery -t st -p $portal 2>&1 | grep -q "$iqn" || \ 294+ @iscsiadm@ -m discovery -t st -p $portal 2>&1 | @grep@ -q "$iqn" || \ 295 fatal "No matching target iqn found" 296 } 297@@ -128,5 +128,5 @@ remove() 298 { 299 find_device 300- do_or_die iscsiadm -m node --targetname "$iqn" -p "$portal" --logout > /dev/null 301+ do_or_die @iscsiadm@ -m node --targetname "$iqn" -p "$portal" --logout > /dev/null 302 } 303 304diff --git a/tools/hotplug/Linux/block-nbd b/tools/hotplug/Linux/block-nbd 305index b29b31564a..a98350b121 100644 306--- a/tools/hotplug/Linux/block-nbd 307+++ b/tools/hotplug/Linux/block-nbd 308@@ -8,5 +8,5 @@ 309 # This assumes you're running a correctly configured server at the other end! 310 311-dir=$(dirname "$0") 312+dir=$(@dirname@ "$0") 313 . "$dir/block-common.sh" 314 315@@ -14,5 +14,5 @@ case "$command" in 316 add) 317 for dev in /dev/nbd*; do 318- if nbd-client $2 $3 $dev; then 319+ if @nbd-client@ $2 $3 $dev; then 320 write_dev $dev 321 exit 0 322@@ -22,5 +22,5 @@ case "$command" in 323 ;; 324 remove) 325- nbd-client -d $2 326+ @nbd-client@ -d $2 327 exit 0 328 ;; 329diff --git a/tools/hotplug/Linux/block-tap b/tools/hotplug/Linux/block-tap 330index 95970a61f6..a03a36f8b6 100755 331--- a/tools/hotplug/Linux/block-tap 332+++ b/tools/hotplug/Linux/block-tap 333@@ -29,10 +29,10 @@ 334 # format/<type> is either "aio" (for raw files), or "vhd" 335 336-dir=$(dirname "$0") 337+dir=$(@dirname@ "$0") 338 . "$dir/block-common.sh" 339 340 remove_label() 341 { 342- echo $1 | sed "s/^\("$2"\)//" 343+ echo $1 | @sed@ "s/^\("$2"\)//" 344 } 345 346@@ -102,5 +102,5 @@ count_using() 347 do 348 f=$(xenstore_read_default "$base_path/$dom/$dev/params" "") 349- f=$(echo "$f" | cut -d ":" -f 2) 350+ f=$(echo "$f" | @cut@ -d ":" -f 2) 351 352 if [ -n "$f" ] && [ "$file" = $f ] ; then 353@@ -131,5 +131,5 @@ check_tap_sharing() 354 for dev in $(xenstore-list "$base_path/$dom") ; do 355 local f=$(xenstore_read_default "$base_path/$dom/$dev/params" "") 356- f=$(echo "$f" | cut -d ":" -f 2) 357+ f=$(echo "$f" | @cut@ -d ":" -f 2) 358 359 if [ -n "$f" ] && [ "$file" = "$f" ] ; then 360diff --git a/tools/hotplug/Linux/colo-proxy-setup b/tools/hotplug/Linux/colo-proxy-setup 361index d709146c47..e0f44364cc 100755 362--- a/tools/hotplug/Linux/colo-proxy-setup 363+++ b/tools/hotplug/Linux/colo-proxy-setup 364@@ -1,5 +1,5 @@ 365 #! /bin/bash 366 367-dir=$(dirname "$0") 368+dir=$(@dirname@ "$0") 369 . "$dir/xen-hotplug-common.sh" 370 . "$dir/hotplugpath.sh" 371@@ -38,60 +38,60 @@ fi 372 function setup_primary() 373 { 374- do_without_error tc qdisc add dev $vifname root handle 1: prio 375- do_without_error tc filter add dev $vifname parent 1: protocol ip prio 10 \ 376+ do_without_error @tc@ qdisc add dev $vifname root handle 1: prio 377+ do_without_error @tc@ filter add dev $vifname parent 1: protocol ip prio 10 \ 378 u32 match u32 0 0 flowid 1:2 action mirred egress mirror dev $forwarddev 379- do_without_error tc filter add dev $vifname parent 1: protocol arp prio 11 \ 380+ do_without_error @tc@ filter add dev $vifname parent 1: protocol arp prio 11 \ 381 u32 match u32 0 0 flowid 1:2 action mirred egress mirror dev $forwarddev 382- do_without_error tc filter add dev $vifname parent 1: protocol ipv6 prio \ 383+ do_without_error @tc@ filter add dev $vifname parent 1: protocol ipv6 prio \ 384 12 u32 match u32 0 0 flowid 1:2 action mirred egress mirror \ 385 dev $forwarddev 386 387- do_without_error modprobe nf_conntrack_ipv4 388- do_without_error modprobe xt_PMYCOLO sec_dev=$forwarddev 389+ do_without_error @modprobe@ nf_conntrack_ipv4 390+ do_without_error @modprobe@ xt_PMYCOLO sec_dev=$forwarddev 391 392- iptables -t mangle -I PREROUTING -m physdev --physdev-in \ 393+ @iptables@ -t mangle -I PREROUTING -m physdev --physdev-in \ 394 $vifname -j PMYCOLO --index $index 395- ip6tables -t mangle -I PREROUTING -m physdev --physdev-in \ 396+ @ip6tables@ -t mangle -I PREROUTING -m physdev --physdev-in \ 397 $vifname -j PMYCOLO --index $index 398- do_without_error arptables -I INPUT -i $forwarddev -j MARK --set-mark $index 399+ do_without_error @arptables@ -I INPUT -i $forwarddev -j MARK --set-mark $index 400 } 401 402 function teardown_primary() 403 { 404- do_without_error tc filter del dev $vifname parent 1: protocol ip prio 10 u32 match u32 \ 405+ do_without_error @tc@ filter del dev $vifname parent 1: protocol ip prio 10 u32 match u32 \ 406 0 0 flowid 1:2 action mirred egress mirror dev $forwarddev 407- do_without_error tc filter del dev $vifname parent 1: protocol arp prio 11 u32 match u32 \ 408+ do_without_error @tc@ filter del dev $vifname parent 1: protocol arp prio 11 u32 match u32 \ 409 0 0 flowid 1:2 action mirred egress mirror dev $forwarddev 410- do_without_error tc filter del dev $vifname parent 1: protocol ipv6 prio 12 u32 match u32 \ 411+ do_without_error @tc@ filter del dev $vifname parent 1: protocol ipv6 prio 12 u32 match u32 \ 412 0 0 flowid 1:2 action mirred egress mirror dev $forwarddev 413- do_without_error tc qdisc del dev $vifname root handle 1: prio 414+ do_without_error @tc@ qdisc del dev $vifname root handle 1: prio 415 416- do_without_error iptables -t mangle -D PREROUTING -m physdev --physdev-in \ 417+ do_without_error @iptables@ -t mangle -D PREROUTING -m physdev --physdev-in \ 418 $vifname -j PMYCOLO --index $index 419- do_without_error ip6tables -t mangle -D PREROUTING -m physdev --physdev-in \ 420+ do_without_error @ip6tables@ -t mangle -D PREROUTING -m physdev --physdev-in \ 421 $vifname -j PMYCOLO --index $index 422- do_without_error arptables -F 423- do_without_error rmmod xt_PMYCOLO 424+ do_without_error @arptables@ -F 425+ do_without_error @rmmod@ xt_PMYCOLO 426 } 427 428 function setup_secondary() 429 { 430- if which brctl >&/dev/null; then 431- do_without_error brctl delif $bridge $vifname 432- do_without_error brctl addbr $forwardbr 433- do_without_error brctl addif $forwardbr $vifname 434- do_without_error brctl addif $forwardbr $forwarddev 435+ if @which@ @brctl@ >&/dev/null; then 436+ do_without_error @brctl@ delif $bridge $vifname 437+ do_without_error @brctl@ addbr $forwardbr 438+ do_without_error @brctl@ addif $forwardbr $vifname 439+ do_without_error @brctl@ addif $forwardbr $forwarddev 440 else 441- do_without_error ip link set $vifname nomaster 442- do_without_error ip link add name $forwardbr type bridge 443- do_without_error ip link set $vifname master $forwardbr 444- do_without_error ip link set $forwarddev master $forwardbr 445+ do_without_error @ip@ link set $vifname nomaster 446+ do_without_error @ip@ link add name $forwardbr type bridge 447+ do_without_error @ip@ link set $vifname master $forwardbr 448+ do_without_error @ip@ link set $forwarddev master $forwardbr 449 fi 450- do_without_error ip link set dev $forwardbr up 451- do_without_error modprobe xt_SECCOLO 452+ do_without_error @ip@ link set dev $forwardbr up 453+ do_without_error @modprobe@ xt_SECCOLO 454 455- iptables -t mangle -I PREROUTING -m physdev --physdev-in \ 456+ @iptables@ -t mangle -I PREROUTING -m physdev --physdev-in \ 457 $vifname -j SECCOLO --index $index 458- ip6tables -t mangle -I PREROUTING -m physdev --physdev-in \ 459+ @ip6tables@ -t mangle -I PREROUTING -m physdev --physdev-in \ 460 $vifname -j SECCOLO --index $index 461 } 462@@ -99,21 +99,21 @@ function setup_secondary() 463 function teardown_secondary() 464 { 465- if which brctl >&/dev/null; then 466- do_without_error brctl delif $forwardbr $forwarddev 467- do_without_error brctl delif $forwardbr $vifname 468- do_without_error brctl delbr $forwardbr 469- do_without_error brctl addif $bridge $vifname 470+ if @which@ @brctl@ >&/dev/null; then 471+ do_without_error @brctl@ delif $forwardbr $forwarddev 472+ do_without_error @brctl@ delif $forwardbr $vifname 473+ do_without_error @brctl@ delbr $forwardbr 474+ do_without_error @brctl@ addif $bridge $vifname 475 else 476- do_without_error ip link set $forwarddev nomaster 477- do_without_error ip link set $vifname nomaster 478- do_without_error ip link delete $forwardbr type bridge 479- do_without_error ip link set $vifname master $bridge 480+ do_without_error @ip@ link set $forwarddev nomaster 481+ do_without_error @ip@ link set $vifname nomaster 482+ do_without_error @ip@ link delete $forwardbr type bridge 483+ do_without_error @ip@ link set $vifname master $bridge 484 fi 485 486- do_without_error iptables -t mangle -D PREROUTING -m physdev --physdev-in \ 487+ do_without_error @iptables@ -t mangle -D PREROUTING -m physdev --physdev-in \ 488 $vifname -j SECCOLO --index $index 489- do_without_error ip6tables -t mangle -D PREROUTING -m physdev --physdev-in \ 490+ do_without_error @ip6tables@ -t mangle -D PREROUTING -m physdev --physdev-in \ 491 $vifname -j SECCOLO --index $index 492- do_without_error rmmod xt_SECCOLO 493+ do_without_error @rmmod@ xt_SECCOLO 494 } 495 496diff --git a/tools/hotplug/Linux/external-device-migrate b/tools/hotplug/Linux/external-device-migrate 497index f5942a6a95..228917b784 100644 498--- a/tools/hotplug/Linux/external-device-migrate 499+++ b/tools/hotplug/Linux/external-device-migrate 500@@ -24,10 +24,10 @@ set -x 501 # synchronization 502 503-dir=$(dirname "$0") 504+dir=$(@dirname@ "$0") 505 . "$dir/logging.sh" 506 507 508 function ext_dev_migrate_usage() { 509-cat <<EOF 510+@cat@ <<EOF 511 Pass the following command line parameters to the script: 512 513diff --git a/tools/hotplug/Linux/init.d/xen-watchdog.in b/tools/hotplug/Linux/init.d/xen-watchdog.in 514index a0bde199c4..cefa3b81f8 100644 515--- a/tools/hotplug/Linux/init.d/xen-watchdog.in 516+++ b/tools/hotplug/Linux/init.d/xen-watchdog.in 517@@ -26,5 +26,5 @@ test -f $xencommons_config/xencommons && . $xencommons_config/xencommons 518 test -n "$XENWATCHDOGD_ARGS" || XENWATCHDOGD_ARGS='30 15' 519 DAEMON=${sbindir}/xenwatchdogd 520-base=$(basename $DAEMON) 521+base=$(@basename@ $DAEMON) 522 523 # Source function library. 524@@ -64,5 +64,5 @@ stop() { 525 echo -n $"Stopping domain watchdog daemon: " 526 527- killall -USR1 $base 2>/dev/null 528+ @killall@ -USR1 $base 2>/dev/null 529 r=$? 530 [ "$r" -eq 0 ] && success $"$base stop" || failure $"$base stop" 531diff --git a/tools/hotplug/Linux/init.d/xencommons.in b/tools/hotplug/Linux/init.d/xencommons.in 532index 7fd6903b98..dcc8de631b 100644 533--- a/tools/hotplug/Linux/init.d/xencommons.in 534+++ b/tools/hotplug/Linux/init.d/xencommons.in 535@@ -39,5 +39,5 @@ fi 536 if test "x$1" = xstart && \ 537 ! test -f /proc/xen/capabilities && \ 538- ! grep '^xenfs ' /proc/mounts >/dev/null; 539+ ! @grep@ '^xenfs ' /proc/mounts >/dev/null; 540 then 541 mount -t xenfs xenfs /proc/xen 542@@ -48,5 +48,5 @@ fi 543 # empty capabilities file in pv_ops domU kernel 544 if test -f /proc/xen/capabilities && \ 545- ! grep -q "control_d" /proc/xen/capabilities ; then 546+ ! @grep@ -q "control_d" /proc/xen/capabilities ; then 547 exit 0 548 fi 549@@ -55,9 +55,9 @@ do_start () { 550 local mod 551 552- for mod in $BACKEND_MODULES ; do modprobe "$mod" &>/dev/null ; done 553+ for mod in $BACKEND_MODULES ; do @modprobe@ "$mod" &>/dev/null ; done 554 555- mkdir -m700 -p ${XEN_RUN_DIR} 556- mkdir -m700 -p ${XEN_LOCK_DIR} 557- mkdir -p ${XEN_LOG_DIR} 558+ @mkdir@ -m700 -p ${XEN_RUN_DIR} 559+ @mkdir@ -m700 -p ${XEN_LOCK_DIR} 560+ @mkdir@ -p ${XEN_LOG_DIR} 561 562 @XEN_SCRIPT_DIR@/launch-xenstore || exit 1 563@@ -79,6 +79,6 @@ do_stop () { 564 if read 2>/dev/null <$XENCONSOLED_PIDFILE pid; then 565 kill $pid 566- while kill -9 $pid >/dev/null 2>&1; do sleep 1; done 567- rm -f $XENCONSOLED_PIDFILE 568+ while kill -9 $pid >/dev/null 2>&1; do @sleep@ 1; done 569+ @rm@ -f $XENCONSOLED_PIDFILE 570 fi 571 572@@ -86,6 +86,6 @@ do_stop () { 573 if read 2>/dev/null <$QEMU_PIDFILE pid; then 574 kill $pid 575- while kill -9 $pid >/dev/null 2>&1; do sleep 1; done 576- rm -f $QEMU_PIDFILE 577+ while kill -9 $pid >/dev/null 2>&1; do @sleep@ 1; done 578+ @rm@ -f $QEMU_PIDFILE 579 fi 580 581diff --git a/tools/hotplug/Linux/init.d/xendriverdomain.in b/tools/hotplug/Linux/init.d/xendriverdomain.in 582index 17b381c3dc..064906f027 100644 583--- a/tools/hotplug/Linux/init.d/xendriverdomain.in 584+++ b/tools/hotplug/Linux/init.d/xendriverdomain.in 585@@ -35,5 +35,5 @@ fi 586 if test "x$1" = xstart && \ 587 ! test -f /proc/xen/capabilities && \ 588- ! grep '^xenfs ' /proc/mounts >/dev/null; 589+ ! @grep@ '^xenfs ' /proc/mounts >/dev/null; 590 then 591 mount -t xenfs xenfs /proc/xen 592@@ -44,5 +44,5 @@ fi 593 # empty capabilities file in pv_ops domU kernel 594 if ! test -f /proc/xen/capabilities || \ 595- grep -q "control_d" /proc/xen/capabilities ; then 596+ @grep@ -q "control_d" /proc/xen/capabilities ; then 597 exit 0 598 fi 599@@ -50,5 +50,5 @@ fi 600 do_start () { 601 echo Starting xl devd... 602- mkdir -p "${XEN_RUN_DIR}" 603+ @mkdir@ -p "${XEN_RUN_DIR}" 604 ${sbindir}/xl devd --pidfile=$XLDEVD_PIDFILE $XLDEVD_ARGS 605 } 606@@ -57,6 +57,6 @@ do_stop () { 607 if read 2>/dev/null <$XLDEVD_PIDFILE pid; then 608 kill $pid 609- while kill -9 $pid >/dev/null 2>&1; do sleep 1; done 610- rm -f $XLDEVD_PIDFILE 611+ while kill -9 $pid >/dev/null 2>&1; do @sleep@ 1; done 612+ @rm@ -f $XLDEVD_PIDFILE 613 fi 614 } 615diff --git a/tools/hotplug/Linux/launch-xenstore.in b/tools/hotplug/Linux/launch-xenstore.in 616index da4eeca7c5..059036d899 100644 617--- a/tools/hotplug/Linux/launch-xenstore.in 618+++ b/tools/hotplug/Linux/launch-xenstore.in 619@@ -32,5 +32,5 @@ timeout_xenstore () { 620 echo -n . 621 time=$(($time+1)) 622- sleep 1 623+ @sleep@ 1 624 done 625 echo 626@@ -51,5 +51,5 @@ test -f @CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons && . @CONFIG_DIR@/@CONFIG_LEAF 627 [ "$XENSTORETYPE" = "" ] && XENSTORETYPE=daemon 628 629-/bin/mkdir -p @XEN_RUN_DIR@ 630+@mkdir@ -p @XEN_RUN_DIR@ 631 632 [ "$XENSTORETYPE" = "daemon" ] && { 633@@ -72,5 +72,5 @@ test -f @CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons && . @CONFIG_DIR@/@CONFIG_LEAF 634 } 635 [ -r /proc/sys/fs/nr_open ] && { 636- MAX_FDS=`cat /proc/sys/fs/nr_open` 637+ MAX_FDS=`@cat@ /proc/sys/fs/nr_open` 638 [ "$XENSTORED_MAX_OPEN_FDS" = "unlimited" ] && XENSTORED_MAX_OPEN_FDS=$MAX_FDS 639 [ $XENSTORED_MAX_OPEN_FDS -gt $MAX_FDS ] && { 640@@ -81,11 +81,11 @@ test -f @CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons && . @CONFIG_DIR@/@CONFIG_LEAF 641 } 642 643- rm -f @XEN_RUN_DIR@/xenstored.pid 644+ @rm@ -f @XEN_RUN_DIR@/xenstored.pid 645 646 echo -n Starting $XENSTORED... 647- prlimit --nofile=$XENSTORED_MAX_OPEN_FDS $XENSTORED --pid-file @XEN_RUN_DIR@/xenstored.pid $XENSTORED_ARGS 648+ @prlimit@ --nofile=$XENSTORED_MAX_OPEN_FDS $XENSTORED --pid-file @XEN_RUN_DIR@/xenstored.pid $XENSTORED_ARGS 649 650- systemd-notify --booted 2>/dev/null || timeout_xenstore $XENSTORED || exit 1 651- XS_PID=`cat @XEN_RUN_DIR@/xenstored.pid` 652+ @systemd-notify@ --booted 2>/dev/null || timeout_xenstore $XENSTORED || exit 1 653+ XS_PID=`@cat@ @XEN_RUN_DIR@/xenstored.pid` 654 echo $XS_OOM_SCORE >/proc/$XS_PID/oom_score_adj 655 656@@ -103,5 +103,5 @@ test -f @CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons && . @CONFIG_DIR@/@CONFIG_LEAF 657 echo -n Starting $XENSTORE_DOMAIN_KERNEL... 658 ${LIBEXEC_BIN}/init-xenstore-domain $XENSTORE_DOMAIN_ARGS || exit 1 659- systemd-notify --ready 2>/dev/null 660+ @systemd-notify@ --ready 2>/dev/null 661 662 exit 0 663diff --git a/tools/hotplug/Linux/locking.sh b/tools/hotplug/Linux/locking.sh 664index 2e6fb35f02..5860157657 100644 665--- a/tools/hotplug/Linux/locking.sh 666+++ b/tools/hotplug/Linux/locking.sh 667@@ -36,5 +36,5 @@ _setlockfd() 668 claim_lock() 669 { 670- mkdir -p "$LOCK_BASEDIR" 671+ @mkdir@ -p "$LOCK_BASEDIR" 672 _setlockfd $1 673 # The locking strategy is identical to that from with-lock-ex(1) 674@@ -45,5 +45,5 @@ claim_lock() 675 while true; do 676 eval "exec $_lockfd<>$_lockfile" 677- flock -x $_lockfd || return $? 678+ @flock@ -x $_lockfd || return $? 679 # Although /dev/stdin (i.e. /proc/self/fd/0) looks like a symlink, 680 # stat(2) bypasses the synthetic symlink and directly accesses the 681@@ -53,5 +53,5 @@ claim_lock() 682 # YY.ZZZ 683 # which need to be separated and compared. 684- if stat=$( stat -L -c '%D.%i' /dev/stdin $_lockfile 0<&$_lockfd 2>/dev/null ) 685+ if stat=$( @stat@ -L -c '%D.%i' /dev/stdin $_lockfile 0<&$_lockfd 2>/dev/null ) 686 then 687 local file_stat 688@@ -75,5 +75,5 @@ release_lock() 689 { 690 _setlockfd $1 691- rm "$_lockfile" 692+ @rm@ "$_lockfile" 693 } 694 695diff --git a/tools/hotplug/Linux/logging.sh b/tools/hotplug/Linux/logging.sh 696index 3e94df1a9e..fa99d8c4c7 100644 697--- a/tools/hotplug/Linux/logging.sh 698+++ b/tools/hotplug/Linux/logging.sh 699@@ -18,4 +18,4 @@ log() { 700 local level="$1" 701 shift 702- logger -p "daemon.$level" -- "$0:" "$@" || echo "$0 $@" >&2 703+ @logger@ -p "daemon.$level" -- "$0:" "$@" || echo "$0 $@" >&2 704 } 705diff --git a/tools/hotplug/Linux/remus-netbuf-setup b/tools/hotplug/Linux/remus-netbuf-setup 706index 87dfa69778..fe4f7b6e36 100644 707--- a/tools/hotplug/Linux/remus-netbuf-setup 708+++ b/tools/hotplug/Linux/remus-netbuf-setup 709@@ -75,5 +75,5 @@ 710 # Unlike other vif scripts, vif-common is not needed here as it executes vif 711 #specific setup code such as renaming. 712-dir=$(dirname "$0") 713+dir=$(@dirname@ "$0") 714 . "$dir/xen-hotplug-common.sh" 715 716@@ -93,11 +93,11 @@ evalVariables "$@" 717 718 check_libnl_tools() { 719- if ! command -v nl-qdisc-list > /dev/null 2>&1; then 720+ if ! command -v @nl-qdisc-list@ > /dev/null 2>&1; then 721 fatal "Unable to find nl-qdisc-list tool" 722 fi 723- if ! command -v nl-qdisc-add > /dev/null 2>&1; then 724+ if ! command -v @nl-qdisc-add@ > /dev/null 2>&1; then 725 fatal "Unable to find nl-qdisc-add tool" 726 fi 727- if ! command -v nl-qdisc-delete > /dev/null 2>&1; then 728+ if ! command -v @nl-qdisc-delete@ > /dev/null 2>&1; then 729 fatal "Unable to find nl-qdisc-delete tool" 730 fi 731@@ -111,5 +111,5 @@ check_modules() { 732 for m in ifb sch_plug sch_ingress act_mirred cls_u32 733 do 734- if ! modinfo $m > /dev/null 2>&1; then 735+ if ! @modinfo@ $m > /dev/null 2>&1; then 736 fatal "Unable to find $m kernel module" 737 fi 738@@ -119,5 +119,5 @@ check_modules() { 739 #return 0 if the ifb is free 740 check_ifb() { 741- local installed=`nl-qdisc-list -d $1` 742+ local installed=`@nl-qdisc-list@ -d $1` 743 [ -n "$installed" ] && return 1 744 745@@ -140,5 +140,5 @@ check_ifb() { 746 setup_ifb() { 747 748- for ifb in `ifconfig -a -s|egrep ^ifb|cut -d ' ' -f1` 749+ for ifb in `@ifconfig@ -a -s|@egrep@ ^ifb|@cut@ -d ' ' -f1` 750 do 751 check_ifb "$ifb" || continue 752@@ -155,5 +155,5 @@ setup_ifb() { 753 #because we need to cleanup 754 xenstore_write "$XENBUS_PATH/ifb" "$REMUS_IFB" 755- do_or_die ip link set dev "$REMUS_IFB" up 756+ do_or_die @ip@ link set dev "$REMUS_IFB" up 757 } 758 759@@ -162,12 +162,12 @@ redirect_vif_traffic() { 760 local ifb=$2 761 762- do_or_die tc qdisc add dev "$vif" ingress 763+ do_or_die @tc@ qdisc add dev "$vif" ingress 764 765- tc filter add dev "$vif" parent ffff: proto ip prio 10 \ 766+ @tc@ filter add dev "$vif" parent ffff: proto ip prio 10 \ 767 u32 match u32 0 0 action mirred egress redirect dev "$ifb" >/dev/null 2>&1 768 769 if [ $? -ne 0 ] 770 then 771- do_without_error tc qdisc del dev "$vif" ingress 772+ do_without_error @tc@ qdisc del dev "$vif" ingress 773 fatal "Failed to redirect traffic from $vif to $ifb" 774 fi 775@@ -178,13 +178,13 @@ add_plug_qdisc() { 776 local ifb=$2 777 778- nl-qdisc-add --dev="$ifb" --parent root plug >/dev/null 2>&1 779+ @nl-qdisc-add@ --dev="$ifb" --parent root plug >/dev/null 2>&1 780 if [ $? -ne 0 ] 781 then 782- do_without_error tc qdisc del dev "$vif" ingress 783+ do_without_error @tc@ qdisc del dev "$vif" ingress 784 fatal "Failed to add plug qdisc to $ifb" 785 fi 786 787 #set ifb buffering limit in bytes. Its okay if this command fails 788- nl-qdisc-add --dev="$ifb" --parent root \ 789+ @nl-qdisc-add@ --dev="$ifb" --parent root \ 790 --update plug --limit=10000000 >/dev/null 2>&1 || true 791 } 792@@ -201,9 +201,9 @@ teardown_netbuf() { 793 794 if [[ "$ifb2" && "$ifb2" == "$ifb" ]]; then 795- do_without_error ip link set dev "$ifb" down 796- do_without_error nl-qdisc-delete --dev="$ifb" --parent root plug >/dev/null 2>&1 797+ do_without_error @ip@ link set dev "$ifb" down 798+ do_without_error @nl-qdisc-delete@ --dev="$ifb" --parent root plug >/dev/null 2>&1 799 xenstore-rm -t "$XENBUS_PATH/ifb" 2>/dev/null || true 800 fi 801- do_without_error tc qdisc del dev "$vif" ingress 802+ do_without_error @tc@ qdisc del dev "$vif" ingress 803 xenstore-rm -t "$XENBUS_PATH/hotplug-status" 2>/dev/null || true 804 xenstore-rm -t "$XENBUS_PATH/hotplug-error" 2>/dev/null || true 805diff --git a/tools/hotplug/Linux/systemd/xen-init-dom0.service.in b/tools/hotplug/Linux/systemd/xen-init-dom0.service.in 806index 98779b8507..cc75339377 100644 807--- a/tools/hotplug/Linux/systemd/xen-init-dom0.service.in 808+++ b/tools/hotplug/Linux/systemd/xen-init-dom0.service.in 809@@ -9,5 +9,5 @@ Type=oneshot 810 RemainAfterExit=true 811 EnvironmentFile=-@CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons 812-ExecStartPre=/bin/grep -q control_d /proc/xen/capabilities 813+ExecStartPre=@grep@ -q control_d /proc/xen/capabilities 814 ExecStart=@LIBEXEC_BIN@/xen-init-dom0 $XEN_DOM0_UUID 815 816diff --git a/tools/hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service.in b/tools/hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service.in 817index f56775bc87..a9091047da 100644 818--- a/tools/hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service.in 819+++ b/tools/hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service.in 820@@ -10,6 +10,6 @@ ConditionPathExists=/proc/xen/capabilities 821 Type=simple 822 PIDFile=@XEN_RUN_DIR@/qemu-dom0.pid 823-ExecStartPre=/bin/grep -q control_d /proc/xen/capabilities 824-ExecStartPre=/bin/mkdir -p @XEN_RUN_DIR@ 825+ExecStartPre=@grep@ -q control_d /proc/xen/capabilities 826+ExecStartPre=@mkdir@ -p @XEN_RUN_DIR@ 827 ExecStart=@qemu_xen_systemd@ -xen-domid 0 \ 828 -xen-attach -name dom0 -nographic -M xenpv -daemonize \ 829diff --git a/tools/hotplug/Linux/systemd/xenconsoled.service.in b/tools/hotplug/Linux/systemd/xenconsoled.service.in 830index d84c09aa9c..68317246ae 100644 831--- a/tools/hotplug/Linux/systemd/xenconsoled.service.in 832+++ b/tools/hotplug/Linux/systemd/xenconsoled.service.in 833@@ -11,6 +11,6 @@ Environment=XENCONSOLED_TRACE=none 834 Environment=XENCONSOLED_LOG_DIR=@XEN_LOG_DIR@/console 835 EnvironmentFile=-@CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons 836-ExecStartPre=/bin/grep -q control_d /proc/xen/capabilities 837-ExecStartPre=/bin/mkdir -p ${XENCONSOLED_LOG_DIR} @XEN_RUN_DIR@ 838+ExecStartPre=@grep@ -q control_d /proc/xen/capabilities 839+ExecStartPre=@mkdir@ -p ${XENCONSOLED_LOG_DIR} @XEN_RUN_DIR@ 840 ExecStart=@sbindir@/xenconsoled -i --log=${XENCONSOLED_TRACE} --log-dir=${XENCONSOLED_LOG_DIR} $XENCONSOLED_ARGS 841 842diff --git a/tools/hotplug/Linux/systemd/xendomains.service.in b/tools/hotplug/Linux/systemd/xendomains.service.in 843index c7bfb61eb4..314ed9e91a 100644 844--- a/tools/hotplug/Linux/systemd/xendomains.service.in 845+++ b/tools/hotplug/Linux/systemd/xendomains.service.in 846@@ -11,5 +11,5 @@ Conflicts=libvirtd.service 847 Type=oneshot 848 RemainAfterExit=true 849-ExecStartPre=/bin/grep -q control_d /proc/xen/capabilities 850+ExecStartPre=@grep@ -q control_d /proc/xen/capabilities 851 ExecStart=-@LIBEXEC_BIN@/xendomains start 852 ExecStop=@LIBEXEC_BIN@/xendomains stop 853diff --git a/tools/hotplug/Linux/systemd/xenstored.service.in b/tools/hotplug/Linux/systemd/xenstored.service.in 854index 261077dc92..7daf7369b8 100644 855--- a/tools/hotplug/Linux/systemd/xenstored.service.in 856+++ b/tools/hotplug/Linux/systemd/xenstored.service.in 857@@ -11,5 +11,5 @@ Type=notify 858 NotifyAccess=all 859 RemainAfterExit=true 860-ExecStartPre=/bin/grep -q control_d /proc/xen/capabilities 861+ExecStartPre=@grep@ -q control_d /proc/xen/capabilities 862 ExecStart=@XEN_SCRIPT_DIR@/launch-xenstore 863 864diff --git a/tools/hotplug/Linux/vif-bridge b/tools/hotplug/Linux/vif-bridge 865index 906047e82f..e110013b14 100644 866--- a/tools/hotplug/Linux/vif-bridge 867+++ b/tools/hotplug/Linux/vif-bridge 868@@ -26,5 +26,5 @@ 869 #============================================================================ 870 871-dir=$(dirname "$0") 872+dir=$(@dirname@ "$0") 873 . "$dir/vif-common.sh" 874 875@@ -33,8 +33,8 @@ bridge=$(xenstore_read_default "$XENBUS_PATH/bridge" "$bridge") 876 877 if [ -z "$bridge" ]; then 878- if which brctl >&/dev/null; then 879- bridge=$(brctl show | awk 'NR==2{print$1}') 880+ if @which@ @brctl@ >&/dev/null; then 881+ bridge=$(@brctl@ show | @awk@ 'NR==2{print$1}') 882 else 883- bridge=$(bridge link | cut -d" " -f7) 884+ bridge=$(@bridge@ link | @cut@ -d" " -f7) 885 fi 886 if [ -z "$bridge" ] 887@@ -71,5 +71,5 @@ fi 888 889 RET=0 890-ip link show dev "$bridge" 1>/dev/null 2>&1 || RET=1 891+@ip@ link show dev "$bridge" 1>/dev/null 2>&1 || RET=1 892 if [ "$RET" -eq 1 ] 893 then 894diff --git a/tools/hotplug/Linux/vif-common.sh b/tools/hotplug/Linux/vif-common.sh 895index a8e65178f9..28eb851f94 100644 896--- a/tools/hotplug/Linux/vif-common.sh 897+++ b/tools/hotplug/Linux/vif-common.sh 898@@ -16,5 +16,5 @@ 899 900 901-dir=$(dirname "$0") 902+dir=$(@dirname@ "$0") 903 . "$dir/xen-hotplug-common.sh" 904 . "$dir/xen-network-common.sh" 905@@ -73,9 +73,9 @@ rename_vif() { 906 # that interface (e.g. another running domU) because it's likely a 907 # configuration error 908- if ip link show "$vifname" >&/dev/null 909+ if @ip@ link show "$vifname" >&/dev/null 910 then 911 fatal "Cannot rename interface $dev. An interface with name $vifname already exists." 912 fi 913- do_or_die ip link set "$dev" name "$vifname" 914+ do_or_die @ip@ link set "$dev" name "$vifname" 915 } 916 917@@ -135,10 +135,10 @@ iptables_w() 918 { 919 if ! $IPTABLES_WAIT_RUNE_CHECKED ; then 920- iptables $IPTABLES_WAIT_RUNE -L -n >& /dev/null 921+ @iptables@ $IPTABLES_WAIT_RUNE -L -n >& /dev/null 922 if [[ $? == 0 ]] ; then 923 # If we succeed, then -w is supported; don't check again 924 IPTABLES_WAIT_RUNE_CHECKED=true 925 elif [[ $? == 2 ]] ; then 926- iptables -L -n >& /dev/null 927+ @iptables@ -L -n >& /dev/null 928 if [[ $? != 2 ]] ; then 929 # If we fail with PARAMETER_PROBLEM (2) with -w and 930@@ -150,5 +150,5 @@ iptables_w() 931 fi 932 fi 933- iptables $IPTABLES_WAIT_RUNE "$@" 934+ @iptables@ $IPTABLES_WAIT_RUNE "$@" 935 } 936 937@@ -221,5 +221,5 @@ handle_iptable() 938 ip_of() 939 { 940- ip -4 -o addr show primary dev "$1" | awk '$3 == "inet" {split($4,i,"/"); print i[1]; exit}' 941+ @ip@ -4 -o addr show primary dev "$1" | @awk@ '$3 == "inet" {split($4,i,"/"); print i[1]; exit}' 942 } 943 944diff --git a/tools/hotplug/Linux/vif-nat b/tools/hotplug/Linux/vif-nat 945index fd34afbb96..8921de58f3 100644 946--- a/tools/hotplug/Linux/vif-nat 947+++ b/tools/hotplug/Linux/vif-nat 948@@ -22,5 +22,5 @@ 949 950 951-dir=$(dirname "$0") 952+dir=$(@dirname@ "$0") 953 . "$dir/vif-common.sh" 954 955@@ -62,5 +62,5 @@ ip_from_dom() 956 routing_ip() 957 { 958- echo $(echo $1 | awk -F. '{print $1"."$2"."$3"."$4 + 127}') 959+ echo $(echo $1 | @awk@ -F. '{print $1"."$2"."$3"."$4 + 127}') 960 } 961 962@@ -84,5 +84,5 @@ router_ip=$(routing_ip "$ip") 963 964 # Split the given IP/bits pair. 965-vif_ip=`echo ${ip} | awk -F/ '{print $1}'` 966+vif_ip=`echo ${ip} | @awk@ -F/ '{print $1}'` 967 968 hostname=dom$domid 969@@ -94,11 +94,11 @@ fi 970 dhcparg_remove_entry() 971 { 972- local tmpfile=$(mktemp) 973- sed -e "s/${dev} //" "$dhcpd_arg_file" >"$tmpfile" 974- if ! diff "$tmpfile" "$dhcpd_arg_file" >/dev/null 975+ local tmpfile=$(@mktemp@) 976+ @sed@ -e "s/${dev} //" "$dhcpd_arg_file" >"$tmpfile" 977+ if ! @diff@ "$tmpfile" "$dhcpd_arg_file" >/dev/null 978 then 979- cp "$tmpfile" "$dhcpd_arg_file" 980+ @cp@ "$tmpfile" "$dhcpd_arg_file" 981 fi 982- rm "$tmpfile" 983+ @rm@ "$tmpfile" 984 } 985 986@@ -106,24 +106,24 @@ dhcparg_add_entry() 987 { 988 dhcparg_remove_entry 989- local tmpfile=$(mktemp) 990+ local tmpfile=$(@mktemp@) 991 # handle Red Hat, SUSE, and Debian styles, with or without quotes 992- sed -e 's/^DHCPDARGS="*\([^"]*\)"*/DHCPDARGS="\1'"${dev} "'"/' \ 993- "$dhcpd_arg_file" >"$tmpfile" && cp "$tmpfile" "$dhcpd_arg_file" 994- sed -e 's/^DHCPD_INTERFACE="*\([^"]*\)"*/DHCPD_INTERFACE="\1'"${dev} "'"/' \ 995- "$dhcpd_arg_file" >"$tmpfile" && cp "$tmpfile" "$dhcpd_arg_file" 996- sed -e 's/^INTERFACES="*\([^"]*\)"*/INTERFACES="\1'"${dev} "'"/' \ 997- "$dhcpd_arg_file" >"$tmpfile" && cp "$tmpfile" "$dhcpd_arg_file" 998- rm -f "$tmpfile" 999+ @sed@ -e 's/^DHCPDARGS="*\([^"]*\)"*/DHCPDARGS="\1'"${dev} "'"/' \ 1000+ "$dhcpd_arg_file" >"$tmpfile" && @cp@ "$tmpfile" "$dhcpd_arg_file" 1001+ @sed@ -e 's/^DHCPD_INTERFACE="*\([^"]*\)"*/DHCPD_INTERFACE="\1'"${dev} "'"/' \ 1002+ "$dhcpd_arg_file" >"$tmpfile" && @cp@ "$tmpfile" "$dhcpd_arg_file" 1003+ @sed@ -e 's/^INTERFACES="*\([^"]*\)"*/INTERFACES="\1'"${dev} "'"/' \ 1004+ "$dhcpd_arg_file" >"$tmpfile" && @cp@ "$tmpfile" "$dhcpd_arg_file" 1005+ @rm@ -f "$tmpfile" 1006 } 1007 1008 dhcp_remove_entry() 1009 { 1010- local tmpfile=$(mktemp) 1011- grep -v "host $hostname" "$dhcpd_conf_file" >"$tmpfile" 1012- if ! diff "$tmpfile" "$dhcpd_conf_file" >/dev/null 1013+ local tmpfile=$(@mktemp@) 1014+ @grep@ -v "host $hostname" "$dhcpd_conf_file" >"$tmpfile" 1015+ if ! @diff@ "$tmpfile" "$dhcpd_conf_file" >/dev/null 1016 then 1017- cp "$tmpfile" "$dhcpd_conf_file" 1018+ @cp@ "$tmpfile" "$dhcpd_conf_file" 1019 fi 1020- rm "$tmpfile" 1021+ @rm@ "$tmpfile" 1022 dhcparg_remove_entry 1023 } 1024@@ -159,5 +159,5 @@ dhcp_down() 1025 case "$command" in 1026 online) 1027- if ip route | grep -q "dev ${dev}" 1028+ if @ip@ route | @grep@ -q "dev ${dev}" 1029 then 1030 log debug "${dev} already up" 1031@@ -165,7 +165,7 @@ case "$command" in 1032 fi 1033 1034- do_or_die ip link set dev "${dev}" up arp on 1035- do_or_die ip addr add "$router_ip" dev "${dev}" 1036- do_or_die ip route add "$vif_ip" dev "${dev}" src "$router_ip" 1037+ do_or_die @ip@ link set dev "${dev}" up arp on 1038+ do_or_die @ip@ addr add "$router_ip" dev "${dev}" 1039+ do_or_die @ip@ route add "$vif_ip" dev "${dev}" src "$router_ip" 1040 echo 1 >/proc/sys/net/ipv4/conf/${dev}/proxy_arp 1041 [ "$dhcp" != 'no' ] && dhcp_up 1042@@ -173,5 +173,5 @@ case "$command" in 1043 offline) 1044 [ "$dhcp" != 'no' ] && dhcp_down 1045- do_without_error ifconfig "${dev}" down 1046+ do_without_error @ifconfig@ "${dev}" down 1047 ;; 1048 esac 1049diff --git a/tools/hotplug/Linux/vif-openvswitch b/tools/hotplug/Linux/vif-openvswitch 1050index 18bfb6cefb..ea983481a3 100644 1051--- a/tools/hotplug/Linux/vif-openvswitch 1052+++ b/tools/hotplug/Linux/vif-openvswitch 1053@@ -25,13 +25,13 @@ 1054 #============================================================================ 1055 1056-dir=$(dirname "$0") 1057+dir=$(@dirname@ "$0") 1058 . "$dir/vif-common.sh" 1059 1060 check_tools() 1061 { 1062- if ! command -v ovs-vsctl > /dev/null 2>&1; then 1063+ if ! command -v @ovs-vsctl@ > /dev/null 2>&1; then 1064 fatal "Unable to find ovs-vsctl tool" 1065 fi 1066- if ! command -v ip > /dev/null 2>&1; then 1067+ if ! command -v @ip@ > /dev/null 2>&1; then 1068 fatal "Unable to find ip tool" 1069 fi 1070@@ -80,8 +80,8 @@ add_to_openvswitch () { 1071 local vif_details="$(openvswitch_external_id_all $dev)" 1072 1073- do_or_die ovs-vsctl --timeout=30 \ 1074+ do_or_die @ovs-vsctl@ --timeout=30 \ 1075 -- --if-exists del-port $dev \ 1076 -- add-port "$bridge" $dev $tag_arg $trunk_arg $vif_details 1077- do_or_die ip link set $dev up 1078+ do_or_die @ip@ link set $dev up 1079 } 1080 1081@@ -94,7 +94,7 @@ case "$command" in 1082 1083 remove|offline) 1084- do_without_error ovs-vsctl --timeout=30 \ 1085+ do_without_error @ovs-vsctl@ --timeout=30 \ 1086 -- --if-exists del-port $dev 1087- do_without_error ip link set $dev down 1088+ do_without_error @ip@ link set $dev down 1089 ;; 1090 esac 1091diff --git a/tools/hotplug/Linux/vif-route b/tools/hotplug/Linux/vif-route 1092index 9cd417a005..98d67a8659 100755 1093--- a/tools/hotplug/Linux/vif-route 1094+++ b/tools/hotplug/Linux/vif-route 1095@@ -17,5 +17,5 @@ 1096 #============================================================================ 1097 1098-dir=$(dirname "$0") 1099+dir=$(@dirname@ "$0") 1100 . "${dir}/vif-common.sh" 1101 1102@@ -24,5 +24,5 @@ main_ip=$(dom0_ip) 1103 case "${command}" in 1104 add|online) 1105- ifconfig ${dev} ${main_ip} netmask 255.255.255.255 up 1106+ @ifconfig@ ${dev} ${main_ip} netmask 255.255.255.255 up 1107 echo 1 >/proc/sys/net/ipv4/conf/${dev}/proxy_arp 1108 ipcmd='add' 1109@@ -51,5 +51,5 @@ esac 1110 # the guest using those addresses. 1111 for addr in ${ip} ; do 1112- ${cmdprefix} ip route ${ipcmd} ${addr} dev ${dev} src ${main_ip} metric ${metric} 1113+ ${cmdprefix} @ip@ route ${ipcmd} ${addr} dev ${dev} src ${main_ip} metric ${metric} 1114 done 1115 1116diff --git a/tools/hotplug/Linux/vscsi b/tools/hotplug/Linux/vscsi 1117index 5ac26147ec..8f297e05df 100644 1118--- a/tools/hotplug/Linux/vscsi 1119+++ b/tools/hotplug/Linux/vscsi 1120@@ -5,5 +5,5 @@ 1121 # 1122 1123-dir=$(dirname "$0") 1124+dir=$(@dirname@ "$0") 1125 . "$dir/xen-hotplug-common.sh" 1126 1127diff --git a/tools/hotplug/Linux/xen-hotplug-common.sh.in b/tools/hotplug/Linux/xen-hotplug-common.sh.in 1128index 8c2cb9e25a..e9c64efcb0 100644 1129--- a/tools/hotplug/Linux/xen-hotplug-common.sh.in 1130+++ b/tools/hotplug/Linux/xen-hotplug-common.sh.in 1131@@ -15,5 +15,5 @@ 1132 # 1133 1134-dir=$(dirname "$0") 1135+dir=$(@dirname@ "$0") 1136 . "$dir/hotplugpath.sh" 1137 . "$dir/logging.sh" 1138@@ -26,5 +26,5 @@ export PATH="${bindir}:${sbindir}:${LIBEXEC_BIN}:/sbin:/bin:/usr/bin:/usr/sbin:$ 1139 export LD_LIBRARY_PATH="${libdir}${LD_LIBRARY_PATH+:}$LD_LIBRARY_PATH" 1140 export LANG="POSIX" 1141-unset $(set | grep ^LC_ | cut -d= -f1) 1142+unset $(set | @grep@ ^LC_ | @cut@ -d= -f1) 1143 1144 fatal() { 1145diff --git a/tools/hotplug/Linux/xen-network-common.sh b/tools/hotplug/Linux/xen-network-common.sh 1146index 42fa704e8d..f6cf1b11c0 100644 1147--- a/tools/hotplug/Linux/xen-network-common.sh 1148+++ b/tools/hotplug/Linux/xen-network-common.sh 1149@@ -27,5 +27,5 @@ 1150 # been renamed. 1151 1152-if ! which ifup >/dev/null 2>/dev/null 1153+if ! @which@ ifup >/dev/null 2>/dev/null 1154 then 1155 preiftransfer() 1156@@ -85,5 +85,5 @@ _setup_bridge_port() { 1157 1158 # take interface down ... 1159- ip link set dev ${dev} down 1160+ @ip@ link set dev ${dev} down 1161 1162 if [ $virtual -ne 0 ] ; then 1163@@ -92,9 +92,9 @@ _setup_bridge_port() { 1164 # stolen by an Ethernet bridge for STP purposes. 1165 # (FE:FF:FF:FF:FF:FF) 1166- ip link set dev ${dev} address fe:ff:ff:ff:ff:ff || true 1167+ @ip@ link set dev ${dev} address fe:ff:ff:ff:ff:ff || true 1168 fi 1169 1170 # ... and configure it 1171- ip address flush dev ${dev} 1172+ @ip@ address flush dev ${dev} 1173 } 1174 1175@@ -112,10 +112,10 @@ create_bridge () { 1176 # Don't create the bridge if it already exists. 1177 if [ ! -e "/sys/class/net/${bridge}/bridge" ]; then 1178- if which brctl >&/dev/null; then 1179- brctl addbr ${bridge} 1180- brctl stp ${bridge} off 1181- brctl setfd ${bridge} 0 1182+ if @which@ @brctl@ >&/dev/null; then 1183+ @brctl@ addbr ${bridge} 1184+ @brctl@ stp ${bridge} off 1185+ @brctl@ setfd ${bridge} 0 1186 else 1187- ip link add name ${bridge} type bridge stp_state 0 forward_delay 0 1188+ @ip@ link add name ${bridge} type bridge stp_state 0 forward_delay 0 1189 fi 1190 fi 1191@@ -130,8 +130,8 @@ add_to_bridge () { 1192 if [ ! -e "/sys/class/net/${bridge}/brif/${dev}" ]; then 1193 log debug "adding $dev to bridge $bridge" 1194- if which brctl >&/dev/null; then 1195- brctl addif ${bridge} ${dev} 1196+ if @which@ @brctl@ >&/dev/null; then 1197+ @brctl@ addif ${bridge} ${dev} 1198 else 1199- ip link set ${dev} master ${bridge} 1200+ @ip@ link set ${dev} master ${bridge} 1201 fi 1202 else 1203@@ -139,5 +139,5 @@ add_to_bridge () { 1204 fi 1205 1206- ip link set dev ${dev} up 1207+ @ip@ link set dev ${dev} up 1208 } 1209 1210@@ -146,13 +146,13 @@ remove_from_bridge () { 1211 local dev=$2 1212 1213- do_without_error ip link set dev ${dev} down 1214+ do_without_error @ip@ link set dev ${dev} down 1215 1216 # Don't remove $dev from $bridge if it's not on the bridge. 1217 if [ -e "/sys/class/net/${bridge}/brif/${dev}" ]; then 1218 log debug "removing $dev from bridge $bridge" 1219- if which brctl >&/dev/null; then 1220- do_without_error brctl delif ${bridge} ${dev} 1221+ if @which@ @brctl@ >&/dev/null; then 1222+ do_without_error @brctl@ delif ${bridge} ${dev} 1223 else 1224- do_without_error ip link set ${dev} nomaster 1225+ do_without_error @ip@ link set ${dev} nomaster 1226 fi 1227 else 1228@@ -172,5 +172,5 @@ set_mtu () { 1229 if [ -z "$mtu" ] 1230 then 1231- mtu="`ip link show dev ${bridge}| awk '/mtu/ { print $5 }'`" 1232+ mtu="`@ip@ link show dev ${bridge}| @awk@ '/mtu/ { print $5 }'`" 1233 if [ -n "$mtu" ] 1234 then 1235@@ -181,5 +181,5 @@ set_mtu () { 1236 then 1237 log debug "setting $dev MTU to $mtu" 1238- ip link set dev ${dev} mtu ${mtu} || : 1239+ @ip@ link set dev ${dev} mtu ${mtu} || : 1240 1241 if [ ${type_if} = vif ] 1242diff --git a/tools/hotplug/Linux/xendomains.in b/tools/hotplug/Linux/xendomains.in 1243index 70f4129ef4..b066404b0d 100644 1244--- a/tools/hotplug/Linux/xendomains.in 1245+++ b/tools/hotplug/Linux/xendomains.in 1246@@ -151,5 +151,5 @@ else 1247 fi 1248 1249-if ! which usleep >&/dev/null 1250+if ! @which@ usleep >&/dev/null 1251 then 1252 usleep() 1253@@ -157,5 +157,5 @@ then 1254 if [ -n "$1" ] 1255 then 1256- sleep $(( $1 / 1000000 )) 1257+ @sleep@ $(( $1 / 1000000 )) 1258 fi 1259 } 1260@@ -171,5 +171,5 @@ rc_reset 1261 contains_something() 1262 { 1263- if [ -d "$1" ] && [ `/bin/ls $1 | wc -l` -gt 0 ] 1264+ if [ -d "$1" ] && [ `@ls@ $1 | wc -l` -gt 0 ] 1265 then 1266 return 0 1267@@ -183,5 +183,5 @@ rdname() 1268 { 1269 NM=$($CMD create --quiet --dryrun --defconfig "$1" | 1270- sed -n 's/^.*(name \(.*\))$/\1/p;s/^.*"name": "\(.*\)",$/\1/p') 1271+ @sed@ -n 's/^.*(name \(.*\))$/\1/p;s/^.*"name": "\(.*\)",$/\1/p') 1272 } 1273 1274@@ -218,11 +218,11 @@ parseln() 1275 name=;id= 1276 elif [[ "$1" =~ '(name' ]]; then 1277- name=$(echo $1 | sed -e 's/^.*(name \(.*\))$/\1/') 1278+ name=$(echo $1 | @sed@ -e 's/^.*(name \(.*\))$/\1/') 1279 elif [[ "$1" =~ '(domid' ]]; then 1280- id=$(echo $1 | sed -e 's/^.*(domid \(.*\))$/\1/') 1281+ id=$(echo $1 | @sed@ -e 's/^.*(domid \(.*\))$/\1/') 1282 elif [[ "$1" =~ '"name":' ]]; then 1283- name=$(echo $1 | sed -e 's/^.*"name": "\(.*\)",$/\1/') 1284+ name=$(echo $1 | @sed@ -e 's/^.*"name": "\(.*\)",$/\1/') 1285 elif [[ "$1" =~ '"domid":' ]]; then 1286- id=$(echo $1 | sed -e 's/^.*"domid": \(.*\),$/\1/') 1287+ id=$(echo $1 | @sed@ -e 's/^.*"domid": \(.*\),$/\1/') 1288 fi 1289 1290@@ -245,5 +245,5 @@ is_running() 1291 ;; 1292 esac 1293- done < <($CMD list -l | grep "$LIST_GREP") 1294+ done < <($CMD list -l | @grep@ "$LIST_GREP") 1295 return $RC 1296 } 1297@@ -256,5 +256,5 @@ start() 1298 fi 1299 1300- mkdir -p $(dirname "$LOCKFILE") 1301+ @mkdir@ -p $(@dirname@ "$LOCKFILE") 1302 touch $LOCKFILE 1303 1304@@ -267,5 +267,5 @@ start() 1305 for dom in $XENDOMAINS_SAVE/*; do 1306 if [ -f $dom ] ; then 1307- HEADER=`head -c 16 $dom | head -n 1 2> /dev/null` 1308+ HEADER=`@head@ -c 16 $dom | @head@ -n 1 2> /dev/null` 1309 if [ "$HEADER" = "$HEADCOMP" ]; then 1310 echo -n " ${dom##*/}" 1311@@ -278,5 +278,5 @@ start() 1312 else 1313 # mv $dom ${dom%/*}/.${dom##*/} 1314- rm $dom 1315+ @rm@ $dom 1316 fi 1317 fi 1318@@ -300,6 +300,6 @@ start() 1319 for dom in $XENDOMAINS_AUTO/*; do 1320 echo -n " ${dom##*/}" 1321- shortdom=$(echo $dom | sed -n 's/^.*\/\(.*\)$/\1/p') 1322- echo $saved_domains | grep -w $shortdom > /dev/null 1323+ shortdom=$(echo $dom | @sed@ -n 's/^.*\/\(.*\)$/\1/p') 1324+ echo $saved_domains | @grep@ -w $shortdom > /dev/null 1325 if [ $? -eq 0 ] || is_running $dom; then 1326 echo -n "(skip)" 1327@@ -329,5 +329,5 @@ all_zombies() 1328 return 1; 1329 fi 1330- done < <($CMD list -l | grep "$LIST_GREP") 1331+ done < <($CMD list -l | @grep@ "$LIST_GREP") 1332 return 0 1333 } 1334@@ -346,14 +346,14 @@ watchdog_xencmd() 1335 1336 usleep 20000 1337- for no in `seq 0 $XENDOMAINS_STOP_MAXWAIT`; do 1338+ for no in `@seq@ 0 $XENDOMAINS_STOP_MAXWAIT`; do 1339 # exit if $CMD save/migrate/shutdown is finished 1340- PSAX=`ps axlw | grep "$CMD $1" | grep -v grep` 1341+ PSAX=`ps axlw | @grep@ "$CMD $1" | @grep@ -v grep` 1342 if test -z "$PSAX"; then exit; fi 1343 if ! test -n "$3"; then echo -n '.'; fi 1344- sleep 1 1345+ @sleep@ 1 1346 # go to kill immediately if there's only zombies left 1347 if all_zombies && test -n "$2"; then break; fi 1348 done 1349- sleep 1 1350+ @sleep@ 1 1351 read PSF PSUID PSPID PSPPID < <(echo "$PSAX") 1352 # kill $CMD $1 1353@@ -435,5 +435,5 @@ stop() 1354 watchdog_xencmd save & 1355 WDOG_PID=$! 1356- mkdir -p "$XENDOMAINS_SAVE" 1357+ @mkdir@ -p "$XENDOMAINS_SAVE" 1358 XMR=`$CMD save $id $XENDOMAINS_SAVE/$name 2>&1 1>/dev/null` 1359 if test $? -ne 0; then 1360@@ -462,5 +462,5 @@ stop() 1361 kill $WDOG_PID >/dev/null 2>&1 1362 fi 1363- done < <($CMD list -l | grep "$LIST_GREP") 1364+ done < <($CMD list -l | @grep@ "$LIST_GREP") 1365 1366 # NB. this shuts down ALL Xen domains (politely), not just the ones in 1367@@ -483,5 +483,5 @@ stop() 1368 1369 # Unconditionally delete lock file 1370- rm -f $LOCKFILE 1371+ @rm@ -f $LOCKFILE 1372 1373 exec 2>&3 1374@@ -499,5 +499,5 @@ check_domain_up() 1375 ;; 1376 esac 1377- done < <($CMD list -l | grep "$LIST_GREP") 1378+ done < <($CMD list -l | @grep@ "$LIST_GREP") 1379 return 1 1380 } 1381@@ -532,5 +532,5 @@ check_all_saved_domains_up() 1382 return 0 1383 fi 1384- missing=`/bin/ls $XENDOMAINS_SAVE` 1385+ missing=`@ls@ $XENDOMAINS_SAVE` 1386 echo -n " MISS SAVED: " $missing 1387 return 1 1388-- 13892.49.0 1390