Exemplo n.º 1
0
def execute(**kwargs):
    """ This requires also patching the tar.gz"""

    logging.info("Executing xrootd routine")
    logging.debug("Arguments %s", kwargs)

    SRPMFile = kwargs['src']
    repository = kwargs['repo']
    mockConfig = kwargs['mockConfig']
    mockRoot = kwargs['mockRoot']
    patchDir = kwargs['patchDir']
    patchFile = None
    pkgList = kwargs['pkgList']

    logging.info(
        "Building %s %s", SRPMFile,
        "%s" % ("with mockConfig %s" % mockConfig if mockConfig else ""))

    if not os.path.isfile(SRPMFile):
        logging.debug("SRPM file is an URL, download it first")
        SRPMFile = diracoslib._downloadFile(SRPMFile, '/tmp')

    # get package name
    pkgName, pkgVersion, _release, _epoch, _arch = rpmUtils.miscutils.splitFilename(
        os.path.basename(SRPMFile))

    # If the src.rpm is already in the repo, do not rebuild it
    #
    existingBuild = glob.glob(
        os.path.join(repository, 'src', '%s-%s*' % (pkgName, pkgVersion)))
    if existingBuild:
        logging.info("The repo already contains a build, not rebuilding: %s",
                     existingBuild)
        return

    if not patchFile and patchDir:

        potentialPatchFile = os.path.join(patchDir, '%s.patch' % pkgName)
        logging.debug("Checking existance of %s", potentialPatchFile)
        if os.path.isfile(potentialPatchFile):
            logging.debug("patch file found")
            patchFile = potentialPatchFile

    if patchFile:
        newSRPM = _mock_patchAndRecreateXroot(SRPMFile,
                                              patchFile,
                                              mockConfig,
                                              mockRoot=mockRoot)
        logging.debug("New SRPM file %s", newSRPM)
        SRPMFile = newSRPM

    diracoslib._mockRebuild(SRPMFile, mockConfig)
    mockResultDir = os.path.join(mockRoot, 'result/')
    diracoslib._copyRPMs(mockResultDir,
                         repository,
                         byRPMType=True,
                         pkgList=pkgList)
    diracoslib._createRepo(repository)
    logging.info('Finished')
Exemplo n.º 2
0
def _mock_patchAndRecreateGlite(srpmFile,
                                patchFile,
                                mockConfigFile=None,
                                mockRoot=None):
    """ Patch and recreate an SRPM """

    tmpDir = diracoslib._extractSRPM(srpmFile)
    tarFn = os.path.join(tmpDir, "glite-ce-cream-cli.tar.gz")
    # extract the archive as well
    tar = tarfile.open(tarFn, "r:gz")
    filesToCompress = tar.getnames()
    tar.extractall(path=tmpDir)
    tar.close()

    diracoslib._applyPatch(patchFile, tmpDir)

    # retar the file
    os.unlink(tarFn)
    tar = tarfile.open(tarFn, "w:gz")
    for fn in filesToCompress:
        tar.add(os.path.join(tmpDir, fn), arcname=fn)
    tar.close()

    specFile = glob.glob(os.path.join(tmpDir, '*.spec'))[0]
    sources = glob.glob(os.path.join(tmpDir, '*.tar.gz'))[0]
    diracoslib._mockBuildSRPM(specFile, sources, mockConfigFile)
    newSrcRpm = diracoslib._copyRPMs(os.path.join(mockRoot, 'result/'),
                                     tmpDir)[0]
    return newSrcRpm
Exemplo n.º 3
0
def execute(**kwargs):
    """ This requires also patching the tar.gz"""

    logging.info("Executing xrootd routine")
    logging.debug("Arguments %s", kwargs)

    srpmFile = kwargs['src']
    repository = kwargs['repo']
    mockConfig = kwargs['mockConfig']
    mockRoot = kwargs['mockRoot']
    patchDir = kwargs['patchDir']
    patchFile = None

    workDir = kwargs.get('workDir', '/tmp')

    logging.info(
        "Building %s %s", srpmFile,
        "%s" % ("with mockConfig %s" % mockConfig if mockConfig else ""))

    if not os.path.isfile(srpmFile):
        logging.debug("SRPM file is an URL, download it first")
        srpmFile = diracoslib._downloadFile(srpmFile, '/tmp')

    # get package name
    pkgName, pkgVersion, _release, _epoch, _arch = rpmUtils.miscutils.splitFilename(
        os.path.basename(srpmFile))

    # If the src.rpm is already in the repo, do not rebuild it
    #
    existingBuild = glob.glob(
        os.path.join(repository, 'src', '%s-%s*' % (pkgName, pkgVersion)))
    if existingBuild:
        logging.info("The repo already contains a build, not rebuilding: %s",
                     existingBuild)
        return

    if not patchFile and patchDir:

        potentialPatchFile = os.path.join(patchDir, '%s.patch' % pkgName)
        logging.debug("Checking existance of %s", potentialPatchFile)
        if os.path.isfile(potentialPatchFile):
            logging.debug("patch file found")
            patchFile = potentialPatchFile

    if patchFile:
        newSRPM = diracoslib._mock_patchAndRecreateSRPM(srpmFile,
                                                        patchFile,
                                                        mockConfig,
                                                        mockRoot=mockRoot)
        logging.debug("New SRPM file %s", newSRPM)
        srpmFile = newSRPM

    # now comes the funky part !
    # Davix decided to use cmake3, which is not easily available on SLC6 as RPM.
    # Luckily for us, there is a binary distribution by cmake themselves which works fine.
    # So we just extract it in the mock environment,
    # and build the RPM without cleaning !

    installer = diracoslib._downloadFile(CMAKE3_SLC6_INSTALLER, workDir)

    mockUsrDir = os.path.join(mockRoot, 'root/usr/')
    cmd = ['sh', installer, '--skip-license', '--prefix=%s' % mockUsrDir]
    logging.info("Installing cmake3 in the mock environment %s", cmd)
    subprocess.check_call(cmd)

    diracoslib._mockRebuild(srpmFile, mockConfig, noClean=True)
    mockResultDir = os.path.join(mockRoot, 'result/')
    diracoslib._copyRPMs(mockResultDir, repository, byRPMType=True)
    diracoslib._createRepo(repository)
    logging.info('Finished')