From patchwork Sat Jun 10 02:11:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent McIntyre X-Patchwork-Id: 9779601 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1A8F360393 for ; Sat, 10 Jun 2017 02:11:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 041092874B for ; Sat, 10 Jun 2017 02:11:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DBCFB2874F; Sat, 10 Jun 2017 02:11:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B89E2874B for ; Sat, 10 Jun 2017 02:11:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751755AbdFJCLg (ORCPT ); Fri, 9 Jun 2017 22:11:36 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:32998 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751641AbdFJCLf (ORCPT ); Fri, 9 Jun 2017 22:11:35 -0400 Received: by mail-pg0-f65.google.com with SMTP id a70so9098411pge.0 for ; Fri, 09 Jun 2017 19:11:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mime-version:content-disposition :user-agent; bh=vQsmEtsQI2WwTWohYlxv5818FMcQeOmokg2xKEFTbYE=; b=LUB1C1vh7guTkbPjdReRf+OBeWWkRnkNFDJRpE/2oOm+A4ABNtkUrM94Q7b5ZMmdID 54EK2rgaS307cdiFVzLF5ra4ADNUEjLXy/69upml7Vl8s5FciAU4SWtj7/3iAeoWeXjD khy4pSwsT11Tlh7CQ/rjVrJTCyJwoGkqusL2ypNrhESskO2dwKjGlkSVAUX6dVLIg5Qj ErWVPJ8C1ctUY3FINwsvCCLFCpd3LeY9EQ7U46CQUE00WC/cKyFa7TJUnwQ94dUUF64a 7uaUB1Uc5teAb5BqUB3ZTR30ew2CEB6Ep4ONTwmQka6Vp7QcuTkfDzqyD4MgR4yHwxRS RLtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=vQsmEtsQI2WwTWohYlxv5818FMcQeOmokg2xKEFTbYE=; b=Qe41R5wg43eWNwgzq5CVShESSPbvAj9pqylwRIztZtkMWxc+SpXuGAN4IKIWB9ammY xuZw5IAzUT6CVoD6vFvEUSP3JsBoFkxkoCnxRHuqoa6Zv3+uE+a8QWbLUhNmYc2SySUH xxw5VbiWpxEl5Cr93jh3UxXxERxumlLzdZMTQO32c6uSPCZmq9QnbvXBZ7EOQBVpVEej szWQhDO3GNQLbhcMkaNeFoH0MhmWOhg0IC7u8gWABiDv/ElzUJCAUXPjxV61oq6ZjkvX IpjsAbW+a7zFBOmehIMXh319n81h6rhYXJ2Yxnai4v0WxaSaCd2l12Va6vOh30ZpfF8O ukDw== X-Gm-Message-State: AODbwcCB98t0SWHT9ZrqEe1QpOA7eqP87ikpShxOLCgStfxxdj5CfCe+ +AQ92CC4wweZzUi8 X-Received: by 10.98.109.2 with SMTP id i2mr30982755pfc.186.1497060694514; Fri, 09 Jun 2017 19:11:34 -0700 (PDT) Received: from ubuntu.windy (c122-106-153-7.carlnfd1.nsw.optusnet.com.au. [122.106.153.7]) by smtp.gmail.com with ESMTPSA id h68sm1163223pfh.45.2017.06.09.19.11.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Jun 2017 19:11:33 -0700 (PDT) Date: Sat, 10 Jun 2017 12:11:55 +1000 From: Vincent McIntyre To: linux-media@vger.kernel.org Subject: [patch] [media_build] small cleanup of build script (resend) Message-ID: <20170610021153.GB12764@ubuntu.windy> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Original send date: Thu, 1 Jun 2017 20:12:32 +1000 Introduce a function to help tracing of system() calls While debugging a recent issue I wanted more complete information about the sequencence of events in a series of calls like system("foo") or die("BAR") Adding this helper did that and cleaned things up a little. Signed-off-by: Vincent McIntyre --- build | 81 +++++++++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 47 insertions(+), 34 deletions(-) -- diff --git a/build b/build index 4457a73..38ffd4f 100755 --- a/build +++ b/build @@ -342,6 +342,19 @@ sub which($) return undef; } +sub run($$) +{ + my $cmd = shift; + my $err = shift; + $err = '' unless defined($err); + + my ($pkg,$filename,$line) = caller; + + print "\$ $cmd\n" if ($level); + system($cmd) == 0 + or die($err . " at $filename line $line\n"); +} + ###### # Main ###### @@ -406,11 +419,11 @@ if (@git == 2) { if (!$local) { print "Getting the latest Kernel tree. This will take some time\n"; if ($depth) { - system("git clone --origin '$rname/$git[1]' git://linuxtv.org/media_tree.git media $depth") == 0 - or die "Can't clone from the upstream tree"; + run("git clone --origin '$rname/$git[1]' git://linuxtv.org/media_tree.git media $depth", + "Can't clone from the upstream tree"); } else { - system("git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git media $depth") == 0 - or die "Can't clone from the upstream tree"; + run("git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git media $depth", + "Can't clone from the upstream tree"); } system('git --git-dir media/.git config format.cc "Linux Media Mailing List "'); system('git --git-dir media/.git config format.signoff true'); @@ -419,56 +432,54 @@ if (@git == 2) { } else { if ($workdir ne "") { print "Creating a new workdir from $git[0] at media\n"; - system("git new-workdir $git[0] media") == 0 - or die "Can't create a new workdir"; + run("git new-workdir $git[0] media", + "Can't create a new workdir"); } else { print "Creating a new clone\n"; - system("git clone -l $git[0] media $depth") == 0 - or die "Can't create a new clone"; + run("git clone -l $git[0] media $depth", + "Can't create a new clone"); } } } elsif ($workdir eq "") { if (check_git("remote", "$rname/$git[1]")) { - system("git --git-dir media/.git remote update '$rname/$git[1]'") == 0 - or die "Can't update from the upstream tree"; + run("git --git-dir media/.git remote update '$rname/$git[1]'", + "Can't update from the upstream tree"); } else { - system("git --git-dir media/.git remote update origin") == 0 - or die "Can't update from the upstream tree"; + run("git --git-dir media/.git remote update origin", + "Can't update from the upstream tree"); } } if ($workdir eq "") { if (!check_git("remote", "$name")) { print "adding remote $name to track $git[0]\n"; - printf "\$ git --git-dir media/.git remote add $name $git[0]\n" if ($level); - system ("git --git-dir media/.git remote add $name $git[0]") == 0 - or die "Can't create remote $name"; + run("git --git-dir media/.git remote add $name $git[0]", + "Can't create remote $name"); } if (!$depth) { print "updating remote $rname\n"; - system ("git --git-dir media/.git remote update $name") == 0 - or die "Can't update remote $name"; + run("git --git-dir media/.git remote update $name", + "Can't update remote $name"); print "creating a local branch $rname\n"; if (!check_git("branch", "$rname/$git[1]")) { - print "\$ (cd media; git checkout -b $rname/$git[1] remotes/$name/$git[1])\n" if ($level); - system ("(cd media; git checkout -b $rname/$git[1] remotes/$name/$git[1])") == 0 - or die "Can't create local branch $rname"; + run("(cd media; git checkout -b $rname/$git[1] remotes/$name/$git[1])", + "Can't create local branch $rname"); } else { - system ("(cd media; git checkout $rname/$git[1])") == 0 - or die "Can't checkout to branch $rname"; - system ("(cd media; git pull . remotes/$name/$git[1])") == 0 - or die "Can't update local branch $name"; + run("(cd media; git checkout $rname/$git[1])", + "Can't checkout to branch $rname"); + run("(cd media; git pull . remotes/$name/$git[1])", + "Can't update local branch $name"); } } } else { print "git checkout $git[1]\n"; - system ("(cd media; git checkout $git[1])") == 0 - or die "Can't checkout $git[1]"; + run("(cd media; git checkout $git[1])", + "Can't checkout $git[1]"); } - system ("make -C linux dir DIR=../media/") == 0 - or die "Can't link the building system to the media directory."; + run("make -C linux dir DIR=../media/", + "Can't link the building system to the media directory."); } else { print "\n"; print "************************************************************\n"; @@ -486,8 +497,8 @@ if (@git == 2) { print "****************************\n"; system("git pull git://linuxtv.org/media_build.git master"); - system ("make -C linux/ download") == 0 or die "Download failed"; - system ("make -C linux/ untar") == 0 or die "Untar failed"; + run("make -C linux/ download", "Download failed"); + run("make -C linux/ untar", "Untar failed"); } print "**********************************************************\n"; @@ -495,17 +506,19 @@ print "* Downloading firmwares from linuxtv.org. *\n"; print "**********************************************************\n"; if (!stat $firmware_tarball) { - system ("wget $firmware_url/$firmware_tarball -O $firmware_tarball") == 0 or die "Can't download $firmware_tarball"; + run("wget $firmware_url/$firmware_tarball -O $firmware_tarball", + "Can't download $firmware_tarball"); } -system ("(cd v4l/firmware/; tar xvfj ../../$firmware_tarball)") == 0 or die "Can't extract $firmware_tarball"; +run("(cd v4l/firmware/; tar xvfj ../../$firmware_tarball)", + "Can't extract $firmware_tarball"); print "******************\n"; print "* Start building *\n"; print "******************\n"; -system ("make allyesconfig") == 0 or die "can't select all drivers"; -system ("make") == 0 or die "build failed"; +run("make allyesconfig", "can't select all drivers"); +run("make", "build failed"); print "**********************************************************\n"; print "* Compilation finished. Use 'make install' to install them\n";