obs: : Minor bash fixes (refactor)

Remove unused variables and set default value to variables.

Signed-off-by: Jose Carlos Venegas Munoz <jose.carlos.venegas.munoz@intel.com>
This commit is contained in:
Jose Carlos Venegas Munoz 2018-08-01 12:23:28 -05:00
parent 6c5c293f81
commit f7074e178a
10 changed files with 13 additions and 21 deletions

View File

@ -27,6 +27,8 @@ runtime
OSCRC="${HOME}/.oscrc"
PUSH=${PUSH:-""}
LOCAL=${LOCAL:-""}
PUSH_TO_OBS=""
export BUILD_DISTROS=${BUILD_DISTROS:-xUbuntu_16.04}
# Packaging use this variable instead of use git user value
@ -38,7 +40,7 @@ cd "$script_dir"
OBS_API="https://api.opensuse.org"
if [ -n "${OBS_USER}" ] && [ -n "${OBS_PASS}" ] && [ ! -e "${OSCRC}" ]; then
if [ -n "${OBS_USER:-}" ] && [ -n "${OBS_PASS:-}" ] && [ ! -e "${OSCRC:-}" ]; then
echo "Creating ${OSCRC} with user $OBS_USER"
cat << eom > "${OSCRC}"
[general]

View File

@ -19,27 +19,25 @@ packaging_repo_dir=$(cd "${script_dir}/.." && pwd )
host_datadir="${PWD}/pkgs"
obs_image="obs-kata"
export USE_DOCKER=1
http_proxy=${http_proxy:-}
https_proxy=${https_proxy:-}
no_proxy=${no_proxy:-}
PUSH=${PUSH:-}
if command -v go; then
export GO_ARCH=$(go env GOARCH)
else
export GO_ARCH=amd64
echo "Go not installed using $GO_ARCH to install go in dockerfile"
fi
export GO_ARCH=$(go env GOARCH)
GO_ARCH=$(go env GOARCH)
export GO_ARCH
sudo docker build \
--build-arg http_proxy="${http_proxy}" \
--build-arg https_proxy="${https_proxy}" \
-t $obs_image ${script_dir}
-t $obs_image "${script_dir}"
pushd "${script_dir}/kata-containers-image/" >> /dev/null
echo "Building image"
./build_image.sh
popd >> /dev/null
function faketty { script -qfc "$(printf "%q " "$@")"; }
faketty sudo docker run \
sudo docker run \
--rm \
-v "${HOME}/.ssh":/root/.ssh \
-v "${HOME}/.gitconfig":/root/.gitconfig \

View File

@ -36,7 +36,6 @@ cli "$@"
PROJECT_REPO=${PROJECT_REPO:-home:${OBS_PROJECT}:${OBS_SUBPROJECT}/kata-containers-image}
RELEASE=$(get_obs_pkg_release "${PROJECT_REPO}")
((RELEASE++))
[ -n "$APIURL" ] && APIURL="-A ${APIURL}"
function check_image() {
[ ! -f "${SCRIPT_DIR}/kata-containers.tar.gz" ] && die "No kata-containers.tar.gz found!\nUse the build_image.sh script" || echo "Image: OK"

View File

@ -36,7 +36,6 @@ cli "$@"
PROJECT_REPO=${PROJECT_REPO:-home:${OBS_PROJECT}:${OBS_SUBPROJECT}/ksm-throttler}
RELEASE=$(get_obs_pkg_release "${PROJECT_REPO}")
((RELEASE++))
[ -n "$APIURL" ] && APIURL="-A ${APIURL}"
set_versions "$kata_ksm_throttler_hash"

View File

@ -32,7 +32,6 @@ cli "$@"
PROJECT_REPO=${PROJECT_REPO:-home:${OBS_PROJECT}:${OBS_SUBPROJECT}/proxy}
RELEASE=$(get_obs_pkg_release "${PROJECT_REPO}")
((RELEASE++))
[ -n "$APIURL" ] && APIURL="-A ${APIURL}"
set_versions $kata_proxy_hash

View File

@ -32,7 +32,6 @@ cli "$@"
PROJECT_REPO=${PROJECT_REPO:-home:${OBS_PROJECT}:${OBS_SUBPROJECT}/qemu-lite}
RELEASE=$(get_obs_pkg_release "${PROJECT_REPO}")
((RELEASE++))
[ -n "$APIURL" ] && APIURL="-A ${APIURL}"
replace_list=(

View File

@ -33,7 +33,6 @@ cli "$@"
PROJECT_REPO=${PROJECT_REPO:-home:${OBS_PROJECT}:${OBS_SUBPROJECT}/qemu-vanilla}
RELEASE=$(get_obs_pkg_release "${PROJECT_REPO}")
((RELEASE++))
[ -n "$APIURL" ] && APIURL="-A ${APIURL}"
replace_list=(
"VERSION=$VERSION"

View File

@ -78,8 +78,6 @@ PROJECT_REPO=${PROJECT_REPO:-home:${OBS_PROJECT}:${OBS_SUBPROJECT}/runtime}
RELEASE=$(get_obs_pkg_release "${PROJECT_REPO}")
((RELEASE++))
[ -n "$APIURL" ] && APIURL="-A ${APIURL}"
set_versions "$kata_runtime_hash"
replace_list=(

View File

@ -313,7 +313,7 @@ function get_obs_pkg_release() {
pkg=$(basename "${obs_pkg_name}")
repo_dir=$(mktemp -d -u -t "${pkg}.XXXXXXXXXXX")
out=$(osc ${APIURL} -q co "${obs_pkg_name}" -o "${repo_dir}") || die "failed to checkout:$out"
out=$(osc ${APIURL:-} -q co "${obs_pkg_name}" -o "${repo_dir}") || die "failed to checkout:$out"
spec_file=$(find "${repo_dir}" -maxdepth 1 -type f -name '*.spec' | head -1)
# Find in specfile in Release: XX field.

View File

@ -33,7 +33,6 @@ cli "$@"
PROJECT_REPO=${PROJECT_REPO:-home:${OBS_PROJECT}:${OBS_SUBPROJECT}/shim}
RELEASE=$(get_obs_pkg_release "${PROJECT_REPO}")
((RELEASE++))
[ -n "$APIURL" ] && APIURL="-A ${APIURL}"
set_versions $kata_shim_hash
replace_list=(