Pierrick Bouvier <[email protected]> writes:

> This script allows to easily build a qemu release container, based on
> dockerfile introduced in previous commit.
>
> It names image "qemu/$version" and automatically detects which ubuntu
> version should be used to build it.
>
> $ ./scripts/build_release_container.sh v3.1.0
> $ podman run -it --rm qemu/v3.1.0 qemu-system-arm --version
> QEMU emulator version 3.1.0 (-dirty)
> Copyright (c) 2003-2018 Fabrice Bellard and the QEMU Project developers
>
> Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
> Signed-off-by: Pierrick Bouvier <[email protected]>
> ---
>  scripts/build_release_container.sh | 63 ++++++++++++++++++++++++++++++
>  1 file changed, 63 insertions(+)
>  create mode 100755 scripts/build_release_container.sh
>
> diff --git a/scripts/build_release_container.sh 
> b/scripts/build_release_container.sh
> new file mode 100755
> index 00000000000..7dd477deea8
> --- /dev/null
> +++ b/scripts/build_release_container.sh
> @@ -0,0 +1,63 @@
> +#!/usr/bin/env bash
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +
> +set -euo pipefail
> +
> +script_dir=$(dirname $(readlink -f $0))
> +
> +# The oldest buildable release we support is v3.1.0, as previous ones require
> +# additional tweaks in Dockerfile.
> +# For building previous releases (down to v0.12.0),
> +# see: [email protected]
> +oldest_release=v3.1.0
> +
> +if [ $# -lt 1 ] || [ $# -gt 2 ]; then
> +    echo "usage: version [git_repo]"
> +    echo
> +    echo "- version: tag or sha-1 (>= v3.1.0)"
> +    echo "- git_repo: (optional) QEMU repository URL"
> +    exit 1
> +fi
> +version=$1;shift
> +
> +git_repo="https://gitlab.com/qemu-project/qemu.git";
> +if [ $# -eq 1 ]; then
> +    git_repo=$1;shift
> +fi
> +
> +year=$(date +%Y)
> +month=$(date +%m)
> +if git rev-parse $version >& /dev/null; then
> +    year=$(git log -1 --format='%cd' --date='format:%Y' $version)
> +    month=$(git log -1 --format='%cd' --date='format:%m' $version)
> +fi
> +
> +# Ubuntu LTS are published every (even) two years in April.
> +ubuntu=
> +if [ $((year % 2)) -eq 1 ]; then
> +    # pick latest LTS from previous year
> +    ubuntu=$((year - 1))
> +elif [ $month -gt 6 ]; then
> +    # LTS published this year should work
> +    ubuntu=$year
> +else
> +    # pick latest LTS from two years ago
> +    ubuntu=$((year - 2))
> +fi
> +if [ $ubuntu -lt 2014 ]; then
> +    # oldest ubuntu release available with containers is 14.04
> +    ubuntu=2014
> +fi
> +ubuntu=$((ubuntu - 2000))
> +ubuntu_version=$ubuntu.04
> +
> +dockerfile=$script_dir/../tests/docker/dockerfiles/release.docker
> +docker=$($script_dir/../tests/docker/docker.py probe)
> +
> +set -x
> +$docker build . \
> +    -f $dockerfile \
> +    --build-arg QEMU_VERSION=$version \
> +    --build-arg UBUNTU_VERSION=$ubuntu_version \
> +    --build-arg QEMU_REPO="$git_repo" \
> +    -t qemu/$version

I have successfully tested the migration-next branch with this
series. It's a great improvement over what I had before. Thank you for
this work.

Reviewed-by: Fabiano Rosas <[email protected]>

Reply via email to