Add priority to repositories in base-image
Now it's possible to add a priority for each repo through --repo-priority on command line and cfg file as well. This is need because of the usage of ceph mirror and to force the images to use ceph packages on that repo. Test plan: Docker images build succeeded. stx-openstack apply succeeded. Closes-Bug: #1949518 Signed-off-by: Delfino Curado <delfinogomes.curadofilho@windriver.com> Change-Id: I202904dccdd727a05bb4d621c4ad735f60221b81
This commit is contained in:
parent
351bd0e724
commit
965e897c71
@ -1,2 +1,3 @@
|
|||||||
repo=ussuri-ceph,http://mirror.starlingx.cengn.ca:80/mirror/centos/download.ceph.com/rpm-mimic/el7/x86_64/
|
repo=ussuri-ceph,http://mirror.starlingx.cengn.ca/mirror/centos/download.ceph.com/rpm-nautilus/el7/x86_64/
|
||||||
|
repo-priority=ussuri-ceph,1
|
||||||
repo=ussuri-wsgi,http://mirror.starlingx.cengn.ca:80/mirror/centos/centos/mirror.centos.org/centos/7/sclo/x86_64/rh/
|
repo=ussuri-wsgi,http://mirror.starlingx.cengn.ca:80/mirror/centos/centos/mirror.centos.org/centos/7/sclo/x86_64/rh/
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
repo=ussuri-ceph,http://mirror.starlingx.cengn.ca:80/mirror/centos/download.ceph.com/rpm-mimic/el7/x86_64/
|
repo=ussuri-ceph,http://mirror.starlingx.cengn.ca/mirror/centos/download.ceph.com/rpm-nautilus/el7/x86_64/
|
||||||
|
repo-priority=ussuri-ceph,1
|
||||||
repo=ussuri-wsgi,http://mirror.starlingx.cengn.ca:80/mirror/centos/centos/mirror.centos.org/centos/7/sclo/x86_64/rh/
|
repo=ussuri-wsgi,http://mirror.starlingx.cengn.ca:80/mirror/centos/centos/mirror.centos.org/centos/7/sclo/x86_64/rh/
|
||||||
|
@ -37,6 +37,7 @@ TAG_LATEST=no
|
|||||||
LATEST_TAG=latest
|
LATEST_TAG=latest
|
||||||
HOST=${HOSTNAME}
|
HOST=${HOSTNAME}
|
||||||
declare -i MAX_ATTEMPTS=1
|
declare -i MAX_ATTEMPTS=1
|
||||||
|
declare -A REPO_PRIORITY_LIST
|
||||||
|
|
||||||
function usage {
|
function usage {
|
||||||
cat >&2 <<EOF
|
cat >&2 <<EOF
|
||||||
@ -49,6 +50,7 @@ Options:
|
|||||||
--version: Specify version for output image
|
--version: Specify version for output image
|
||||||
--stream: Build stream, stable or dev (default: stable)
|
--stream: Build stream, stable or dev (default: stable)
|
||||||
--repo: Software repository (Format: name,baseurl), can be specified multiple times
|
--repo: Software repository (Format: name,baseurl), can be specified multiple times
|
||||||
|
--repo-priority: Define priority for added repo (Format: name,priority). The priority must be an integer from 1 to 99 (The default is 99). The lowest number have the highest priority.
|
||||||
--local: Use local build for software repository (cannot be used with --repo)
|
--local: Use local build for software repository (cannot be used with --repo)
|
||||||
--push: Push to docker repo
|
--push: Push to docker repo
|
||||||
--proxy: Set proxy <URL>:<PORT>
|
--proxy: Set proxy <URL>:<PORT>
|
||||||
@ -59,7 +61,7 @@ Options:
|
|||||||
--clean: Remove image(s) from local registry
|
--clean: Remove image(s) from local registry
|
||||||
--hostname: build repo host
|
--hostname: build repo host
|
||||||
--attempts: Max attempts, in case of failure (default: 1)
|
--attempts: Max attempts, in case of failure (default: 1)
|
||||||
--config-file:Specify a path to a config file which will specify additional arguments to be passed into the command
|
--config-file: Specify a path to a config file which will specify additional arguments to be passed into the command
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
@ -98,11 +100,15 @@ function get_args_from_file {
|
|||||||
repo)
|
repo)
|
||||||
REPO_LIST+=(${config_items[1]})
|
REPO_LIST+=(${config_items[1]})
|
||||||
;;
|
;;
|
||||||
|
repo-priority)
|
||||||
|
priority_value=(${config_items[1]//,/ })
|
||||||
|
REPO_PRIORITY_LIST[${priority_value[0]}]=${priority_value[1]}
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
OPTS=$(getopt -o h -l help,os:,os-version:,version:,stream:,release:,repo:,push,proxy:,latest,latest-tag:,user:,registry:,local,clean,hostname:,attempts:,config-file: -- "$@")
|
OPTS=$(getopt -o h -l help,os:,os-version:,version:,stream:,release:,repo:,repo-priority:,push,proxy:,latest,latest-tag:,user:,registry:,local,clean,hostname:,attempts:,config-file: -- "$@")
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
usage
|
usage
|
||||||
exit 1
|
exit 1
|
||||||
@ -186,6 +192,11 @@ while true; do
|
|||||||
CONFIG_FILE=$2
|
CONFIG_FILE=$2
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
|
--repo-priority)
|
||||||
|
priority_value=(${2//,/ })
|
||||||
|
REPO_PRIORITY_LIST[${priority_value[0]}]=${priority_value[1]}
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
-h | --help )
|
-h | --help )
|
||||||
usage
|
usage
|
||||||
exit 1
|
exit 1
|
||||||
@ -267,6 +278,10 @@ STX_REPO_FILE=${BUILDDIR}/stx.repo
|
|||||||
for repo in ${REPO_LIST[@]}; do
|
for repo in ${REPO_LIST[@]}; do
|
||||||
repo_name=$(echo $repo | awk -F, '{print $1}')
|
repo_name=$(echo $repo | awk -F, '{print $1}')
|
||||||
repo_baseurl=$(echo $repo | awk -F, '{print $2}')
|
repo_baseurl=$(echo $repo | awk -F, '{print $2}')
|
||||||
|
priority=''
|
||||||
|
if [[ ! -z "${REPO_PRIORITY_LIST[$repo_name]}" ]] ; then
|
||||||
|
priority="priority=${REPO_PRIORITY_LIST[$repo_name]}"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z "${repo_name}" -o -z "${repo_baseurl}" ]; then
|
if [ -z "${repo_name}" -o -z "${repo_baseurl}" ]; then
|
||||||
echo "Invalid repo specified: ${repo}" >&2
|
echo "Invalid repo specified: ${repo}" >&2
|
||||||
@ -282,6 +297,7 @@ enabled=1
|
|||||||
gpgcheck=0
|
gpgcheck=0
|
||||||
skip_if_unavailable=1
|
skip_if_unavailable=1
|
||||||
metadata_expire=0
|
metadata_expire=0
|
||||||
|
${priority}
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
@ -6,6 +6,8 @@ FROM centos:${RELEASE}
|
|||||||
|
|
||||||
RUN set -ex ;\
|
RUN set -ex ;\
|
||||||
sed -i '/\[main\]/ atimeout=120' /etc/yum.conf ;\
|
sed -i '/\[main\]/ atimeout=120' /etc/yum.conf ;\
|
||||||
|
yum install --disablerepo=* ${REPO_OPTS} -y \
|
||||||
|
yum-priorities ;\
|
||||||
yum install -y centos-release-openstack-stein ;\
|
yum install -y centos-release-openstack-stein ;\
|
||||||
rm -rf \
|
rm -rf \
|
||||||
/var/log/* \
|
/var/log/* \
|
||||||
|
@ -14,6 +14,8 @@ RUN set -ex ;\
|
|||||||
sed -i '/\[main\]/ atimeout=120' /etc/yum.conf ;\
|
sed -i '/\[main\]/ atimeout=120' /etc/yum.conf ;\
|
||||||
mv /stx.repo /etc/yum.repos.d/ ;\
|
mv /stx.repo /etc/yum.repos.d/ ;\
|
||||||
yum upgrade --disablerepo=* ${REPO_OPTS} -y ;\
|
yum upgrade --disablerepo=* ${REPO_OPTS} -y ;\
|
||||||
|
yum install --disablerepo=* ${REPO_OPTS} -y \
|
||||||
|
yum-priorities ;\
|
||||||
yum install --disablerepo=* ${REPO_OPTS} -y \
|
yum install --disablerepo=* ${REPO_OPTS} -y \
|
||||||
qemu-img \
|
qemu-img \
|
||||||
openssh-clients \
|
openssh-clients \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user