blob: 5ec3dd158bbf693d9cefc116bdcc4231cff36bd9 [file] [log] [blame]
#!/usr/bin/perl
use strict;
use warnings;
use File::Basename;
use lib File::Basename::dirname($0);
use LinuxStableQueue qw(quilt_dir_from_git_dir next_update);
use FileHandle;
my $quilt_dir = quilt_dir_from_git_dir('.')
or die "couldn't find patch queue";
# Init quilt status if not yet done
if (! -d '.pc') {
mkdir('.pc') or die "mkdir: $!";
my $fh = new FileHandle('.pc/.quilt_patches', 'w') or die "open: $!";
$fh->print("$quilt_dir\n");
$fh->close or die "close: $!";
$fh = new FileHandle('.pc/.quilt_series', 'w') or die "open: $!";
$fh->print("series\n");
$fh->close or die "close: $!";
$fh = new FileHandle('.pc/.version', 'w') or die "open: $!";
$fh->print("2\n");
$fh->close;
}
# Bump version in Makefile if not yet done
my $version = `make kernelversion`;
chomp $version;
if ($version !~ /-rc\d+$/) {
$version = next_update($version);
$version =~ /^\d+\.\d+\.(\d+)(.*)/;
my ($sublevel, $extraversion) = ($1, $2 . '-rc1');
my $old = new FileHandle('Makefile', 'r') or die "Makefile: $!";
my $new = new FileHandle('Makefile.new', 'w') or die "Makefile.new: $!";
while (<$old>) {
s/^SUBLEVEL =.*/SUBLEVEL = $sublevel/;
s/^EXTRAVERSION =.*/EXTRAVERSION = $extraversion/;
$new->print($_);
}
$old->close;
$new->close or die "close: $!";
rename('Makefile.new', 'Makefile') or die "rename: $!";
}
# Push, refresh and build until we fail or hit the end of the queue
my $nproc = (`nproc` || 1) + 0; # POSIX::sysconf sucks
while (1) {
system('quilt', 'push', '--fuzz=0') == 0 or die;
system('quilt', 'refresh') == 0 or die;
system('make', "-j$nproc") == 0 or die;
}