From patchwork Mon Apr 24 05:24:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abhimanyu Vishwakarma X-Patchwork-Id: 754105 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wBFCg4sZSz9sCZ for ; Mon, 24 Apr 2017 15:25:03 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="H9Ib5M+J"; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id C4DAF261F7; Mon, 24 Apr 2017 05:24:59 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id iWaPIFtmlPrK; Mon, 24 Apr 2017 05:24:58 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id C3E552E5CE; Mon, 24 Apr 2017 05:24:57 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 1400B1BFB44 for ; Mon, 24 Apr 2017 05:24:56 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 06AED82E0E for ; Mon, 24 Apr 2017 05:24:56 +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 F6ZzgrEM7UFo for ; Mon, 24 Apr 2017 05:24:55 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-it0-f68.google.com (mail-it0-f68.google.com [209.85.214.68]) by whitealder.osuosl.org (Postfix) with ESMTPS id 0B3EA8232A for ; Mon, 24 Apr 2017 05:24:55 +0000 (UTC) Received: by mail-it0-f68.google.com with SMTP id c26so5941411itd.1 for ; Sun, 23 Apr 2017 22:24:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=8/3zX2oDoOVXPKn+k/ZuJdsOcnFTiKNcS6u/l1ROgsY=; b=H9Ib5M+JldmD0wdTUHNoi8aiMdYkizwWo78aABQvb9s8zUZF9X9r1yQbCdxUfb3MMc 8NAZic1l+ZP3SBge/ogGYwqNZtCaVtr6FLpC2H4/2144AKABzGGRCiYJFFOxzKOxrUeq PClVyFHDIrpYXsUv7e3vVlyf0taNqHc3a8fp0uBxN0q8NXNHFw8QcFrIJHmezyu3gqEA CutuHNkG03WRVrZOb2AJodYUfiANqOAPVmsyXrZ84MgRfqvV1ctUNHpBRGqrFbCAq7Rh lFVHu+f7+SKy7LaxrAEIp+dPBoUnD2LWy9PlHNB1xBip6vMSYXqPSRiapEMQIHexaI1w /ugw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=8/3zX2oDoOVXPKn+k/ZuJdsOcnFTiKNcS6u/l1ROgsY=; b=twNXhOzHNKSmIJA9qx1TwO2m+W9E6tTZPd9vyL+bLKbE6CNR0YurCc2G+XObBOErg/ UHqKp2zT1PALj0ajYGhzfxEEiDe6Pz7LIaE4FantOR0cpNr3M5jqj5oVmhMFKQFvAlaj QqCS3OMPgfK1eOXVuv3JqXUKMCmKb7Ix5rAvLOxNr+KnG8vrXdo+A6nNE07SBrFQqvZ9 QXR1ag45S2ngsf3mV2jRSt9K3lOEQbFYu6pQsIi1jmSbbAwJgbUsmhwbZzklTXbebghy qi0Je3hEssCfNvEeGYP2qajJM5cfOuNRIbaRKH2IcvZ0Zh9NfhxSGCRGefj2uh1jkHav vMsw== X-Gm-Message-State: AN3rC/780T/Y+5WcFkndk5n+9KVG3vsQj5kl3MMnwQgDKUxKLPRH2rlK ofnuAlF4lyfU7Q== X-Received: by 10.84.222.135 with SMTP id x7mr30717729pls.50.1493011494277; Sun, 23 Apr 2017 22:24:54 -0700 (PDT) Received: from localhost.localdomain ([117.247.62.66]) by smtp.gmail.com with ESMTPSA id 186sm27928553pfx.72.2017.04.23.22.24.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 23 Apr 2017 22:24:53 -0700 (PDT) From: Abhimanyu Vishwakarma To: buildroot@buildroot.org Date: Mon, 24 Apr 2017 10:54:45 +0530 Message-Id: <20170424052445.7637-1-abhimanyu.v@gmail.com> X-Mailer: git-send-email 2.11.0 Cc: thomas.petazzoni@free-electrons.com, etienne.phelip@savoirfairelinux.com, Abhimanyu Vishwakarma Subject: [Buildroot] [PATCH v10 1/2] genimage.sh: fix calling from BR2_ROOTFS_POST_IMAGE_SCRIPT X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" From: Abhimanyu Vishwakarma When called from BR2_ROOTFS_POST_IMAGE_SCRIPT, this script ends up with following error: Error: Missing argument This is because, an extra positional argument is also passed along with BR2_ROOTFS_POST_SCRIPT_ARGS. genimage.sh didn't have support to parse positional and optional arguments together. Signed-off-by: Abhimanyu Vishwakarma Reviewed-by: Arnout Vandecappelle (Essensium/Mind) Tested-by: Rahul Bedarkar --- Changes v7->v8 - New file Changes v8->v9 - Fix indentation - Use bash basename as script name instead hardcoding (by arnout) Changes v9->v10 (Suggested by Arnout) - Remove tab indentation (use existing 2 space indent) - Fix commit message grammer - add reviewed-by tag - keep tested-by tag as no code change just indentation support/scripts/genimage.sh | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/support/scripts/genimage.sh b/support/scripts/genimage.sh index 0ed0e8bcc..6c8d9e5ad 100755 --- a/support/scripts/genimage.sh +++ b/support/scripts/genimage.sh @@ -5,13 +5,22 @@ die() { exit 1 } +# Parse arguments and put into argument list of the script +opts="$(getopt -n "${0##*/}" -o c: -- "$@")" || exit $? +eval set -- "$opts" + GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp" -while getopts c: OPT ; do - case "${OPT}" in - c) GENIMAGE_CFG="${OPTARG}";; - :) die "option '${OPTARG}' expects a mandatory argument\n";; - \?) die "unknown option '${OPTARG}'\n";; +while true ; do + case "$1" in + -c) + GENIMAGE_CFG="${2}"; + shift 2 ;; + --) # Discard all non-option parameters + shift 1; + break ;; + *) + die "unknown option '${1}'" ;; esac done