BuildSourceImage: bail with information, if not inputs are provided
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
84b889e1ad
commit
9fabac2890
1 changed files with 28 additions and 23 deletions
|
@ -883,18 +883,18 @@ sourcedriver_extra_src_dir() {
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
local base_dir
|
local base_dir
|
||||||
local context_dir
|
local input_context_dir
|
||||||
|
local input_extra_src_dir
|
||||||
|
local input_inspect_image_ref
|
||||||
|
local input_srpm_dir
|
||||||
local drivers
|
local drivers
|
||||||
local extra_src_dir
|
|
||||||
local image_ref
|
local image_ref
|
||||||
local img_layout
|
local img_layout
|
||||||
local inspect_image_ref
|
|
||||||
local list_drivers
|
local list_drivers
|
||||||
local output_dir
|
local output_dir
|
||||||
local push_image_ref
|
local push_image_ref
|
||||||
local ret
|
local ret
|
||||||
local rootfs
|
local rootfs
|
||||||
local srpm_dir
|
|
||||||
local src_dir
|
local src_dir
|
||||||
local src_img_dir
|
local src_img_dir
|
||||||
local src_img_tag
|
local src_img_tag
|
||||||
|
@ -912,10 +912,10 @@ main() {
|
||||||
base_dir="${OPTARG}"
|
base_dir="${OPTARG}"
|
||||||
;;
|
;;
|
||||||
c)
|
c)
|
||||||
context_dir=${OPTARG}
|
input_context_dir=${OPTARG}
|
||||||
;;
|
;;
|
||||||
e)
|
e)
|
||||||
extra_src_dir=${OPTARG}
|
input_extra_src_dir=${OPTARG}
|
||||||
;;
|
;;
|
||||||
d)
|
d)
|
||||||
drivers=${OPTARG}
|
drivers=${OPTARG}
|
||||||
|
@ -924,7 +924,7 @@ main() {
|
||||||
_usage
|
_usage
|
||||||
;;
|
;;
|
||||||
i)
|
i)
|
||||||
inspect_image_ref=${OPTARG}
|
input_inspect_image_ref=${OPTARG}
|
||||||
;;
|
;;
|
||||||
l)
|
l)
|
||||||
list_drivers=1
|
list_drivers=1
|
||||||
|
@ -936,7 +936,7 @@ main() {
|
||||||
push_image_ref=${OPTARG}
|
push_image_ref=${OPTARG}
|
||||||
;;
|
;;
|
||||||
s)
|
s)
|
||||||
srpm_dir=${OPTARG}
|
input_srpm_dir=${OPTARG}
|
||||||
;;
|
;;
|
||||||
v)
|
v)
|
||||||
_version
|
_version
|
||||||
|
@ -957,11 +957,16 @@ main() {
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# "local" variables are not set in `env`, but are seen in `set`
|
||||||
|
if [ "$(set | grep -c '^input_')" -eq 0 ] ; then
|
||||||
|
_error "provide an input (example: $(basename "${0}") -i docker.io/centos -e ./my-sources/ )"
|
||||||
|
fi
|
||||||
|
|
||||||
# These three variables are slightly special, in that they're globals that
|
# These three variables are slightly special, in that they're globals that
|
||||||
# specific drivers will expect.
|
# specific drivers will expect.
|
||||||
export CONTEXT_DIR="${CONTEXT_DIR:-$context_dir}"
|
export CONTEXT_DIR="${CONTEXT_DIR:-$input_context_dir}"
|
||||||
export EXTRA_SRC_DIR="${EXTRA_SRC_DIR:-$extra_src_dir}"
|
export EXTRA_SRC_DIR="${EXTRA_SRC_DIR:-$input_extra_src_dir}"
|
||||||
export SRPM_DIR="${SRPM_DIR:-$srpm_dir}"
|
export SRPM_DIR="${SRPM_DIR:-$input_srpm_dir}"
|
||||||
|
|
||||||
output_dir="${OUTPUT_DIR:-$output_dir}"
|
output_dir="${OUTPUT_DIR:-$output_dir}"
|
||||||
|
|
||||||
|
@ -976,16 +981,16 @@ main() {
|
||||||
image_ref=""
|
image_ref=""
|
||||||
src_dir=""
|
src_dir=""
|
||||||
work_dir="${base_dir}/work"
|
work_dir="${base_dir}/work"
|
||||||
if [ -n "${inspect_image_ref}" ] ; then
|
if [ -n "${input_inspect_image_ref}" ] ; then
|
||||||
_debug "Image Reference provided: ${inspect_image_ref}"
|
_debug "Image Reference provided: ${input_inspect_image_ref}"
|
||||||
_debug "Image Reference base: $(parse_img_base "${inspect_image_ref}")"
|
_debug "Image Reference base: $(parse_img_base "${input_inspect_image_ref}")"
|
||||||
_debug "Image Reference tag: $(parse_img_tag "${inspect_image_ref}")"
|
_debug "Image Reference tag: $(parse_img_tag "${input_inspect_image_ref}")"
|
||||||
|
|
||||||
inspect_image_digest="$(parse_img_digest "${inspect_image_ref}")"
|
inspect_image_digest="$(parse_img_digest "${input_inspect_image_ref}")"
|
||||||
# determine missing digest before fetch, so that we fetch the precise image
|
# determine missing digest before fetch, so that we fetch the precise image
|
||||||
# including its digest.
|
# including its digest.
|
||||||
if [ -z "${inspect_image_digest}" ] ; then
|
if [ -z "${inspect_image_digest}" ] ; then
|
||||||
inspect_image_digest="$(fetch_img_digest "$(parse_img_base "${inspect_image_ref}"):$(parse_img_tag "${inspect_image_ref}")")"
|
inspect_image_digest="$(fetch_img_digest "$(parse_img_base "${input_inspect_image_ref}"):$(parse_img_tag "${input_inspect_image_ref}")")"
|
||||||
fi
|
fi
|
||||||
_debug "inspect_image_digest: ${inspect_image_digest}"
|
_debug "inspect_image_digest: ${inspect_image_digest}"
|
||||||
|
|
||||||
|
@ -993,13 +998,13 @@ main() {
|
||||||
# if inspect and fetch image, then to an OCI layout dir
|
# if inspect and fetch image, then to an OCI layout dir
|
||||||
if [ ! -d "${work_dir}/layouts/${inspect_image_digest/:/\/}" ] ; then
|
if [ ! -d "${work_dir}/layouts/${inspect_image_digest/:/\/}" ] ; then
|
||||||
# we'll store the image to a path based on its digest, that it can be reused
|
# we'll store the image to a path based on its digest, that it can be reused
|
||||||
img_layout="$(fetch_img "$(parse_img_base "${inspect_image_ref}")":"$(parse_img_tag "${inspect_image_ref}")"@"${inspect_image_digest}" "${work_dir}"/layouts/"${inspect_image_digest/:/\/}" )"
|
img_layout="$(fetch_img "$(parse_img_base "${input_inspect_image_ref}")":"$(parse_img_tag "${input_inspect_image_ref}")"@"${inspect_image_digest}" "${work_dir}"/layouts/"${inspect_image_digest/:/\/}" )"
|
||||||
ret=$?
|
ret=$?
|
||||||
if [ ${ret} -ne 0 ] ; then
|
if [ ${ret} -ne 0 ] ; then
|
||||||
_error "failed to copy image: $(parse_img_base "${inspect_image_ref}"):$(parse_img_tag "${inspect_image_ref}")@${inspect_image_digest}"
|
_error "failed to copy image: $(parse_img_base "${input_inspect_image_ref}"):$(parse_img_tag "${input_inspect_image_ref}")@${inspect_image_digest}"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
img_layout="${work_dir}/layouts/${inspect_image_digest/:/\/}:$(parse_img_tag "${inspect_image_ref}")"
|
img_layout="${work_dir}/layouts/${inspect_image_digest/:/\/}:$(parse_img_tag "${input_inspect_image_ref}")"
|
||||||
fi
|
fi
|
||||||
_debug "image layout: ${img_layout}"
|
_debug "image layout: ${img_layout}"
|
||||||
|
|
||||||
|
@ -1015,7 +1020,7 @@ main() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rootfs="${unpack_dir}/rootfs"
|
rootfs="${unpack_dir}/rootfs"
|
||||||
image_ref="$(parse_img_base "${inspect_image_ref}"):$(parse_img_tag "${inspect_image_ref}")@${inspect_image_digest}"
|
image_ref="$(parse_img_base "${input_inspect_image_ref}"):$(parse_img_tag "${input_inspect_image_ref}")@${inspect_image_digest}"
|
||||||
src_dir="${base_dir}/src/${inspect_image_digest/:/\/}"
|
src_dir="${base_dir}/src/${inspect_image_digest/:/\/}"
|
||||||
work_dir="${base_dir}/work/${inspect_image_digest/:/\/}"
|
work_dir="${base_dir}/work/${inspect_image_digest/:/\/}"
|
||||||
_info "inspecting image reference ${image_ref}"
|
_info "inspecting image reference ${image_ref}"
|
||||||
|
@ -1094,8 +1099,8 @@ main() {
|
||||||
## if an output directory is provided then save a copy to it
|
## if an output directory is provided then save a copy to it
|
||||||
if [ -n "${output_dir}" ] ; then
|
if [ -n "${output_dir}" ] ; then
|
||||||
_mkdir_p "${output_dir}"
|
_mkdir_p "${output_dir}"
|
||||||
# XXX this $inspect_image_ref currently relies on the user passing in the `-i` flag
|
# XXX this $input_inspect_image_ref currently relies on the user passing in the `-i` flag
|
||||||
push_img "oci:$src_img_dir:${src_img_tag}" "oci:$output_dir:$(ref_src_img_tag "$(parse_img_tag "${inspect_image_ref}")")"
|
push_img "oci:$src_img_dir:${src_img_tag}" "oci:$output_dir:$(ref_src_img_tag "$(parse_img_tag "${input_inspect_image_ref}")")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "${push_image_ref}" ] ; then
|
if [ -n "${push_image_ref}" ] ; then
|
||||||
|
|
Loading…
Reference in a new issue