Files
kata-containers/obs-packaging/build_from_docker.sh
Jose Carlos Venegas Munoz 1a751c5214 obs: docker-build: move osc file creation.
We need to create the osc file before enter the container.
If build_all.sh is executed without a container and osc
is intalled osc will ask for setup but in the container
fails do to a missing tty.

Signed-off-by: Jose Carlos Venegas Munoz <jose.carlos.venegas.munoz@intel.com>
2018-08-28 11:31:26 -05:00

74 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
#
# Copyright (c) 2018 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#
[ -z "${DEBUG}" ] || set -o xtrace
set -o errexit
set -o nounset
set -o pipefail
script_dir=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)
script_name="$(basename "${BASH_SOURCE[0]}")"
#where packaing repo lives
packaging_repo_dir=$(cd "${script_dir}/.." && pwd)
export USE_DOCKER=1
http_proxy=${http_proxy:-}
https_proxy=${https_proxy:-}
no_proxy=${no_proxy:-}
PUSH=${PUSH:-}
# shellcheck source=scripts/obs-docker.sh
source "${script_dir}/scripts/obs-docker.sh"
GO_ARCH=$(go env GOARCH)
export GO_ARCH
OSCRC="${HOME}/.oscrc"
OBS_API="https://api.opensuse.org"
usage() {
msg="${1:-}"
exit_code=$"${2:-0}"
cat <<EOT
${msg}
Usage:
${script_name} <kata-branch/tag>
EOT
exit "${exit_code}"
}
main() {
local branch="${1:-}"
[ -n "${branch}" ] || usage "missing branch" "1"
pushd "${script_dir}/kata-containers-image/" >>/dev/null
echo "Building image"
image_tarball=$(find . -name 'kata-containers-'"${branch}"'-*.tar.gz')
[ -f "${image_tarball}" ] || "${script_dir}/../obs-packaging/kata-containers-image/build_image.sh" -v "${branch}"
image_tarball=$(find . -name 'kata-containers-'"${branch}"'-*.tar.gz')
[ -f "${image_tarball}" ] || die "image not found"
popd >>/dev/null
#Build all kata packages
make -f "${script_dir}/Makefile" clean
if [ -n "${OBS_USER:-}" ] && [ -n "${OBS_PASS:-}" ] && [ ! -e "${OSCRC}" ]; then
echo "Creating ${OSCRC} with user $OBS_USER"
cat <<eom >"${OSCRC}"
[general]
apiurl = ${OBS_API}
[${OBS_API}]
user = ${OBS_USER}
pass = ${OBS_PASS}
eom
fi
if [ ! -e "${OSCRC}" ]; then
echo "${OSCRC}, please do 'export OBS_USER=your_user ; export OBS_PASS=your_pass' to configure osc for first time."
exit 1
fi
docker_run "${packaging_repo_dir}/obs-packaging/build_all.sh ${branch}"
}
main "$@"