mirror of
				https://github.com/Telecominfraproject/wlan-ap.git
				synced 2025-10-31 02:17:58 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			132 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
			
		
		
	
	
			132 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
| From 0af1d76c05f739dd4dbe090ac0d20e429b3c7869 Mon Sep 17 00:00:00 2001
 | |
| From: John Crispin <john@phrozen.org>
 | |
| Date: Fri, 19 Jun 2020 13:25:27 +0200
 | |
| Subject: [PATCH 07/40] scripts: update feed script
 | |
| 
 | |
| gen_config.py requires the latest version of the feeds script.
 | |
| 
 | |
| Signed-off-by: John Crispin <john@phrozen.org>
 | |
| ---
 | |
|  scripts/feeds | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++
 | |
|  1 file changed, 77 insertions(+)
 | |
| 
 | |
| diff --git a/scripts/feeds b/scripts/feeds
 | |
| index 69ab60278a..46c5f5cb9f 100755
 | |
| --- a/scripts/feeds
 | |
| +++ b/scripts/feeds
 | |
| @@ -644,6 +644,35 @@ sub refresh_config {
 | |
|  	}
 | |
|  }
 | |
|  
 | |
| +sub install_profiles {
 | |
| +	my $feed = shift;
 | |
| +	my $dir = sprintf('feeds/%s/', $feed->[1]);
 | |
| +
 | |
| +	-d "./feeds/profiles" or mkdir "./feeds/profiles" or return 1;
 | |
| +
 | |
| +	opendir (DIR, $dir) or return 0;
 | |
| +	while (my $file = readdir(DIR)) {
 | |
| +		next unless (-f "$dir/$file");
 | |
| +		next unless ($file =~ m/\.profile$/);
 | |
| +		-e "./feeds/profiles/$file" or system("ln -s ../$feed->[1]/$file ./feeds/profiles/");
 | |
| +	}
 | |
| +	closedir(DIR);
 | |
| +}
 | |
| +
 | |
| +sub install_dl {
 | |
| +	my $feed = shift;
 | |
| +	my $dir = sprintf('feeds/%s/dl/', $feed->[1]);
 | |
| +
 | |
| +	-d "./dl" or mkdir "./dl" or return 1;
 | |
| +
 | |
| +	opendir (DIR, $dir) or return 0;
 | |
| +	while (my $file = readdir(DIR)) {
 | |
| +		next unless (-f "$dir/$file");
 | |
| +		-e "./dl/$file" or system("ln -s ../feeds/$feed->[1]/dl/$file ./dl/");
 | |
| +	}
 | |
| +	closedir(DIR);
 | |
| +}
 | |
| +
 | |
|  sub install {
 | |
|  	my $name;
 | |
|  	my %opts;
 | |
| @@ -676,6 +705,8 @@ sub install {
 | |
|  					install_src($feed, $name, exists($opts{f})) == 0 or $ret = 1;
 | |
|  					get_feed($f->[1]);
 | |
|  				}
 | |
| +				install_profiles($f);
 | |
| +				install_dl($f);
 | |
|  			}
 | |
|  		}
 | |
|  	} else {
 | |
| @@ -846,6 +877,47 @@ sub update {
 | |
|  	return $failed;
 | |
|  }
 | |
|  
 | |
| +sub setup {
 | |
| +	my %opts;
 | |
| +
 | |
| +	getopts('bh', \%opts);
 | |
| +
 | |
| +	if ($opts{h}) {
 | |
| +		usage();
 | |
| +		return 0;
 | |
| +	}
 | |
| +
 | |
| +	if (-e "feeds.conf") {
 | |
| +		warn "The file feeds.conf already exists.\n";
 | |
| +		return 1;
 | |
| +	}
 | |
| +
 | |
| +	open(my $fd, ">>feeds.conf");
 | |
| +
 | |
| +	if ($opts{b}) {
 | |
| +		printf $fd "src-include defaults feeds.conf.default\n";
 | |
| +	}
 | |
| +
 | |
| +	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-]/) {
 | |
| +			warn "Feed names or sources may not contain whitespace or - 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");
 | |
| @@ -897,6 +969,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] <type,name,link> <type,name,link> ...: generate feeds.conf
 | |
| +	Options:
 | |
| +	    -b :           Use feeds.conf.default as base for new feeds.conf.
 | |
| +
 | |
|  	clean:             Remove downloaded/generated files.
 | |
|  
 | |
|  EOF
 | |
| @@ -910,6 +986,7 @@ my %commands = (
 | |
|  	'search' => \&search,
 | |
|  	'uninstall' => \&uninstall,
 | |
|  	'feed_config' => \&feed_config,
 | |
| +	'setup' => \&setup,
 | |
|  	'clean' => sub {
 | |
|  		system("rm -rf ./feeds ./package/feeds");
 | |
|  	}
 | |
| -- 
 | |
| 2.25.1
 | |
| 
 | 
