Browse Source

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
master
Chandan Kumar 3 months ago
parent
commit
410408ef1b
4 changed files with 20 additions and 7 deletions
  1. 1
    1
      files/dev_install.sh
  2. 1
    1
      files/rpm_install.sh
  3. 11
    4
      files/yum_update.sh
  4. 7
    1
      templates/Dockerfile-dev.j2

+ 1
- 1
files/dev_install.sh View File

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

+ 1
- 1
files/rpm_install.sh View File

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

+ 11
- 4
files/yum_update.sh View File

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

+ 7
- 1
templates/Dockerfile-dev.j2 View File

@@ -4,6 +4,12 @@ LABEL modified_append_tag={{ modified_append_tag }}
4 4
 USER root
5 5
 
6 6
 COPY refspec_projects /root/refspec_projects
7
-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'
7
+RUN /bin/bash -c 'PKG="$(command -v dnf || command -v yum)"; \
8
+    PKG_MGR="$(echo ${PKG:(-3)})"; \
9
+    if [ $PKG_MGR == "dnf" ]; then $PKG install python3-pip; PIP=pip3; else $PKG install python-pip; \
10
+    PIP=pip; fi; \
11
+    cd /; \
12
+    for X in $(ls /root/refspec_projects/*.tar.gz); do $PIP install $X; done; \
13
+    rm -Rf /root/refspec_projects'
8 14
 
9 15
 USER "{{ original_user }}"

Loading…
Cancel
Save