Esempio n. 1
0
 def test_prepare(self):
     checked_osg_build(["prepare", self.pkg_dir])
     srcdir = opj(self.pkg_dir, C.WD_RESULTS, "BUILD", "mash-0.5.22")
     self.assertTrue(os.path.exists(srcdir), "SRPM not unpacked")
     try:
         checked_call(["grep", "-q", "LCMAPS plugins", opj(srcdir, "mash/multilib.py")])
     except CalledProcessError:
         self.fail("Patches not applied")
Esempio n. 2
0
def download_srpm(url, output=None):
    """Download an srpm from url. Return the filename."""
    # TODO: This should probably use urllib2
    if output is None:
        output = os.path.basename(url)
    cmd = ["wget", "-q", url, "-O", output]
    utils.checked_call(cmd)
    return output
Esempio n. 3
0
    def test_github_fetch(self):
        svn_export('native/redhat/branches/matyas/osg-build', '{2017-04-26}',
                   'osg-build1')
        checked_call(["python", "-m", "osgbuild.fetch_sources", "osg-build1"])
        contents = get_listing('osg-build1')

        self.assertTrue("osg-build.spec" in contents, "spec file not found")
        self.assertTrue("osg-build-1.8.90.tar.gz" in contents,
                        "source tarball not found")
Esempio n. 4
0
    def test_github_fetch_spec(self):
        svn_export('native/redhat/trunk/osg-build', '{2018-01-24}',
                   'osg-build2')
        checked_call(["python", "-m", "osgbuild.fetch_sources", "osg-build2"])
        contents = get_listing('osg-build2')

        self.assertTrue("osg-build.spec" in contents, "spec file not found")
        self.assertTrue("osg-build-1.11.1.tar.gz" in contents,
                        "source tarball not found")
Esempio n. 5
0
    def test_cache_fetch(self):
        common_setUp(opj(TRUNK, "mash"), "{2011-12-08}")
        checked_call(["python", "-m", "osgbuild.fetch_sources", "mash"])
        contents = get_listing('mash')

        self.assertTrue("mash.spec" in contents, "spec file not found")
        self.assertTrue("mash-0.5.22.tar.gz" in contents,
                        "source tarball not found")
        head_out = checked_backtick(["head", "-n", "15", "mash/mash.spec"])
        self.assertRegexpMatches(head_out, r"Patch0:\s+multilib-python.patch",
                                 "Spec file not overridden")
Esempio n. 6
0
    def test_fetch(self):
        os.chdir('mash')
        checked_call("../fetch-sources")
        contents = get_listing('.')

        self.assertTrue("mash.spec" in contents, "spec file not found")
        self.assertTrue("mash-0.5.22.tar.gz" in contents,
                        "source tarball not found")
        head_out = checked_backtick(["head", "-n", "15", "mash.spec"])
        self.assertRegexpMatches(head_out, r"Patch0:\s+multilib-python.patch",
                                 "Spec file not overridden")
Esempio n. 7
0
 def test_prepare(self):
     checked_osg_build(["prepare", self.pkg_dir])
     srcdir = opj(self.pkg_dir, C.WD_RESULTS, "BUILD", "mash-0.5.22")
     self.assertTrue(os.path.exists(srcdir), "SRPM not unpacked")
     try:
         checked_call([
             "grep", "-q", "LCMAPS plugins",
             opj(srcdir, "mash/multilib.py")
         ])
     except CalledProcessError:
         self.fail("Patches not applied")
Esempio n. 8
0
def extract_orig_spec(osg_dir):
    """Save a copy of the original upstream spec file from before the
    import into the osg_dir
    """
    utils.pushd(osg_dir)
    try:
        utils.checked_call(['osg-build', 'prebuild', '..'])
        spec_paths = list(glob.glob("../_upstream_srpm_contents/*.spec"))
        for spec_path in spec_paths:
            spec_name_orig = os.path.basename(spec_path) + '.orig'
            logging.info("Saving original upstream spec file as %s",
                         spec_name_orig)
            shutil.copy(spec_path, spec_name_orig)
    finally:
        utils.popd()
