set -u and -o pipefail everywhere

As with the previous similar changes, this is intended to catch
problems as they happen instead of ignoring them and continuing on
to potentially fail later.  Setting this on all existing scripts
will allow us to enforce use via Jenkins.

Change-Id: Iad2d490c86dceab148ea9ab08f457c49a5d5352e
This commit is contained in:
Ben Nemec 2014-04-02 21:24:15 -05:00
parent 35d18b8a60
commit 16be6d7ce0
84 changed files with 141 additions and 62 deletions
elements
apt-conf/extra-data.d
apt-sources/extra-data.d
baremetal/cleanup.d
base
cache-url/bin
debian-systemd/root.d
debian-upstart/root.d
debian/root.d
dhcp-all-interfaces/install.d
dib-run-parts
dpkg
dracut-network/install.d
fedora/root.d
hwdiscovery/install.d
local-config
extra-data.d
install.d
pre-install.d
manifests
cleanup.d
environment.d
extra-data.d
mellanox/install.d
modprobe-blacklist/install.d
opensuse
pip-cache/root.d
pypi
ramdisk
redhat-common
rhel
rhel7/root.d
rpm-distro/pre-install.d
serial-console/install.d
source-repositories
ubuntu
vm
yum
zypper

@ -2,6 +2,7 @@
# Override the default /etc/apt/apt.conf with $DIB_APT_CONF
set -ue
set -o pipefail
# exit directly if DIB_APT_CONF is not defined properly
if [ -z "${DIB_APT_CONF:-}" ] ; then

@ -1,7 +1,8 @@
#!/bin/bash
# Override the default /etc/apt/sources.list with $DIB_APT_SOURCES
set -e
set -eu
set -o pipefail
# exit directly if DIB_APT_SOURCES is not defined properly
if [ -z "$DIB_APT_SOURCES" ] ; then

@ -14,7 +14,8 @@
# License for the specific language governing permissions and limitations
# under the License.
set -e
set -eu
set -o pipefail
[ -n "$TARGET_ROOT" ]

@ -1,6 +1,7 @@
#!/bin/bash
set -e
set -eu
set -o pipefail
# As this is run in cleanup, it's already been automatically unmounted,
# so all we need to do here is remove the directory

@ -1,5 +1,6 @@
#!/bin/bash
set -e
set -eu
set -o pipefail
set -o xtrace
touch /var/log/first-boot.d.log

@ -1,6 +1,7 @@
#!/bin/bash
set -eu
set -o pipefail
if [ -f /sbin/initctl ]; then
echo "upstart"

@ -1,7 +1,9 @@
#!/bin/bash
# Store the build-time environment and command line arguments
set -e
set -eu
set -o pipefail
source $_LIB/die
[ -n "$TMP_HOOKS_PATH" ] || die "Temp hook path not set"

@ -15,6 +15,7 @@
set -eux
set -o pipefail
declare -a SPECIFIED_ELEMS

@ -1,5 +1,6 @@
#!/bin/bash
set -e
set -eu
set -o pipefail
if [ -d /etc/first-boot.d ]; then
install -m 0755 -o root -g root $(dirname $0)/../dib-first-boot /usr/sbin/

@ -1,6 +1,7 @@
#!/bin/bash
# These are useful, or at worst not harmful, for all images we build.
set -e
set -eu
set -o pipefail
install-packages vlan open-iscsi

@ -1,7 +1,8 @@
#!/bin/bash
# Tweak the stock ubuntu cloud-init config
set -e
set -eu
set -o pipefail
dd of=/etc/cloud/cloud.cfg.d/10_etc_hosts.cfg << EOF
manage_etc_hosts: True

@ -1,7 +1,8 @@
#!/bin/bash
# Store build-time environment and command line arguments
set -e
set -eu
set -o pipefail
if [ -e "/tmp/in_target.d/dib_environment" ]; then
cp /tmp/in_target.d/dib_environment /etc/

@ -1,7 +1,8 @@
#!/bin/bash
# Install baseline packages and tools.
set -e
set -eu
set -o pipefail
# If lsb_release is missing, just do nothing.
DISTRO=`lsb_release -si` || true

@ -1,5 +1,6 @@
#!/bin/bash
set -e
set -eu
set -o pipefail
install -m 0755 -o root -g root $(dirname $0)/../dib-init-system /usr/bin/

@ -1,6 +1,7 @@
#!/bin/bash
set -e
set -eu
set -o pipefail
# Don't do anything if already mounted (if disk-image-create is invoked with
# no elements specified, this hook actually fires twice, once during

@ -15,7 +15,8 @@
# License for the specific language governing permissions and limitations
# under the License.
set -e
set -eu
set -o pipefail
# Download a URL to a local cache
# e.g. cache-url http://.../foo ~/.cache/image-create/foo

