コード例 #1
0
ファイル: bzr.py プロジェクト: decathorpe/builpy
def get_srcrev_bzr(pkgname, srcname):
    """
    builpy.bzr.get_srcrev_bzr()
    function that returns the current revision number of the source branch
    """
    goto_srcdir(pkgname, srcname)
    rev = subprocess.check_output(["bzr", "revno"]).decode().rstrip('\n\r')
    goto_basedir()

    dbg(pkgname + " repo is at revno: " + rev)
    return rev
コード例 #2
0
ファイル: rpm.py プロジェクト: decathorpe/builpy
def rpmbuild_build_srpm(pkgname):
    """
    builpy.rpm.rpmbuild_build_srpm()
    function that builds srpm in rpmbuild/SRPMS
    prerequisite: execution of rpmbuild_copy_sources()
    """
    check_rpmbuild()

    os.chdir(RPMBUILD_SPECS)
    subprocess.call(["rpmbuild", "-bs", "./" + pkgname + ".spec"])
    goto_basedir()
コード例 #3
0
ファイル: git.py プロジェクト: decathorpe/builpy
def get_srcrev_git(pkgname, srcname):
    """
    builpy.git.get_srcrev_git()
    function that returns the current commit id of the repository
    """
    goto_srcdir(pkgname, srcname)
    rev = subprocess.check_output(["git", "rev-parse", "HEAD"]).decode()
    rev = rev.rstrip('\r\n')[0:8]
    goto_basedir()

    dbg(pkgname + " repo is at commit: " + rev)
    return rev
コード例 #4
0
ファイル: conf.py プロジェクト: decathorpe/builpy
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
コード例 #5
0
ファイル: rpm.py プロジェクト: decathorpe/builpy
def rpmbuild_copy_result(pkgname):
    """
    builpy.rpm.rpmbuild_copy_result()
    function that copies built srpm files to package directory
    """
    check_rpmbuild()

    pkgdir = os.path.join(BASEDIR, pkgname)

    os.chdir(RPMBUILD_SRPMS)

    src_rpms = glob.glob("*.src.rpm")

    for src_rpm in src_rpms:
        subprocess.call(["cp", src_rpm, pkgdir])

    goto_basedir()
コード例 #6
0
ファイル: url.py プロジェクト: decathorpe/builpy
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
コード例 #7
0
ファイル: git.py プロジェクト: decathorpe/builpy
def src_update_git(pkgname, srcname):
    """
    builpy.git.src_update_git()
    function that updates the specified git repository
    """
    rev_old = get_srcrev_git(pkgname, srcname)

    goto_srcdir(pkgname, srcname)
    if DEBUG:
        subprocess.call(["git", "pull", "--rebase"])
    else:
        subprocess.call(["git", "pull", "--rebase", "--quiet"])
    goto_basedir()

    rev_new = get_srcrev_git(pkgname, srcname)

    if rev_new != rev_old:
        return rev_new
    else:
        return 0
コード例 #8
0
ファイル: bzr.py プロジェクト: decathorpe/builpy
def src_export_bzr(pkgname, srcname, pkgvers, keep=True):
    """
    builpy.bzr.src_export_bzr()
    function that exports the specified bzr branch or lightweight checkout
    to a .tar.gz archive
    """
    rev = get_srcrev_bzr(pkgname, srcname)

    strvers = format_version_bzr(pkgvers, rev)
    strpkgv = pkgname + "-" + strvers

    filename = "../" + strpkgv + ".tar.gz"

    goto_srcdir(pkgname, srcname)
    subprocess.call(["bzr", "export", filename])
    if not keep:
        subprocess.call(["rm", "-r", srcname])
    goto_basedir()

    dbg("Export to ../" + strpkgv + ".tar.gz successful.")
コード例 #9
0
ファイル: git.py プロジェクト: decathorpe/builpy
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
コード例 #10
0
ファイル: bzr.py プロジェクト: decathorpe/builpy
def src_update_bzr(pkgname, srcname):
    """
    builpy.bzr.src_update_bzr()
    function that updates the specified bzr branch or lightweight checkout
    """

    rev_old = get_srcrev_bzr(pkgname, srcname)

    goto_srcdir(pkgname, srcname)
    if DEBUG:
        subprocess.call(["bzr", "pull"])
    else:
        subprocess.call(["bzr", "pull", "--quiet"])
    goto_basedir()

    rev_new = get_srcrev_bzr(pkgname, srcname)

    if rev_new != rev_old:
        return rev_new
    else:
        return 0
コード例 #11
0
ファイル: bzr.py プロジェクト: decathorpe/builpy
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
コード例 #12
0
ファイル: rpm.py プロジェクト: decathorpe/builpy
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()
コード例 #13
0
ファイル: git.py プロジェクト: decathorpe/builpy
def src_export_git(pkgname, srcname, pkgvers, keep=True):
    """
    builpy.git.src_export_git()
    function that exports the specified git repository
    """
    rev = get_srcrev_git(pkgname, srcname)

    version_str = format_version_git(pkgvers, rev)
    pkgpver_str = pkgname + "-" + version_str

    prefix_str = "--prefix=" + pkgpver_str + "/"
    target_str = "../" + pkgpver_str + ".tar.gz"

    goto_srcdir(pkgname, srcname)
    ret_code = subprocess.call(["git", "archive", prefix_str, "HEAD", "--output", target_str])
    if not keep:
        subprocess.call(["rm", "-r", srcname])
    goto_basedir()

    if ret_code:
        print("ERROR: Export to " + target_str + ".tar.gz not successful.")
    else:
        dbg("Export to " + target_str + ".tar.gz successful.")
コード例 #14
0
ファイル: copr.py プロジェクト: decathorpe/builpy
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()