~ubuntu-branches/ubuntu/lucid/sbuild/lucid

« back to all changes in this revision

Viewing changes to bin/wanna-build-merge-quinn

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook
  • Date: 2009-05-09 16:06:44 UTC
  • mfrom: (8.1.6 upstream) (3.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090509160644-9k0fgp6c2ajcu54h
Tags: 0.58.2-1ubuntu1
* Merge from debian unstable, remaining changes:
  - bin/sbuild, lib/Sbuild/{Base,Conf,Options}.pm: add --setup-hook
    to allow pre-build modifications to underlying chroots (needed
    to adjust pockets and components in sources.list).  (debian bug
    500746).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
#
 
3
# do-merge-quinn: merge current quinn-diff output into wanna-build
 
4
# database and make wanna-build statistics
 
5
# Copyright © 1998-2000 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
 
6
#
 
7
# This program is free software: you can redistribute it and/or modify
 
8
# it under the terms of the GNU General Public License as published by
 
9
# the Free Software Foundation, either version 2 of the License, or
 
10
# (at your option) any later version.
 
11
#
 
12
# This program is distributed in the hope that it will be useful, but
 
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
15
# General Public License for more details.
 
16
#
 
17
# You should have received a copy of the GNU General Public License
 
18
# along with this program.  If not, see
 
19
# <http://www.gnu.org/licenses/>.
 
20
#
 
21
#######################################################################
 
22
 
 
23
package conf;
 
24
use WannaBuild::Conf;
 
25
 
 
26
package main;
 
27
 
 
28
sub cleanup ($);
 
29
 
 
30
use strict;
 
31
use warnings;
 
32
use vars qw($HOME $tmpdir $arch @dists $locked);
 
33
 
 
34
$HOME = $ENV{'HOME'}
 
35
or die "HOME not defined in environment!\n";
 
36
@dists = qw(stable frozen unstable);
 
37
 
 
38
open( STDOUT, ">>$HOME/lib/merge.log" );
 
39
open( STDERR, ">&STDOUT" );
 
40
$| = 1;
 
41
select(STDERR); $| = 1; select(STDOUT);
 
42
chomp( my $date = `date` );
 
43
print "-------------- merge-quinn $date --------------\n";
 
44
 
 
45
$tmpdir = "/tmp/merge-quinn.$$";
 
46
chomp( $arch = `dpkg --print-installation-architecture` );
 
47
 
 
48
mkdir( $tmpdir, 0755 ) or die "mkdir $tmpdir: $!\n";
 
49
chdir( $tmpdir ) or die "chdir $tmpdir: $!\n";
 
50
 
 
51
my $stats_only = 1 if @ARGV >= 1 && $ARGV[0] eq "--stat-only";
 
52
 
 
53
foreach (qw(HUP INT QUIT PIPE TERM __DIE__)) {
 
54
    $SIG{$_} = \&cleanup;
 
55
}
 
56
 
 
57
my ($dist, $sect);
 
58
 
 
59
if (!$stats_only) {
 
60
 
 
61
    system "wanna-build", "--create-maintenance-lock"
 
62
        and die "wanna-build --create-maintenance-lock error status $?\n";
 
63
    $locked = 1;
 
64
 
 
65
    foreach $dist (@dists) {
 
66
        my $ofile = "quinn-$dist";
 
67
        unlink( $ofile );
 
68
 
 
69
        foreach $sect (@conf::sections) {
 
70
            my $bf = ($conf::quinn_source_multi_section ?
 
71
                      $dist : "by_section-$arch.txt");
 
72
            unlink( $bf );
 
73
            my $f = ($conf::quinn_source_multi_section ?
 
74
                     "$conf::quinn_source/$arch/$sect/$dist" :
 
75
                     "$conf::quinn_source/$dist/by_section-$arch.txt");
 
76
            if ($f =~ m,^/,) {
 
77
                if (system "cat '$f' >>$ofile") {
 
78
                    warn "cat $f >>$ofile error status $?\n";
 
79
                    next;
 
80
                }
 
81
            }
 
82
            else {
 
83
                system "wget", "-q", $f and next;
 
84
                if (system "cat '$bf' >>$ofile") {
 
85
                    warn "cat $bf >>$ofile error status $?\n";
 
86
                    unlink( $bf );
 
87
                    next;
 
88
                }
 
89
            }
 
90
            print "Got $f\n";
 
91
            unlink( $bf );
 
92
        }
 
93
 
 
94
        next if ! -s $ofile;
 
95
        next if ! -f "$conf::basedir/$conf::dbbase-$dist";
 
96
        print "--> $dist\n";
 
97
        system "wanna-build", "--merge-quinn", "-v", "--dist=$dist", "$ofile"
 
98
            and warn "wanna-build --merge-quinn error status $?\n";
 
99
        unlink( $ofile );
 
100
    }
 
101
 
 
102
    system "wanna-build", "--remove-maintenance-lock";
 
103
    $locked = 0;
 
104
}
 
105
 
 
106
unlink( "stats" );
 
107
foreach $dist (@dists) {
 
108
    system "wanna-build-statistics --dist=$dist >>stats";
 
109
    system "echo '' >>stats";
 
110
}
 
111
 
 
112
if (-s "stats" && defined($conf::stat_mail) && $conf::stat_mail) {
 
113
    system "mail -s 'wanna-build statistics $date' $conf::stat_mail <stats"
 
114
        and warn "mail for statistics error status: $?\n";
 
115
    if ($conf::web_stats && -w $conf::web_stats) {
 
116
        open( F, ">$conf::web_stats" )
 
117
            or die "Cannot create $conf::web_stats: $!\n";
 
118
        print F "wanna-build statistics $date\n";
 
119
        print F "===================================================\n\n";
 
120
        close( F );
 
121
        system "cat stats >>'$conf::web_stats'";
 
122
        system "chmod", "644", $conf::web_stats;
 
123
    }
 
124
}
 
125
 
 
126
chdir( "/" ) or die "chdir /: $!\n";
 
127
system "rm", "-rf", $tmpdir and die "rm -rf $tmpdir error status $?";
 
128
 
 
129
exit( 0 );
 
130
 
 
131
sub cleanup ($) {
 
132
    system "wanna-build", "--remove-maintenance-lock" if $locked;
 
133
    system "rm -rf $tmpdir" if $tmpdir;
 
134
}