@ -1,5 +1,6 @@
#!/bin/bash
set -eux
set -o pipefail
cat > ${TARGET_ROOT}/.extra_settings << EOF
DIB_DEBIAN_ALT_INIT_PACKAGE=systemd-sysv
EOF

@ -1,5 +1,7 @@
#!/bin/bash
set -eux
set -o pipefail
cat > ${TARGET_ROOT}/.extra_settings << EOF
DIB_DEBIAN_ALT_INIT_PACKAGE=upstart
EOF

@ -1,5 +1,6 @@
#!/bin/bash
set -eux
set -o pipefail
# Working around bug in Debian cloud-init packages with upstart
# where startpar will wait forever for these because they are tasks
# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=735204

@ -15,6 +15,7 @@
# under the License.
#
set -eu
set -o pipefail
if [ -f ${TARGET_ROOT}/.extra_settings ] ; then
. ${TARGET_ROOT}/.extra_settings
fi

@ -1,6 +1,7 @@
#!/bin/bash
set -e
set -eu
set -o pipefail
INTERFACE=${1:-} #optional, if not specified configure all available interfaces
ENI_FILE="/etc/network/interfaces"
@ -68,7 +69,7 @@ function config_exists() {
return 0
fi
else
ifquery $interface >/dev/null 2>&1 && return 0
ifquery $interface >/dev/null 2>&1 && return 0 || return 1
fi
return 1
}

@ -19,6 +19,7 @@ allowed_regex=${RUN_PARTS_REGEX:-"^[0-9A-Za-z_-]+$"}
show_list=
set -ue
set -o pipefail
name=$(basename $0)

@ -1,6 +1,6 @@
#!/bin/bash
set -e
set -eu
set -o pipefail
home=$(dirname $0)

@ -14,7 +14,8 @@
# License for the specific language governing permissions and limitations
# under the License.
set -e
set -eu
set -o pipefail
# install-packages package [package ...]

@ -1,6 +1,7 @@
#!/bin/bash
set -e
set -eu
set -o pipefail
[ -n "$TARGET_ROOT" ]

@ -1,6 +1,7 @@
#!/bin/bash
set -e
set -eu
set -o pipefail
[ -n "$TARGET_ROOT" ]

@ -1,6 +1,7 @@
#!/bin/bash
# Do an apt-get clean. This will free some space.
set -e
set -eu
set -o pipefail
apt-get clean

@ -15,6 +15,7 @@
# under the License.
#
set -eux
set -o pipefail
DPKG_MANIFEST_NAME=dib-manifest-dpkg-$(basename ${IMAGE_NAME})

@ -1,6 +1,7 @@
#!/bin/bash
# Do an apt-get update, so that packages can be installed.
set -e
set -eu
set -o pipefail
apt-get -y update

@ -1,6 +1,7 @@
#!/bin/bash
set -e
set -eu
set -o pipefail
[ -n "$TARGET_ROOT" ]

@ -1,6 +1,7 @@
#!/bin/bash
set -e
set -eu
set -o pipefail
[ -n "$TARGET_ROOT" ]

@ -1,6 +1,7 @@
#!/bin/bash
set -e
set -eu
set -o pipefail
[ -n "$TARGET_ROOT" ]

@ -1,5 +1,6 @@
#!/bin/bash
set -e
set -eu
set -o pipefail
install-packages dracut-network patch

@ -1,6 +1,7 @@
#!/bin/bash
set -eu
set -o pipefail
[ -n "$ARCH" ]
[ -n "$TARGET_ROOT" ]

@ -1,7 +1,8 @@
#!/bin/bash
# Support for hard ware discovery
set -e
set -eu
set -o pipefail
set -o xtrace
install-packages hwinfo

@ -2,7 +2,9 @@
# Save user SSH public key if available.
# (Obviously not suitable for downloadable images).
set -e
set -eu
set -o pipefail
source $_LIB/die
[ -n "$TMP_HOOKS_PATH" ] || die "Temp hook path not set"

@ -2,7 +2,8 @@
# Save user SSH public key if available.
# XXX: Obviously not suitable for downloadable images.
set -e
set -eu
set -o pipefail
if [ -e "/tmp/in_target.d/ssh-authorized-keys" ]; then
mkdir -p /root/.ssh

@ -2,7 +2,8 @@
# Save the HTTP/[S] and noproxy settings if available.
# XXX: Obviously not suitable for downloadable images.
set -e
set -eu
set -o pipefail
set -o xtrace
have_apt=

@ -15,6 +15,7 @@
# under the License.
#
set -eux
set -o pipefail
if [ -d $TMP_MOUNT_PATH/${DIB_MANIFEST_IMAGE_DIR} ]; then
# Move the dib_environment and dib_arguments files into the manifests dir

