Ported tripleo-modify-image to py3

It makes yum and pip installs work with py3 packages. The package manager
dnf/yum and pip binary are determined at run time from the OS.

Use dnf-plugins-core for dnf with respect to
yum-plugin-priorities.

Use pipefail with set -ex to fix linter errors.

Change-Id: I997509204e30abb8b21ef936ea44440fbaa5a0e4
Closes-Bug: #1813546
This commit is contained in:
Chandan Kumar 2019-02-12 08:05:22 +00:00
parent b541c5ef99
commit 410408ef1b
4 changed files with 20 additions and 7 deletions

View File

@ -1,4 +1,4 @@
set -e
set -eou pipefail
# Cherry-pick a refspec
# $1 : project name e.g. keystone

View File

@ -1,6 +1,6 @@
#!/bin/sh
set -ex
set -eox pipefail
rpm -Uvh /tmp/*.rpm
rm -f /tmp/*.rpm

View File

@ -1,6 +1,6 @@
#!/bin/bash
set -eux
set -eoux pipefail
packages_for_update=
if [ -n "$1" ] && command -v repoquery >/dev/null 2>&1; then
@ -14,6 +14,13 @@ if [ -z "$packages_for_update" ]; then
exit
fi
yum install -y yum-plugin-priorities
yum -y update $packages_for_update
rm -rf /var/cache/yum
PKG="$(command -v dnf || command -v yum)"
PKG_MGR="$(echo ${PKG:(-3)})"
if [ $PKG_MGR == "dnf" ]; then
$PKG install -y dnf-plugins-core
else:
$PKG install -y yum-plugin-priorities
fi
$PKG -y update $packages_for_update
rm -rf /var/cache/$PKG_MGR

View File

@ -4,6 +4,12 @@ LABEL modified_append_tag={{ modified_append_tag }}
USER root
COPY refspec_projects /root/refspec_projects
RUN /bin/bash -c 'rpm -qi python-pip || yum install -y python-pip; cd /; for X in $(ls /root/refspec_projects/*.tar.gz); do pip install $X; done; rm -Rf /root/refspec_projects'
RUN /bin/bash -c 'PKG="$(command -v dnf || command -v yum)"; \
PKG_MGR="$(echo ${PKG:(-3)})"; \
if [ $PKG_MGR == "dnf" ]; then $PKG install python3-pip; PIP=pip3; else $PKG install python-pip; \
PIP=pip; fi; \
cd /; \
for X in $(ls /root/refspec_projects/*.tar.gz); do $PIP install $X; done; \
rm -Rf /root/refspec_projects'
USER "{{ original_user }}"