root/build-tools/stxRpmUtils.py
Scott Little 7f7154ef56 Correct build failure after mock updrade
Problem:
   Mockchain-parallel requires python2-requests, but it is not found.
Mockchain-parallel runs inside docker. the Dockerfile does not
explicitly list python2-requests as a requires package. The Dockerfile
does list mock, which used to resolve to mock-1.4.15-1.el7.noarch,
which pulled in python2-requests. Centos/EPEL upgraded to
mock-1.4.16-1.el7.noarch 2019-06-04, and it now pulls in
python36-requests, rather than python2-requests.

   Mockchain-parallel also uses functions from yum and mock.
Yum remains at python2, mock is now at python3.

   There is also one api change in the new mock.

   Whatever solution should allow mockchain-parallel function
in both a new or an old container.  The difference being the
mock version, and the verion of python required to run
mock/mockchain.  Supporting the old mock will also allow more
time for conversion of old build systems that pre-date
the conversion to docker.

Solution:
   1) For now, ship two versions of mock-parallel.  One
compatible with the new mock (python 3, new api). The
second compatible with the older mock (python 2, old api).
The old version can eventually be retired, so not worth
trying to break out common functions.
   2) Remove the dependency on yum.  We only needed
one function to split an rpm file name into components
(package-name, version, release, architecture, epoch).
We'll write our own.
   3) mockchain-parallel becomes a wrapper that detects
which mock is present, and from that determine which
version of mock-parallel-* to use, and which python to use.

Change-Id: Ia56dfd39e349096b09351e89ad3d4f024e60e4e4
Depends-On: I7c5d9b52eed49cdce02224603b9bfd17e4426558
Closes-Bug: 1831768
Signed-off-by: Scott Little <scott.little@windriver.com>
2019-06-06 13:39:34 -04:00

42 lines
839 B
Python

#
# Copyright (c) 2019 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
#
# A place to collect potentially reusable python functions
#
def splitRpmFilename(filename):
"""
Split an rpm filename into components:
package name, version, release, epoch, architecture
"""
if filename[-4:] == '.rpm':
filename = filename[:-4]
idx = filename.rfind('.')
arch = filename[idx+1:]
filename = filename[:idx]
idx = filename.rfind('-')
rel = filename[idx+1:]
filename = filename[:idx]
idx = filename.rfind('-')
ver = filename[idx+1:]
filename = filename[:idx]
idx = filename.find(':')
if idx == -1:
epoch = ''
name = filename
else:
epoch = filename[:idx]
name = filename[idx+1:]
return name, ver, rel, epoch, arch