4 spaces indent

ensure 4 spaces indentation is used everywhere.

Change-Id: Ieb48faacb4c96b7b358771d70c17f2f22d0354f4
This commit is contained in:
Gonéri Le Bouder 2014-05-02 19:02:38 +02:00
parent 83aee34534
commit ea3f4dd459
30 changed files with 323 additions and 323 deletions

View File

@ -5,9 +5,9 @@ set -eu
set -o pipefail set -o pipefail
if [ -e "/tmp/in_target.d/dib_environment" ]; then if [ -e "/tmp/in_target.d/dib_environment" ]; then
cp /tmp/in_target.d/dib_environment /etc/ cp /tmp/in_target.d/dib_environment /etc/
fi fi
if [ -e "/tmp/in_target.d/dib_arguments" ]; then if [ -e "/tmp/in_target.d/dib_arguments" ]; then
cp /tmp/in_target.d/dib_arguments /etc/ cp /tmp/in_target.d/dib_arguments /etc/
fi fi

View File

@ -8,10 +8,10 @@ set -o pipefail
DISTRO=`lsb_release -si` || true DISTRO=`lsb_release -si` || true
case $DISTRO in case $DISTRO in
'Ubuntu'|'Debian') 'Ubuntu'|'Debian')
# Note: add-apt-repository would be nice for RPM platforms too - so when we # Note: add-apt-repository would be nice for RPM platforms too - so when we
# need something like it, create a wrapper in dpkg/bin and fedora/bin. # need something like it, create a wrapper in dpkg/bin and fedora/bin.
apt-get -y update apt-get -y update
install-packages python-software-properties install-packages python-software-properties
;; ;;
esac esac

View File

@ -26,12 +26,12 @@ dest=$2
time_cond= time_cond=
if [ -p $dest ]; then if [ -p $dest ]; then
type="fifo" type="fifo"
tmp=$(mktemp --tmpdir download.XXXXXXXX) tmp=$(mktemp --tmpdir download.XXXXXXXX)
else else
type="normal" type="normal"
mkdir -p $(dirname $dest) mkdir -p $(dirname $dest)
tmp=$(mktemp $(dirname $dest)/.download.XXXXXXXX) tmp=$(mktemp $(dirname $dest)/.download.XXXXXXXX)
fi fi
if [ -f $dest -a -s $dest ] ; then if [ -f $dest -a -s $dest ] ; then
@ -52,14 +52,14 @@ if [ "$rcode" == "200" -o "${url:0:7}" == "file://" ] ; then
else else
echo $success echo $success
if [ "fifo" = "$type" ]; then if [ "fifo" = "$type" ]; then
cp $tmp $dest cp $tmp $dest
rm $tmp rm $tmp
else else
mv $tmp $dest mv $tmp $dest
fi fi
fi fi
# 213 is the response to a ftp MDTM command, curl outputs a 213 as the status # 213 is the response to a ftp MDTM command, curl outputs a 213 as the status
# if the url redirected to a ftp server and Not-Modified # if the url redirected to a ftp server and Not-Modified
elif [ "$rcode" = "304" -o "$rcode" = "213" ] ; then elif [ "$rcode" = "304" -o "$rcode" = "213" ] ; then
echo "Server copy has not changed. Using locally cached $url" echo "Server copy has not changed. Using locally cached $url"
rm -f $tmp rm -f $tmp

View File

