source: trunk/debathena/scripts/SbuildHack.pm @ 22748

Revision 22748, 1.0 KB checked in by ghudson, 17 years ago (diff)
Fixes for r22739. * debathena/scripts/da, debathena/scripts/daequivsupload, debathena/scripts/daupload-release, debathena/scripts/all-schroots: Use "." instead of "source". The latter is a csh-ism and will not work in /bin/sh on (at least) Gutsy. debathena/scripts/sbuildhack, debathena/scripts/SbuildHack.pm: Pass the NMU tag in as an environment variable, since the useful value of $0 is long gone by the time we execute a shell command inside the sbuild perl script, making it hard to find debian-versions.sh.
Line 
1package SbuildHack;
2
3use Sbuild qw(binNMU_version);
4use Sbuild::Chroot qw(begin_session);
5use Fcntl qw(:flock);
6
7sub new_binNMU_version {
8    my $v = shift;
9    my $binNMUver = shift;
10    die("Wrong binNMUver!") unless ($binNMUver == 171717);
11    die("No NMUTAG set in environment!") unless ($ENV{"NMUTAG"});
12    return $v . $ENV{"NMUTAG"};
13};
14
15*old_begin_session = \&Sbuild::Chroot::begin_session;
16
17sub new_begin_session {
18    open(APTLOCK, ">/tmp/debathena-repository-lock");
19    flock(APTLOCK, LOCK_SH);
20    my $r = old_begin_session(@_);
21    if (!open(PIPE, Sbuild::Chroot::get_apt_command("$conf::apt_get", "-q update", "root", 1) . " 2>&1 |")) {
22        print PLOG "Can't open pipe to apt-get: $!\n";
23        return 0;
24    }
25    while(<PIPE>) {
26        print PLOG;
27        print STDERR;
28    }
29    close(PIPE);
30    print PLOG "apt-get update failed\n" if $?;
31    flock(APTLOCK, LOCK_UN);
32    close(APTLOCK);
33    return $r;
34}
35
36{
37    no warnings 'redefine';
38    *Sbuild::binNMU_version = \&new_binNMU_version;
39    *Sbuild::Chroot::begin_session = \&new_begin_session;
40}
41
421;
Note: See TracBrowser for help on using the repository browser.