| |
@@ -20,46 +20,12 @@
|
| |
import yaml
|
| |
import tempfile
|
| |
import rpmfluff
|
| |
- import rpmUtils.arch
|
| |
- import rpmUtils.miscutils
|
| |
import subprocess
|
| |
|
| |
+ from libtaskotron.ext.fedora import rpm_utils
|
| |
|
| |
- __all__ = ['create_repos']
|
| |
|
| |
- def parseENVRA(envra, fmt = "envra"):
|
| |
- """
|
| |
- @param envra string to be 'manipulated' - can be standard style rpm filename,
|
| |
- envra, envr, nvr
|
| |
- @param fmt desired format of the string to be returned. Allowed options are:
|
| |
- envra, envr, nvra, nvr, e, n, v, r, a. If arch is not present in envra,
|
| |
- 'noarch' is returned wherever needed.
|
| |
- @returns list of strings based on the specified format; if epoch is requested but not
|
| |
- present, it is se to empty string
|
| |
- """
|
| |
- fmt = fmt.lower()
|
| |
- supported_formats = ['envra', 'envr', 'nvra', 'nvr', 'e', 'n', 'v', 'r', 'a']
|
| |
- if fmt not in supported_formats:
|
| |
- raise ValueError("Format '%s' not in supported formats (%s)" % (fmt, ', '.join(supported_formats)))
|
| |
-
|
| |
- # prepare envra so it can be used with rpmUtils.miscutils.splitFilename()
|
| |
- parts = envra.split('.')
|
| |
- if parts[-1].lower() != 'rpm':
|
| |
- parts.append('rpm')
|
| |
- if parts[-2].lower() not in rpmUtils.arch.arches.keys() + ['noarch', 'src']:
|
| |
- parts.insert(-1, 'noarch')
|
| |
-
|
| |
- # split the filename
|
| |
- (n, v, r, e, a) = rpmUtils.miscutils.splitFilename('.'.join(parts))
|
| |
-
|
| |
- if len(fmt) == 1:
|
| |
- return {'e':e, 'n':n, 'v':v, 'r':r, 'a':a}[fmt]
|
| |
-
|
| |
- return {'envra': (e, n, v, r, a),
|
| |
- 'envr' : (e, n, v ,r),
|
| |
- 'nvra' : (n, v, r ,a),
|
| |
- 'nvr' : (n, v, r),
|
| |
- }[fmt]
|
| |
+ __all__ = ['create_repos']
|
| |
|
| |
class MySimpleRpmBuild(rpmfluff.SimpleRpmBuild):
|
| |
"""Derivative of SimpleRpmBuild which allows setting output directory"""
|
| |
@@ -84,7 +50,12 @@
|
| |
@returns instance of MySimpleRpmBuild
|
| |
"""
|
| |
|
| |
- e,n,v,r,a = parseENVRA(package['envra'])
|
| |
+ n = rpm_utils.rpmformat(package['nevra'], fmt='n', end_arch=True)
|
| |
+ e = rpm_utils.rpmformat(package['nevra'], fmt='e', end_arch=True)
|
| |
+ v = rpm_utils.rpmformat(package['nevra'], fmt='v', end_arch=True)
|
| |
+ r = rpm_utils.rpmformat(package['nevra'], fmt='r', end_arch=True)
|
| |
+ a = rpm_utils.rpmformat(package['nevra'], fmt='a', end_arch=True)
|
| |
+
|
| |
p = MySimpleRpmBuild(n, v, r, [a], rpmdir)
|
| |
p.epoch = e
|
| |
|
| |
@@ -182,7 +153,7 @@
|
| |
for root, dirs, files in os.walk(os.path.join(rpmdir, directory, 'RPMS')):
|
| |
for file in [f for f in files if f.endswith('.rpm')]:
|
| |
subprocess.check_call(['cp', os.path.join(root, file), repodir])
|
| |
- print "copied %s to %s" % (file, repodir)
|
| |
+ print("copied %s to %s" % (file, repodir))
|
| |
# create repo
|
| |
subprocess.check_call(['createrepo_c', repodir])
|
| |
|
| |
@@ -194,7 +165,7 @@
|
| |
try:
|
| |
data = yaml.load(open(sys.argv[1]).read())
|
| |
except:
|
| |
- print >> sys.stderr, ("\n\nMust supply valid yaml.")
|
| |
+ print("\n\nMust supply valid yaml.", file=sys.stderr)
|
| |
sys.exit(1)
|
| |
|
| |
create_repos(data)
|
| |