@ -20,46 +20,46 @@ fi
ARGS="$0 $@" ARGS="$0 $@"
function serialize_me() { function serialize_me() {
if [ "$CONF_TYPE" == "eni" ]; then if [ "$CONF_TYPE" == "eni" ]; then
# Serialize runs so that we don't miss hot-add interfaces # Serialize runs so that we don't miss hot-add interfaces
FLOCKED=${FLOCKED:-} FLOCKED=${FLOCKED:-}
if [ -z "$FLOCKED" ] ; then if [ -z "$FLOCKED" ] ; then
FLOCKED=true exec flock -x $ENI_FILE $ARGS FLOCKED=true exec flock -x $ENI_FILE $ARGS
fi fi
fi fi
} }
function get_if_link() { function get_if_link() {
cat /sys/class/net/${1}/carrier cat /sys/class/net/${1}/carrier
} }
function enable_interface() { function enable_interface() {
local interface=$1 local interface=$1
serialize_me serialize_me
if [ "$CONF_TYPE" == "eni" ]; then if [ "$CONF_TYPE" == "eni" ]; then
printf "auto $interface\niface $interface inet dhcp\n\n" >>$ENI_FILE printf "auto $interface\niface $interface inet dhcp\n\n" >>$ENI_FILE
elif [ "$CONF_TYPE" == "netscripts" ]; then elif [ "$CONF_TYPE" == "netscripts" ]; then
printf "DEVICE=\"$interface\"\nBOOTPROTO=\"dhcp\"\nONBOOT=\"yes\"\nTYPE=\"Ethernet\"" >"/etc/sysconfig/network-scripts/ifcfg-$interface" printf "DEVICE=\"$interface\"\nBOOTPROTO=\"dhcp\"\nONBOOT=\"yes\"\nTYPE=\"Ethernet\"" >"/etc/sysconfig/network-scripts/ifcfg-$interface"
fi fi
echo "Configured $1" echo "Configured $1"
} }
function disable_interface() { function disable_interface() {
local interface=$1 local interface=$1
serialize_me serialize_me
if [ "$CONF_TYPE" == "netscripts" ]; then if [ "$CONF_TYPE" == "netscripts" ]; then
local IFCFG_FILE="/etc/sysconfig/network-scripts/ifcfg-$interface" local IFCFG_FILE="/etc/sysconfig/network-scripts/ifcfg-$interface"
if [ -f "$IFCFG_FILE" ]; then if [ -f "$IFCFG_FILE" ]; then
rm $IFCFG_FILE rm $IFCFG_FILE
else else
echo "No link detected, skipping" echo "No link detected, skipping"
fi fi
else else
echo "No link detected, skipping" echo "No link detected, skipping"
fi fi
} }
function config_exists() { function config_exists() {
@ -75,34 +75,34 @@ function config_exists() {
} }
function inspect_interface() { function inspect_interface() {
local interface=$1 local interface=$1
local mac_addr_type="$(cat /sys/class/net/${interface}/addr_assign_type)" local mac_addr_type="$(cat /sys/class/net/${interface}/addr_assign_type)"
echo -n "Inspecting interface: $interface..." echo -n "Inspecting interface: $interface..."
if config_exists $interface; then if config_exists $interface; then
echo "Has config, skipping." echo "Has config, skipping."
elif [ "$mac_addr_type" != "0" ]; then elif [ "$mac_addr_type" != "0" ]; then
echo "Device has generated MAC, skipping." echo "Device has generated MAC, skipping."
else else
ip link set dev $interface up &>/dev/null ip link set dev $interface up &>/dev/null
HAS_LINK="$(get_if_link $interface)" HAS_LINK="$(get_if_link $interface)"
TRIES=10 TRIES=10
while [ "$HAS_LINK" == "0" -a $TRIES -gt 0 ]; do while [ "$HAS_LINK" == "0" -a $TRIES -gt 0 ]; do
HAS_LINK="$(get_if_link $interface)" HAS_LINK="$(get_if_link $interface)"
if [ "$HAS_LINK" == "1" ]; then if [ "$HAS_LINK" == "1" ]; then
break break
else else
sleep 1 sleep 1
fi fi
TRIES=$(( TRIES - 1 )) TRIES=$(( TRIES - 1 ))
done done
if [ "$HAS_LINK" == "1" ] ; then if [ "$HAS_LINK" == "1" ] ; then
enable_interface "$interface" enable_interface "$interface"
else else
disable_interface "$interface" disable_interface "$interface"
fi
fi fi
fi
} }

View File

@ -62,10 +62,10 @@ fi
targets=$(find $target_dir -maxdepth 1 -xtype f -executable -printf '%f\n' | grep -E "$allowed_regex" | LANG=C sort -n || echo "") targets=$(find $target_dir -maxdepth 1 -xtype f -executable -printf '%f\n' | grep -E "$allowed_regex" | LANG=C sort -n || echo "")
if [ "$show_list" == "1" ] ; then if [ "$show_list" == "1" ] ; then
for target in $targets ; do for target in $targets ; do
echo "${target_dir}/${target}" echo "${target_dir}/${target}"
done done
exit 0 exit 0
fi fi
PROFILE_DIR=$(mktemp -d /tmp/profiledir.XXXXXX) PROFILE_DIR=$(mktemp -d /tmp/profiledir.XXXXXX)

View File

@ -9,19 +9,19 @@ modules=$(dkms status | tr ',:' ' ' | awk '{ print $1 "/" $2 }')
kernels=$(ls /usr/src/linux-headers-*-*-* -d | sed -e 's|/usr/src/linux-headers-||' || echo "") kernels=$(ls /usr/src/linux-headers-*-*-* -d | sed -e 's|/usr/src/linux-headers-||' || echo "")
# NOTE(bnemec): On Fedora, the versions can be found in /usr/src/kernels # NOTE(bnemec): On Fedora, the versions can be found in /usr/src/kernels
if [ -z "$kernels" ]; then if [ -z "$kernels" ]; then
kernels=$(ls /usr/src/kernels/* -d | sed -e 's|/usr/src/kernels/||' || echo "") kernels=$(ls /usr/src/kernels/* -d | sed -e 's|/usr/src/kernels/||' || echo "")
fi fi
if [ -z "$kernels" ]; then if [ -z "$kernels" ]; then
echo "Warning: No kernel versions found for DKMS" echo "Warning: No kernel versions found for DKMS"
fi fi
__ARCH=$ARCH __ARCH=$ARCH
unset ARCH unset ARCH
for module in $modules ; do for module in $modules ; do
for kernel in $kernels ; do for kernel in $kernels ; do
dkms build $module -k $kernel dkms build $module -k $kernel
dkms install $module -k $kernel dkms install $module -k $kernel
done done
done done
ARCH=$__ARCH ARCH=$__ARCH

View File

@ -20,18 +20,18 @@ set -o pipefail
# install-packages package [package ...] # install-packages package [package ...]
install_deb_packages () { install_deb_packages () {
DEBIAN_FRONTEND=noninteractive \ DEBIAN_FRONTEND=noninteractive \
http_proxy=${http_proxy:-} https_proxy=${https_proxy:-} \ http_proxy=${http_proxy:-} https_proxy=${https_proxy:-} \
no_proxy=${no_proxy:-} \ no_proxy=${no_proxy:-} \
apt-get --option "Dpkg::Options::=--force-confold" --assume-yes "$@" apt-get --option "Dpkg::Options::=--force-confold" --assume-yes "$@"
} }
if [ "$1" = "-u" ] ; then if [ "$1" = "-u" ] ; then
install_deb_packages dist-upgrade install_deb_packages dist-upgrade
exit 0 exit 0
elif [ "$1" = "-e" ]; then elif [ "$1" = "-e" ]; then
install_deb_packages remove $@ install_deb_packages remove $@
shift shift
else else
install_deb_packages install $@ install_deb_packages install $@
fi fi

View File

@ -13,7 +13,7 @@ IFCFG_FILE="/usr/lib/dracut/modules.d/45ifcfg/write-ifcfg.sh"
NETGEN_FILE="/usr/lib/dracut/modules.d/40network/net-genrules.sh" NETGEN_FILE="/usr/lib/dracut/modules.d/40network/net-genrules.sh"
if patch --dry-run $NETGEN_FILE < $(dirname $0)/../dracut-029-netgen.patch > /dev/null; then if patch --dry-run $NETGEN_FILE < $(dirname $0)/../dracut-029-netgen.patch > /dev/null; then
patch $NETGEN_FILE < $(dirname $0)/../dracut-029-netgen.patch || true patch $NETGEN_FILE < $(dirname $0)/../dracut-029-netgen.patch || true
else else
patch $IFCFG_FILE < $(dirname $0)/../dracut-write-ifcfg.patch || true patch $IFCFG_FILE < $(dirname $0)/../dracut-write-ifcfg.patch || true
fi fi

View File

@ -7,7 +7,7 @@ set -o pipefail
[ -n "$TARGET_ROOT" ] [ -n "$TARGET_ROOT" ]
if [ 'amd64' = "$ARCH" ] ; then if [ 'amd64' = "$ARCH" ] ; then
ARCH="x86_64" ARCH="x86_64"
fi fi
DIB_LOCAL_IMAGE=${DIB_LOCAL_IMAGE:-""} DIB_LOCAL_IMAGE=${DIB_LOCAL_IMAGE:-""}

View File

@ -9,5 +9,5 @@ source $_LIB/die
[ -n "$TMP_HOOKS_PATH" ] || die "Temp hook path not set" [ -n "$TMP_HOOKS_PATH" ] || die "Temp hook path not set"
if [ -e ~/.ssh/authorized_keys ]; then if [ -e ~/.ssh/authorized_keys ]; then
cat ~/.ssh/authorized_keys > $TMP_HOOKS_PATH/ssh-authorized-keys cat ~/.ssh/authorized_keys > $TMP_HOOKS_PATH/ssh-authorized-keys
fi fi

View File

@ -6,8 +6,8 @@ set -eu
set -o pipefail set -o pipefail
if [ -e "/tmp/in_target.d/ssh-authorized-keys" ]; then if [ -e "/tmp/in_target.d/ssh-authorized-keys" ]; then
mkdir -p /root/.ssh mkdir -p /root/.ssh
cat /tmp/in_target.d/ssh-authorized-keys >> /root/.ssh/authorized_keys cat /tmp/in_target.d/ssh-authorized-keys >> /root/.ssh/authorized_keys
chmod 0700 /root/.ssh chmod 0700 /root/.ssh
chmod 0600 /root/.ssh/authorized_keys chmod 0600 /root/.ssh/authorized_keys
fi fi

View File

@ -13,60 +13,60 @@ http_proxy=${http_proxy:-""}
https_proxy=${https_proxy:-""} https_proxy=${https_proxy:-""}
if [ -d /etc/apt ] ; then if [ -d /etc/apt ] ; then
have_apt=1 have_apt=1
fi fi
if [ -e /etc/yum.conf ] ; then if [ -e /etc/yum.conf ] ; then
have_yum=1 have_yum=1
fi fi
if [ -d /etc/zypp ] ; then if [ -d /etc/zypp ] ; then
have_zypper=1 have_zypper=1
fi fi
if [ -n "$http_proxy" ]; then if [ -n "$http_proxy" ]; then
if [ -d ~stack ]; then if [ -d ~stack ]; then
echo export http_proxy=$http_proxy >> ~stack/.profile echo export http_proxy=$http_proxy >> ~stack/.profile
fi fi
if [ -n "$have_apt" ] ; then if [ -n "$have_apt" ] ; then
echo "Acquire::http::Proxy \"$http_proxy\";" > /etc/apt/apt.conf.d/02-use-http-proxy echo "Acquire::http::Proxy \"$http_proxy\";" > /etc/apt/apt.conf.d/02-use-http-proxy
fi fi
if [ -n "$have_yum" ] ; then if [ -n "$have_yum" ] ; then
sed -i -e "s,\[main\],[main]\nproxy=$http_proxy," /etc/yum.conf sed -i -e "s,\[main\],[main]\nproxy=$http_proxy," /etc/yum.conf
fi fi
if [ -n "$have_zypper" ] ; then if [ -n "$have_zypper" ] ; then
sed -i -e "s,^HTTP_PROXY=.*$,HTTP_PROXY=\"$http_proxy\"," /etc/sysconfig/proxy sed -i -e "s,^HTTP_PROXY=.*$,HTTP_PROXY=\"$http_proxy\"," /etc/sysconfig/proxy
fi fi
fi fi
if [ -n "$https_proxy" ]; then if [ -n "$https_proxy" ]; then
if [ -d ~stack ]; then if [ -d ~stack ]; then
echo export https_proxy=$https_proxy >> ~stack/.profile echo export https_proxy=$https_proxy >> ~stack/.profile
fi fi
if [ -n "$have_apt" ] ; then if [ -n "$have_apt" ] ; then
echo "Acquire::https::Proxy \"$https_proxy\";" > /etc/apt/apt.conf.d/02-use-https-proxy echo "Acquire::https::Proxy \"$https_proxy\";" > /etc/apt/apt.conf.d/02-use-https-proxy
fi fi
if [ -n "$have_zypper" ] ; then if [ -n "$have_zypper" ] ; then
sed -i -e "s,^HTTPS_PROXY=.*$,HTTPS_PROXY=\"$https_proxy\"," /etc/sysconfig/proxy sed -i -e "s,^HTTPS_PROXY=.*$,HTTPS_PROXY=\"$https_proxy\"," /etc/sysconfig/proxy
fi fi
fi fi
no_proxy=${no_proxy:+"$no_proxy,192.0.2.1"} no_proxy=${no_proxy:+"$no_proxy,192.0.2.1"}
no_proxy=${no_proxy:-"192.0.2.1"} no_proxy=${no_proxy:-"192.0.2.1"}
if [ -n "$no_proxy" ]; then if [ -n "$no_proxy" ]; then
if [ -d ~stack ]; then if [ -d ~stack ]; then
echo export no_proxy=$no_proxy >> ~stack/.profile echo export no_proxy=$no_proxy >> ~stack/.profile
fi fi
if [ -n "$have_apt" ] ; then if [ -n "$have_apt" ] ; then
for host in $(sed 's/,/ /g' <<<$no_proxy); do for host in $(sed 's/,/ /g' <<<$no_proxy); do
echo "Acquire::http::Proxy::$host \"DIRECT\";" >> /etc/apt/apt.conf.d/02-no-proxy echo "Acquire::http::Proxy::$host \"DIRECT\";" >> /etc/apt/apt.conf.d/02-no-proxy
done done
fi fi
if [ -n "$have_zypper" ] ; then if [ -n "$have_zypper" ] ; then
sed -i -e "s,^\(NO_PROXY=.*\)\"$,\1\, $no_proxy\"," /etc/sysconfig/proxy sed -i -e "s,^\(NO_PROXY=.*\)\"$,\1\, $no_proxy\"," /etc/sysconfig/proxy
fi fi
fi fi
if [ -n "$http_proxy" -o -n "$https_proxy" -o -n "$no_proxy" ]; then if [ -n "$http_proxy" -o -n "$https_proxy" -o -n "$no_proxy" ]; then
if [ -n "$have_zypper" ] ; then if [ -n "$have_zypper" ] ; then
sed -i -e "s,^PROXY_ENABLED=.*$,PROXY_ENABLED=\"yes\"," /etc/sysconfig/proxy sed -i -e "s,^PROXY_ENABLED=.*$,PROXY_ENABLED=\"yes\"," /etc/sysconfig/proxy
fi fi
fi fi

View File

@ -18,16 +18,16 @@ set -eu
set -o pipefail set -o pipefail
function run_zypper() { function run_zypper() {
# TODO: Uncertain if this can ever block wanting input from user # TODO: Uncertain if this can ever block wanting input from user
zypper --non-interactive --gpg-auto-import-keys "$@" zypper --non-interactive --gpg-auto-import-keys "$@"
} }
if [ "$1" = "-u" ] ; then if [ "$1" = "-u" ] ; then
run_zypper dist-upgrade run_zypper dist-upgrade
exit 0 exit 0
elif [ "$1" = "-d" ] ; then elif [ "$1" = "-d" ] ; then
EXTRA_ARGS="--download-only" EXTRA_ARGS="--download-only"
shift shift
fi fi
# Packages that aren't available in the distro but requested for installation # Packages that aren't available in the distro but requested for installation
@ -36,12 +36,12 @@ BLACKLIST=(dkms)
WHITELIST=() WHITELIST=()
for i in "$@" for i in "$@"
do do
if [[ ! ${BLACKLIST[*]} =~ $i ]]; then if [[ ! ${BLACKLIST[*]} =~ $i ]]; then
WHITELIST+="$i " WHITELIST+="$i "
else else
echo "The package $i is not available and will not be installed" echo "The package $i is not available and will not be installed"
fi fi
done done
if [ -n "$WHITELIST" ]; then if [ -n "$WHITELIST" ]; then
run_zypper install $EXTRA_ARGS $(map-packages $WHITELIST) run_zypper install $EXTRA_ARGS $(map-packages $WHITELIST)
fi fi

View File

@ -7,6 +7,6 @@ export OPENSUSE_EXTRAS_PATH="$TMP_MOUNT_PATH/tmp/opensuse-extras"
mkdir -p $OPENSUSE_EXTRAS_PATH mkdir -p $OPENSUSE_EXTRAS_PATH
for file in common-defaults img-defaults ; do for file in common-defaults img-defaults ; do
cp $_LIB/$file $OPENSUSE_EXTRAS_PATH cp $_LIB/$file $OPENSUSE_EXTRAS_PATH
done done

View File

@ -26,12 +26,12 @@ if [ -z "$DIB_OFFLINE" ] ; then
# https://bugzilla.novell.com/show_bug.cgi?id=853882 is deployed # https://bugzilla.novell.com/show_bug.cgi?id=853882 is deployed
echo "Looking up current built of Base Image ($BASE_IMAGE_NAME):" echo "Looking up current built of Base Image ($BASE_IMAGE_NAME):"
BASE_IMAGE_FILE=${BASE_IMAGE_FILE:-$(curl $DIB_CLOUD_IMAGES | \ BASE_IMAGE_FILE=${BASE_IMAGE_FILE:-$(curl $DIB_CLOUD_IMAGES | \
sed -n "s/^.*\<a\ href\=\"\($BASE_IMAGE_NAME.*\.tbz\)\".*$/\1/p")} sed -n "s/^.*\<a\ href\=\"\($BASE_IMAGE_NAME.*\.tbz\)\".*$/\1/p")}
if [ -n "$BASE_IMAGE_FILE" ]; then if [ -n "$BASE_IMAGE_FILE" ]; then
echo "Using base image: $DIB_CLOUD_IMAGES/$BASE_IMAGE_FILE" echo "Using base image: $DIB_CLOUD_IMAGES/$BASE_IMAGE_FILE"
else else
echo -e "Failed to extract image file name from $DIB_CLOUD_IMAGES" \ echo -e "Failed to extract image file name from $DIB_CLOUD_IMAGES" \
"\nPlease set BASE_IMAGE_FILE manually and retry." "\nPlease set BASE_IMAGE_FILE manually and retry."
exit 1 exit 1
fi fi
else else

View File

@ -5,8 +5,8 @@ set -o pipefail
PYPI_MIRROR_URL=${PYPI_MIRROR_URL:-''} PYPI_MIRROR_URL=${PYPI_MIRROR_URL:-''}
if [ -n "$PYPI_MIRROR_URL" ]; then if [ -n "$PYPI_MIRROR_URL" ]; then
# External mirror URL being used - no need to bind mount anything. # External mirror URL being used - no need to bind mount anything.
exit 0 exit 0
fi fi
MIRROR_SOURCE=~/.cache/image-create/pypi/mirror/ MIRROR_SOURCE=~/.cache/image-create/pypi/mirror/
MIRROR_TARGET=$TMP_MOUNT_PATH/tmp/pypi MIRROR_TARGET=$TMP_MOUNT_PATH/tmp/pypi

View File

@ -7,7 +7,7 @@ export RAMDISK_BUILD_PATH="$TMP_MOUNT_PATH/tmp/ramdisk-build"
mkdir -p $RAMDISK_BUILD_PATH mkdir -p $RAMDISK_BUILD_PATH
for file in common-defaults common-functions ramdisk-defaults ramdisk-functions img-defaults img-functions ; do for file in common-defaults common-functions ramdisk-defaults ramdisk-functions img-defaults img-functions ; do
cp $_LIB/$file $RAMDISK_BUILD_PATH cp $_LIB/$file $RAMDISK_BUILD_PATH
done done
cp -r $(dirname $0)/scripts $RAMDISK_BUILD_PATH cp -r $(dirname $0)/scripts $RAMDISK_BUILD_PATH

View File

@ -7,39 +7,39 @@ set -o pipefail
export TARGET_DIR="/tmp/in_target.d/" export TARGET_DIR="/tmp/in_target.d/"
if [ -z $TARGET_DIR ] ; then if [ -z $TARGET_DIR ] ; then
echo "Target dir not specified" echo "Target dir not specified"
exit 1 exit 1
fi fi
if [ ! -d $TARGET_DIR ] ; then if [ ! -d $TARGET_DIR ] ; then
echo "Unable to find specified directory in target: $TARGET_DIR" echo "Unable to find specified directory in target: $TARGET_DIR"
bash bash
exit 1 exit 1
fi fi
BINARY_DEPS= BINARY_DEPS=
for _FILE in $(ls ${TARGET_DIR}/binary-deps.d/) ; do for _FILE in $(ls ${TARGET_DIR}/binary-deps.d/) ; do
_FILE="${TARGET_DIR}/binary-deps.d/${_FILE}" _FILE="${TARGET_DIR}/binary-deps.d/${_FILE}"
if [ -a $_FILE ]; then if [ -a $_FILE ]; then
for _LINE in $(cat $_FILE) ; do for _LINE in $(cat $_FILE) ; do
BINARY_DEPS="${BINARY_DEPS} $_LINE" BINARY_DEPS="${BINARY_DEPS} $_LINE"
done done
fi fi
done done
for _BIN in $BINARY_DEPS ; do for _BIN in $BINARY_DEPS ; do
_LOCATION=$(which "$_BIN" || echo "") _LOCATION=$(which "$_BIN" || echo "")
if [ -z "$_LOCATION" ]; then if [ -z "$_LOCATION" ]; then
echo "$_BIN is not found in PATH. Please ensure your elements install it" echo "$_BIN is not found in PATH. Please ensure your elements install it"
exit 1 exit 1
fi fi
done done
if [ "$BINARY_DEPS" == "" ]; then if [ "$BINARY_DEPS" == "" ]; then
echo "No binary-deps found" echo "No binary-deps found"
else else
DEPS_OUTPUT="/etc/dib_binary_deps" DEPS_OUTPUT="/etc/dib_binary_deps"
echo "Creating binary_deps record at: ${DEPS_OUTPUT}" echo "Creating binary_deps record at: ${DEPS_OUTPUT}"
echo "$BINARY_DEPS" >${DEPS_OUTPUT} echo "$BINARY_DEPS" >${DEPS_OUTPUT}
fi fi

View File

@ -84,5 +84,5 @@ fi
echo "Extracting base root image from $CACHED_TAR" echo "Extracting base root image from $CACHED_TAR"
sudo tar -C $TARGET_ROOT --numeric-owner -xzf $CACHED_TAR sudo tar -C $TARGET_ROOT --numeric-owner -xzf $CACHED_TAR
if [ -e "$TARGET_ROOT/lost+found" ]; then if [ -e "$TARGET_ROOT/lost+found" ]; then
sudo rmdir $TARGET_ROOT/lost+found sudo rmdir $TARGET_ROOT/lost+found
fi fi

View File

@ -20,17 +20,17 @@ set -o xtrace
dib-first-boot dib-first-boot
EOF EOF
if [ $FILE_EXISTED ] if [ $FILE_EXISTED ]
then then
echo "mv $rc_local.REAL $rc_local" >> $rc_local echo "mv $rc_local.REAL $rc_local" >> $rc_local
else else
echo "rm \$0" >> $rc_local echo "rm \$0" >> $rc_local
fi fi
echo "exit 0" >> $rc_local echo "exit 0" >> $rc_local
chmod 755 $rc_local chmod 755 $rc_local
# Enable the service # Enable the service
systemctl enable rc-local.service systemctl enable rc-local.service
fi fi

View File

@ -4,9 +4,9 @@ set -eu
set -o pipefail set -o pipefail
if [ -n "$DIB_RHSM_USER" ] && [ -n "$DIB_RHSM_PASSWORD" ]; then if [ -n "$DIB_RHSM_USER" ] && [ -n "$DIB_RHSM_PASSWORD" ]; then
if [[ "$DIB_REG_TYPE" == "rhn" ]]; then if [[ "$DIB_REG_TYPE" == "rhn" ]]; then
rm -rf /etc/sysconfig/rhn/systemid rm -rf /etc/sysconfig/rhn/systemid
else else
subscription-manager unregister subscription-manager unregister
fi fi
fi fi

View File

@ -4,52 +4,52 @@ set -eu
set -o pipefail set -o pipefail
if [ -n "$DIB_RHSM_USER" ] && [ -n "$DIB_RHSM_PASSWORD" ] if [ -n "$DIB_RHSM_USER" ] && [ -n "$DIB_RHSM_PASSWORD" ]
then then
opts="--force" opts="--force"
if [[ -n "$DIB_SAT_KEY" ]]; then if [[ -n "$DIB_SAT_KEY" ]]; then
opts="$opts --activationkey ${DIB_SAT_KEY}" opts="$opts --activationkey ${DIB_SAT_KEY}"
else else
opts="$opts --username ${DIB_RHSM_USER} --password ${DIB_RHSM_PASSWORD}" opts="$opts --username ${DIB_RHSM_USER} --password ${DIB_RHSM_PASSWORD}"
fi fi
if [[ -n "$DIB_SAT_URL" ]]; then if [[ -n "$DIB_SAT_URL" ]]; then
if [[ "$DIB_REG_TYPE" == "rhn" ]]; then if [[ "$DIB_REG_TYPE" == "rhn" ]]; then
opts="$opts --serverUrl ${DIB_SAT_URL}" opts="$opts --serverUrl ${DIB_SAT_URL}"
else else
opts="$opts --serverurl ${DIB_SAT_URL} --sslCACert /usr/share/rhn/RHN-ORG-TRUSTED-SSL-CERT" opts="$opts --serverurl ${DIB_SAT_URL} --sslCACert /usr/share/rhn/RHN-ORG-TRUSTED-SSL-CERT"
fi fi
fi fi
if [[ -n "$DIB_SAT_CERT_RPM_URL" ]]; then if [[ -n "$DIB_SAT_CERT_RPM_URL" ]]; then
yum install -y ${DIB_SAT_CERT_RPM_URL} yum install -y ${DIB_SAT_CERT_RPM_URL}
fi fi
if [[ "$DIB_REG_TYPE" == "rhn" ]]; then if [[ "$DIB_REG_TYPE" == "rhn" ]]; then
rhnreg_ks $opts --norhnsd rhnreg_ks $opts --norhnsd
sleep 1 sleep 1
# optional channel required for diskimage-builder dependency # optional channel required for diskimage-builder dependency
channels="-a -c rhel-x86_64-server-optional-6" channels="-a -c rhel-x86_64-server-optional-6"
if [[ -n "$DIB_RHN_CHANNELS" ]]; then if [[ -n "$DIB_RHN_CHANNELS" ]]; then
for chan in $DIB_RHN_CHANNELS; do for chan in $DIB_RHN_CHANNELS; do
channels="$channels -a -c $chan" channels="$channels -a -c $chan"
done done
fi fi
rhn-channel --user=$DIB_RHSM_USER --password=$DIB_RHSM_PASSWORD $channels rhn-channel --user=$DIB_RHSM_USER --password=$DIB_RHSM_PASSWORD $channels
rhn-channel -l rhn-channel -l
else else
subscription-manager register $opts subscription-manager register $opts
# wait a second to ensure consumer certificate is finished writing to disk # wait a second to ensure consumer certificate is finished writing to disk
sleep 1 sleep 1
if [ -z $DIB_RHSM_POOL ]; then if [ -z $DIB_RHSM_POOL ]; then
subscription-manager attach --auto subscription-manager attach --auto
else else
subscription-manager attach --pool $DIB_RHSM_POOL subscription-manager attach --pool $DIB_RHSM_POOL
fi fi
# optional repo required for diskimage-builder dependency # optional repo required for diskimage-builder dependency
repos="--enable rhel-6-server-optional-rpms" repos="--enable rhel-6-server-optional-rpms"
if [[ -n "$DIB_RHSM_REPOS" ]]; then if [[ -n "$DIB_RHSM_REPOS" ]]; then
for repo in $DIB_RHSM_REPOS; do for repo in $DIB_RHSM_REPOS; do
repos="$repos --enable $repo" repos="$repos --enable $repo"
done done
fi fi
subscription-manager repos $repos subscription-manager repos $repos
subscription-manager repos --list subscription-manager repos --list
fi fi
fi fi

View File

@ -7,7 +7,7 @@ set -o pipefail
[ -n "$TARGET_ROOT" ] [ -n "$TARGET_ROOT" ]
if [ 'amd64' = "$ARCH" ] ; then if [ 'amd64' = "$ARCH" ] ; then
ARCH="x86_64" ARCH="x86_64"
fi fi
DIB_RELEASE=${DIB_RELEASE:-"6.5-20140121.0"} DIB_RELEASE=${DIB_RELEASE:-"6.5-20140121.0"}
@ -38,8 +38,8 @@ else
export LOOPDEV=$LOOPDEV export LOOPDEV=$LOOPDEV
echo "Loop device is set to: $LOOPDEV" echo "Loop device is set to: $LOOPDEV"
if ! timeout 5 sh -c "while ! [ -e /dev/mapper/$LOOPDEV ]; do sleep 1; done"; then if ! timeout 5 sh -c "while ! [ -e /dev/mapper/$LOOPDEV ]; do sleep 1; done"; then
echo "Error: Could not find /dev/mapper/$LOOPDEV" echo "Error: Could not find /dev/mapper/$LOOPDEV"
exit 1 exit 1
fi fi
EACTION="sudo kpartx -d $WORKING/$RAW_FILE;$EACTION" EACTION="sudo kpartx -d $WORKING/$RAW_FILE;$EACTION"
trap "$EACTION" EXIT trap "$EACTION" EXIT
@ -56,5 +56,5 @@ fi
# image tarball and host OS e.g. when building RHEL image on an openSUSE host) # image tarball and host OS e.g. when building RHEL image on an openSUSE host)
sudo tar -C $TARGET_ROOT --numeric-owner -xzf $DIB_IMAGE_CACHE/$BASE_IMAGE_TAR sudo tar -C $TARGET_ROOT --numeric-owner -xzf $DIB_IMAGE_CACHE/$BASE_IMAGE_TAR
if [ -e "$TARGET_ROOT/lost+found" ]; then if [ -e "$TARGET_ROOT/lost+found" ]; then
sudo rmdir $TARGET_ROOT/lost+found sudo rmdir $TARGET_ROOT/lost+found
fi fi

View File

@ -7,7 +7,7 @@ set -o pipefail
[ -n "$TARGET_ROOT" ] [ -n "$TARGET_ROOT" ]
if [ 'amd64' = "$ARCH" ] ; then if [ 'amd64' = "$ARCH" ] ; then
ARCH="x86_64" ARCH="x86_64"
fi fi
DIB_LOCAL_IMAGE=${DIB_LOCAL_IMAGE:-""} DIB_LOCAL_IMAGE=${DIB_LOCAL_IMAGE:-""}

View File

@ -4,16 +4,16 @@ set -eu
set -o pipefail set -o pipefail
if [ "i386" = "$ARCH" ]; then if [ "i386" = "$ARCH" ]; then
basearch=i386 basearch=i386
arch=i686 arch=i686
elif [ "amd64" = "$ARCH" ]; then elif [ "amd64" = "$ARCH" ]; then
basearch=x86_64 basearch=x86_64
arch=x86_64 arch=x86_64
else else
echo "********************" echo "********************"
echo "Unknown arch '$ARCH'" echo "Unknown arch '$ARCH'"
echo "********************" echo "********************"
exit 1 exit 1
fi fi
echo $basearch > /etc/yum/vars/basearch echo $basearch > /etc/yum/vars/basearch

View File

@ -18,5 +18,5 @@ mv $rc_local.REAL $rc_local
exit 0 exit 0
EOF EOF
chmod 755 $rc_local chmod 755 $rc_local
fi fi

View File

@ -7,9 +7,9 @@ set -eu
set -o pipefail set -o pipefail
if dpkg-query -W grub-pc; then if dpkg-query -W grub-pc; then
apt-get -y remove grub-pc apt-get -y remove grub-pc
fi fi
if dpkg-query -W grub2-common; then if dpkg-query -W grub2-common; then
apt-get -y remove grub2-common apt-get -y remove grub2-common
fi fi

View File

@ -18,16 +18,16 @@ CACHED_FILE=$DIB_IMAGE_CACHE/$BASE_IMAGE_FILE
if [ -n "$DIB_OFFLINE" -a -f "$CACHED_FILE" ] ; then if [ -n "$DIB_OFFLINE" -a -f "$CACHED_FILE" ] ; then
echo "Not checking freshness of cached $CACHED_FILE." echo "Not checking freshness of cached $CACHED_FILE."
else else
echo "Fetching Base Image" echo "Fetching Base Image"
$TMP_HOOKS_PATH/bin/cache-url $SHA256SUMS $DIB_IMAGE_CACHE/SHA256SUMS.ubuntu.$DIB_RELEASE.$ARCH $TMP_HOOKS_PATH/bin/cache-url $SHA256SUMS $DIB_IMAGE_CACHE/SHA256SUMS.ubuntu.$DIB_RELEASE.$ARCH
$TMP_HOOKS_PATH/bin/cache-url $DIB_CLOUD_IMAGES/$DIB_RELEASE/current/$BASE_IMAGE_FILE $CACHED_FILE $TMP_HOOKS_PATH/bin/cache-url $DIB_CLOUD_IMAGES/$DIB_RELEASE/current/$BASE_IMAGE_FILE $CACHED_FILE
pushd $DIB_IMAGE_CACHE pushd $DIB_IMAGE_CACHE
grep "$BASE_IMAGE_FILE" SHA256SUMS.ubuntu.$DIB_RELEASE.$ARCH | sha256sum --check - grep "$BASE_IMAGE_FILE" SHA256SUMS.ubuntu.$DIB_RELEASE.$ARCH | sha256sum --check -
popd popd
fi fi
# Extract the base image (use --numeric-owner to avoid UID/GID mismatch between # Extract the base image (use --numeric-owner to avoid UID/GID mismatch between
# image tarball and host OS e.g. when building Ubuntu image on an openSUSE host) # image tarball and host OS e.g. when building Ubuntu image on an openSUSE host)
sudo tar -C $TARGET_ROOT --numeric-owner -xzf $DIB_IMAGE_CACHE/$BASE_IMAGE_FILE sudo tar -C $TARGET_ROOT --numeric-owner -xzf $DIB_IMAGE_CACHE/$BASE_IMAGE_FILE
if [ -e "$TARGET_ROOT/lost+found" ]; then if [ -e "$TARGET_ROOT/lost+found" ]; then
sudo rmdir $TARGET_ROOT/lost+found sudo rmdir $TARGET_ROOT/lost+found
fi fi

View File

@ -52,9 +52,9 @@ function install_extlinux {
DEFAULT linux DEFAULT linux
LABEL linux LABEL linux
KERNEL $kernel KERNEL $kernel
APPEND ro root=LABEL=cloudimg-rootfs console=tty0 console=ttyS0,115200 APPEND ro root=LABEL=cloudimg-rootfs console=tty0 console=ttyS0,115200
INITRD $initrd INITRD $initrd
_EOF_ _EOF_
} }
@ -89,35 +89,35 @@ function install_grub2 {
# - and for UEFI too. # - and for UEFI too.
# GRUB_OPTS="$GRUB_OPTS --target=i386-pc" # GRUB_OPTS="$GRUB_OPTS --target=i386-pc"
if [[ ! $GRUB_OPTS == *--target* ]] && [[ $($GRUBNAME --version) =~ ' 2.' ]]; then if [[ ! $GRUB_OPTS == *--target* ]] && [[ $($GRUBNAME --version) =~ ' 2.' ]]; then
# /sys/ comes from the host machine. If the host machine is using EFI # /sys/ comes from the host machine. If the host machine is using EFI
# but the image being built doesn't have EFI boot-images installed we # but the image being built doesn't have EFI boot-images installed we
# should set the --target to use a BIOS-based boot-image. # should set the --target to use a BIOS-based boot-image.
# #
# * --target tells grub what's the target platform # * --target tells grub what's the target platform
# * the boot images are placed in /usr/lib/grub/<cpu>-<platform> # * the boot images are placed in /usr/lib/grub/<cpu>-<platform>
# * i386-pc is used for BIOS-based machines # * i386-pc is used for BIOS-based machines
# http://www.gnu.org/software/grub/manual/grub.html#Installation # http://www.gnu.org/software/grub/manual/grub.html#Installation
# #
if [ -d /sys/firmware/efi ]; then if [ -d /sys/firmware/efi ]; then
if [ ! -d /usr/lib/grub/*-efi ]; then if [ ! -d /usr/lib/grub/*-efi ]; then
case $ARCH in case $ARCH in
"x86_64"|"amd64") "x86_64"|"amd64")
GRUB_OPTS="$GRUB_OPTS --target=i386-pc" GRUB_OPTS="$GRUB_OPTS --target=i386-pc"
;; ;;
"i386") "i386")
target=i386-pc target=i386-pc
if [ -e /proc/device-tree ]; then if [ -e /proc/device-tree ]; then
for x in /proc/device-tree/*; do for x in /proc/device-tree/*; do
if [ -e "$x" ]; then if [ -e "$x" ]; then
target="i386-ieee1275" target="i386-ieee1275"
fi fi
done done
fi fi
GRUB_OPTS="$GRUB_OPTS --target=$target" GRUB_OPTS="$GRUB_OPTS --target=$target"
;; ;;
esac esac
fi
fi fi
fi
fi fi
$GRUBNAME --modules="biosdisk part_msdos" $GRUB_OPTS $BOOT_DEV $GRUBNAME --modules="biosdisk part_msdos" $GRUB_OPTS $BOOT_DEV
@ -125,9 +125,9 @@ function install_grub2 {
# This might be better factored out into a per-distro 'install-bootblock' # This might be better factored out into a per-distro 'install-bootblock'
# helper. # helper.
if [ -d /boot/grub2 ]; then if [ -d /boot/grub2 ]; then
GRUB_CFG=/boot/grub2/grub.cfg GRUB_CFG=/boot/grub2/grub.cfg
elif [ -d /boot/grub ]; then elif [ -d /boot/grub ]; then
GRUB_CFG=/boot/grub/grub.cfg GRUB_CFG=/boot/grub/grub.cfg
fi fi
DIST=`lsb_release -is` DIST=`lsb_release -is`
@ -136,15 +136,15 @@ function install_grub2 {
echo 'GRUB_GFXPAYLOAD_LINUX=text' >>/etc/default/grub echo 'GRUB_GFXPAYLOAD_LINUX=text' >>/etc/default/grub
GRUB_MKCONFIG="grub2-mkconfig -o $GRUB_CFG" GRUB_MKCONFIG="grub2-mkconfig -o $GRUB_CFG"
case $DIST in case $DIST in
'Ubuntu'|'Debian') 'Ubuntu'|'Debian')
sed -i -e 's/\(^GRUB_CMDLINE_LINUX.*\)"$/\1 nofb nomodeset vga=normal"/' /etc/default/grub sed -i -e 's/\(^GRUB_CMDLINE_LINUX.*\)"$/\1 nofb nomodeset vga=normal"/' /etc/default/grub
GRUB_MKCONFIG=update-grub GRUB_MKCONFIG=update-grub
;; ;;
'Fedora') 'Fedora')
echo 'GRUB_CMDLINE_LINUX="nofb nomodeset vga=normal"' >>/etc/default/grub echo 'GRUB_CMDLINE_LINUX="nofb nomodeset vga=normal"' >>/etc/default/grub
;; ;;
'openSUSE project') 'openSUSE project')
sed -i -e 's/\(^GRUB_CMDLINE_LINUX.*\)"$/\1 nofb nomodeset vga=normal"/' /etc/default/grub sed -i -e 's/\(^GRUB_CMDLINE_LINUX.*\)"$/\1 nofb nomodeset vga=normal"/' /etc/default/grub
;; ;;
esac esac
$GRUB_MKCONFIG $GRUB_MKCONFIG
@ -154,8 +154,8 @@ function install_grub2 {
# grub-mkconfig generates a config with the device in it, # grub-mkconfig generates a config with the device in it,
# This shouldn't be needed, but old code has bugs # This shouldn't be needed, but old code has bugs
if [ $RELEASE = 'precise' ] || [ $RELEASE = 'wheezy' ]; then if [ $RELEASE = 'precise' ] || [ $RELEASE = 'wheezy' ]; then
sed -i "s%search --no.*%%" $GRUB_CFG sed -i "s%search --no.*%%" $GRUB_CFG
sed -i "s%set root=.*%set root=(hd0,1)%" $GRUB_CFG sed -i "s%set root=.*%set root=(hd0,1)%" $GRUB_CFG
fi fi
# force use of a LABEL: # force use of a LABEL:
# NOTE: Updating the grub config by hand once deployed should work, its just # NOTE: Updating the grub config by hand once deployed should work, its just
@ -164,15 +164,15 @@ function install_grub2 {
sed -i "s%search --no-floppy --fs-uuid --set=root .*$%search --no-floppy --set=root --label cloudimg-rootfs%" $GRUB_CFG sed -i "s%search --no-floppy --fs-uuid --set=root .*$%search --no-floppy --set=root --label cloudimg-rootfs%" $GRUB_CFG
sed -i "s%root=UUID=[A-Za-z0-9\-]*%root=LABEL=cloudimg-rootfs%" $GRUB_CFG sed -i "s%root=UUID=[A-Za-z0-9\-]*%root=LABEL=cloudimg-rootfs%" $GRUB_CFG
if [ "$DIST" = 'Fedora' ] ; then if [ "$DIST" = 'Fedora' ] ; then
# enable serial console # enable serial console
sed -i "s%LABEL=cloudimg-rootfs%LABEL=cloudimg-rootfs console=tty0 console=ttyS0,115200%" $GRUB_CFG sed -i "s%LABEL=cloudimg-rootfs%LABEL=cloudimg-rootfs console=tty0 console=ttyS0,115200%" $GRUB_CFG
if [ $(lsb_release -rs) = '19' ]; then if [ $(lsb_release -rs) = '19' ]; then
sed -i "s%UUID=[A-Za-z0-9\-]*%LABEL=cloudimg-rootfs%" /etc/fstab sed -i "s%UUID=[A-Za-z0-9\-]*%LABEL=cloudimg-rootfs%" /etc/fstab
fi fi
# Fix efi specific instructions in grub config file # Fix efi specific instructions in grub config file
if [ -d /sys/firmware/efi ]; then if [ -d /sys/firmware/efi ]; then
sed -i 's%\(initrd\|linux\)efi /boot%\1 /boot%g' $GRUB_CFG sed -i 's%\(initrd\|linux\)efi /boot%\1 /boot%g' $GRUB_CFG
fi fi
fi fi
} }

View File

@ -21,14 +21,14 @@ EXTRA_ARGS=
ACTION=install ACTION=install
if [ "$1" = "-u" ] ; then if [ "$1" = "-u" ] ; then
yum -y update yum -y update
exit 0 exit 0
elif [ "$1" = "-d" ] ; then elif [ "$1" = "-d" ] ; then
EXTRA_ARGS="--downloadonly" EXTRA_ARGS="--downloadonly"
shift shift
elif [ "$1" = "-e" ]; then elif [ "$1" = "-e" ]; then
ACTION=erase ACTION=erase
shift shift
fi fi
# Packages that aren't available in the distro but requested for installation # Packages that aren't available in the distro but requested for installation
@ -37,20 +37,20 @@ BLACKLIST=$(cat /tmp/yum-blacklist 2>/dev/null || echo "")
WHITELIST=() WHITELIST=()
for i in "$@" for i in "$@"
do do
if [[ ! ${BLACKLIST[*]} =~ $i ]]; then if [[ ! ${BLACKLIST[*]} =~ $i ]]; then
WHITELIST+="$i " WHITELIST+="$i "
else else
echo "The package $i is not available and will not be installed" echo "The package $i is not available and will not be installed"
fi fi
done done
if [ -n "$WHITELIST" ]; then if [ -n "$WHITELIST" ]; then
if [ -f /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release ]; then if [ -f /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release ]; then
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
fi
yum -y $ACTION $EXTRA_ARGS $(map-packages $WHITELIST)
for pkg in "$@"; do
if [ "$pkg" = "python-pip" ] ; then
alternatives --install /usr/bin/pip pip /usr/bin/pip-python 10
fi fi
done yum -y $ACTION $EXTRA_ARGS $(map-packages $WHITELIST)
for pkg in "$@"; do
if [ "$pkg" = "python-pip" ] ; then
alternatives --install /usr/bin/pip pip /usr/bin/pip-python 10
fi
done
fi fi