@ -15,6 +15,7 @@
# under the License.
#
set -eu
set -o pipefail
export DIB_MANIFEST_IMAGE_DIR=${DIB_MANIFEST_IMAGE_DIR:-/etc/dib-manifests}
export DIB_MANIFEST_SAVE_DIR=${DIB_MANIFEST_SAVE_DIR:-${IMAGE_NAME}.d/}

@ -15,5 +15,6 @@
# under the License.
#
set -eux
set -o pipefail
sudo mkdir -p $TMP_MOUNT_PATH/${DIB_MANIFEST_IMAGE_DIR}

@ -1,7 +1,8 @@
#!/bin/bash
# Ensure we load the mellanox driver somehow
set -e
set -eu
set -o pipefail
home=$(dirname $0)

@ -1,5 +1,6 @@
#!/bin/bash
set -ex
set -eux
set -o pipefail
MODULES_LIST=${DIB_MODPROBE_BLACKLIST:?"Please set DIB_MODPROBE_BLACKLIST."}

@ -14,7 +14,8 @@
# License for the specific language governing permissions and limitations
# under the License.
set -e
set -eu
set -o pipefail
function run_zypper() {
# TODO: Uncertain if this can ever block wanting input from user

@ -1,7 +1,7 @@
#!/bin/bash
set -e
set -x
set -eux
set -o pipefail
export OPENSUSE_EXTRAS_PATH="$TMP_MOUNT_PATH/tmp/opensuse-extras"
mkdir -p $OPENSUSE_EXTRAS_PATH

@ -1,5 +1,6 @@
#!/bin/bash
set -e
set -eu
set -o pipefail
# Setup ccache symlinks, as openSUSE's ccache package doesn't
# include them.

@ -1,5 +1,6 @@
#!/bin/bash
set -e
set -eu
set -o pipefail
sed -i -e "s,^USERGROUPS_ENAB.*$,USERGROUPS_ENAB yes," /etc/login.defs

@ -3,6 +3,7 @@
# here.
set -eu
set -o pipefail
# To have access to FS_TYPE
_LIB="/tmp/opensuse-extras"

@ -1,6 +1,7 @@
#!/bin/bash
set -eu
set -o pipefail
[ -n "$ARCH" ]
[ -n "$TARGET_ROOT" ]

@ -1,6 +1,7 @@
#!/bin/bash
set -e
set -eu
set -o pipefail
PIP_CACHE_DIR=$HOME/.cache/image-create/pip
mkdir -p $PIP_CACHE_DIR

@ -1,6 +1,7 @@
#!/bin/bash
set -eu
set -o pipefail
PYPI_MIRROR_URL=${PYPI_MIRROR_URL:-''}
if [ -n "$PYPI_MIRROR_URL" ]; then

@ -1,6 +1,7 @@
#!/bin/bash
set -eu
set -o pipefail
if [ -e ~/.pip/pip.conf.orig ]; then
mv ~/.pip/pip.conf{.orig,}

@ -1,7 +1,7 @@
#!/bin/bash
set -e
set -x
set -eux
set -o pipefail
IMAGE_NAME=${IMAGE_NAME:-'image'}

@ -1,7 +1,7 @@
#!/bin/bash
set -e
set -x
set -eux
set -o pipefail
export RAMDISK_BUILD_PATH="$TMP_MOUNT_PATH/tmp/ramdisk-build"
mkdir -p $RAMDISK_BUILD_PATH

@ -1,5 +1,6 @@
#!/bin/bash
set -eux
set -o pipefail
DISTRO=`lsb_release -si` || true

@ -1,8 +1,8 @@
#!/bin/bash
# Ensure that all binaries listed in ramdisk elements, exist
set -e
set -x
set -eux
set -o pipefail
export TARGET_DIR="/tmp/in_target.d/"

@ -1,7 +1,7 @@
#!/bin/bash
set -e
set -x
set -eux
set -o pipefail
_LIB="/tmp/ramdisk-build"

@ -5,6 +5,7 @@
set -eu
set -o pipefail
BASE_IMAGE_FILE=$1
BASE_IMAGE_TAR=$2

@ -1,5 +1,6 @@
#!/bin/bash
set -eux
set -o pipefail
rm -rf /tmp/grub

@ -1,5 +1,6 @@
#!/bin/bash
set -e
set -eu
set -o pipefail
if [ -d /etc/first-boot.d ]; then
rc_local=/etc/rc.d/rc.local

@ -1,5 +1,6 @@
#!/bin/bash
set -eu
set -o pipefail
install -m 0755 -o root -g root /opt/stack/lsb-release/lsb_release /usr/local/bin

@ -1,6 +1,7 @@
#!/bin/bash
set -e
set -eu
set -o pipefail
yum remove -y grub2
# Install grub2 dependencies to minimise packages installed during finalise.

@ -1,6 +1,7 @@
#!/bin/bash
set -e
set -eu
set -o pipefail
if [ -n "$DIB_RHSM_USER" ] && [ -n "$DIB_RHSM_PASSWORD" ]; then
if [[ "$DIB_REG_TYPE" == "rhn" ]]; then

@ -1,6 +1,7 @@
#!/bin/bash
set -e
set -eu
set -o pipefail
if [ -n "$DIB_RHSM_USER" ] && [ -n "$DIB_RHSM_PASSWORD" ]
then

@ -1,6 +1,7 @@
#!/bin/bash
set -eu
set -o pipefail
[ -n "$ARCH" ]
[ -n "$TARGET_ROOT" ]

@ -1,6 +1,7 @@
#!/bin/bash
set -eu
set -o pipefail
[ -n "$ARCH" ]
[ -n "$TARGET_ROOT" ]

@ -1,6 +1,6 @@
#!/bin/bash
set -e
set -eu
set -o pipefail
if [ "i386" = "$ARCH" ]; then

@ -1,5 +1,6 @@
#!/bin/bash
set -uex
set -o pipefail
SCRIPTDIR=$(dirname $0)
DIB_INIT_SYSTEM=$(dib-init-system)

@ -1,6 +1,7 @@
#!/bin/bash
set -eu
set -o pipefail
# If the old cache exists, move it to the new name
function make_new_cache(){

@ -1,6 +1,7 @@
#!/bin/bash
set -uex
set -o pipefail
# Git isn't a dependency of this element, but is a dependency of pbr
# if you are doing pip install on a git cloned directoy, because this

@ -1,5 +1,6 @@
#!/bin/bash
set -e
set -eu
set -o pipefail
if [ -d /etc/first-boot.d ]; then
rc_local=/etc/rc.local

@ -1,6 +1,7 @@
#!/bin/bash
set -e
set -eu
set -o pipefail
# Ubuntu's cloud images don't include drivers for real hardware.
install-packages linux-image-generic

@ -3,7 +3,8 @@
# found (as happens in a chroot).
# Temporarily remove grub, to avoid that confusion.
set -e
set -eu
set -o pipefail
if dpkg-query -W grub-pc; then
apt-get -y remove grub-pc

@ -1,6 +1,7 @@
#!/bin/bash
set -eu
set -o pipefail
DIB_DISTRIBUTION_MIRROR=${DIB_DISTRIBUTION_MIRROR:-}

@ -2,6 +2,7 @@
# These are useful, or at worst not harmful, for all images we build.
set -eu
set -o pipefail
[ -n "$ARCH" ]
[ -n "$TARGET_ROOT" ]

@ -1,6 +1,7 @@
#!/bin/bash
set -e
set -eu
set -o pipefail
source $_LIB/die
[ -n "$IMAGE_BLOCK_DEVICE" ] || die "Image block device not set"

@ -1,6 +1,7 @@
#!/bin/bash
set -eux
set -o pipefail
if [ "openSUSE project" = "$(lsb_release -is)" ]; then
# workaround for https://bugzilla.novell.com/show_bug.cgi?id=859493

@ -3,8 +3,8 @@
# Configure grub. Note that the various conditionals here are to handle
# different distributions gracefully.
set -e
set -x
set -eux
set -o pipefail
# FIXME:
[ -n "$IMAGE_BLOCK_DEVICE" ]

@ -14,7 +14,8 @@
# License for the specific language governing permissions and limitations
# under the License.
set -e
set -eu
set -o pipefail
EXTRA_ARGS=
ACTION=install

@ -1,6 +1,7 @@
#!/bin/bash
set -e
set -eu
set -o pipefail
sudo sed -i 's/keepcache=0/keepcache=1/' /etc/yum.conf
sudo sed -i 's/cachedir=\/var\/cache\/yum/cachedir=\/tmp\/yum/' /etc/yum.conf

@ -1,6 +1,7 @@
#!/bin/bash
set -e
set -eu
set -o pipefail
[ -n "$TARGET_ROOT" ]

@ -1,6 +1,7 @@
#!/bin/bash
set -e
set -eu
set -o pipefail
# Disable caching packages for all repositories
sudo zypper modifyrepo --all --no-keep-packages

@ -1,6 +1,7 @@
#!/bin/bash
set -e
set -eu
set -o pipefail
# Enable caching packages for all repositories
sudo zypper modifyrepo --all --keep-packages

@ -1,6 +1,7 @@
#!/bin/bash
set -e
set -eu
set -o pipefail
[ -n "$TARGET_ROOT" ]