From patchwork Wed Mar 7 20:27:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yann E. MORIN" X-Patchwork-Id: 882778 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=free.fr Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="X8OWMrL1"; dkim-atps=neutral Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zxQDh3Vjfz9sdB for ; Thu, 8 Mar 2018 07:27:32 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id B184688C96; Wed, 7 Mar 2018 20:27:28 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4MOQk832PJyJ; Wed, 7 Mar 2018 20:27:25 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 3693D88C6D; Wed, 7 Mar 2018 20:27:25 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 00F741BFFA2 for ; Wed, 7 Mar 2018 20:27:24 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id F1A6B89CCA for ; Wed, 7 Mar 2018 20:27:23 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id eV70EsCGBGNs for ; Wed, 7 Mar 2018 20:27:23 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wr0-f196.google.com (mail-wr0-f196.google.com [209.85.128.196]) by hemlock.osuosl.org (Postfix) with ESMTPS id C949F89CB8 for ; Wed, 7 Mar 2018 20:27:22 +0000 (UTC) Received: by mail-wr0-f196.google.com with SMTP id k9so3478238wre.9 for ; Wed, 07 Mar 2018 12:27:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=Re/RVXZuctKJZZfA4hW8aYlSMiZ9fSPJ4imLlsvgyUY=; b=X8OWMrL1bZ1L2bkDKPe/SO5UNEtrsBDORV2Z/8ieAGoYjqJ1weU+2lyh935SPwxLAR StaidBlGcd9kT0xJW1sAZL7UyXsitDuCNtQFSqFntVI8oFMMS9JbvMzZvxFUJ2LHnAby U95cTztRqVKyUWJ/ACQL9BDGWbthUxIhXjEKqO4Dl3Y+F9Ebr/Utni0zPte30UsRzcip BYDaOD2JeNTvxmkt7aGU8ZYyizLur9hZipva0wfibdthkNaCwqSmecDVYh+TY+uZULzz Sc7lDvm3hkR3oo2IDON+nU9xVDcAh1ceR9ZCfR7cJ5Lzob9SBIGFeceiI2xJefYrOjgb FjYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=Re/RVXZuctKJZZfA4hW8aYlSMiZ9fSPJ4imLlsvgyUY=; b=XPCcuMH/nP+o74a/NXTBOfHq56VNpLMu7BZ1Q6zC3vxmrimUaSAF72D4H+nBdwiHtU LRrHEY7BQfDLwfkravIOQMFo+CaAu8snirsY8mDHJvw58iluHq5lBYYq51iGFSg1QRl4 iuNsB2Tvy29oXqJ7mIVMrnNz44erHshSOks/xLI4rvEyycoIp4HxBknP/hmhMtL+he0q TbQ6jArCW9JGfvOVr6r/GBWh6UNOcvLJfEqRZbDHdSrC5xt1j9J+31TpLSnznToCBEnT BT+MlLvCxg3S/MhDEgprlZ8ncWwM+81KI/AA1Sncf0qglEubERACCRdvan/fmHzcyFpp BpCQ== X-Gm-Message-State: APf1xPBfUuYVaKkzJ7DDN/lTgOa3HDjLsBc/zL+zoYvXRhb3M4hcd53E RQk/LGG9BL6wUnB2o7uZXWXzzQ== X-Google-Smtp-Source: AG47ELt392gX0cEMeOW5R1Um72W4yD5qTwmEyXsPN65/zxCeZJ4Iz8NBH7GXGSAqas4reF9Awa1zmQ== X-Received: by 10.223.128.201 with SMTP id 67mr19769603wrl.131.1520454440893; Wed, 07 Mar 2018 12:27:20 -0800 (PST) Received: from scaer.bzh.lan (2a01cb0886107300a556795e0851f8aa.ipv6.abo.wanadoo.fr. [2a01:cb08:8610:7300:a556:795e:851:f8aa]) by smtp.gmail.com with ESMTPSA id g7sm15993564wrb.78.2018.03.07.12.27.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Mar 2018 12:27:19 -0800 (PST) From: "Yann E. MORIN" To: buildroot@buildroot.org Date: Wed, 7 Mar 2018 21:27:18 +0100 Message-Id: <8a08e5fbfab7e4d021565077544576ad495c8097.1520454419.git.yann.morin.1998@free.fr> X-Mailer: git-send-email 2.14.1 In-Reply-To: References: Subject: [Buildroot] [PATCH 1/2] spport/check-bin-arch: accept arbitrary ignore paths X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.24 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Yann E. MORIN" , Thomas Petazzoni MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" Some packages (mostly, out-of-tree) may want to install binary blobs for another architecture, outside the locations we currently exclude, like in /opt or whatever... Add support in check-bin-arch to accept any arbitrary location, that individual package can each request to excude from the check, when they are installed. Signed-off-by: "Yann E. MORIN" Cc: Peter Korsgaard Cc: Thomas Petazzoni --- docs/manual/adding-packages-generic.txt | 7 ++++ package/pkg-generic.mk | 1 + support/scripts/check-bin-arch | 58 ++++++++++++++++++++------------- 3 files changed, 44 insertions(+), 22 deletions(-) diff --git a/docs/manual/adding-packages-generic.txt b/docs/manual/adding-packages-generic.txt index 63ea51bf89..1f5d92d2c9 100644 --- a/docs/manual/adding-packages-generic.txt +++ b/docs/manual/adding-packages-generic.txt @@ -453,6 +453,13 @@ information is (assuming the package name is +libfoo+) : FLAT binary format is only 4k bytes. If the application consumes more stack, append the required number here. +* +LIBFOO_BIN_ARCH_EXCLUDE+ is a space-separated list of path (relative + to the target directory) to ignore when checking that the package + installs correctly cross-compiled binaries. You seldom need to set this + variable, unless the package installs installs binary blobs in the + non-default locations: `/lib/firmware`, `/usr/lib/firmware`, + `/lib/modules`, and `/usr/share`. + The recommended way to define these variables is to use the following syntax: diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk index a2a12e7b56..9eddaeee57 100644 --- a/package/pkg-generic.mk +++ b/package/pkg-generic.mk @@ -112,6 +112,7 @@ define check_bin_arch $(if $(filter end-install-target,$(1)-$(2)),\ support/scripts/check-bin-arch -p $(3) \ -l $(BUILD_DIR)/packages-file-list.txt \ + $(foreach i,$($(PKG)_BIN_ARCH_EXCLUDE),-i "$(i)") \ -r $(TARGET_READELF) \ -a $(BR2_READELF_ARCH_NAME)) endef diff --git a/support/scripts/check-bin-arch b/support/scripts/check-bin-arch index f6a4569c62..922791ab89 100755 --- a/support/scripts/check-bin-arch +++ b/support/scripts/check-bin-arch @@ -1,18 +1,47 @@ #!/usr/bin/env bash -while getopts p:l:r:a: OPT ; do +# List of hardcoded paths that should be ignored, as they may +# contain binaries for an architecture different from the +# architecture of the target. +declare -a IGNORES=( + # Skip firmware files, they could be ELF files for other + # architectures + "/lib/firmware" + "/usr/lib/firmware" + + # Skip kernel modules + # When building a 32-bit userland on 64-bit architectures, the kernel + # and its modules may still be 64-bit. To keep the basic + # check-bin-arch logic simple, just skip this directory. + "/lib/modules" + + # Skip files in /usr/share, several packages (qemu, + # pru-software-support) legitimately install ELF binaries that + # are not for the target architecture + "/usr/share" +) + +while getopts p:l:r:a:i: OPT ; do case "${OPT}" in p) package="${OPTARG}";; l) pkg_list="${OPTARG}";; r) readelf="${OPTARG}";; a) arch_name="${OPTARG}";; + i) + # Ensure we do have single '/' as separators, + # and that we have a leading and a trailing one. + IGNORES+=( "$(sed -r -e 's:/+:/:g; s:^/*:/:; s:/*$:/:;' \ + <<<"${OPTARG}" + )" + ) + ;; :) error "option '%s' expects a mandatory argument\n" "${OPTARG}";; \?) error "unknown option '%s'\n" "${OPTARG}";; esac done if test -z "${package}" -o -z "${pkg_list}" -o -z "${readelf}" -o -z "${arch_name}" ; then - echo "Usage: $0 -p -l -r -a " + echo "Usage: $0 -p -l -r -a [-i PATTERN ...]" exit 1 fi @@ -23,26 +52,11 @@ IFS=" " while read f; do - # Skip firmware files, they could be ELF files for other - # architectures - if [[ "${f}" =~ ^/(usr/)?lib/firmware/.* ]]; then - continue - fi - - # Skip kernel modules - # When building a 32-bit userland on 64-bit architectures, the kernel - # and its modules may still be 64-bit. To keep the basic - # check-bin-arch logic simple, just skip this directory. - if [[ "${f}" =~ ^/lib/modules/.* ]]; then - continue - fi - - # Skip files in /usr/share, several packages (qemu, - # pru-software-support) legitimately install ELF binaries that - # are not for the target architecture - if [[ "${f}" =~ ^/usr/share/.* ]]; then - continue - fi + for ignore in "${IGNORES[@]}"; do + if [[ "${f}" =~ ^"${ignore}" ]]; then + continue 2 + fi + done # Skip symlinks. Some symlinks may have absolute paths as # target, pointing to host binaries while we're building.