Skip to content
This repository has been archived by the owner on Jan 11, 2019. It is now read-only.

Commit

Permalink
Release 0.3.3 (#34)
Browse files Browse the repository at this point in the history
* 🚑 Fixes issue with pushing images to Docker Hub

* 📚 Updated examples in README

* 🚑 Fixes setting default squash state, in case build.json is missing

* 🚑 Fixes unbound variable error when building with a build.json file

* 📚 Updated CHANGELOG for release v0.3.3
  • Loading branch information
frenck authored Sep 26, 2017
1 parent ed6e3be commit 09f5afe
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 44 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@ and this project adheres to [Semantic Versioning][semantic-versioning].

No unreleased changes yet.

## [v0.3.3][v0.3.3] (2017-09-26)

[Full Changelog][v0.3.2-v0.3.3]

### Changed

- Updated examples in README [#34][34]

### Fixed

- Fixes issue with pushing images to Docker Hub [#34][34]
- Fixes setting default squash state, in case of a missing build.json [#34][34]
- Fixes unbound variable error when building without a build.json file [#34][34]

## [v0.3.2][v0.3.2] (2017-09-26)

[Full Changelog][v0.3.1-v0.3.2]
Expand Down Expand Up @@ -190,6 +204,7 @@ No unreleased changes yet.
[31]: https://github.com/hassio-addons/build-env/pull/31
[32]: https://github.com/hassio-addons/build-env/pull/32
[33]: https://github.com/hassio-addons/build-env/pull/33
[34]: https://github.com/hassio-addons/build-env/pull/34
[4]: https://github.com/hassio-addons/build-env/pull/4
[6]: https://github.com/hassio-addons/build-env/pull/6
[8]: https://github.com/hassio-addons/build-env/pull/8
Expand Down Expand Up @@ -224,4 +239,6 @@ No unreleased changes yet.
[v0.3.0]: https://github.com/hassio-addons/build-env/tree/v0.3.0
[v0.3.1-v0.3.2]: https://github.com/hassio-addons/build-env/compare/v0.3.1...v0.3.2
[v0.3.1]: https://github.com/hassio-addons/build-env/tree/v0.3.1
[v0.3.2-v0.3.3]: https://github.com/hassio-addons/build-env/compare/v0.3.2...v0.3.3
[v0.3.2]: https://github.com/hassio-addons/build-env/tree/v0.3.2
[v0.3.3]: https://github.com/hassio-addons/build-env/tree/v0.3.3
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ a single Docker image. This makes this version portable and removes the
need for "large" and complicated Bash scripts (as provided by Home Assistant).

```bash
docker run -it --rm --privileged --name buildenv \
docker run --rm --privileged \
-v ~/.docker:/root/.docker \
-v "$(pwd)":/docker \
hassioaddons/build-env:latest \
Expand All @@ -37,7 +37,7 @@ the built environment. This line may be omitted in case you don't want to
push your image.

Adding `-v "$(pwd)":/docker` shares your current working directory as the
directory to start the build process from. This line can be omitted in case
directory to start the build process from. This line MUST be omitted in case
you are building from a remote repository.

The `[options]` can be replaced by one or more of the following options:
Expand Down Expand Up @@ -201,10 +201,11 @@ Options:
The following example will build a local add-on and push it onto Docker hub.

```bash
docker run -it --rm --privileged --name buildenv \
docker run --rm --privileged \
-v ~/.docker:/root/.docker \
-v "$(pwd)":/docker \
hassioaddons/build-env:latest \
--target addon-slug \
--tag-latest \
--push \
--all
Expand All @@ -220,7 +221,7 @@ docker run -it --rm --privileged --name build \
hassioaddons/build-env:latest \
--repository https://github.com/hassio-addons/addon-example \
--target example \
--tag-test \
--git \
--all
```

Expand Down Expand Up @@ -312,4 +313,4 @@ SOFTWARE.
[reddit]: https://reddit.com/r/homeassistant
[repository]: https://github.com/hassio-addons/repository
[semver]: http://semver.org/spec/v2.0.0.html
[version-shield]: https://images.microbadger.com/badges/version/hassioaddons/build-env.svg
[version-shield]: https://images.microbadger.com/badges/version/hassioaddons/build-env.svg
82 changes: 43 additions & 39 deletions build-env/rootfs/usr/bin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -405,12 +405,12 @@ docker_build() {

[[ "${DOCKER_SQUASH}" = true ]] && build_args+=(--squash)

if [[ "${BUILD_ARCHS_FROM[${arch}]}" ]]; then
if [[ ! -z "${BUILD_ARCHS_FROM[${arch}]:-}" ]]; then
build_args+=(--build-arg "BUILD_FROM=${BUILD_ARCHS_FROM[${arch}]}")
else
from="${BUILD_FROM//\{arch\}/${arch}}"
build_args+=(--build-arg "BUILD_FROM=${from}")
fi
fi

if [[ "${DOCKER_CACHE}" = true ]]; then
build_args+=(--cache-from "${image}:latest")
Expand Down Expand Up @@ -489,10 +489,10 @@ docker_disable_crosscompile() {

(
update-binfmts --disable qemu-arm && \
update-binfmts --disable qemu-aarch64
update-binfmts --disable qemu-aarch64
) || display_error_message 'Failed disabling cross compile features!' \
"${EX_CROSS}"

return "${EX_OK}"
}

Expand All @@ -506,13 +506,13 @@ docker_disable_crosscompile() {
# ------------------------------------------------------------------------------
docker_enable_crosscompile() {
display_status_message 'Enabling cross compile features'
(
(
mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc && \
update-binfmts --enable qemu-arm && \
update-binfmts --enable qemu-aarch64
update-binfmts --enable qemu-aarch64
) || display_error_message 'Failed enabling cross compile features!' \
"${EX_CROSS}"

return "${EX_OK}"
}

Expand Down Expand Up @@ -621,7 +621,7 @@ docker_stop_daemon() {
display_error_message \
'Timeout while waiting for Docker to shut down' \
"${EX_DOCKER_TIMEOUT}"
fi
fi
done

display_status_message 'Docker daemon has been stopped'
Expand Down Expand Up @@ -724,7 +724,7 @@ get_info_json() {
".build_from | .${arch}" "${jsonfile}")
fi
done <<< "${archs}"

if [[ -z "${DOCKER_SQUASH:-}" ]]; then
squash=$(jq -r '.squash | not | not' "${jsonfile}")
[[ "${squash}" = true ]] && DOCKER_SQUASH=true
Expand All @@ -740,7 +740,7 @@ get_info_json() {
BUILD_ARGS[${arg}]=$(jq -r \
".args | .${arg}" "${jsonfile}")
fi
done <<< "${args}"
done <<< "${args}"

return "${EX_OK}"
}
Expand All @@ -764,8 +764,8 @@ get_info_dockerfile() {
DOCKERFILE=$(<"${BUILD_TARGET}/Dockerfile")
json=$(dockerfile2json "${BUILD_TARGET}/Dockerfile")

if [[
! -z $(jq -r '.[] | select(.cmd=="arg") // empty' <<< "${json}")
if [[
! -z $(jq -r '.[] | select(.cmd=="arg") // empty' <<< "${json}")
]]; then
args=$(jq -r '.[] | select(.cmd=="arg") | .value | .[]' \
<<< "${json}")
Expand Down Expand Up @@ -824,9 +824,9 @@ get_info_dockerfile() {
BUILD_MAINTAINER=$(jq \
-r '.[] | select(.cmd=="maintainer") | .value[0]' \
<<< "${json}")
fi
fi

if [[
if [[
! -z $(jq -r '.[] | select(.cmd=="label") // empty' <<< "${json}")
]]; then
labels=$(jq -r '.[] | select(.cmd=="label") | .value | .[]' \
Expand Down Expand Up @@ -890,7 +890,7 @@ get_info_git() {
# Is this even a Git repository?
if ! git -C . rev-parse; then

if [[ "${USE_GIT}" = true ]]; then
if [[ "${USE_GIT}" = true ]]; then
display_error_message \
'You have added --git, but is this a Git repo?' \
"${EX_GIT}"
Expand All @@ -912,9 +912,9 @@ get_info_git() {
|| true)

# Is current HEAD on a tag and master branch?
if [[
! -z "${tag:-}"
&& "${branch}" = "master"
if [[
! -z "${tag:-}"
&& "${branch}" = "master"
&& "${USE_GIT}" = true
]]; then
# Is it the latest tag?
Expand All @@ -927,7 +927,7 @@ get_info_git() {
BUILD_VERSION="${ref}"
[[ "${branch}" = "master" ]] && DOCKER_TAG_TEST=true
fi

else
# Uncomitted changes on the Git repository, dirty!
BUILD_REF="dirty"
Expand Down Expand Up @@ -1025,7 +1025,7 @@ parse_cli_arguments() {
-p|--push)
DOCKER_PUSH=true
;;
-n|--no-cache)
-n|--no-cache)
DOCKER_CACHE=false
;;
--squash)
Expand Down Expand Up @@ -1129,7 +1129,7 @@ preflight_checks() {
# Is the requested architecture supported?
if [[ ${#BUILD_ARCHS[@]} -ne 0 ]] \
&& [[ "${BUILD_ALL}" = false ]] \
&& [[ ! -z "${SUPPORTED_ARCHS[*]:-}" ]];
&& [[ ! -z "${SUPPORTED_ARCHS[*]:-}" ]];
then
for arch in "${BUILD_ARCHS[@]}"; do
[[ "${SUPPORTED_ARCHS[*]}" = *"${arch}"* ]] || \
Expand All @@ -1145,7 +1145,7 @@ preflight_checks() {
[[ ! -z $arch && -z "${BUILD_ARCHS_FROM[${arch}]:-}" ]] \
&& display_error_message \
"Architucure ${arch}, is missing a image to build from" \
"${EX_NO_FROM}"
"${EX_NO_FROM}"
done
fi

Expand Down Expand Up @@ -1182,7 +1182,7 @@ preflight_checks() {

[[ -z "${BUILD_DOC_URL:-}" ]] \
&& display_notice_message 'Documentation url is not set!'

return "${EX_OK}"
}

Expand All @@ -1206,6 +1206,9 @@ prepare_defaults() {
BUILD_ARCHS=(${SUPPORTED_ARCHS[*]});
fi

[[ -z "${DOCKER_SQUASH:-}" ]] \
&& DOCKER_SQUASH=false

[[ -z "${BUILD_TYPE:-}" ]] \
&& BUILD_TYPE="addon"

Expand Down Expand Up @@ -1270,7 +1273,7 @@ prepare_dockerfile() {
fi

if [[ "${BUILD_LABEL_OVERRIDE}" = true
|| ! "${EXISTING_LABELS[*]:-}" = *"org.label-schema.build-date"*
|| ! "${EXISTING_LABELS[*]:-}" = *"org.label-schema.build-date"*
]]; then
if [[ ! "${EXISTING_ARGS[*]}" = *"BUILD_DATE"* ]]; then
DOCKERFILE+="ARG BUILD_DATE"$'\n'
Expand All @@ -1279,32 +1282,32 @@ prepare_dockerfile() {
labels+=("org.label-schema.build-date=\${BUILD_DATE}")
fi

if [[ "${BUILD_LABEL_OVERRIDE}" = true
|| ! "${EXISTING_LABELS[*]:-}" = *"org.label-schema.name"*
if [[ "${BUILD_LABEL_OVERRIDE}" = true
|| ! "${EXISTING_LABELS[*]:-}" = *"org.label-schema.name"*
]]; then
labels+=("org.label-schema.name=${BUILD_NAME}")
fi

if [[ "${BUILD_LABEL_OVERRIDE}" = true
|| ! "${EXISTING_LABELS[*]:-}" = *"org.label-schema.description"*
if [[ "${BUILD_LABEL_OVERRIDE}" = true
|| ! "${EXISTING_LABELS[*]:-}" = *"org.label-schema.description"*
]]; then
labels+=("org.label-schema.description=${BUILD_DESCRIPTION}")
fi

if [[ "${BUILD_LABEL_OVERRIDE}" = true
|| ! "${EXISTING_LABELS[*]:-}" = *"org.label-schema.url"*
if [[ "${BUILD_LABEL_OVERRIDE}" = true
|| ! "${EXISTING_LABELS[*]:-}" = *"org.label-schema.url"*
]]; then
labels+=("org.label-schema.url=\"${BUILD_URL}\"")
fi

if [[ "${BUILD_LABEL_OVERRIDE}" = true
|| ! "${EXISTING_LABELS[*]:-}" = *"org.label-schema.vcs-url"*
|| ! "${EXISTING_LABELS[*]:-}" = *"org.label-schema.vcs-url"*
]]; then
labels+=("org.label-schema.vcs-url=${BUILD_GIT_URL}")
fi

if [[ "${BUILD_LABEL_OVERRIDE}" = true
|| ! "${EXISTING_LABELS[*]:-}" = *"org.label-schema.vcs-ref"*
if [[ "${BUILD_LABEL_OVERRIDE}" = true
|| ! "${EXISTING_LABELS[*]:-}" = *"org.label-schema.vcs-ref"*
]]; then
labels+=("org.label-schema.vcs-ref=${BUILD_REF}")
fi
Expand All @@ -1316,18 +1319,18 @@ prepare_dockerfile() {
fi

if [[ "${BUILD_LABEL_OVERRIDE}" = true
|| ! "${EXISTING_LABELS[*]:-}" = *"org.label-schema.usage"*
|| ! "${EXISTING_LABELS[*]:-}" = *"org.label-schema.usage"*
]]; then
labels+=("org.label-schema.usage=${BUILD_DOC_URL}")
fi

if [[ "${BUILD_LABEL_OVERRIDE}" = true
|| ! "${EXISTING_LABELS[*]:-}" = *"maintainer"*
|| ! "${EXISTING_LABELS[*]:-}" = *"maintainer"*
]]; then
labels+=("maintainer=${BUILD_MAINTAINER}")
fi

if [[ "${BUILD_LABEL_OVERRIDE}" = true
if [[ "${BUILD_LABEL_OVERRIDE}" = true
|| ! "${EXISTING_LABELS[*]:-}" = *"io.hass.type"*
]]; then
labels+=("io.hass.type=${BUILD_TYPE}")
Expand All @@ -1340,7 +1343,7 @@ prepare_dockerfile() {
fi

if [[
"${BUILD_LABEL_OVERRIDE}" = true
"${BUILD_LABEL_OVERRIDE}" = true
|| ! "${EXISTING_LABELS[*]:-}" = *"io.hass.version"*
]]; then
labels+=("io.hass.version=${BUILD_VERSION}")
Expand Down Expand Up @@ -1431,7 +1434,7 @@ main() {
for arch in "${BUILD_ARCHS[@]}"; do
docker_build "${arch}" | sed -u "s/^/[${arch}] /"
done
fi
fi
display_status_message 'Build of all requested architectures finished'

# Tag it
Expand All @@ -1447,6 +1450,7 @@ main() {
background_jobs=()
for arch in "${BUILD_ARCHS[@]}"; do
docker_push "${arch}" | sed -u "s/^/[${arch}] /" &
background_jobs+=($!)
done

# Wait for all push jobs to finish
Expand All @@ -1467,4 +1471,4 @@ main() {
if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
# Direct call to file
main "$@"
fi # Else file is included from another script
fi # Else file is included from another script

0 comments on commit 09f5afe

Please sign in to comment.