Esempio n. 9
0
def extract_orig_spec(osg_dir):
    """Save a copy of the original upstream spec file from before the
    import into the osg_dir
    """
    utils.pushd(osg_dir)
    try:
        utils.checked_call(['osg-build', 'prebuild', '..'])
        spec_paths = list(glob.glob("../_upstream_srpm_contents/*.spec"))
        for spec_path in spec_paths:
            spec_name_orig = os.path.basename(spec_path) + '.orig'
            logging.info("Saving original upstream spec file as %s",
                         spec_name_orig)
            shutil.copy(spec_path, spec_name_orig)
    finally:
        utils.popd()
Esempio n. 10
0
def make_svn_tree(srpm, url, extra_action=None, provider=None, sha1sum=None):
    """Create an svn tree for the srpm and populate it as follows:
    $name/osg/*.spec        - the spec file as extracted from the srpm
                              (if extract_spec is True)
    $name/upstream/*.source - the location of the srpm under the upstream cache
                              as well as a comment describing where it's from

    """
    name, version = srpm_nvr(srpm)[0:2]
    abs_srpm = os.path.abspath(srpm)

    package_dir = os.path.abspath(os.getcwd())
    if os.path.basename(package_dir) != name:
        package_dir = os.path.join(package_dir, name)

    if not os.path.exists(package_dir):
        utils.checked_call(["svn", "mkdir", package_dir])

    osg_dir = os.path.join(package_dir, "osg")
    if extra_action == EXTRA_ACTION_DIFF_SPEC:
        diff_spec(abs_srpm, osg_dir, want_diff3=False)
    elif extra_action == EXTRA_ACTION_EXTRACT_SPEC:
        extract_spec(abs_srpm, osg_dir)
    elif extra_action == EXTRA_ACTION_DIFF3_SPEC:
        if os.path.isdir(osg_dir):
            extract_orig_spec(osg_dir)
        diff_spec(abs_srpm, osg_dir, want_diff3=True)
    elif extra_action == EXTRA_ACTION_UPDATE:
        if os.path.isdir(osg_dir):
            logging.info("osg dir found -- doing 3-way diff")
            extract_orig_spec(osg_dir)
            diff_spec(abs_srpm, osg_dir, want_diff3=True)
        else:
            logging.info("osg dir not found -- updating .source file only")

    upstream_dir = os.path.join(package_dir, "upstream")

    if not os.path.exists(upstream_dir):
        utils.checked_call(["svn", "mkdir", upstream_dir])

    cached_filename = os.path.join(name, version, os.path.basename(srpm))

    make_source_file(url, cached_filename, upstream_dir, provider, sha1sum)

    if len(glob.glob(os.path.join(upstream_dir, "*.source"))) > 1:
        logging.info("More than one .source file found in upstream dir.")
        logging.info("Examine them to make sure there aren't duplicates.")
