def get_confval(pkgname, section, key): """ builpy.conf.get_confval generic function that reads a value from a package config file """ dbg("Getting value from config file: [" + section + "]: " + key) assert isinstance(section, str) assert isinstance(key, str) goto_pkgdir(pkgname) pkgconfig = configparser.ConfigParser() pkgconfig.read(pkgname + ".conf") value = pkgconfig[section][key] goto_basedir() dbg("Got value from config file: [" + section + "]: " + key + ": " + value) return value
def get_source_url(pkgname, orig, dest=None): """ builpy.url.get_source_url() function that downloads a file via the specified url (wget) curl could also be supported in the future """ quietstr = "--quiet" if DEBUG: quietstr = "--verbose" goto_pkgdir(pkgname) if dest != None: dbg("Downloading source tarball " + orig + " to " + dest + ".") subprocess.call(["wget", quietstr, orig, "-O", dest]) else: dbg("Downloading source tarball " + orig + ".") subprocess.call(["wget", quietstr, orig]) goto_basedir() return None
def get_source_git(pkgname, orig, dest): """ builpy.git.get_source_git() function that downloads the specified git repository (whole or shallow) """ srcname = get_srcname(pkgname) dbg("Checking out git repository " + orig + " to directory " + dest + ".") quietstr = "--quiet" if DEBUG: quietstr = "--verbose" goto_pkgdir(pkgname) subprocess.call(["git", "clone", quietstr, orig, dest]) goto_basedir() dbg("Checkout to " + dest + " successful.") rev = get_srcrev_git(pkgname, srcname) dbg("Revision of checkout: " + rev) return rev
def get_source_bzr(pkgname, orig, dest): """ builpy.bzr.get_source_bzr() function that downloads the specified bzr branch or lightweight checkout """ srcname = get_srcname(pkgname) dbg("Checking out bzr repository " + orig + " to directory " + dest + ".") quietstr = "--quiet" if DEBUG: quietstr = "--verbose" goto_pkgdir(pkgname) subprocess.call(["bzr", "branch", quietstr, orig, "./" + dest]) goto_basedir() dbg("Checkout to " + dest + " successful.") rev = get_srcrev_bzr(pkgname, srcname) dbg("Revision number of checkout: " + rev) return rev
def rpmbuild_copy_sources(pkgname): """ builpy.rpm.rpmbuild_copy_sources() function that copies sources and spec files to rpmbuild directory """ check_rpmbuild() goto_pkgdir(pkgname) conf_file = pkgname + ".conf" spec_file = pkgname + ".spec" patches = glob.glob("*.patch") sources = list() others = list() for archive_type in SUPPORTED_ARCHIVE_TYPES: archive_list = glob.glob(archive_type) for archive in archive_list: sources.append(archive) for other_type in SUPPORTED_OTHER_TYPES: other_list = glob.glob(other_type) for other in other_list: others.append(other) for patch in patches: subprocess.call(["cp", patch, RPMBUILD_SOURCES]) for source in sources: subprocess.call(["mv", source, RPMBUILD_SOURCES]) for other in others: subprocess.call(["cp", other, RPMBUILD_SOURCES]) subprocess.call(["cp", conf_file, RPMBUILD_SOURCES]) subprocess.call(["cp", spec_file, RPMBUILD_SPECS]) goto_basedir()
def copr_build(pkgname, wait=False): """ builpy.copr.copr_build() uploads and builds all srpms in rpmbuild directory """ pkgcopr = get_pkgcopr(pkgname) if not pkgcopr: return None coprrepo = get_coprrepo(pkgname) goto_pkgdir(pkgname) src_rpms = glob.glob("*.src.rpm") for src_rpm in src_rpms: if wait: subprocess.call(["copr-cli", "build", coprrepo, src_rpm]) else: subprocess.call(["copr-cli", "build", "--nowait", coprrepo, src_rpm]) subprocess.call(["rm", src_rpm]) goto_basedir()