Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inform if build information are not available #143

Merged
merged 2 commits into from
Jun 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 28 additions & 18 deletions builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -431,14 +431,17 @@ function build_base() {
local docker_tags=()

# Read build.json
if bashio::fs.file_exists "/tmp/build_config/build.json"; then
build_from="$(jq --raw-output ".build_from.${build_arch} // empty" "/tmp/build_config/build.json")"
args="$(jq --raw-output '.args // empty | keys[]' "/tmp/build_config/build.json")"
labels="$(jq --raw-output '.labels // empty | keys[]' "/tmp/build_config/build.json")"
raw_image="$(jq --raw-output '.image // empty' "/tmp/build_config/build.json")"
shadow_repository="$(jq --raw-output '.shadow_repository // empty' "/tmp/build_config/build.json")"
if ! bashio::fs.file_exists "/tmp/build_config/build.json"; then
bashio::log.error "Build information not found!"
return 1
fi

build_from="$(jq --raw-output ".build_from.${build_arch} // empty" "/tmp/build_config/build.json")"
args="$(jq --raw-output '.args // empty | keys[]' "/tmp/build_config/build.json")"
labels="$(jq --raw-output '.labels // empty | keys[]' "/tmp/build_config/build.json")"
raw_image="$(jq --raw-output '.image // empty' "/tmp/build_config/build.json")"
shadow_repository="$(jq --raw-output '.shadow_repository // empty' "/tmp/build_config/build.json")"

# Set defaults build things
if ! bashio::var.has_value "${build_from}"; then
bashio::log.error "${build_arch} not supported for this build"
Expand Down Expand Up @@ -522,6 +525,7 @@ function build_addon() {

# Set defaults build things
if [ -z "$build_from" ]; then
bashio::log.info "No build information or from not provided. Using default base image."
build_from="homeassistant/${build_arch}-base:latest"
fi

Expand Down Expand Up @@ -595,14 +599,17 @@ function build_generic() {
local docker_tags=()

# Read build.json
if bashio::fs.file_exists "/tmp/build_config/build.json"; then
build_from="$(jq --raw-output ".build_from.$build_arch // empty" "/tmp/build_config/build.json")"
args="$(jq --raw-output '.args // empty | keys[]' "/tmp/build_config/build.json")"
labels="$(jq --raw-output '.labels // empty | keys[]' "/tmp/build_config/build.json")"
raw_image="$(jq --raw-output '.image // empty' "/tmp/build_config/build.json")"
shadow_repository="$(jq --raw-output '.shadow_repository // empty' "/tmp/build_config/build.json")"
if ! bashio::fs.file_exists "/tmp/build_config/build.json"; then
bashio::log.error "Build information not found!"
return 1
fi

build_from="$(jq --raw-output ".build_from.$build_arch // empty" "/tmp/build_config/build.json")"
args="$(jq --raw-output '.args // empty | keys[]' "/tmp/build_config/build.json")"
labels="$(jq --raw-output '.labels // empty | keys[]' "/tmp/build_config/build.json")"
raw_image="$(jq --raw-output '.image // empty' "/tmp/build_config/build.json")"
shadow_repository="$(jq --raw-output '.shadow_repository // empty' "/tmp/build_config/build.json")"

# Set defaults build things
if ! bashio::var.has_value "$build_from"; then
bashio::log.error "$build_arch not supported for this build"
Expand Down Expand Up @@ -653,14 +660,17 @@ function build_machine() {
local docker_tags=()

# Read build.json
if bashio::fs.file_exists "/tmp/build_config/build.json"; then
build_from="$(jq --raw-output ".build_from.${build_arch} // empty" "/tmp/build_config/build.json")"
args="$(jq --raw-output '.args // empty | keys[]' "/tmp/build_config/build.json")"
labels="$(jq --raw-output '.labels // empty | keys[]' "/tmp/build_config/build.json")"
raw_image="$(jq --raw-output '.image // empty' "/tmp/build_config/build.json")"
shadow_repository="$(jq --raw-output '.shadow_repository // empty' "/tmp/build_config/build.json")"
if ! bashio::fs.file_exists "/tmp/build_config/build.json"; then
bashio::log.error "Build information not found!"
return 1
fi

build_from="$(jq --raw-output ".build_from.${build_arch} // empty" "/tmp/build_config/build.json")"
args="$(jq --raw-output '.args // empty | keys[]' "/tmp/build_config/build.json")"
labels="$(jq --raw-output '.labels // empty | keys[]' "/tmp/build_config/build.json")"
raw_image="$(jq --raw-output '.image // empty' "/tmp/build_config/build.json")"
shadow_repository="$(jq --raw-output '.shadow_repository // empty' "/tmp/build_config/build.json")"

# Modify build_from
if [[ "${build_from}" =~ :$ ]]; then
build_from="${build_from}${VERSION}"
Expand Down