From d31a2555bdf0c482d087ba2621b95c42e87016a7 Mon Sep 17 00:00:00 2001 From: Michael Shigorin Date: Mon, 9 Jul 2012 21:50:57 +0300 Subject: [PATCH] non-native ARM support via qemu mkimage and hasher can make use of qemu to run non-native binaries while working on the chroots; thanks kas@, manowar@ and sbolshakov@ for implementing this functionality as well as providing nice examples through mkimage-profiles-arm and mkimage-profile-armrootfs. This required the architecture check to be added since baking a tarball with "arm" as its specified arch and x86_64 inside isn't particularly good thing to let slip through; however the implementation is quite fragile, bugreports and patches are seriously welcome. NB: APTCONF evaluation order between lazy make and nimble shell turned out to be quite a delicate issue in this particular case. --- doc/arm.txt | 18 ++++++++++++++++++ image.in/Makefile | 3 +++ lib/build.mk | 11 ++++++++--- lib/profile.mk | 16 ++++++++++++++-- 4 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 doc/arm.txt diff --git a/doc/arm.txt b/doc/arm.txt new file mode 100644 index 00000000..606feb0f --- /dev/null +++ b/doc/arm.txt @@ -0,0 +1,18 @@ +Для сборки с применением трансляции посредством QEMU +выполните от имени root следующие команды: + +apt-get install qemu-user-binfmt_misc +modprobe binfmt_misc +echo ":arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/.host/qemu-arm:" > /proc/sys/fs/binfmt_misc/register +echo 32768 > /proc/sys/vm/mmap_min_addr + +Если файл /proc/sys/fs/binfmt_misc/register не существует, +потребуется установить и загрузить иное ядро (например, std-def). + +Также нужен sources.list с указанием arm-репозитория +и ссылающийся на него apt.conf (см. apt.conf.sample); +например: + +--- sources.list.sisyphus.arm +rpm http://ftp.altlinux.org/pub/distributions/ALTLinux/Sisyphus arm classic +--- diff --git a/image.in/Makefile b/image.in/Makefile index 5800b0fb..cc3b0356 100644 --- a/image.in/Makefile +++ b/image.in/Makefile @@ -48,6 +48,7 @@ COPY_TREE = ./files # outdir shouldn't be wiped clean before use CLEANUP_OUTDIR ?= +GLOBAL_TARGET := $(ARCH) GLOBAL_HSH_APT_CONFIG := $(wildcard $(APTCONF)) # the lib/build-*.mk comes from features.in/build-*/lib @@ -88,4 +89,6 @@ debug: @echo "TOPDIR=$(TOPDIR)" @echo "IMAGEDIR=$(IMAGEDIR)" @echo "ARCH=$(ARCH)" + @echo "GLOBAL_TARGET=$(GLOBAL_TARGET)" @echo "GLOBAL_HSH_APT_CONFIG=$(GLOBAL_HSH_APT_CONFIG)" + @echo "GLOBAL_HSH_USE_QEMU=$(GLOBAL_HSH_USE_QEMU)" diff --git a/lib/build.mk b/lib/build.mk index acd1f15d..baf407b8 100644 --- a/lib/build.mk +++ b/lib/build.mk @@ -3,7 +3,7 @@ ANSI_OK ?= 1;32 ANSI_FAIL ?= 1;31 MAX_ERRORS = 3 -GOTCHA := ^(((\*\* )?(E:|[Ee]rror|[Ww]arning).*)|(.* (conflicts|Depends:) .*)|(.* (Stop|failed)\.))$$ +GOTCHA := ^(((\*\* )?(E:|[Ee]rror|[Ww]arning).*)|(.* (conflicts|Depends:) .*)|(.* (Stop|failed|not found)\.))$$ ifndef MKIMAGE_PROFILES $(error this makefile is designed to be included in toplevel one) @@ -20,8 +20,13 @@ LOWSPACE = 1024 # it's also nice to know how long and much it takes START += time -f "%E %PCPU %Mk" -ifneq (,$(wildcard $(subst :,/$(ARCH) ,$(PATH):))) -# /usr/bin/{i586,x86_64} are setarch(8) symlinks but arm is not +# /usr/bin/{i586,x86_64} are setarch(8) symlinks but arm is not; +# also check whether non-x86 build is running native +ifeq (,$(wildcard $(subst :,/$(ARCH) ,$(PATH):))) +ifeq (,$(findstring $(ARCH),$(shell uname -m))) +export GLOBAL_HSH_USE_QEMU=$(ARCH) +endif +else START += $(ARCH) endif diff --git a/lib/profile.mk b/lib/profile.mk index 56164dd9..f3d85f18 100644 --- a/lib/profile.mk +++ b/lib/profile.mk @@ -52,13 +52,25 @@ profile/init: distclean fi $(LOG); \ fi; \ { \ - eval `apt-config shell $${APTCONF:+-c=$(wildcard $(APTCONF))} \ + APTCONF="$(wildcard $(APTCONF))"; \ + echo "** using $${APTCONF:-system apt configuration}:"; \ + eval `apt-config shell $${APTCONF:+-c=$$APTCONF} \ SOURCELIST Dir::Etc::sourcelist/f \ SOURCEPARTS Dir::Etc::sourceparts/d`; \ find "$$SOURCEPARTS" -name '*.list' \ - | xargs egrep -Rhv '^#|^[[:blank:]]*$$' "$$SOURCELIST" && \ + | xargs egrep -Rhv '^#|^[[:blank:]]*$$' "$$SOURCELIST" \ + | tee $(BUILDDIR)/sources.list; \ echo; \ } $(LOG); \ + if ! grep -q "[ ]$(ARCH)[ ]" $(BUILDDIR)/sources.list; then \ + echo -n "requested arch '$$ARCH' unavailable" >&2; \ + if [ -z "$(APTCONF)" ]; then \ + echo " (no APTCONF)"; \ + else \ + echo; \ + fi >&2; \ + exit 1; \ + fi; \ if type -t git >&/dev/null; then \ if cd $(BUILDDIR); then \ git init -q && \