Commit c65d6192 authored by Matt Travers's avatar Matt Travers

ENH: Added nd_freeze logging to better let the user know what the script is up...

ENH: Added nd_freeze logging to better let the user know what the script is up to and see what is happening when things go bad.
parent 8bd3dc93
......@@ -80,11 +80,11 @@ sub get_www_content {
# Function to run apt-get update
sub run_apt_get_update {
info("Refreshing apt cache ...");
info "Refreshing apt cache ...";
if (qx!grep ubuntu /etc/os-release!) {
qx/apt-get update --no-allow-insecure-repositories/;
print qx/apt-get update --no-allow-insecure-repositories/;
} else {
qx/apt-get update/;
print qx/apt-get update/;
}
}
......@@ -211,6 +211,7 @@ sub get_sources {
$repo = 'debian-security' if ($domain eq 'Debian' && $url =~ 'security');
$repo = 'neurodebian' if ($domain eq 'NeuroDebian');
if ($domain ne "Ubuntu") { # Skip Ubuntu repos because there are no snapshots available.
info "Found $domain archive $archive at $url";
my $key = "$domain|$repo|$archive";
if (exists $sources{$key}) {
$sources{$key}{type} .= " $type";
......@@ -257,6 +258,7 @@ sub write_snapshot_sources {
}
my $domain = 'snapshot-neuro.debian.net:5002';
$domain = 'snapshot.debian.org' if ($sources{$key}{domain} eq 'Debian');
info "Finding snapshot at http://$domain for $user_timestamp";
$contents = get_www_content("http://${domain}/archive/${sources{$key}{repo}}/${user_timestamp}/");
# Handle 404 redirect page not found.
if ($contents =~ /HTTP\/1.1 404 Not Found/) {
......@@ -277,6 +279,7 @@ sub write_snapshot_sources {
next;
}
print $fp "deb http://${domain}/archive/${sources{$key}{repo}}/${next_timestamp}/ ${sources{$key}{archive}} ${sources{$key}{type}}\n";
info "Adding 'deb http://${domain}/archive/${sources{$key}{repo}}/${next_timestamp}/ ${sources{$key}{archive}} ${sources{$key}{type}}' to $snapshots_sources_file";
$found_count += 1;
}
close $fp;
......@@ -313,10 +316,12 @@ sub disable_lines {
my $found = 0;
# Loop through the sources from apt-cache policy for each line in the
# sources file to determine if it is one we need to comment out.
my $file_line = '';
my $source_line = '';
for my $key (keys %sources) {
$_ =~ /(http:\S+)(.*)$/;
my $file_line = $1 . join ' ', sort split /\s+/, $2;
my $source_line = $sources{$key}{url} . ' ' . join ' ', sort split /\s+/, "$sources{$key}{archive} $sources{$key}{type}";
$file_line = $1 . join ' ', sort split /\s+/, $2;
$source_line = $sources{$key}{url} . ' ' . join ' ', sort split /\s+/, "$sources{$key}{archive} $sources{$key}{type}";
if ($file_line eq $source_line) {
$found = 1;
last;
......@@ -324,6 +329,7 @@ sub disable_lines {
}
if ($found) {
print $out "# $_\n";
info "Disabling '$source_line' in $sources_file";
} else {
print $out "$_\n";
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment