From patchwork Tue Mar 12 15:57:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Whitcroft X-Patchwork-Id: 1055502 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44JfkV0f3Qz9s4Y; Wed, 13 Mar 2019 02:57:38 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1h3jmV-000657-Kp; Tue, 12 Mar 2019 15:57:31 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1h3jmQ-00060p-TZ for kernel-team@lists.ubuntu.com; Tue, 12 Mar 2019 15:57:26 +0000 Received: from 1.general.apw.uk.vpn ([10.172.192.78] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1h3jmP-0005AE-UM; Tue, 12 Mar 2019 15:57:26 +0000 From: Andy Whitcroft To: kernel-team@lists.ubuntu.com Subject: [disco/master-next 8/9] UBUNTU: [Packaging] fix-filenames -- handle exact string removal Date: Tue, 12 Mar 2019 15:57:18 +0000 Message-Id: <20190312155719.3532-9-apw@canonical.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190312155719.3532-1-apw@canonical.com> References: <20190312155719.3532-1-apw@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andy Whitcroft Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" We would like to be able to remove full strings from the *.o files, to allow us to remove GCC version strings. Fix up handling of this edge case. Also fix up filename reporting so we do not break when doing non-prefix removal. BugLink: http://bugs.launchpad.net/bugs/1764792 Signed-off-by: Andy Whitcroft --- debian/scripts/fix-filenames.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/debian/scripts/fix-filenames.c b/debian/scripts/fix-filenames.c index e58dc72f8f94..f1367922655c 100644 --- a/debian/scripts/fix-filenames.c +++ b/debian/scripts/fix-filenames.c @@ -48,7 +48,7 @@ main(int argc, char *argv[]) exit(1); } size = in_info.st_size; - printf("%s %ld bytes\n", in_name + prefix_len + 1, size); + printf("%s %ld bytes\n", in_name, size); in = mmap((void *)0, size, PROT_READ|PROT_WRITE, MAP_SHARED, in_fd, (off_t)0); if (!in) { @@ -61,13 +61,21 @@ main(int argc, char *argv[]) continue; if (strncmp(in, prefix, prefix_len) != 0) continue; - length = strlen(in + prefix_len + 1) + 1; + /* In the case of an exact match there there is nothing to move. */ + if (in[prefix_len] == '\0') + length = 0; + /* If this is a filename, strip the leading slash. */ + else if (in[prefix_len] == '/') + length = strlen(in + prefix_len + 1) + 1; + /* Otherwise just keep the suffix. */ + else + length = strlen(in + prefix_len) + 1; /* * Copy the suffix portion down to the start and clear * the remainder of the space to 0. */ memmove(in, in + prefix_len + 1, length); - memset(in + length, '_', prefix_len); + memset(in + length, '\0', prefix_len); } }