summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-06-11 09:30:34 +0000
committerGerrit Code Review <review@openstack.org>2017-06-11 09:30:34 +0000
commit1324f5b7dbc148f1bf4ab35d77ef7c21da18e533 (patch)
tree7f78655faa3eb0c5d3b88de49b4a866965275016
parent5ac8a98e9ad119a27b6f24ae14f3ba20ecda8918 (diff)
parent84d10dce570d351e364281dc3965a7f90e7ff51e (diff)
Merge "Remove use of 'which'."2.6.0
-rwxr-xr-xbin/dib-lint17
-rwxr-xr-xdiskimage_builder/elements/bootloader/finalise.d/50-bootloader6
-rwxr-xr-xdiskimage_builder/elements/dracut-ramdisk/post-install.d/99-build-dracut-ramdisk2
-rw-r--r--diskimage_builder/elements/hwdiscovery/init.d/60-hwdiscovery2
-rwxr-xr-xdiskimage_builder/elements/ramdisk-base/post-install.d/01-ensure-binaries2
-rwxr-xr-xdiskimage_builder/elements/ramdisk/post-install.d/99-build-ramdisk2
-rwxr-xr-xdiskimage_builder/elements/rpm-distro/finalise.d/90-selinux-fixfiles-restore2
-rw-r--r--diskimage_builder/lib/disk-image-create10
-rw-r--r--diskimage_builder/lib/ramdisk-functions2
-rwxr-xr-xtests/run_output_format_test.sh2
10 files changed, 32 insertions, 15 deletions
diff --git a/bin/dib-lint b/bin/dib-lint
index c622e0e..ba528bd 100755
--- a/bin/dib-lint
+++ b/bin/dib-lint
@@ -209,6 +209,23 @@ for i in $(find $ELEMENTS_DIR -type f \
209 fi 209 fi
210 fi 210 fi
211 211
212 # check that which calls are not used. It is not built in and is missing
213 # from some constrained environments
214 if ! excluded which; then
215 while read LINE
216 do
217 if [[ $LINE =~ "which " ]]; then
218 # Don't match:
219 # - explicitly ignored
220 # - commented
221 if [[ $LINE =~ (dib-lint: which|^#) ]]; then
222 continue
223 fi
224 error "$i : potential use of which\n -- $LINE"
225 fi
226 done < $i
227 fi
228
212done 229done
213 230
214echo "Checking indents..." 231echo "Checking indents..."
diff --git a/diskimage_builder/elements/bootloader/finalise.d/50-bootloader b/diskimage_builder/elements/bootloader/finalise.d/50-bootloader
index b208783..d19846a 100755
--- a/diskimage_builder/elements/bootloader/finalise.d/50-bootloader
+++ b/diskimage_builder/elements/bootloader/finalise.d/50-bootloader
@@ -63,9 +63,9 @@ function install_grub2 {
63 63
64 # XXX: grub-probe on the nbd0/loop0 device returns nothing - workaround, manually 64 # XXX: grub-probe on the nbd0/loop0 device returns nothing - workaround, manually
65 # specify modules. https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1073731 65 # specify modules. https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1073731
66 GRUBNAME=$(which grub-install) || echo "trying grub2-install" 66 GRUBNAME=$(type -p grub-install) || echo "trying grub2-install"
67 if [ -z "$GRUBNAME" ]; then 67 if [ -z "$GRUBNAME" ]; then
68 GRUBNAME=$(which grub2-install) 68 GRUBNAME=$(type -p grub2-install)
69 fi 69 fi
70 70
71 # If no GRUB2 is found, fallback to extlinux 71 # If no GRUB2 is found, fallback to extlinux
@@ -145,7 +145,7 @@ function install_grub2 {
145 echo 'GRUB_GFXPAYLOAD_LINUX=text' >>/etc/default/grub 145 echo 'GRUB_GFXPAYLOAD_LINUX=text' >>/etc/default/grub
146 echo 'GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200 no_timer_check"' >>/etc/default/grub 146 echo 'GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200 no_timer_check"' >>/etc/default/grub
147 echo 'GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"' >>/etc/default/grub 147 echo 'GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"' >>/etc/default/grub
148 if which grub2-mkconfig >/dev/null; then 148 if type grub2-mkconfig >/dev/null; then
149 GRUB_MKCONFIG="grub2-mkconfig -o $GRUB_CFG" 149 GRUB_MKCONFIG="grub2-mkconfig -o $GRUB_CFG"
150 else 150 else
151 GRUB_MKCONFIG="grub-mkconfig -o $GRUB_CFG" 151 GRUB_MKCONFIG="grub-mkconfig -o $GRUB_CFG"
diff --git a/diskimage_builder/elements/dracut-ramdisk/post-install.d/99-build-dracut-ramdisk b/diskimage_builder/elements/dracut-ramdisk/post-install.d/99-build-dracut-ramdisk
index a4ef693..e7d939b 100755
--- a/diskimage_builder/elements/dracut-ramdisk/post-install.d/99-build-dracut-ramdisk
+++ b/diskimage_builder/elements/dracut-ramdisk/post-install.d/99-build-dracut-ramdisk
@@ -46,7 +46,7 @@ mv "$TMP_MOUNT_PATH/init" "$MODULE_PATH/80deploy-ramdisk/init.sh"
46# been released for all of our supported platforms we can remove this. Until then 46# been released for all of our supported platforms we can remove this. Until then
47# this makes --include work correctly and will be a noop if we're running a fixed 47# this makes --include work correctly and will be a noop if we're running a fixed
48# Dracut version. 48# Dracut version.
49sed -i 's|cp --reflink=auto --sparse=auto -fa -t "$s" "$i"$|cp --reflink=auto --sparse=auto -fa -t "${initdir}/${tgt}" "$i"|g' $(which dracut) 49sed -i 's|cp --reflink=auto --sparse=auto -fa -t "$s" "$i"$|cp --reflink=auto --sparse=auto -fa -t "${initdir}/${tgt}" "$i"|g' $(type -p dracut)
50 50
51# Notes on the options passed to Dracut: 51# Notes on the options passed to Dracut:
52# -N: Do not build a host-specific ramdisk. We want to be able to run this ramdisk 52# -N: Do not build a host-specific ramdisk. We want to be able to run this ramdisk
diff --git a/diskimage_builder/elements/hwdiscovery/init.d/60-hwdiscovery b/diskimage_builder/elements/hwdiscovery/init.d/60-hwdiscovery
index a87aed0..0b5115b 100644
--- a/diskimage_builder/elements/hwdiscovery/init.d/60-hwdiscovery
+++ b/diskimage_builder/elements/hwdiscovery/init.d/60-hwdiscovery
@@ -20,7 +20,7 @@ function pxe_mac() {
20 # boot interface with no problems. 20 # boot interface with no problems.
21 _mac="${BASH_REMATCH[1]//-/:}" 21 _mac="${BASH_REMATCH[1]//-/:}"
22 _mac="${_mac#*:}" 22 _mac="${_mac#*:}"
23 elif [[ -d /sys/firmware/efi ]] && which efibootmgr &>/dev/null; then 23 elif [[ -d /sys/firmware/efi ]] && type efibootmgr &>/dev/null; then
24 # Likewise, if we booted via the network while running in UEFI mode, and 24 # Likewise, if we booted via the network while running in UEFI mode, and
25 # efibootmgr is installed, we can determine the MAC address of the nic we 25 # efibootmgr is installed, we can determine the MAC address of the nic we
26 # booted from. It would be good to have code that can also do this using 26 # booted from. It would be good to have code that can also do this using
diff --git a/diskimage_builder/elements/ramdisk-base/post-install.d/01-ensure-binaries b/diskimage_builder/elements/ramdisk-base/post-install.d/01-ensure-binaries
index 82c29f6..9483852 100755
--- a/diskimage_builder/elements/ramdisk-base/post-install.d/01-ensure-binaries
+++ b/diskimage_builder/elements/ramdisk-base/post-install.d/01-ensure-binaries
@@ -32,7 +32,7 @@ for _FILE in $(ls ${TARGET_DIR}/binary-deps.d/) ; do
32done 32done
33 33
34for _BIN in $BINARY_DEPS ; do 34for _BIN in $BINARY_DEPS ; do
35 _LOCATION=$(which "$_BIN" || echo "") 35 _LOCATION=$(type -p "$_BIN" || echo "")
36 if [ -z "$_LOCATION" ]; then 36 if [ -z "$_LOCATION" ]; then
37 echo "$_BIN is not found in PATH. Please ensure your elements install it" 37 echo "$_BIN is not found in PATH. Please ensure your elements install it"
38 exit 1 38 exit 1
diff --git a/diskimage_builder/elements/ramdisk/post-install.d/99-build-ramdisk b/diskimage_builder/elements/ramdisk/post-install.d/99-build-ramdisk
index 44fbc81..80948db 100755
--- a/diskimage_builder/elements/ramdisk/post-install.d/99-build-ramdisk
+++ b/diskimage_builder/elements/ramdisk/post-install.d/99-build-ramdisk
@@ -33,7 +33,7 @@ FIRMWARE_DIR=$MODULE_ROOT/lib/firmware
33LIB_UDEV=$LIB_UDEV_ROOT/lib/udev 33LIB_UDEV=$LIB_UDEV_ROOT/lib/udev
34INIT="$_LIB/scripts/init" 34INIT="$_LIB/scripts/init"
35FUNCTIONS_D="$_LIB/scripts/d" 35FUNCTIONS_D="$_LIB/scripts/d"
36BUSYBOX=${BUSYBOX:-$(which busybox)} 36BUSYBOX=${BUSYBOX:-$(type -p busybox)}
37# NOTE(bnemec): IMAGE_ELEMENT is normally set in disk-image-create, but we're 37# NOTE(bnemec): IMAGE_ELEMENT is normally set in disk-image-create, but we're
38# not using that to build the image here. 38# not using that to build the image here.
39IMAGE_ELEMENT= 39IMAGE_ELEMENT=
diff --git a/diskimage_builder/elements/rpm-distro/finalise.d/90-selinux-fixfiles-restore b/diskimage_builder/elements/rpm-distro/finalise.d/90-selinux-fixfiles-restore
index 0598d63..9abdda0 100755
--- a/diskimage_builder/elements/rpm-distro/finalise.d/90-selinux-fixfiles-restore
+++ b/diskimage_builder/elements/rpm-distro/finalise.d/90-selinux-fixfiles-restore
@@ -6,7 +6,7 @@ fi
6set -eu 6set -eu
7set -o pipefail 7set -o pipefail
8 8
9SETFILES=$(which setfiles || true) 9SETFILES=$(type -p setfiles || true)
10if [ -e /etc/selinux/targeted/contexts/files/file_contexts -a -x "${SETFILES}" ]; then 10if [ -e /etc/selinux/targeted/contexts/files/file_contexts -a -x "${SETFILES}" ]; then
11 # get all mounpoints in the system 11 # get all mounpoints in the system
12 IFS='|' read -ra SPLIT_MOUNTS <<< "$DIB_MOUNTPOINTS" 12 IFS='|' read -ra SPLIT_MOUNTS <<< "$DIB_MOUNTPOINTS"
diff --git a/diskimage_builder/lib/disk-image-create b/diskimage_builder/lib/disk-image-create
index ff3dceb..cb36d3f 100644
--- a/diskimage_builder/lib/disk-image-create
+++ b/diskimage_builder/lib/disk-image-create
@@ -208,7 +208,7 @@ fi
208for X in ${!IMAGE_TYPES[@]}; do 208for X in ${!IMAGE_TYPES[@]}; do
209 case "${IMAGE_TYPES[$X]}" in 209 case "${IMAGE_TYPES[$X]}" in
210 qcow2) 210 qcow2)
211 if [ -z "$(which qemu-img)" ]; then 211 if ! type qemu-img > /dev/null 2>&1; then
212 echo "qcow2 output format specified but qemu-img executable not found." 212 echo "qcow2 output format specified but qemu-img executable not found."
213 exit 1 213 exit 1
214 fi 214 fi
@@ -218,19 +218,19 @@ for X in ${!IMAGE_TYPES[@]}; do
218 IMAGE_TYPES+=('tar') 218 IMAGE_TYPES+=('tar')
219 ;; 219 ;;
220 vhd) 220 vhd)
221 if [ -z "$(which vhd-util)" ]; then 221 if ! type vhd-util > /dev/null 2>&1; then
222 echo "vhd output format specified but no vhd-util executable found." 222 echo "vhd output format specified but no vhd-util executable found."
223 exit 1 223 exit 1
224 fi 224 fi
225 ;; 225 ;;
226 squashfs) 226 squashfs)
227 if [ -z "$(which mksquashfs)" ]; then 227 if ! type mksquashfs > /dev/null 2>&1; then
228 echo "squashfs output format specified but no mksquashfs executable found." 228 echo "squashfs output format specified but no mksquashfs executable found."
229 exit 1 229 exit 1
230 fi 230 fi
231 ;; 231 ;;
232 docker) 232 docker)
233 if [ -z "$(which docker)" ]; then 233 if ! type docker > /dev/null 2>&1; then
234 echo "docker output format specified but no docker executable found." 234 echo "docker output format specified but no docker executable found."
235 exit 1 235 exit 1
236 fi 236 fi
@@ -244,7 +244,7 @@ done
244 244
245# NOTE: fstrim is on most all recent systems. It is provided by the util-linux 245# NOTE: fstrim is on most all recent systems. It is provided by the util-linux
246# package. 246# package.
247if [[ -z "$(which fstrim)" ]]; then 247if ! type fstrim > /dev/null 2>&1; then
248 echo "fstrim utility is not found. This is provided by util-linux package" 248 echo "fstrim utility is not found. This is provided by util-linux package"
249 echo "Please check your PATH variable is set correctly" 249 echo "Please check your PATH variable is set correctly"
250 exit 1 250 exit 1
diff --git a/diskimage_builder/lib/ramdisk-functions b/diskimage_builder/lib/ramdisk-functions
index 6797114..68bea83 100644
--- a/diskimage_builder/lib/ramdisk-functions
+++ b/diskimage_builder/lib/ramdisk-functions
@@ -163,7 +163,7 @@ function populate_lib () {
163 if busybox_list | grep -v "^ip$" | grep "^$i\$" >/dev/null; then 163 if busybox_list | grep -v "^ip$" | grep "^$i\$" >/dev/null; then
164 continue 164 continue
165 fi 165 fi
166 path=`which $i 2>/dev/null` || path=$i 166 path=`type -p $i 2>/dev/null` || path=$i
167 if ! [ -x "$path" ]; then 167 if ! [ -x "$path" ]; then
168 echo "$i is not found in PATH" 2>&1 168 echo "$i is not found in PATH" 2>&1
169 exit 1 169 exit 1
diff --git a/tests/run_output_format_test.sh b/tests/run_output_format_test.sh
index 8f2e968..bbff162 100755
--- a/tests/run_output_format_test.sh
+++ b/tests/run_output_format_test.sh
@@ -61,7 +61,7 @@ function build_test_image() {
61 61
62test_formats="tar tgz squashfs raw qcow2 docker aci" 62test_formats="tar tgz squashfs raw qcow2 docker aci"
63for binary in qemu-img docker mksquashfs; do 63for binary in qemu-img docker mksquashfs; do
64 if [ -z "$(which $binary)" ]; then 64 if [ -z "$(type $binary)" ]; then
65 echo "Warning: No $binary binary found, cowardly refusing to run tests." 65 echo "Warning: No $binary binary found, cowardly refusing to run tests."
66 exit 1 66 exit 1
67 fi 67 fi