def svn_export(path, rev, destpath): """Run svn export on a revision rev of path into destpath""" try: checked_backtick( ["svn", "export", opj(C.SVN_ROOT, path) + "@" + rev, "-r", rev, destpath], err2out=True) except CalledProcessError as err: errprintf("Error in svn export:\n%s", err.output) raise
def svn_export(path, rev, destpath): '''Run svn export on a revision rev of path into destpath''' try: checked_backtick([ "svn", "export", opj(C.SVN_ROOT, path) + "@" + rev, "-r", rev, destpath ], err2out=True) except CalledProcessError as err: errprintf("Error in svn export:\n%s", err.output) raise
def test_github_fetch_with_tarball(self): go_to_temp_dir() tarball = "tarfile.tar.gz" hash = "5ea1914b621cef204879ec1cc55e0216e3812785" os.mkdir("upstream") unslurp( "upstream/github.source", "type=github repo=opensciencegrid/cvmfs-config-osg tag=v2.1-2 tarball=%s hash=%s" % (tarball, hash)) contents = self.fetch_sources(".") self.assertTrue(tarball in contents, "source tarball not found") tarfh = tarfile.open(tarball, "r") try: try: tardir = tarfh.getmember("tarfile") except KeyError: self.fail("directory not found in tarball") self.assertTrue(tardir.isdir(), "directory not a directory in tarball") finally: tarfh.close() tarhash = checked_backtick("gunzip -c %s | git get-tar-commit-id" % tarball, shell=True) self.assertEqual(hash, tarhash, "source tarball has wrong hash")
def do_openssl_lookup(self): cmd = [ "openssl", "x509", "-in", self.filename, "-noout", "-subject", "-nameopt", "multiline", "-dates" ] output = utils.checked_backtick(cmd) self.startdate, self.enddate = self.extract_dates(output) self.first_commonname = self.extract_first_commonname(output)
def test_cache_fetch(self): common_setUp(opj(DEVOPS, "mash"), "{2019-10-01}") contents = self.fetch_sources("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")
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")
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")
def test_prepare(self): checked_osg_build(["prepare", self.pkg_dir]) self.assertTrue( os.path.exists( opj(self.pkg_dir, C.WD_RESULTS, "BUILD", "globus_gatekeeper-8.1")), "SRPM unpacked") head_out = checked_backtick([ "head", "-n", "10", opj(self.pkg_dir, C.WD_RESULTS, "BUILD", "globus_gatekeeper-8.1", "init", "globus-gatekeeper-lsb.in") ]) self.assertRegexpMatches(head_out, r"Default-Stop:\s+0 1 2 3 4 5 6", "Patches not applied")
def get_build_and_dest_tags(self, target): """Return the build and destination tags for the current target.""" line = utils.checked_backtick(self.koji_cmd + ["-q", "list-targets", "--name", target]) if not line: raise KojiError("Unable to find koji target with the name " + target) else: try: fields = re.split(r"\s*", line, 2) target_build_tag = fields[1] target_dest_tag = fields[2] except IndexError: raise KojiError("Unable to determine koji tags from target") return (target_build_tag, target_dest_tag)
def test_cache_fetch(self): common_setUp(opj(TRUNK, "mash"), "{2011-12-08}") contents = self.fetch_sources("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")
def get_cn(): """Return the user's koji login (their CN, unless otherwise specified on the command line. """ subject = utils.checked_backtick("openssl x509 -in '%s' -noout -subject" " -nameopt multiline" % KOJI_CLIENT_CERT) # Get the last commonName cn_match = re.search( r"""(?xms) ^ \s* commonName \s* = \s* ([^\n]+) \s* $ (?!.*commonName)""", subject) if cn_match: return cn_match.group(1) else: return None
def test_github_fetch_with_tarball(self): go_to_temp_dir() tarball = "tarfile.tar.gz" hash = "5ea1914b621cef204879ec1cc55e0216e3812785" os.mkdir("upstream") unslurp("upstream/github.source", "type=github repo=opensciencegrid/cvmfs-config-osg tag=v2.1-2 tarball=%s hash=%s" % (tarball, hash)) contents = self.fetch_sources(".") self.assertTrue(tarball in contents, "source tarball not found") tarfh = tarfile.open(tarball, "r") try: try: tardir = tarfh.getmember("tarfile") except KeyError: self.fail("directory not found in tarball") self.assertTrue(tardir.isdir(), "directory not a directory in tarball") finally: tarfh.close() tarhash = checked_backtick("gunzip -c %s | git get-tar-commit-id" % tarball, shell=True) self.assertEqual(hash, tarhash, "source tarball has wrong hash")
def get_listing(directory): return checked_backtick(["ls", directory]).split("\n")
def backtick_osg_build(cmd_args, *args, **kwargs): kwargs['clocale'] = True kwargs['err2out'] = True return checked_backtick(osg_build_command + cmd_args, *args, **kwargs)
def get_listing(directory): return checked_backtick( ["ls", directory]).split("\n")