Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/apt-mirror/apt-mirror.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTao Wang <twang2218@gmail.com>2016-12-05 04:56:21 +0300
committerBenjamin Drung <benjamin.drung@profitbricks.com>2017-01-03 22:15:01 +0300
commite63ef059b09651f8a37eb76e1189fef0bcb39285 (patch)
tree7e700dfcd9e704aaa167bba64cc08dd27cbd3540
parent815b856aac5e46d0927d394469de60d28236260d (diff)
Adding support for 'deb [arch=amd64] ...' format
fixes #32, #65 Signed-off-by: Tao Wang <twang2218@gmail.com> Signed-off-by: Benjamin Drung <benjamin.drung@profitbricks.com>
-rwxr-xr-xapt-mirror87
1 files changed, 48 insertions, 39 deletions
diff --git a/apt-mirror b/apt-mirror
index ec9ceed..c6e8c2c 100755
--- a/apt-mirror
+++ b/apt-mirror
@@ -279,57 +279,66 @@ sub download_urls
## Parse config
+sub parse_config_line
+{
+ my $pattern_deb_line = qr/^[\t ]*(?<type>deb-src|deb)(?:-(?<arch>[\w\-]+))?[\t ]+(?:\[(?<options>[^\]]+)\][\t ]+)?(?<uri>[^\s]+)[\t ]+(?<components>.+)$/;
+ my $line = $_;
+ my %config;
+ if ( $line =~ $pattern_deb_line ) {
+ $config{'type'} = $+{type};
+ $config{'arch'} = $+{arch};
+ $config{'options'} = $+{options};
+ $config{'uri'} = $+{uri};
+ $config{'components'} = $+{components};
+ if ( $config{'options'} =~ /arch=((?<arch>[\w\-]+)[,]*)/g ) {
+ $config{'arch'} = $+{arch};
+ }
+ $config{'components'} = [ split /\s+/, $config{'components'} ];
+ } elsif ( $line =~ /set[\t ]+(?<key>[^\s]+)[\t ]+(?<value>[^\s]+)/ ) {
+ $config{'type'} = 'set';
+ $config{'key'} = $+{key};
+ $config{'value'} = $+{value};
+ } elsif ( $line =~ /(?<type>clean|skip-clean)[\t ]+(?<uri>[^\s]+)/ ) {
+ $config{'type'} = $+{type};
+ $config{'uri'} = $+{uri};
+ }
+
+ return %config;
+}
+
open CONFIG, "<$config_file" or die("apt-mirror: can't open config file ($config_file)");
while (<CONFIG>)
{
next if /^\s*#/;
next unless /\S/;
- my @config_line = split;
- my $config_line = shift @config_line;
+ my $line = $_;
+ my %config_line = parse_config_line;
- if ( $config_line eq "set" )
- {
- $config_variables{ $config_line[0] } = $config_line[1];
+ if ( $config_line{'type'} eq "set" ) {
+ $config_variables{ $config_line{'key'} } = $config_line{'value'};
next;
- }
-
- if ( $config_line eq "deb" )
- {
- push @config_binaries, [ get_variable("defaultarch"), @config_line ];
+ } elsif ( $config_line{'type'} eq "deb" ) {
+ my $arch = $config_line{'arch'};
+ $arch = get_variable("defaultarch") if ! defined $config_line{'arch'};
+ push @config_binaries, [ $arch, $config_line{'uri'}, @{$config_line{'components'}} ];
next;
- }
-
- if ( $config_line eq "deb-src" )
- {
- push @config_sources, [@config_line];
+ } elsif ( $config_line{'type'} eq "deb-src" ) {
+ push @config_sources, [ $config_line{'uri'}, @{$config_line{'components'}} ];
next;
- }
-
- if ( $config_line =~ /deb-([\w\-]+)/ )
- {
- push @config_binaries, [ $1, @config_line ];
- next;
- }
-
- if ( $config_line eq "skip-clean" )
- {
- $config_line[0] =~ s[^(\w+)://][];
- $config_line[0] =~ s[/$][];
- $config_line[0] =~ s[~][%7E]g if get_variable("_tilde");
- $skipclean{ $config_line[0] } = 1;
- next;
- }
-
- if ( $config_line eq "clean" )
- {
- $config_line[0] =~ s[^(\w+)://][];
- $config_line[0] =~ s[/$][];
- $config_line[0] =~ s[~][%7E]g if get_variable("_tilde");
- $clean_directory{ $config_line[0] } = 1;
+ } elsif ( $config_line{'type'} =~ /(skip-clean|clean)/ ) {
+ my $link = $config_line{'uri'};
+ $link =~ s[^(\w+)://][];
+ $link =~ s[/$][];
+ $link =~ s[~][%7E]g if get_variable("_tilde");
+ if ( $config_line{'type'} eq "skip-clean" ) {
+ $skipclean{ $link } = 1;
+ } elsif ( $config_line{'type'} eq "clean" ) {
+ $clean_directory{ $link } = 1;
+ }
next;
}
- die("apt-mirror: invalid line in config file ($.: $config_line ...)");
+ die("apt-mirror: invalid line in config file ($.: $line ...)");
}
close CONFIG;