c4d19f7f8e
In preparation for having multiple top-level kiwi description files, expose the ability to define which file to read. Additionally, tests are updated to use this new flag.
75 lines
2.6 KiB
Bash
Executable File
75 lines
2.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Simple wrapper to call kiwi properly for image builds
|
|
# Author: Neal Gompa <ngompa@fedoraproject.org>
|
|
|
|
set -eu -o pipefail
|
|
|
|
kiwibuildsh="$(basename "$0")"
|
|
|
|
usage() {
|
|
echo >&2 "usage: $kiwibuildsh [--kiwi-description-dir=DIR] [--kiwi-file=FILE] [--isolated] --output-dir=DIR --image-type=TYPE --image-profile=PROFILE [--debug]"
|
|
echo >&2 " eg: $kiwibuildsh --kiwi-description-dir=/var/tmp/desc --kiwi-file=config.kiwi --output-dir=/var/tmp/work --image-type=oem --image-profile=Cloud-Base-Generic --debug"
|
|
echo >&2 " eg: $kiwibuildsh --output-dir=/var/tmp/work --image-type=oem --image-profile=Cloud-Base-Generic"
|
|
echo >&2 " eg: $kiwibuildsh --isolated --output-dir=/var/tmp/work --image-type=oem --image-profile=Cloud-Base-Generic"
|
|
exit 255
|
|
}
|
|
|
|
optTemp=$(getopt --options '+k:,f:,i,o:,t:,p:,d,h' --longoptions 'kiwi-description-dir:,kiwi-file:,isolated,output-dir:,image-type:,image-profile:,debug,help' --name "$kiwibuildsh" -- "$@")
|
|
eval set -- "$optTemp"
|
|
unset optTemp
|
|
|
|
output_dir=
|
|
image_type=
|
|
image_profile=
|
|
debug=
|
|
kiwi_isolated=
|
|
# For compatibility with older scripts where these did not exist
|
|
kiwi_description_dir="./"
|
|
kiwi_file="Fedora.kiwi"
|
|
|
|
while true; do
|
|
case "$1" in
|
|
-i|--isolated) kiwi_isolated=1; shift ;;
|
|
-k|--kiwi-description-dir) kiwi_description_dir="$2" ; shift 2 ;;
|
|
-f|--kiwi-file) kiwi_file="$2" ; shift 2 ;;
|
|
-o|--output-dir) output_dir="$2" ; shift 2 ;;
|
|
-t|--image-type) image_type="$2" ; shift 2 ;;
|
|
-p|--image-profile) image_profile="$2" ; shift 2 ;;
|
|
-d|--debug) debug="--debug" ; shift ;;
|
|
-h|--help) usage ;;
|
|
--) shift ; break ;;
|
|
esac
|
|
done
|
|
|
|
if [ -z "$output_dir" ] || [ -z "$image_type" ] || [ -z "$image_profile" ] || [ -z "$kiwi_file" ]; then
|
|
echo "Options not set!"
|
|
usage
|
|
fi
|
|
|
|
if [ ! ${kiwi_isolated} ] && [ -e "/sys/fs/selinux/enforce" ]; then
|
|
# Disable SELinux enforcement during the image build if it's enforcing
|
|
selinux_enforcing="$(cat /sys/fs/selinux/enforce)"
|
|
if [ "$selinux_enforcing" = "1" ]; then
|
|
setenforce 0
|
|
fi
|
|
fi
|
|
|
|
set +e
|
|
if [ ! ${kiwi_isolated} ]; then
|
|
kiwi-ng ${debug} --type="${image_type}" --profile="${image_profile}" --kiwi-file="${kiwi_file}" --color-output system build --description "${kiwi_description_dir}" --target-dir "${output_dir}"
|
|
else
|
|
kiwi-ng ${debug} --type="${image_type}" --profile="${image_profile}" --kiwi-file="${kiwi_file}" --color-output system boxbuild --box universal --sshfs-sharing -- --description "${kiwi_description_dir}" --target-dir "${output_dir}"
|
|
fi
|
|
kiwi_status=$?
|
|
set -e
|
|
|
|
if [ ! ${kiwi_isolated} ] && [ -e "/sys/fs/selinux/enforce" ]; then
|
|
# Re-enable SELinux enforcement now that image build is done
|
|
if [ "$selinux_enforcing" = "1" ]; then
|
|
setenforce 1
|
|
fi
|
|
fi
|
|
|
|
exit $kiwi_status
|