|
Brian Stinson |
2fb8a5 |
import pyrpkg
|
|
Brian Stinson |
ca61eb |
import os
|
|
Brian Stinson |
ca61eb |
import re
|
|
Brian Stinson |
2fb8a5 |
|
|
Brian Stinson |
2fb8a5 |
from . import cli
|
|
Brian Stinson |
2fb8a5 |
|
|
Brian Stinson |
2fb8a5 |
class Commands(pyrpkg.Commands):
|
|
Brian Stinson |
2fb8a5 |
def __init__(self, path, lookaside, lookasidehash, lookaside_cgi,
|
|
Brian Stinson |
2fb8a5 |
gitbaseurl, anongiturl, branchre, kojiconfig,
|
|
Brian Stinson |
2fb8a5 |
build_client, user=None, dist=None, target=None,
|
|
Brian Stinson |
2fb8a5 |
quiet=False):
|
|
Brian Stinson |
2fb8a5 |
|
|
Brian Stinson |
2fb8a5 |
super(Commands,self).__init__(path, lookaside, lookasidehash,
|
|
Brian Stinson |
2fb8a5 |
lookaside_cgi, gitbaseurl, anongiturl,
|
|
Brian Stinson |
2fb8a5 |
branchre, kojiconfig, build_client,
|
|
Brian Stinson |
2fb8a5 |
user, dist, target,
|
|
Brian Stinson |
2fb8a5 |
quiet)
|
|
Brian Stinson |
2fb8a5 |
|
|
Brian Stinson |
2fb8a5 |
|
|
Brian Stinson |
ca61eb |
# redefined loaders
|
|
Brian Stinson |
ca61eb |
def load_rpmdefines(self):
|
|
Brian Stinson |
ca61eb |
try:
|
|
Brian Stinson |
ca61eb |
osver = re.search(r'\d.*$', self.branch_merge).group()
|
|
Brian Stinson |
ca61eb |
except AttributeError:
|
|
Brian Stinson |
ca61eb |
raise pyrpkg.rpkgError('Could not find the base OS ver from branch name'
|
|
Brian Stinson |
ca61eb |
' %s' % self.branch_merge)
|
|
Brian Stinson |
ca61eb |
self._distval = osver
|
|
Brian Stinson |
ca61eb |
self._distval = self._distval.replace('.', '_')
|
|
Brian Stinson |
ca61eb |
self._disttag = 'el%s' % self._distval
|
|
Brian Stinson |
ca61eb |
self._rpmdefines = ["--define '_sourcedir %s'" % os.path.join(self.path,'SOURCES'),
|
|
Brian Stinson |
ca61eb |
"--define '_specdir %s'" % os.path.join(self.path,'SPECS'),
|
|
Brian Stinson |
ca61eb |
"--define '_builddir %s'" % os.path.join(self.path,'BUILD'),
|
|
Brian Stinson |
ca61eb |
"--define '_srcrpmdir %s'" % os.path.join(self.path,'SRPMS'),
|
|
Brian Stinson |
ca61eb |
"--define '_rpmdir %s'" % os.path.join(self.path, 'RPMS'),
|
|
Brian Stinson |
ca61eb |
"--define 'dist .%s'" % self._disttag,
|
|
Brian Stinson |
ca61eb |
# int and float this to remove the decimal
|
|
Brian Stinson |
ca61eb |
"--define '%s 1'" % self._disttag]
|
|
Brian Stinson |
ca61eb |
|
|
Brian Stinson |
ca61eb |
def load_spec(self):
|
|
Brian Stinson |
ca61eb |
"""This sets the spec attribute"""
|
|
Brian Stinson |
ca61eb |
|
|
Brian Stinson |
ca61eb |
# We are not using the upstream load_spec because the file structure is
|
|
Brian Stinson |
ca61eb |
# hard-coded
|
|
Brian Stinson |
ca61eb |
|
|
Brian Stinson |
ca61eb |
deadpackage = False
|
|
Brian Stinson |
ca61eb |
|
|
Brian Stinson |
ca61eb |
# Get a list of files in the path we're looking at
|
|
Brian Stinson |
ca61eb |
files = os.listdir(os.path.join(self.path,'SPECS'))
|
|
Brian Stinson |
ca61eb |
# Search the files for the first one that ends with ".spec"
|
|
Brian Stinson |
ca61eb |
for f in files:
|
|
Brian Stinson |
ca61eb |
if f.endswith('.spec') and not f.startswith('.'):
|
|
Brian Stinson |
ca61eb |
self._spec = os.path.join('SPECS',f)
|
|
Brian Stinson |
ca61eb |
return
|
|
Brian Stinson |
ca61eb |
if f == 'dead.package':
|
|
Brian Stinson |
ca61eb |
deadpackage = True
|
|
Brian Stinson |
ca61eb |
if deadpackage:
|
|
Brian Stinson |
ca61eb |
raise pyrpkg.rpkgError('No spec file found. This package is retired')
|
|
Brian Stinson |
ca61eb |
else:
|
|
Brian Stinson |
ca61eb |
raise pyrpkg.rpkgError('No spec file found.')
|
|
Brian Stinson |
ca61eb |
|
|
Brian Stinson |
ca61eb |
|
|
Brian Stinson |
2fb8a5 |
# These are the commands defined in the base pyrpkg.Commands class
|
|
Brian Stinson |
2fb8a5 |
def load_kojisession(self, *args, **kwargs):
|
|
Brian Stinson |
2fb8a5 |
raise NotImplementedError("This command is not yet implemented in centpkg")
|
|
Brian Stinson |
2fb8a5 |
|
|
Brian Stinson |
2fb8a5 |
def add_tag(self, *args, **kwargs):
|
|
Brian Stinson |
2fb8a5 |
raise NotImplementedError("This command is not yet implemented in centpkg")
|
|
Brian Stinson |
2fb8a5 |
|
|
Brian Stinson |
2fb8a5 |
def clean(self, *args, **kwargs):
|
|
Brian Stinson |
2fb8a5 |
raise NotImplementedError("This command is not yet implemented in centpkg")
|
|
Brian Stinson |
2fb8a5 |
|
|
Brian Stinson |
2fb8a5 |
def clone(self, *args, **kwargs):
|
|
Brian Stinson |
6f323d |
super(Commands,self).clone(*args, **kwargs)
|
|
Brian Stinson |
2fb8a5 |
|
|
Brian Stinson |
2fb8a5 |
def clone_with_dirs(self, *args, **kwargs):
|
|
Brian Stinson |
2fb8a5 |
raise NotImplementedError("This command is not yet implemented in centpkg")
|
|
Brian Stinson |
2fb8a5 |
|
|
Brian Stinson |
2fb8a5 |
def commit(self, *args, **kwargs):
|
|
Brian Stinson |
2fb8a5 |
raise NotImplementedError("This command is not yet implemented in centpkg")
|
|
Brian Stinson |
2fb8a5 |
|
|
Brian Stinson |
2fb8a5 |
def delete_tag(self, *args, **kwargs):
|
|
Brian Stinson |
2fb8a5 |
raise NotImplementedError("This command is not yet implemented in centpkg")
|
|
Brian Stinson |
2fb8a5 |
|
|
Brian Stinson |
2fb8a5 |
def get_latest_commit(self, *args, **kwargs):
|
|
Brian Stinson |
2fb8a5 |
raise NotImplementedError("This command is not yet implemented in centpkg")
|
|
Brian Stinson |
2fb8a5 |
|
|
Brian Stinson |
2fb8a5 |
def gitbuildhash(self, *args, **kwargs):
|
|
Brian Stinson |
2fb8a5 |
raise NotImplementedError("This command is not yet implemented in centpkg")
|
|
Brian Stinson |
2fb8a5 |
|
|
Brian Stinson |
2fb8a5 |
def import_srpm(self, *args, **kwargs):
|
|
Brian Stinson |
2fb8a5 |
raise NotImplementedError("This command is not yet implemented in centpkg")
|
|
Brian Stinson |
2fb8a5 |
|
|
Brian Stinson |
2fb8a5 |
def list_tag(self, *args, **kwargs):
|
|
Brian Stinson |
2fb8a5 |
raise NotImplementedError("This command is not yet implemented in centpkg")
|
|
Brian Stinson |
2fb8a5 |
|
|
Brian Stinson |
2fb8a5 |
def new(self, *args, **kwargs):
|
|
Brian Stinson |
2fb8a5 |
raise NotImplementedError("This command is not yet implemented in centpkg")
|
|
Brian Stinson |
2fb8a5 |
|
|
Brian Stinson |
2fb8a5 |
def patch(self, *args, **kwargs):
|
|
Brian Stinson |
2fb8a5 |
raise NotImplementedError("This command is not yet implemented in centpkg")
|
|
Brian Stinson |
2fb8a5 |
|
|
Brian Stinson |
2fb8a5 |
def pull(self, *args, **kwargs):
|
|
Brian Stinson |
2fb8a5 |
raise NotImplementedError("This command is not yet implemented in centpkg")
|
|
Brian Stinson |
2fb8a5 |
|
|
Brian Stinson |
2fb8a5 |
def push(self, *args, **kwargs):
|
|
Brian Stinson |
2fb8a5 |
raise NotImplementedError("This command is not yet implemented in centpkg")
|
|
Brian Stinson |
2fb8a5 |
|
|
Brian Stinson |
9bd7b3 |
def sources(self, outdir=None):
|
|
Brian Stinson |
9bd7b3 |
"""Download source files"""
|
|
Brian Stinson |
9bd7b3 |
|
|
Brian Stinson |
9bd7b3 |
# We are not using sources() in super because the metadata file is
|
|
Brian Stinson |
9bd7b3 |
# hard-coded into the first open() call. Otherwise this is copied from
|
|
Brian Stinson |
9bd7b3 |
# upstream pyrpkg
|
|
Brian Stinson |
9bd7b3 |
|
|
Brian Stinson |
9bd7b3 |
try:
|
|
Brian Stinson |
9bd7b3 |
archives = open(os.path.join(self.path,
|
|
Brian Stinson |
9bd7b3 |
'.{0}.metadata'.format(self.module_name)),
|
|
Brian Stinson |
9bd7b3 |
'r').readlines()
|
|
Brian Stinson |
9bd7b3 |
except IOError, e:
|
|
Brian Stinson |
9bd7b3 |
raise pyrpkg.rpkgError('%s is not a valid repo: %s' % (self.path, e))
|
|
Brian Stinson |
9bd7b3 |
# Default to putting the files where the module is
|
|
Brian Stinson |
9bd7b3 |
if not outdir:
|
|
Brian Stinson |
9bd7b3 |
outdir = self.path
|
|
Brian Stinson |
9bd7b3 |
for archive in archives:
|
|
Brian Stinson |
9bd7b3 |
try:
|
|
Brian Stinson |
9bd7b3 |
# This strip / split is kind a ugly, but checksums shouldn't have
|
|
Brian Stinson |
9bd7b3 |
# two spaces in them. sources file might need more structure in the
|
|
Brian Stinson |
9bd7b3 |
# future
|
|
Brian Stinson |
9bd7b3 |
csum, file = archive.strip().split(' ', 1)
|
|
Brian Stinson |
9bd7b3 |
except ValueError:
|
|
Brian Stinson |
9bd7b3 |
raise pyrpkg.rpkgError('Malformed sources file.')
|
|
Brian Stinson |
9bd7b3 |
# See if we already have a valid copy downloaded
|
|
Brian Stinson |
9bd7b3 |
outfile = os.path.join(outdir, file)
|
|
Brian Stinson |
9bd7b3 |
if os.path.exists(outfile):
|
|
Brian Stinson |
9bd7b3 |
if self._verify_file(outfile, csum, self.lookasidehash):
|
|
Brian Stinson |
9bd7b3 |
continue
|
|
Brian Stinson |
9bd7b3 |
self.log.info("Downloading %s" % (file))
|
|
Brian Stinson |
9bd7b3 |
url = '%s/%s/%s/%s' % (self.lookaside, self.module_name,
|
|
Brian Stinson |
9bd7b3 |
self.branch_merge,
|
|
Brian Stinson |
9bd7b3 |
csum,
|
|
Brian Stinson |
9bd7b3 |
)
|
|
Brian Stinson |
9bd7b3 |
# There is some code here for using pycurl, but for now,
|
|
Brian Stinson |
9bd7b3 |
# just use subprocess
|
|
Brian Stinson |
9bd7b3 |
#output = open(file, 'wb')
|
|
Brian Stinson |
9bd7b3 |
#curl = pycurl.Curl()
|
|
Brian Stinson |
9bd7b3 |
#curl.setopt(pycurl.URL, url)
|
|
Brian Stinson |
9bd7b3 |
#curl.setopt(pycurl.FOLLOWLOCATION, 1)
|
|
Brian Stinson |
9bd7b3 |
#curl.setopt(pycurl.MAXREDIRS, 5)
|
|
Brian Stinson |
9bd7b3 |
#curl.setopt(pycurl.CONNECTTIMEOUT, 30)
|
|
Brian Stinson |
9bd7b3 |
#curl.setopt(pycurl.TIMEOUT, 300)
|
|
Brian Stinson |
9bd7b3 |
#curl.setopt(pycurl.WRITEDATA, output)
|
|
Brian Stinson |
9bd7b3 |
#try:
|
|
Brian Stinson |
9bd7b3 |
# curl.perform()
|
|
Brian Stinson |
9bd7b3 |
#except:
|
|
Brian Stinson |
9bd7b3 |
# print "Problems downloading %s" % url
|
|
Brian Stinson |
9bd7b3 |
# curl.close()
|
|
Brian Stinson |
9bd7b3 |
# output.close()
|
|
Brian Stinson |
9bd7b3 |
# return 1
|
|
Brian Stinson |
9bd7b3 |
#curl.close()
|
|
Brian Stinson |
9bd7b3 |
#output.close()
|
|
Brian Stinson |
9bd7b3 |
# These options came from Makefile.common.
|
|
Brian Stinson |
9bd7b3 |
# Probably need to support wget as well
|
|
Brian Stinson |
9bd7b3 |
command = ['curl', '-H', 'Pragma:', '-o', outfile, '-R', '-S', '--fail']
|
|
Brian Stinson |
9bd7b3 |
if self.quiet:
|
|
Brian Stinson |
9bd7b3 |
command.append('-s')
|
|
Brian Stinson |
9bd7b3 |
command.append(url)
|
|
Brian Stinson |
9bd7b3 |
self._run_command(command)
|
|
Brian Stinson |
9bd7b3 |
if not self._verify_file(outfile, csum, self.lookasidehash):
|
|
Brian Stinson |
9bd7b3 |
raise pyrpkg.rpkgError('%s failed checksum' % file)
|
|
Brian Stinson |
9bd7b3 |
return
|
|
Brian Stinson |
2fb8a5 |
|
|
Brian Stinson |
2fb8a5 |
def switch_branch(self, *args, **kwargs):
|
|
Brian Stinson |
2fb8a5 |
raise NotImplementedError("This command is not yet implemented in centpkg")
|
|
Brian Stinson |
2fb8a5 |
|
|
Brian Stinson |
2fb8a5 |
def file_exists(self, *args, **kwargs):
|
|
Brian Stinson |
2fb8a5 |
raise NotImplementedError("This command is not yet implemented in centpkg")
|
|
Brian Stinson |
2fb8a5 |
|
|
Brian Stinson |
2fb8a5 |
def upload_file(self, *args, **kwargs):
|
|
Brian Stinson |
2fb8a5 |
raise NotImplementedError("This command is not yet implemented in centpkg")
|
|
Brian Stinson |
2fb8a5 |
|
|
Brian Stinson |
2fb8a5 |
def build(self, *args, **kwargs):
|
|
Brian Stinson |
2fb8a5 |
raise NotImplementedError("This command is not yet implemented in centpkg")
|
|
Brian Stinson |
2fb8a5 |
|
|
Brian Stinson |
2fb8a5 |
def clog(self, *args, **kwargs):
|
|
Brian Stinson |
2fb8a5 |
raise NotImplementedError("This command is not yet implemented in centpkg")
|
|
Brian Stinson |
2fb8a5 |
|
|
Brian Stinson |
2fb8a5 |
def compile(self, *args, **kwargs):
|
|
Brian Stinson |
2fb8a5 |
raise NotImplementedError("This command is not yet implemented in centpkg")
|
|
Brian Stinson |
2fb8a5 |
|
|
Brian Stinson |
2fb8a5 |
def giturl(self, *args, **kwargs):
|
|
Brian Stinson |
2fb8a5 |
raise NotImplementedError("This command is not yet implemented in centpkg")
|
|
Brian Stinson |
2fb8a5 |
|
|
Brian Stinson |
2fb8a5 |
def koji_upload(self, *args, **kwargs):
|
|
Brian Stinson |
2fb8a5 |
raise NotImplementedError("This command is not yet implemented in centpkg")
|
|
Brian Stinson |
2fb8a5 |
|
|
Brian Stinson |
2fb8a5 |
def install(self, *args, **kwargs):
|
|
Brian Stinson |
2fb8a5 |
raise NotImplementedError("This command is not yet implemented in centpkg")
|
|
Brian Stinson |
2fb8a5 |
|
|
Brian Stinson |
2fb8a5 |
def lint(self, *args, **kwargs):
|
|
Brian Stinson |
2fb8a5 |
raise NotImplementedError("This command is not yet implemented in centpkg")
|
|
Brian Stinson |
2fb8a5 |
|
|
Brian Stinson |
2fb8a5 |
def local(self, *args, **kwargs):
|
|
Brian Stinson |
2fb8a5 |
raise NotImplementedError("This command is not yet implemented in centpkg")
|
|
Brian Stinson |
2fb8a5 |
|
|
Brian Stinson |
2fb8a5 |
def mock_config(self, *args, **kwargs):
|
|
Brian Stinson |
2fb8a5 |
raise NotImplementedError("This command is not yet implemented in centpkg")
|
|
Brian Stinson |
2fb8a5 |
|
|
Brian Stinson |
2fb8a5 |
def mockbuild(self, *args, **kwargs):
|
|
Brian Stinson |
2fb8a5 |
raise NotImplementedError("This command is not yet implemented in centpkg")
|
|
Brian Stinson |
2fb8a5 |
|
|
Brian Stinson |
2fb8a5 |
def upload(self, *args, **kwargs):
|
|
Brian Stinson |
2fb8a5 |
raise NotImplementedError("This command is not yet implemented in centpkg")
|
|
Brian Stinson |
2fb8a5 |
|
|
Brian Stinson |
2fb8a5 |
def prep(self, *args, **kwargs):
|
|
Brian Stinson |
2fb8a5 |
raise NotImplementedError("This command is not yet implemented in centpkg")
|
|
Brian Stinson |
2fb8a5 |
|
|
Brian Stinson |
2fb8a5 |
def srpm(self, *args, **kwargs):
|
|
Brian Stinson |
2fb8a5 |
raise NotImplementedError("This command is not yet implemented in centpkg")
|
|
Brian Stinson |
2fb8a5 |
|
|
Brian Stinson |
2fb8a5 |
def unused_patches(self, *args, **kwargs):
|
|
Brian Stinson |
2fb8a5 |
raise NotImplementedError("This command is not yet implemented in centpkg")
|
|
Brian Stinson |
2fb8a5 |
|
|
Brian Stinson |
2fb8a5 |
def verify_files(self, *args, **kwargs):
|
|
Brian Stinson |
2fb8a5 |
raise NotImplementedError("This command is not yet implemented in centpkg")
|