From patchwork Fri Apr 21 18:58:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abhimanyu Vishwakarma X-Patchwork-Id: 753535 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3w8lQ816j3z9s4s for ; Sat, 22 Apr 2017 04:58:56 +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="vU3oSB1c"; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 5AC2E8AA9A; Fri, 21 Apr 2017 18:58:53 +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 dEM5KtlpkWyP; Fri, 21 Apr 2017 18:58:52 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id EE43E8AA98; Fri, 21 Apr 2017 18:58:51 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 4A49F1C1E8B for ; Fri, 21 Apr 2017 18:58:50 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 3D0E3303F4 for ; Fri, 21 Apr 2017 18:58:50 +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 p2ZiLuJsyNVZ for ; Fri, 21 Apr 2017 18:58:49 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-io0-f194.google.com (mail-io0-f194.google.com [209.85.223.194]) by silver.osuosl.org (Postfix) with ESMTPS id 95E5B301C0 for ; Fri, 21 Apr 2017 18:58:49 +0000 (UTC) Received: by mail-io0-f194.google.com with SMTP id h41so33488134ioi.1 for ; Fri, 21 Apr 2017 11:58:49 -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=EFzGRCgh/zFRqqeJ1I6+H6EiOSFXNBiI7L1nvAsr5qY=; b=vU3oSB1cGogMPfw76+hVqMqWwnfv5vYcNdAfXUR16rbm8SOsQC7zUjoeIfdyTmgter Je6Ge8VCz45Y/WiUHMNH0FX3RWbKzTCtolZFr2jp5ZNAHUFjfYbb0EFpf5SDnt1lhY4Y eo6nXqufjXLiLdzXnNGrQ6TygGnx48ExhPbf7S66SDEekSeYXnuHrmdFs+lu9KzNwVKh oKbkI/K6BSI39QS6I4aOPjL+agHGQPvbaCcKs6yq1goAXZ4mqayB178g8E6D3hPsUAZu /SmdsL5SwgRyEd6fZuDjNbq3NreD/rGycMcfobyWx+JvIySx1UH2lZAhsd59SZQWNVbf KAbw== 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=EFzGRCgh/zFRqqeJ1I6+H6EiOSFXNBiI7L1nvAsr5qY=; b=HDVOCGqSrODEqQH3PAi751zZlEaQe7d0d01wugBB7zKgP/ODvacqFU+kORiI6DS6Xi qG18ZXiM0199JV/CRVpRVGqGWthxvKfcPgnfeH0cH/fAgTNkGZ2tBvuboIrzNMNTOUri K3/koQuD8F0F7wRu9u5udhXlsycrIdg7XJgWKbULhSkbUe7bP5x7DKJZeiDwykwJbJ50 NTywJbHjvRcLlaac95y9d+UEP1ZhNTLkHwwP3T7UNSB+F825NoMU0QzkQP60aef0jk1H A/TSrS2rZ0ZWqyPdnWvCa411u2CiBIqaFXzNO9RLYi8NhxoNEYECmppaaQbdM53Lg0/t tl9w== X-Gm-Message-State: AN3rC/6tpugCtIqz3exwMj5011ZKMUH73Jnc88BvSCI16W8B2uXqj+Hs UkfgIAn65vTBFQ== X-Received: by 10.98.213.138 with SMTP id d132mr13776381pfg.172.1492801128994; Fri, 21 Apr 2017 11:58:48 -0700 (PDT) Received: from localhost.localdomain ([117.247.62.46]) by smtp.gmail.com with ESMTPSA id h14sm17451005pgn.64.2017.04.21.11.58.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Apr 2017 11:58:48 -0700 (PDT) From: Abhimanyu Vishwakarma To: buildroot@buildroot.org Date: Sat, 22 Apr 2017 00:28:38 +0530 Message-Id: <20170421185839.17905-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 v9 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, extra positional argument is also passed along with BR2_ROOTFS_POST_SCRIPT_ARGS. genimage.sh didnt had support to parse positional and optional argument together. Signed-off-by: Abhimanyu Vishwakarma Tested-by: Rahul Bedarkar Reviewed-by: Arnout Vandecappelle (Essensium/Mind) --- Changes v7->v8 - New file Changes v8->v9 - Fix indentation - Use bash basename as script name instead hardcoding support/scripts/genimage.sh | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/support/scripts/genimage.sh b/support/scripts/genimage.sh index 0ed0e8bcc..a2309e224 100755 --- a/support/scripts/genimage.sh +++ b/support/scripts/genimage.sh @@ -1,17 +1,26 @@ #!/bin/bash die() { - echo "Error: $@" >&2 - exit 1 + echo "Error: $@" >&2 + 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