Fix #90: noarch: create symlinks for all supported architectures

* The supported architectures are inside the config now
* Symlinks get created for that list of supported architectures now.
* During initialization, the architecture from the selected device
  gets checked against the list of supported architectures. When
  it is not included, a meaningful exception gets raised.
* the aportgen and (cross-compiler) build tests make use of the
  new variable now (they had armhf and aarch64 hardcoded previously).
This commit is contained in:
Oliver Smith 2017-06-15 02:26:32 +02:00
parent 9ab3270b2a
commit 1adeee70b6
No known key found for this signature in database
GPG Key ID: 5AE7F5513E0885CB
5 changed files with 31 additions and 14 deletions

View File

@ -129,18 +129,17 @@ def symlink_noarch_package(args, arch_apk):
:param arch_apk: for example: x86_64/mypackage-1.2.3-r0.apk
"""
# Create the arch folder
device_arch = args.deviceinfo["arch"]
device_repo = args.work + "/packages/" + device_arch
if not os.path.exists(device_repo):
pmb.chroot.user(args, ["mkdir", "-p", "/home/user/packages/user/" +
device_arch])
for arch in pmb.config.build_device_architectures:
# Create the arch folder
arch_folder = "/home/user/packages/user/" + arch
arch_folder_outside = args.work + "/packages/" + arch
if not os.path.exists(arch_folder_outside):
pmb.chroot.user(args, ["mkdir", "-p", arch_folder])
# Add symlink, rewrite index
device_repo_chroot = "/home/user/packages/user/" + device_arch
pmb.chroot.user(args, ["ln", "-sf", "../" + arch_apk, "."],
working_dir=device_repo_chroot)
index_repo(args, device_arch)
# Add symlink, rewrite index
pmb.chroot.user(args, ["ln", "-sf", "../" + arch_apk, "."],
working_dir=arch_folder)
index_repo(args, arch)
def ccache_stats(args, arch):

View File

@ -109,6 +109,12 @@ chroot_device_nodes = [
# BUILD
#
# Officially supported target architectures for postmarketOS. Only
# specify architectures supported by Alpine here. When creating a noarch
# package, symlinks for all architectures get created - so only specify
# architectures, where we really have device-* packages for.
build_device_architectures = ["armhf", "aarch64"]
# Packages, that will be installed in a chroot before it builds packages
# for the first time
build_packages = ["abuild", "build-base", "ccache"]

View File

@ -194,8 +194,18 @@ def arguments():
# Add convinience shortcuts
setattr(args, "arch_native", pmb.parse.arch.alpine_native())
# Add the deviceinfo (only after initialization)
# Add and verify the deviceinfo (only after initialization)
if args.action != "init":
setattr(args, "deviceinfo", pmb.parse.deviceinfo(args))
arch = args.deviceinfo["arch"]
if (arch != args.arch_native and
arch not in pmb.config.build_device_architectures):
raise ValueError("Arch '" + arch + "' is not officially enabled"
" in postmarketOS yet. However, this should be straight"
" forward. Simply enable it in pmb/config/__init__.py"
" in build_device_architectures, zap your package cache"
" (otherwise you will have issues with noarch packages)"
" and try again. Some other things might break, but"
" they should be easy to fix them.")
return args

View File

@ -25,6 +25,7 @@ import filecmp
sys.path.append(os.path.abspath(
os.path.join(os.path.dirname(__file__) + "/..")))
import pmb.aportgen
import pmb.config
@pytest.fixture
@ -45,7 +46,7 @@ def test_aportgen(args):
# Generate all valid packages
pkgnames = []
for arch in ["armhf", "aarch64"]:
for arch in pmb.config.build_device_architectures:
# gcc twice, so the output folder already exists -> different code path
for pkgname in ["binutils", "musl", "gcc", "gcc"]:
pkgnames.append(pkgname + "-" + arch)

View File

@ -24,6 +24,7 @@ import pytest
sys.path.append(os.path.abspath(
os.path.join(os.path.dirname(__file__) + "/..")))
import pmb.aportgen
import pmb.config
@pytest.fixture
@ -44,5 +45,5 @@ def test_build_cross(args):
"""
Build in non-native chroot, with cross-compiler through distcc.
"""
for arch in ["armhf", "aarch64"]:
for arch in pmb.config.build_device_architectures:
pmb.build.package(args, "hello-world", arch, True)