Esempio n. 11
0
def make_svn_tree(srpm, url, extra_action=None, provider=None, sha1sum=None):
    """Create an svn tree for the srpm and populate it as follows:
    $name/osg/*.spec        - the spec file as extracted from the srpm
                              (if extract_spec is True)
    $name/upstream/*.source - the location of the srpm under the upstream cache
                              as well as a comment describing where it's from

    """
    name, version = srpm_nvr(srpm)[0:2]
    abs_srpm = os.path.abspath(srpm)

    package_dir = os.path.abspath(os.getcwd())
    if os.path.basename(package_dir) != name:
        package_dir = os.path.join(package_dir, name)

    if not os.path.exists(package_dir):
        utils.checked_call(["svn", "mkdir", package_dir])

    osg_dir = os.path.join(package_dir, "osg")
    if extra_action == EXTRA_ACTION_DIFF_SPEC:
        diff_spec(abs_srpm, osg_dir, want_diff3=False)
    elif extra_action == EXTRA_ACTION_EXTRACT_SPEC:
        extract_spec(abs_srpm, osg_dir)
    elif extra_action == EXTRA_ACTION_DIFF3_SPEC:
        if os.path.isdir(osg_dir):
            extract_orig_spec(osg_dir)
        diff_spec(abs_srpm, osg_dir, want_diff3=True)
    elif extra_action == EXTRA_ACTION_UPDATE:
        if os.path.isdir(osg_dir):
            logging.info("osg dir found -- doing 3-way diff")
            extract_orig_spec(osg_dir)
            diff_spec(abs_srpm, osg_dir, want_diff3=True)
        else:
            logging.info("osg dir not found -- updating .source file only")

    upstream_dir = os.path.join(package_dir, "upstream")

    if not os.path.exists(upstream_dir):
        utils.checked_call(["svn", "mkdir", upstream_dir])

    cached_filename = os.path.join(name, version, os.path.basename(srpm))

    make_source_file(url, cached_filename, upstream_dir, provider, sha1sum)

    if len(glob.glob(os.path.join(upstream_dir, "*.source"))) > 1:
        logging.info("More than one .source file found in upstream dir.")
        logging.info("Examine them to make sure there aren't duplicates.")
Esempio n. 12
0
    def add_pkg(self, tag, package, owner=None):
        if owner is None:
            owner = self.user

        found = False
        list_pkgs = utils.backtick(self.koji_cmd +
                                   ["list-pkgs", "--package", package])
        for line in list_pkgs.split("\n"):
            fields = re.split(r"\s*", line, 2)
            try:
                if fields[1] == tag:
                    found = True
            except IndexError:
                pass

        if not found:
            cmd = (self.koji_cmd + ["add-pkg", tag, package, "--owner", owner])
            log.info("Calling koji to add the package to tag %s", tag)
            if not self.dry_run:
                utils.checked_call(cmd)
            else:
                print " ".join(cmd)
Esempio n. 13
0
def extract_from_rpm(rpm, file_or_pattern=None):
    """Extract a specific file or glob from an rpm."""
    command = "rpm2cpio " + utils.shell_quote(rpm) + " | cpio -ivd"
    if file_or_pattern:
        command += " " + utils.shell_quote(file_or_pattern)
    return utils.checked_call(command, shell=True)
Esempio n. 14
0
def extract_from_rpm(rpm, file_or_pattern=None):
    """Extract a specific file or glob from an rpm."""
    command = "rpm2cpio " + utils.shell_quote(rpm) + " | cpio -ivd"
    if file_or_pattern:
        command += " " + utils.shell_quote(file_or_pattern)
    return utils.checked_call(command, shell=True)
Esempio n. 15
0
def checked_osg_build(cmd_args, *args, **kwargs):
    return checked_call(osg_build_command + cmd_args, *args, **kwargs)
Esempio n. 16
0
 def fetch_sources(pdir, nocheck=False):
     cmd = ["python", "-m", "osgbuild.fetch_sources", pdir]
     if nocheck:
         cmd.append("--nocheck")
     checked_call(cmd)
     return get_listing(pdir)
Esempio n. 17
0
 def fetch_sources(pdir, nocheck=False):
     cmd = ["python", "-m", "osgbuild.fetch_sources", pdir]
     if nocheck:
         cmd.append("--nocheck")
     checked_call(cmd)
     return get_listing(pdir)
Esempio n. 18
0
def checked_osg_build(cmd_args, *args, **kwargs):
    return checked_call(osg_build_command + cmd_args, *args, **kwargs)
Esempio n. 19
0
 def clean(self):
     """Clean the mock chroot"""
     utils.checked_call(self.mock_cmd + ["clean"])
Esempio n. 20
0
 def clean(self):
     """Clean the mock chroot"""
     utils.checked_call(self.mock_cmd + ["clean"])