Workaround for Qemu aarch64 abuild-tar bug (#907)

See also: <https://github.com/postmarketOS/pmbootstrap/issues/546>
This commit is contained in:
Oliver Smith 2017-11-15 22:28:10 +00:00 committed by GitHub
parent c50ecd7c5a
commit 4c7793e766
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 86 additions and 2 deletions

View File

@ -0,0 +1,25 @@
pkgname=abuild-aarch64-qemu-workaround
pkgver=3.1.0
pkgrel=0
pkgdesc="Patched abuild-tar that works with Qemu"
url="https://github.com/postmarketOS/pmbootstrap/issues/546"
arch="aarch64"
license="GPL2"
depends=""
install="$pkgname.post-install"
options="!check"
source="abuild-$pkgver.tar.gz::https://github.com/alpinelinux/abuild/archive/v$pkgver.tar.gz write-check-count.patch"
makedepends="libressl-dev"
builddir="$srcdir/abuild-$pkgver"
build() {
make VERSION="$pkgver-r$pkgrel" abuild-tar
}
package() {
cd "$builddir"
install -Dm755 abuild-tar "$pkgdir"/usr/bin/abuild-tar-patched
}
sha512sums="fcdbef96b06a908148d6df41981fca19fe1767274b283efbb3f1adaefc074a4daa7b8eea8d49c533858c464e45b3954f97cd3d0185f0ed7e464244f9802001f5 abuild-3.1.0.tar.gz
a80c55fe6cb6cc410ca409558c1e1ab8edec9a675031c404cec84c19b4b8460fbbba92db5c1401c0027f8fc0f5be4b82177ec2fad9d734cbc50ca24bfe6e149f write-check-count.patch"

View File

@ -0,0 +1,2 @@
#!/bin/sh
ln -svf /usr/bin/abuild-tar-patched /usr/local/bin/abuild-tar

View File

@ -0,0 +1,13 @@
--- a/abuild-tar.c
+++ b/abuild-tar.c
@@ -156,7 +156,9 @@ static ssize_t full_write(int fd, const void *buf, size_t count)
count -= n;
} while (1);
- if (total == 0 && n < 0)
+ // Workaround for Qemu bug: also check for count:
+ // <https://github.com/postmarketOS/pmbootstrap/issues/546>
+ if (total == 0 && n < 0 && count)
return -errno;
return total;

View File

@ -23,3 +23,4 @@ from pmb.build.other import copy_to_buildpath, is_necessary, \
symlink_noarch_packages, find_aport, ccache_stats, index_repo
from pmb.build.package import package
from pmb.build.menuconfig import menuconfig
from pmb.build.qemu_workaround_aarch64 import qemu_workaround_aarch64

View File

@ -20,6 +20,7 @@ import os
import logging
import glob
import pmb.build
import pmb.config
import pmb.chroot
import pmb.chroot.apk
@ -83,5 +84,11 @@ def init(args, suffix="native"):
pmb.chroot.root(args, ["sed", "-i", "-e", "s/^CLEANUP=.*/CLEANUP=''/",
"/etc/abuild.conf"], suffix)
# Qemu workaround (aarch64 only)
arch = pmb.parse.arch.from_chroot_suffix(args, suffix)
emulate = pmb.parse.arch.cpu_emulation_required(args, arch)
if emulate and arch == "aarch64":
pmb.build.qemu_workaround_aarch64(args, suffix)
# Mark the chroot as initialized
pmb.chroot.root(args, ["touch", marker], suffix)

View File

@ -29,7 +29,8 @@ import pmb.parse
import pmb.parse.arch
def package(args, pkgname, carch, force=False, buildinfo=False, strict=False):
def package(args, pkgname, carch, force=False, buildinfo=False, strict=False,
init_buildenv=True):
"""
Build a package with Alpine Linux' abuild.
@ -57,7 +58,8 @@ def package(args, pkgname, carch, force=False, buildinfo=False, strict=False):
return
# Initialize build environment, install/build makedepends
pmb.build.init(args, suffix)
if init_buildenv:
pmb.build.init(args, suffix)
if len(apkbuild["makedepends"]):
if strict:
for makedepend in apkbuild["makedepends"]:

View File

@ -0,0 +1,34 @@
"""
Copyright 2017 Oliver Smith
This file is part of pmbootstrap.
pmbootstrap is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
pmbootstrap is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with pmbootstrap. If not, see <http://www.gnu.org/licenses/>.
"""
import pmb.build.package
import pmb.chroot.apk
def qemu_workaround_aarch64(args, suffix="buildroot_aarch64"):
"""
Qemu has a bug in aarch64 emulation, that causes abuild-tar to omit files
from the archives it generates in some cases. We build a patched abuild-tar,
which avoids the bug.
https://github.com/postmarketOS/pmbootstrap/issues/546
"""
pkgname = "abuild-aarch64-qemu-workaround"
pmb.build.package(args, pkgname, "aarch64", True,
init_buildenv=False)
pmb.chroot.apk.install(args, [pkgname], suffix, False)