forked from Mirror/pmbootstrap
get_upstream_aport: change arg to pkgname (!1811)
This commit is contained in:
parent
c3a9452ccb
commit
3ce1ea277c
4 changed files with 24 additions and 12 deletions
|
@ -24,7 +24,7 @@ import pmb.helpers.run
|
||||||
def generate(args, pkgname):
|
def generate(args, pkgname):
|
||||||
# Copy original aport
|
# Copy original aport
|
||||||
arch = pkgname.split("-")[1]
|
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"])
|
pmb.helpers.run.user(args, ["cp", "-r", upstream, args.work + "/aportgen"])
|
||||||
|
|
||||||
# Architectures to build this package for
|
# Architectures to build this package for
|
||||||
|
|
|
@ -19,6 +19,7 @@ along with pmbootstrap. If not, see <http://www.gnu.org/licenses/>.
|
||||||
import fnmatch
|
import fnmatch
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
|
import glob
|
||||||
import pmb.helpers.git
|
import pmb.helpers.git
|
||||||
|
|
||||||
|
|
||||||
|
@ -149,26 +150,37 @@ def rewrite(args, pkgname, path_original, fields={}, replace_pkgname=None,
|
||||||
handle.truncate()
|
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.
|
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.
|
:param pkgname: package name
|
||||||
"main/gcc"
|
|
||||||
:returns: absolute path on disk where the Alpine aport is checked out
|
:returns: absolute path on disk where the Alpine aport is checked out
|
||||||
example: /opt/pmbootstrap_work/cache_git/aports/upstream/main/gcc
|
example: /opt/pmbootstrap_work/cache_git/aports/upstream/main/gcc
|
||||||
"""
|
"""
|
||||||
# APKBUILD
|
# APKBUILD
|
||||||
pmb.helpers.git.clone(args, "aports_upstream")
|
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",
|
apkbuild = pmb.parse.apkbuild(args, aport_path + "/APKBUILD",
|
||||||
check_pkgname=False)
|
check_pkgname=False)
|
||||||
apkbuild_version = apkbuild["pkgver"] + "-r" + apkbuild["pkgrel"]
|
apkbuild_version = apkbuild["pkgver"] + "-r" + apkbuild["pkgrel"]
|
||||||
|
|
||||||
# Binary package
|
# Binary package
|
||||||
split = upstream_path.split("/", 1)
|
split = aport_path.split("/")
|
||||||
repo = split[0]
|
repo = split[-2]
|
||||||
pkgname = split[1]
|
pkgname = split[-1]
|
||||||
index_path = pmb.helpers.repo.alpine_apkindex_path(args, repo)
|
index_path = pmb.helpers.repo.alpine_apkindex_path(args, repo)
|
||||||
package = pmb.parse.apkindex.package(args, pkgname, indexes=[index_path])
|
package = pmb.parse.apkindex.package(args, pkgname, indexes=[index_path])
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ def generate(args, pkgname):
|
||||||
prefix = pkgname.split("-")[0]
|
prefix = pkgname.split("-")[0]
|
||||||
arch = pkgname.split("-")[1]
|
arch = pkgname.split("-")[1]
|
||||||
if prefix == "gcc":
|
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)"
|
based_on = "main/gcc (from Alpine)"
|
||||||
elif prefix == "gcc4":
|
elif prefix == "gcc4":
|
||||||
upstream = args.aports + "/main/gcc4"
|
upstream = args.aports + "/main/gcc4"
|
||||||
|
|
|
@ -52,7 +52,7 @@ def test_aportgen_compare_output(args, tmpdir, monkeypatch):
|
||||||
|
|
||||||
# Override get_upstream_aport() to point to testdata
|
# Override get_upstream_aport() to point to testdata
|
||||||
def func(args, upstream_path):
|
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)
|
monkeypatch.setattr(pmb.aportgen.core, "get_upstream_aport", func)
|
||||||
|
|
||||||
# Run aportgen and compare output
|
# Run aportgen and compare output
|
||||||
|
@ -99,8 +99,8 @@ def test_aportgen_get_upstream_aport(args, monkeypatch):
|
||||||
|
|
||||||
# Equal version
|
# Equal version
|
||||||
func = pmb.aportgen.core.get_upstream_aport
|
func = pmb.aportgen.core.get_upstream_aport
|
||||||
upstream = "main/gcc"
|
upstream = "gcc"
|
||||||
upstream_full = args.work + "/cache_git/aports_upstream/" + upstream
|
upstream_full = args.work + "/cache_git/aports_upstream/main/" + upstream
|
||||||
apkbuild = {"pkgver": "2.0", "pkgrel": "0"}
|
apkbuild = {"pkgver": "2.0", "pkgrel": "0"}
|
||||||
package = {"version": "2.0-r0"}
|
package = {"version": "2.0-r0"}
|
||||||
assert func(args, upstream) == upstream_full
|
assert func(args, upstream) == upstream_full
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue