From patchwork Tue Nov 26 13:03:17 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: christian.braunersorensen@prevas.dk X-Patchwork-Id: 294321 X-Patchwork-Delegate: esben@haabendal.dk Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from hugin.dotsrc.org (hugin.dotsrc.org [IPv6:2001:878:346::102]) by ozlabs.org (Postfix) with ESMTP id 766BA2C00B6 for ; Wed, 27 Nov 2013 00:03:28 +1100 (EST) Received: from hugin.dotsrc.org (localhost [127.0.0.1]) by hugin.dotsrc.org (Postfix) with ESMTP id 053183FEF4 for ; Tue, 26 Nov 2013 14:03:24 +0100 (CET) X-Original-To: dev@oe-lite.org Delivered-To: dev@oe-lite.org Received: from mail02.prevas.se (mail02.prevas.se [62.95.78.10]) by hugin.dotsrc.org (Postfix) with ESMTPS id 122C03FDE6 for ; Tue, 26 Nov 2013 14:03:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=prevas.dk; i=@prevas.dk; l=3347; q=dns/txt; s=ironport2; t=1385471001; x=1417007001; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DuO3eDcsNXwqSqO5+Xl7Tkd+Iaggz/ryJXbN/9h7ZQM=; b=K8/0A69xpT4aSrTtrNZZSO0LAG04QflimBaalSDzYhK03tuSvwHRucVQ 9lFSmfc4i+0m+6AkSYynSSBORWtnXQAks5hHC3B85Ioyw6aUDEiumJoda oQwMSSJc5xGcGSzgCMdd6ynkftwCnn56RoOQRA/liOV6vRE2n50gFSU68 M=; X-IronPort-AV: E=Sophos;i="4.93,774,1378850400"; d="scan'208";a="70442" Received: from vmprevas3.prevas.se (HELO smtp.prevas.se) ([172.16.8.103]) by ironport2.prevas.se with ESMTP/TLS/AES128-SHA; 26 Nov 2013 14:03:21 +0100 Received: from localhost (172.16.10.102) by smtp.prevas.se (172.16.8.105) with Microsoft SMTP Server id 14.2.347.0; Tue, 26 Nov 2013 14:03:21 +0100 Received: by localhost (Postfix, from userid 30007) id 47A1E6814DB; Tue, 26 Nov 2013 13:03:21 +0000 (UTC) From: To: Subject: [PATCH 2/4] sdk-image: Use elfwrapper class. Date: Tue, 26 Nov 2013 13:03:17 +0000 Message-ID: X-Mailer: git-send-email 1.8.4 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: dev@oe-lite.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: OE-lite development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dev-bounces@oe-lite.org Errors-To: dev-bounces@oe-lite.org From: Christian Sørensen Signed-off-by: Christian Sørensen --- classes/sdk-image.oeclass | 67 +---------------------------------------------- 1 file changed, 1 insertion(+), 66 deletions(-) diff --git a/classes/sdk-image.oeclass b/classes/sdk-image.oeclass index b2113f4..5870ee2 100644 --- a/classes/sdk-image.oeclass +++ b/classes/sdk-image.oeclass @@ -25,73 +25,8 @@ IMAGE_PREPROCESS_NETFILTER = "" IMAGE_PREPROCESS_NETFILTER:HOST_OS_mingw32 = "image_preprocess_linux_netfilter_headers" IMAGE_PREPROCESS_FUNCS += "${IMAGE_PREPROCESS_NETFILTER}" -SDK_IMAGE_ELF_SOWRAP_DIRS ?= "${base_bindir} ${bindir}" -SDK_IMAGE_ELF_SOWRAP_LD_SO ?= "/lib/ld-linux*.so.2" - -RSTAGE_FIXUP_FUNCS += "${IMAGE_PREPROCESS_ELF_SOWRAP}" -IMAGE_PREPROCESS_ELF_SOWRAP = "" -IMAGE_PREPROCESS_ELF_SOWRAP:HOST_BINFMT_elf = " image_preprocess_elf_sowrap" +inherit elfwrapper IMAGE_PREPROCESS_ELF_SOWRAP:USE_sdk_static = "" -def image_preprocess_elf_sowrap(d): - import stat - import magic - - filemagic = magic.open(magic.MAGIC_NONE) - filemagic.load() - host_elf_re = re.compile(d.get("HOST_ELF")) - ld_so = d.get("SDK_IMAGE_ELF_SOWRAP_LD_SO") - - def is_elf(path): - filetype = filemagic.file(path) - return bool(host_elf_re.match(filetype)) - - def is_static(path): - filetype = filemagic.file(path) - static_re = re.compile(".*statically.*") - return bool(static_re.match(filetype)) - - def sowrap_dir(dir, recursive=False): - if not os.path.exists(dir): - return True - assert os.path.isdir(dir) - ok = True - for file in os.listdir(dir): - path = os.path.join(dir, file) - if os.path.islink(path): - continue - if os.path.isdir(path): - if recursive: - sowrap_dir(path, recursive) - continue - dotpath = "%s/.%s"%(os.path.dirname(path), os.path.basename(path)) - if os.path.exists(dotpath): - print "ERROR: file already exists:", os.path.join(dir, path) - ok = False - continue - if is_elf(path) and is_static(path): - continue - os.rename(path, dotpath) - with open(path, "w") as wrapper: - dirparts = len(os.path.dirname(path).split('/')) - relative_root = "/".join([".."] * dirparts) - wrapper.write("#!/bin/sh\n") - wrapper.write("$(dirname $0)/%s%s $(dirname $0)/%s $*\n"%( - relative_root, ld_so, os.path.basename(dotpath))) - os.chmod(path, stat.S_IRWXU|stat.S_IRWXG|stat.S_IROTH|stat.S_IXOTH) - return True - - bindirs = set(d.get("SDK_IMAGE_ELF_SOWRAP_DIRS").split()) - for dir in bindirs: - recursive=False - if dir.endswith("//"): - recursive=True - dir = dir.strip("/") - rc = sowrap_dir(dir, recursive) - if not rc: - filemagic.close() - return rc - filemagic.close() - return image_preprocess_linux_netfilter_headers () { oenote image_preprocess_linux_netfilter_headers