1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
|
#!/usr/bin/perl
# Copyright (C) 2006-2008 Neil Williams <codehelp@debian.org>
#
# This package is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
use Debconf::Client::ConfModule qw(:all);
use vars qw($src @srclist $line $sources @packageslist @sourcelist );
use warnings;
use strict;
version("2.0");
my $capb=capb("backup");
beginblock();
title("Emdebian Setup - package building");
input("medium", "emsetup/aptagent");
input("medium", "emsource/svnusername");
input("medium", "emsource/workdir");
input("medium", "emsource/targetsuite");
$sources = "/etc/apt/sources.list.d/emdebian.sources.list";
if (-e "/etc/apt/sources.list") {
open (SOURCES, "/etc/apt/sources.list") or die "cannot open apt sources list. $!";
@srclist=<SOURCES>;
close (SOURCES);
# ensure we have a primary deb-src at the same time.
foreach $line (@srclist)
{
$src = $1 if ($line =~ /^deb (.*) [a-z]+ main( non\-free)?( contrib)?$/);
if (defined $src) {
$src =~ s/^(ht|f)tp:\/\///;
$src =~ s/\/debian\/?$//;
push @packageslist, $src;
}
$src = $1
if ($line =~ /^deb\-src (.*) [a-z]+ main( non\-free)?( contrib)?$/);
if (defined $src) {
$src =~ s/^(ht|f)tp:\/\///;
$src =~ s/\/debian\/?$//;
push @sourcelist, $src;
}
$src = "";
}
close (SOURCES);
}
if (-d "/etc/apt/sources.list.d/") {
opendir (FILES, "/etc/apt/sources.list.d/")
or die "cannot open apt sources.list directory $!";
my @files = grep(!/^\.\.?$/, readdir FILES);
foreach my $f (@files) {
# ignore our own source so that reconfigure can work.
next if ("/etc/apt/sources.list.d/$f" eq $sources);
open (SOURCES, "/etc/apt/sources.list.d/$f") or
die "cannot open /etc/apt/sources.list.d/$f $!";
# ensure we have a primary deb-src at the same time.
while(<SOURCES>) {
$src = $1 if (/^deb (.*) [a-z]* main( non\-free)?( contrib)?$/);
if ($src ne "") {
$src =~ s/^(ht|f)tp:\/\///;
$src =~ s/\/debian\/?$//;
push @packageslist, $src;
}
$src = $1 if (/^deb\-src (.*) [a-z]* main( non\-free)?( contrib)?$/);
if ($src ne "") {
$src =~ s/^(ht|f)tp:\/\///;
$src =~ s/\/debian\/?$//;
push @sourcelist, $src;
}
$src = "";
}
close (SOURCES);
}
closedir (FILES);
}
# now work out how many 'main' sources are primaries.
my $apt = &primary_check(\@packageslist);
my $apt_src = &primary_check(\@sourcelist);
input("high", "emsetup/primary") if (scalar @$apt == 0);
set("emsetup/primary", "") if (scalar @$apt > 0);
endblock();
go();
sub primary_check
{
my %checked=();
# ftp.be.debian.org, ftp.no.debian.org and ftp.hk.debian.org removed due to
# lack of certain architectures.
my @primaries = qw/ ftp.at.debian.org ftp.au.debian.org ftp.wa.au.debian.org
ftp.br.debian.org ftp.ch.debian.org ftp.cl.debian.org ftp.cz.debian.org
ftp.de.debian.org ftp2.de.debian.org ftp.dk.debian.org ftp.ee.debian.org
ftp.es.debian.org ftp.fi.debian.org ftp.fr.debian.org ftp2.fr.debian.org
ftp.uk.debian.org ftp.hr.debian.org ftp.hu.debian.org ftp.ie.debian.org
ftp.is.debian.org ftp.it.debian.org ftp.jp.debian.org ftp2.jp.debian.org
ftp.kr.debian.org ftp.mx.debian.org ftp.nl.debian.org ftp.nz.debian.org
ftp.pl.debian.org ftp.ro.debian.org ftp.ru.debian.org ftp.se.debian.org
ftp.si.debian.org ftp.sk.debian.org ftp.tr.debian.org ftp.tw.debian.org
ftp.uk.debian.org ftp.us.debian.org /;
$a = $_[0];
foreach (@primaries) {
$checked{$_}=1;
}
my @matches = grep ($checked{$_}, @$a);
return \@matches;
}
|