From patchwork Wed Jun 5 06:34:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Crispin X-Patchwork-Id: 1110330 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=phrozen.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="s+TEITLu"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45JfCV1jq8z9s7h for ; Wed, 5 Jun 2019 16:34:30 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:Message-Id:Date:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=urtqeYd400D3MngrOt3fZB4DJ5+v3FxuBExe8B9Plwc=; b=s+TEITLu+Cc4q/ 42sRpQPVMUsKq4OmZbpdqRG9rQ1xd/xIEEHls5Sn9i8mu4aKI2Dh4lSnLj6t8TCTEAOgm0AKo/8B3 Wp9l17P6e8+J76K/QtqRgkqyv7YXDpawqITUmxiu2DEk21IJcLADFAC6DwtU//8cSniHv/3+ESp7L 8FVtRb12mqighdz2AgSP7tZfOjDl9CIgvI3fiw6+dwUJfcyScxDF/ybL7gIn5E/CjX8Cxv83DUa9Z 43jpuuWrpi++DtY1E8ejcV9Zjahe8tY88gAD+aCvrIgW0MzzwLyiqGpgkqTdLowEihT8/mHWweWde 98DRVKKuaja2mY7sg/xA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hYPV6-0005XT-B2; Wed, 05 Jun 2019 06:34:20 +0000 Received: from nbd.name ([2a01:4f8:221:3d45::2]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hYPV2-0005X2-Rd for openwrt-devel@lists.openwrt.org; Wed, 05 Jun 2019 06:34:18 +0000 Received: from p5dcfb869.dip0.t-ipconnect.de ([93.207.184.105] helo=bertha.fritz.box) by ds12 with esmtpa (Exim 4.89) (envelope-from ) id 1hYPV1-0007f5-2Q; Wed, 05 Jun 2019 08:34:15 +0200 From: John Crispin To: openwrt-devel@lists.openwrt.org Date: Wed, 5 Jun 2019 08:34:09 +0200 Message-Id: <20190605063409.27769-1-john@phrozen.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190604_233417_063031_B8A11A3D X-CRM114-Status: UNSURE ( 8.58 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record Subject: [OpenWrt-Devel] [PATCH V3 2/2] script/feeds: add a new command that allows generating a new feeds.conf X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Crispin Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org This can be used inside build setups for easy feeds.conf generation. Signed-off-by: John Crispin --- scripts/feeds | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/scripts/feeds b/scripts/feeds index 304ef6cbaf..7cd4639ca6 100755 --- a/scripts/feeds +++ b/scripts/feeds @@ -7,6 +7,7 @@ use metadata; use warnings; use strict; use Cwd 'abs_path'; +use File::Copy; chdir "$FindBin::Bin/.."; $ENV{TOPDIR} //= getcwd(); @@ -819,6 +820,42 @@ sub update { return $failed; } +sub setup { + my %opts; + + getopts('bh', \%opts); + + if ($opts{h}) { + usage(); + return 0; + } + + if ($opts{b}) { + copy("feeds.conf.default", "feeds.conf") or die "Copy failed: $!" + } else { + unlink "feeds.conf" + } + + open(my $fd, ">>feeds.conf"); + while (my $entry = shift @ARGV) { + my ($type, $name, $src) = split /,/, $entry; + + $update_method{$type} or do { + warn "Unknown type '$type' in parameter $entry\n"; + unlink "feeds.conf"; + return 1; + }; + if ($name =~ /\s/ || $src =~ /\s/) { + warn "Feed names or sources may not contain whitespace characters in parameter $entry\n"; + unlink "feeds.conf"; + return 1; + } + printf $fd "%s %s %s\n", $type, $name, $src; + } + + return 0; +} + sub feed_config() { foreach my $feed (@feeds) { my $installed = (-f "feeds/$feed->[1].index"); @@ -870,6 +907,10 @@ Commands: -i : Recreate the index only. No feed update from repository is performed. -f : Force updating feeds even if there are changed, uncommitted files. + setup [options] ...: generate feeds.conf + Options: + -b : Use feeds.conf.default as base for new feeds.conf. + clean: Remove downloaded/generated files. EOF @@ -883,6 +924,7 @@ my %commands = ( 'search' => \&search, 'uninstall' => \&uninstall, 'feed_config' => \&feed_config, + 'setup' => \&setup, 'clean' => sub { system("rm -rf ./feeds ./package/feeds"); }