示例#1
0
文件: rpm.py 项目: darian19/what
def YOMPCloneIntoFakeroot(fakeroot,
                         installDirectory,
                         repoDirectory,
                         YOMPURL,
                         sha=None,
                         logger=None):
  """
  Clone a YOMP repository into a specific path in a fakeroot

  @param fakeroot: path to the directory to use as the root of the RPM's
    install tree

  @param installDirectory: Where to put the new YOMP clone

  @param repoDirectory: what to name the cloned directory

  @param YOMPURL: YOMP URL used to clone

  @param sha (optional): SHA to checkout once we've cloned the repository

  @param logger - Optional logger object, will be used to output more
  debugging information.

  @returns the SHA of the resulting YOMP clone. We may not have been invoked
  with a specific SHA (we normally build tip of master, for example), but we
  always want to include the exact SHA packaged in our RPM descriptions.
  """
  if logger:
    logger.debug("Prepping fakeroot in %s", fakeroot)
  installPath = "%s/%s" % (fakeroot, installDirectory)
  with changeToWorkingDir(installPath):
    if logger:
      logger.debug("Cloning %s into %s/%s/%s",
                   YOMPURL,
                   fakeroot,
                   installDirectory,
                   repoDirectory)
    YOMP.clone(YOMPURL, directory=repoDirectory)
    workDirectory = "%s/%s/%s" % (fakeroot, installDirectory, repoDirectory)
    with changeToWorkingDir(workDirectory):
      if sha:
        YOMP.resetHard()
        logger.debug("Checking out SHA %s in %s", sha, workDirectory)
        YOMP.checkout(sha)
      else:
        logger.debug("No SHA specified, using head of master")
      return YOMP.getCurrentSha()
示例#2
0
def YOMPCloneIntoFakeroot(fakeroot,
                          installDirectory,
                          repoDirectory,
                          YOMPURL,
                          sha=None,
                          logger=None):
    """
  Clone a YOMP repository into a specific path in a fakeroot

  @param fakeroot: path to the directory to use as the root of the RPM's
    install tree

  @param installDirectory: Where to put the new YOMP clone

  @param repoDirectory: what to name the cloned directory

  @param YOMPURL: YOMP URL used to clone

  @param sha (optional): SHA to checkout once we've cloned the repository

  @param logger - Optional logger object, will be used to output more
  debugging information.

  @returns the SHA of the resulting YOMP clone. We may not have been invoked
  with a specific SHA (we normally build tip of master, for example), but we
  always want to include the exact SHA packaged in our RPM descriptions.
  """
    if logger:
        logger.debug("Prepping fakeroot in %s", fakeroot)
    installPath = "%s/%s" % (fakeroot, installDirectory)
    with changeToWorkingDir(installPath):
        if logger:
            logger.debug("Cloning %s into %s/%s/%s", YOMPURL, fakeroot,
                         installDirectory, repoDirectory)
        YOMP.clone(YOMPURL, directory=repoDirectory)
        workDirectory = "%s/%s/%s" % (fakeroot, installDirectory,
                                      repoDirectory)
        with changeToWorkingDir(workDirectory):
            if sha:
                YOMP.resetHard()
                logger.debug("Checking out SHA %s in %s", sha, workDirectory)
                YOMP.checkout(sha)
            else:
                logger.debug("No SHA specified, using head of master")
            return YOMP.getCurrentSha()
示例#3
0
def prepFakerootFromGit(fakeroot,
                        installDirectory,
                        repoDirectory,
                        YOMPURL,
                        sha=None):
  """Clone a YOMP repository and make a fakeroot out of it.

  :param fakeroot: path to the directory to use as the root of the RPM's
    install tree
  :param installDirectory: Where to put the new YOMP clone
  :param repoDirectory: what to name the cloned directory
  :param YOMPURL: YOMP URL used to clone
  :param sha (optional): SHA to checkout once we've cloned the repository
  """

  g_logger.debug("Prepping fakeroot in %s", fakeroot)
  installPath = commonFakerootPrep(fakeroot, installDirectory)
  with changeToWorkingDir(installPath):
    g_logger.info("Cloning %s into %s/%s/%s",
                                        YOMPURL,
                                        fakeroot,
                                        installDirectory,
                                        repoDirectory)
    YOMP.clone(YOMPURL, directory=repoDirectory)
    workDirectory = "%s/%s/%s" % (fakeroot, installDirectory, repoDirectory)
    if sha:
      with changeToWorkingDir(workDirectory):
        g_logger.info("Checking out SHA %s in %s", sha, workDirectory)
        YOMP.checkout(sha)
        YOMP.resetHard()
    else:
      g_logger.info("No sha specified, using head of master")
    YOMPVersionData = loadGitDescribeFromDirectory(workDirectory)
    sourceFiles = os.listdir("%s/%s/%s" % (fakeroot,
                                           installDirectory,
                                           repoDirectory))
    for directoryEntry in sourceFiles:
      cleanseFakeroot(fakeroot,
                      installDirectory,
                      "%s/%s" % (repoDirectory, directoryEntry))
    cleanseFakeroot(fakeroot, installDirectory, repoDirectory)
  return YOMPVersionData