build: Explicitly use bash for shell scripts 14/40214/2
authorTom Jones <thj@freebsd.org>
Thu, 18 Jan 2024 14:51:44 +0000 (14:51 +0000)
committerDamjan Marion <dmarion@0xa5.net>
Fri, 19 Jan 2024 12:30:01 +0000 (12:30 +0000)
VPP requires bash for all shell scripts. Align shebang lines in build
and test scripts to look up the location of bash rather than hard coding
'/bin/bash'.

Look up the location of bash for makefiles.

Type: improvement
Change-Id: I23b705d81d60389fa8af61c680cf0abd74f0ea24
Signed-off-by: Tom Jones <thj@freebsd.org>
19 files changed:
Makefile
build-root/Makefile
build-root/scripts/set-rpath
build/external/Makefile
extras/vagrant/build.sh
extras/vagrant/clearinterfaces.sh
extras/vagrant/install.sh
extras/vagrant/run.sh
extras/vagrant/update.sh
extras/vagrant/vcl_test.sh
src/scripts/generate_version_h
src/scripts/remove-rpath
src/scripts/vnet/dhcp/left-ping-target.sh
test/scripts/compress_failed.sh
test/scripts/run.sh
test/scripts/run_in_venv_with_cleanup.sh
test/scripts/setsid_wrapper.sh
test/scripts/socket_test.sh
test/scripts/test-loop.sh

index ccfc2a5..d82a625 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,7 @@
 export WS_ROOT=$(CURDIR)
 export BR=$(WS_ROOT)/build-root
 CCACHE_DIR?=$(BR)/.ccache
-SHELL:=/bin/bash
+SHELL:=$(shell which bash)
 GDB?=gdb
 PLATFORM?=vpp
 SAMPLE_PLUGIN?=no
index d35b7a1..6416de2 100644 (file)
@@ -39,7 +39,7 @@
 ######################################################################
 
 # Scripts require non-POSIX parts of bash
-SHELL := /bin/bash
+SHELL := $(shell which bash)
 
 # Where this makefile lives
 MU_BUILD_ROOT_DIR = $(shell pwd)
@@ -962,7 +962,7 @@ $(PLATFORM_IMAGE_DIR)/ro.img ro-image: $(patsubst %,%-find-source,$(ROOT_PACKAGE
        chmod 0755 $${tmp_dir} ;                                        \
        cd $${tmp_dir} ;                                                \
        trap "rm -rf $${tmp_dir}" err ;                                 \
-       fakeroot /bin/bash -c "{                                        \
+       fakeroot $(SHELL) -c "{                                 \
          set -eu$(BUILD_DEBUG) ;                                       \
          $(MAKE) -C $(MU_BUILD_ROOT_DIR) IMAGE_INSTALL_DIR=$${tmp_dir} \
            $(patsubst %,%-image_install,                               \
@@ -1054,7 +1054,7 @@ rw-image: rw-image-check-type ro-image
        chmod 0755 $${tmp_dir} ;                                \
        cd $${tmp_dir} ;                                        \
        trap "rm -rf $${tmp_dir}" err ;                         \
-       fakeroot /bin/bash -c "{                                \
+       fakeroot $(SHELL) -c "{                         \
          set -eu$(BUILD_DEBUG) ;                               \
          $(linuxrc_makedev) ;                                  \
          $(call rw_image_embed_ro_image_fn,$${ro_image}) ;     \
index f20ff3f..805f11d 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 # Copyright (c) 2015 Cisco and/or its affiliates.
 # Licensed under the Apache License, Version 2.0 (the "License");
index 1e1f5da..a445d7b 100644 (file)
@@ -12,7 +12,7 @@
 # limitations under the License.
 
 # Scripts require non-POSIX parts of bash
-SHELL := /bin/bash
+SHELL := $(shell which bash)
 
 DL_CACHE_DIR = $(HOME)/Downloads
 MAKE ?= make
index 0e63947..631b990 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 # Get Command Line arguements if present
 VPP_DIR=$1
index 31a6309..50b96f0 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 # Capture all the interface IPs, in case we need them later
 ip -o addr show > ~vagrant/ifconfiga
index cfe5fe5..67a2e4f 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 # Get Command Line arguements if present
 VPP_DIR=$1
index 3e87e25..be2d842 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 # Figure out what system we are running on
 if [ "$(uname)" <> "Darwin" ] ; then
index 3fb456b..e56e6ba 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 # Make sure that we get the hugepages we need on provision boot
 # Note: The package install should take care of this at the end
index 5d58d73..2bad0f6 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 if [ -n "$1" ]; then
     VPP_DIR=$1
index 5912368..cdcdf5d 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 : ${VPP_BUILD_USER:=$(whoami)}
 : ${VPP_BUILD_HOST:=$(hostname)}
 DATE_FMT="+%Y-%m-%dT%H:%M:%S"
index 3e20b06..b6df461 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 # Copyright (c) 2015 Cisco and/or its affiliates.
 # Licensed under the Apache License, Version 2.0 (the "License");
index 2edc2a5..4dab842 100644 (file)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 # to obtain dhcp address from leftpeer
 dhclient -d -v eth1
index ff17d24..7e2cd9c 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 if [ "$(ls -A ${FAILED_DIR})" ]
 then
index 51c1c62..504edd6 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 ff="0"
 items=
index 030c3b0..550c7b9 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 cmd=$1
 force_foreground=$2
index b94a2f3..3ba739a 100755 (executable)
@@ -1,4 +1,4 @@
-#! /bin/bash
+#!/usr/bin/env bash
 #
 # socket_test.sh -- script to run socket tests.
 #
index 51f5d5c..b825f2b 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 function usage() {
  echo "$0" 1>&2