get_upstream_aport: change arg to pkgname (!1811)

This commit is contained in:
Daniele Debernardi 2019-09-12 21:20:08 +02:00
parent c3a9452ccb
commit 3ce1ea277c
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
4 changed files with 24 additions and 12 deletions

View file

@ -24,7 +24,7 @@ import pmb.helpers.run
def generate(args, pkgname):
# Copy original aport
arch = pkgname.split("-")[1]
upstream = pmb.aportgen.core.get_upstream_aport(args, "main/binutils")
upstream = pmb.aportgen.core.get_upstream_aport(args, "binutils")
pmb.helpers.run.user(args, ["cp", "-r", upstream, args.work + "/aportgen"])
# Architectures to build this package for

View file

@ -19,6 +19,7 @@ along with pmbootstrap. If not, see <http://www.gnu.org/licenses/>.
import fnmatch
import logging
import re
import glob
import pmb.helpers.git
@ -149,26 +150,37 @@ def rewrite(args, pkgname, path_original, fields={}, replace_pkgname=None,
handle.truncate()
def get_upstream_aport(args, upstream_path):
def get_upstream_aport(args, pkgname):
"""
Perform a git checkout of Alpine's aports and get the path to the aport.
:param upstream_path: where the aport is in the git repository, e.g.
"main/gcc"
:param pkgname: package name
:returns: absolute path on disk where the Alpine aport is checked out
example: /opt/pmbootstrap_work/cache_git/aports/upstream/main/gcc
"""
# APKBUILD
pmb.helpers.git.clone(args, "aports_upstream")
aport_path = (args.work + "/cache_git/aports_upstream/" + upstream_path)
aports_upstream_path = args.work + "/cache_git/aports_upstream"
# Search package
paths = glob.glob(aports_upstream_path + "/*/" + pkgname)
if len(paths) > 1:
raise RuntimeError("Package " + pkgname + " found in multiple"
" aports subfolders.")
elif len(paths) == 0:
raise RuntimeError("Package " + pkgname + " not found in alpine"
" aports repository.")
aport_path = paths[0]
# Parse APKBUILD
apkbuild = pmb.parse.apkbuild(args, aport_path + "/APKBUILD",
check_pkgname=False)
apkbuild_version = apkbuild["pkgver"] + "-r" + apkbuild["pkgrel"]
# Binary package
split = upstream_path.split("/", 1)
repo = split[0]
pkgname = split[1]
split = aport_path.split("/")
repo = split[-2]
pkgname = split[-1]
index_path = pmb.helpers.repo.alpine_apkindex_path(args, repo)
package = pmb.parse.apkindex.package(args, pkgname, indexes=[index_path])

View file

@ -26,7 +26,7 @@ def generate(args, pkgname):
prefix = pkgname.split("-")[0]
arch = pkgname.split("-")[1]
if prefix == "gcc":
upstream = pmb.aportgen.core.get_upstream_aport(args, "main/gcc")
upstream = pmb.aportgen.core.get_upstream_aport(args, "gcc")
based_on = "main/gcc (from Alpine)"
elif prefix == "gcc4":
upstream = args.aports + "/main/gcc4"

View file

@ -52,7 +52,7 @@ def test_aportgen_compare_output(args, tmpdir, monkeypatch):
# Override get_upstream_aport() to point to testdata
def func(args, upstream_path):
return testdata + "/aports/" + upstream_path
return testdata + "/aports/main/" + upstream_path
monkeypatch.setattr(pmb.aportgen.core, "get_upstream_aport", func)
# Run aportgen and compare output
@ -99,8 +99,8 @@ def test_aportgen_get_upstream_aport(args, monkeypatch):
# Equal version
func = pmb.aportgen.core.get_upstream_aport
upstream = "main/gcc"
upstream_full = args.work + "/cache_git/aports_upstream/" + upstream
upstream = "gcc"
upstream_full = args.work + "/cache_git/aports_upstream/main/" + upstream
apkbuild = {"pkgver": "2.0", "pkgrel": "0"}
package = {"version": "2.0-r0"}
assert func(args, upstream) == upstream_full