From patchwork Sun Apr 16 17:40:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abhimanyu Vishwakarma X-Patchwork-Id: 751165 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3w5dwv1xB9z9s3w for ; Mon, 17 Apr 2017 03:41:18 +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="rvrPHh+e"; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 57E3C88150; Sun, 16 Apr 2017 17:41:15 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id l52hJv2W3pHd; Sun, 16 Apr 2017 17:41:14 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 1319A88132; Sun, 16 Apr 2017 17:41:14 +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 87BAA1C0345 for ; Sun, 16 Apr 2017 17:41:12 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 7F4D786E40 for ; Sun, 16 Apr 2017 17:41:12 +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 4lV8QUIJw36S for ; Sun, 16 Apr 2017 17:41:12 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pf0-f196.google.com (mail-pf0-f196.google.com [209.85.192.196]) by hemlock.osuosl.org (Postfix) with ESMTPS id 19EF486E1E for ; Sun, 16 Apr 2017 17:41:12 +0000 (UTC) Received: by mail-pf0-f196.google.com with SMTP id i5so21425789pfc.3 for ; Sun, 16 Apr 2017 10:41:12 -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=c7/9LNQ2BtSneHW9o+4NslTZOHqvn/a2eiyOZsybeIc=; b=rvrPHh+eSk3Ot58KTk1xIOFkiO0+Nf5legMEMpDS/lldbBqHCPb3KUgQ3F5QaFzeAz YxdXLbvJWlsSl4kgaXGmB9dqF6JY3Q1yH1nZyjzlEeiC0QzZ00T0cxWzGIZkMYvOknI5 2ex9Y303JZKP61GO5HRKFqL1olN9U20Z8yriVtjc/Z4ixmlMyrq4QqOxL7Y4i2CTG7Nk MqyeyqPyDR1HEONwca6HfXn/BkNWutUIiTlCcZmkmZ7PxjlMYBfst4PjycYHhASzSoXf C7k5dqZqWsrhz+zUfUPeAixNgyEBZZle2hF7T1McR6n+xLSVK1VYEozmBPudr+9CRAmO qXtw== 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=c7/9LNQ2BtSneHW9o+4NslTZOHqvn/a2eiyOZsybeIc=; b=BQPh7FYQvT3kMI9djcaFEZIpp6yKM4pbFle+1KeOMIiNuSPlYE30oIE5leTXfsvbUL gn5A0syP5GO+cTx8Cfp1NBRz5gGNCt/6Y+Uj0ljqbnREtKfAn0Cd6QrNbNJ/ypWinzcl +nVj2WKhwlRDTvjmhIUKmRldMJYQN/M+w+v+VHXai6N5fUCLqbkGZZkHvpQOuQWtHPBb xsWijU+uTmaR6AQMUJc/ZPjYFkmfZXHDoc/Jp9TIyO1Wi/lttVMr+0w6Mjx7+0D9a5GG 5/pNlP6dwx2pGtm6f61fqN4hl4CStTiudDA+4vk3sXo+IPsi9pDcAgsLUT0W1Gku+9Sj vIqw== X-Gm-Message-State: AN3rC/5hui8jqLFdCgIHGfr3ym4cDduCSzwgKE3T7J2eoZni3ELhoJiC 16ahiwb92nmDWA== X-Received: by 10.98.102.153 with SMTP id s25mr7886485pfj.257.1492364471668; Sun, 16 Apr 2017 10:41:11 -0700 (PDT) Received: from localhost.localdomain ([117.247.62.16]) by smtp.gmail.com with ESMTPSA id s11sm13423956pgc.61.2017.04.16.10.41.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 16 Apr 2017 10:41:11 -0700 (PDT) From: Abhimanyu Vishwakarma To: buildroot@buildroot.org Date: Sun, 16 Apr 2017 23:10:47 +0530 Message-Id: <20170416174048.4737-1-abhimanyu.v@gmail.com> X-Mailer: git-send-email 2.11.0 Cc: thomas.petazzoni@free-electrons.com, Abhimanyu Vishwakarma Subject: [Buildroot] [PATCH v8 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 --- Changes v7->v8 - New file support/scripts/genimage.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/support/scripts/genimage.sh b/support/scripts/genimage.sh index 0ed0e8bcc..2b5549fb0 100755 --- a/support/scripts/genimage.sh +++ b/support/scripts/genimage.sh @@ -5,13 +5,18 @@ die() { exit 1 } +# Parse arguments and put into argument list of the script +eval set -- $(getopt -n genimage.sh -o c: -- "$@") + 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) [ ! -z "$2" ] || die "option '${1}' expects a mandatory argument\n"; + GENIMAGE_CFG="${2}"; + shift 2 ;; + --) shift 1; break ;; + *) die "unknown option '${1}'\n";; esac done