diff --git a/assets/entry b/assets/entry index 6a99312..001e533 100755 --- a/assets/entry +++ b/assets/entry @@ -1,27 +1,9 @@ #!/bin/bash -arguments=() -for arg in "$@"; do - arguments+=($arg) -done - -# First argument is the command -request=${arguments[0]} -# Rest of the arguments -arguments=("${arguments[@]:1}") - -commands=(info help version shell) -for file in assets/commands/*; do - [[ -x "${file}" ]] && commands+=("${file}") -done - -. /assets/SOLUTION -. /etc/os-release - name() { cat << EOF Intel Accelerated Graphics and Media Access container -Copyright (C) 2019 Intel Corporation +Copyright (C) 2019-2021 Intel Corporation ----- EOF } @@ -89,18 +71,105 @@ EOF echo "" } -[[ "${request}" == "" ]] && { - request="help" -} +# ***************************************************************************** +# Execution begins here +# ***************************************************************************** -[[ " ${commands[@]} " =~ " ${request} " ]] && { +# Parse arguments, looking for -r REPO and -s STREAM at the start +arguments=() +REPO= +STREAM= +while (( ${#@} > 0 )); do + arg=$1 + shift + # If any arguments have been provided, stop looking for + # -r and -s options + if (( ${#arguments[@]} )); then + arguments+=($arg) + continue + fi + + if [[ "${arg}" == "-r" ]]; then + REPO=$1 + shift + elif [[ "${arg}" == "-s" ]]; then + STREAM=$1 + shift + else + arguments+=($arg) + fi +done + +# First argument is the command +request=${arguments[0]} +# Rest of the arguments +arguments=("${arguments[@]:1}") + +# Build up the set of supported commands, including +# on the built-in 'info', 'help', 'version', and 'shell' +commands=(info help version shell) +for file in assets/commands/*; do + [[ -x "${file}" ]] && commands+=("${file}") +done + +# Include solution specific defines +. /assets/SOLUTION + +# Include OS specific defines +. /etc/os-release + +# If REPO is set, re-configure the system repo file to point to the requested repo +if [[ "${REPO}" != "" ]]; then + echo "Setting repository to: ${REPO}" + case $OS_DISTRO in + ubuntu) + sudo sed -i -e "s,${GPGPU_PACKAGE_REPOSITORY},${REPO},g" /etc/apt/sources.list + ;; + sles) + ;; + rhel) + ;; + esac + + export GPGPU_PACKAGE_REPOSITORY=${REPO} +fi + +# If STREAM is set, re-configure the system repo file to point to the requested stream +if [[ "${STREAM}" != "" ]]; then + echo "Setting stream to: ${STREAM}" + case $OS_DISTRO in + ubuntu) + sudo sed -i -e "s,${GPGPU_PACKAGE_STREAM},${STREAM},g" /etc/apt/sources.list + ;; + sles) + ;; + rhel) + ;; + esac + + export GPGPU_PACKAGE_STREAM=${STREAM} +fi + +if [[ "${REPO}" != "" ]] || [[ "${STREAM}" != "" ]]; then + echo -e "\nUpdated container information:" + info +fi + +# If no entry point was provided, default to help +request=${request:=help} + +# If the requested command is in the set of build-in +# commands then run it with the rest of the arguments +if [[ " ${commands[@]} " =~ " ${request} " ]]; then $request "${arguments[@]}" exit $? -} +fi -[ ! -f /assets/commands/$request ] && { +# Otherwise if there is not a file with this command, run +# it from within a shell +if [ ! -f /assets/commands/$request ]; then shell "${request}" "${arguments[@]}" -} || { +else /assets/commands/$request "${arguments[@]}" exit $? -} +fi diff --git a/scripts/promote-image.sh b/scripts/promote-image.sh index c43aff0..6416a99 100755 --- a/scripts/promote-image.sh +++ b/scripts/promote-image.sh @@ -90,7 +90,7 @@ if echo ${RESULTS} | grep -q "HTTP.*200"; then else echo "Error deleting tag:" >&2 echo "${RESULTS}" >&2 -fi +done iter=5 while (( iter )); do diff --git a/scripts/test-image.sh b/scripts/test-image.sh index 08e897e..48192ea 100755 --- a/scripts/test-image.sh +++ b/scripts/test-image.sh @@ -29,17 +29,26 @@ function usage { usage: scripts/test-image.sh [OPTIONS] Options: - -l Use the local image (vs. from ${REGISTRY}) + -l Use the local image (vs. from ${REGISTRY}) + -r REPO Switch image to use REPO + -s STREAM Switch image to use STREAM EOF } LOCAL=0 -while getopts l opt; do +REPO= +while getopts lr:s: opt; do case "${opt}" in l) LOCAL=1 ;; + r) + REPO=${OPTARG} + ;; + s) + STREAM=${OPTARG} + ;; [?]) >&2 echo -e "\nInvalid parameter: ${opt}\n" usage >&2 @@ -60,6 +69,12 @@ shift $(( OPTIND-1 )) # Take entry-point from command line arguments, or set to 'test' # if nothing provided ENTRY="${*}" +if [[ "${REPO}" != "" ]]; then + ENTRY="-r ${REPO} ${ENTRY}" +fi +if [[ "${STREAM}" != "" ]]; then + ENTRY="-s ${STREAM} ${ENTRY}" +fi [[ "${ENTRY}" == "" ]] && { DOCKER_ARGS="" ENTRY="test" @@ -98,5 +113,5 @@ $( echo " ${CMD} ${ENTRY}" | sed -e "s, , \\\\\n ,g") EOF -${CMD} info || fail "Unable to execute 'info' on ${IMAGE}." +${CMD} info || fail "Unable to execute 'test' on ${IMAGE}." ${CMD} ${ENTRY} || fail "Unable to execute 'test' on ${IMAGE}." diff --git a/templates/sles/15sp2/00-from.in b/templates/sles/15sp2/00-from.in index 1f045fc..364dcb9 100644 --- a/templates/sles/15sp2/00-from.in +++ b/templates/sles/15sp2/00-from.in @@ -1,3 +1,3 @@ -# Pull internal sles 15sp1 image. +# Pull internal sles 15sp2 image. -FROM dockerv2-gfx-build.gfx-assets.intel.com/upstream/sle15:15.2 AS xe-base-stage +FROM amr-registry.caas.intel.com/vtt-osgc/os/sles:15.2 AS xe-base-stage