forked from lix-project/hydra
initial bzr support
This commit is contained in:
parent
e17fec61b2
commit
c645fa55ff
|
@ -314,6 +314,9 @@ sub clearvcscache : Chained('admin') Path('clear-vcs-cache') Args(0) {
|
||||||
print "Clearing subversion cache\n";
|
print "Clearing subversion cache\n";
|
||||||
$c->model('DB::CachedSubversionInputs')->delete_all;
|
$c->model('DB::CachedSubversionInputs')->delete_all;
|
||||||
|
|
||||||
|
print "Clearing bazaar cache\n";
|
||||||
|
$c->model('DB::CachedBazaarInputs')->delete_all;
|
||||||
|
|
||||||
$c->res->redirect("/admin");
|
$c->res->redirect("/admin");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -381,6 +381,77 @@ sub fetchInputGit {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub fetchInputBazaar {
|
||||||
|
my ($db, $project, $jobset, $name, $type, $value, $checkout) = @_;
|
||||||
|
|
||||||
|
my $uri = $value;
|
||||||
|
|
||||||
|
my $sha256;
|
||||||
|
my $storePath;
|
||||||
|
|
||||||
|
my $stdout; my $stderr;
|
||||||
|
my $clonePath;
|
||||||
|
mkpath(scmPath);
|
||||||
|
$clonePath = scmPath . "/" . sha256_hex($uri);
|
||||||
|
|
||||||
|
if (! -d $clonePath) {
|
||||||
|
(my $res, $stdout, $stderr) = captureStdoutStderr(600,
|
||||||
|
("bzr", "branch", $uri, $clonePath));
|
||||||
|
die "Error cloning bazaar branch at `$uri':\n$stderr" unless $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
chdir $clonePath or die $!;
|
||||||
|
(my $res, $stdout, $stderr) = captureStdoutStderr(600,
|
||||||
|
("bzr", "pull"));
|
||||||
|
die "Error pulling latest change bazaar branch at `$uri':\n$stderr" unless $res;
|
||||||
|
|
||||||
|
# First figure out the last-modified revision of the URI.
|
||||||
|
my @cmd = (["bzr", "revno"],
|
||||||
|
"|", ["sed", 's/^ *\([0-9]*\).*/\1/']);
|
||||||
|
|
||||||
|
die "Cannot get head revision of Bazaar branch at `$uri':\n$stderr"
|
||||||
|
unless IPC::Run::run(@cmd, \$stdout, \$stderr);
|
||||||
|
my $revision = $stdout; chomp $revision;
|
||||||
|
die unless $revision =~ /^\d+$/;
|
||||||
|
|
||||||
|
(my $cachedInput) = $db->resultset('CachedBazaarInputs')->search(
|
||||||
|
{uri => $uri, revision => $revision});
|
||||||
|
|
||||||
|
if (defined $cachedInput && isValidPath($cachedInput->storepath)) {
|
||||||
|
$storePath = $cachedInput->storepath;
|
||||||
|
$sha256 = $cachedInput->sha256hash;
|
||||||
|
} else {
|
||||||
|
|
||||||
|
# Then download this revision into the store.
|
||||||
|
print STDERR "checking out Bazaar input ", $name, " from $uri revision $revision\n";
|
||||||
|
$ENV{"NIX_HASH_ALGO"} = "sha256";
|
||||||
|
$ENV{"PRINT_PATH"} = "1";
|
||||||
|
$ENV{"NIX_PREFETCH_BZR_LEAVE_DOT_BZR"} = "$checkout";
|
||||||
|
|
||||||
|
(my $res, $stdout, $stderr) = captureStdoutStderr(600,
|
||||||
|
("nix-prefetch-bzr", $clonePath, $revision));
|
||||||
|
die "Cannot check out Bazaar branch `$uri':\n$stderr" unless $res;
|
||||||
|
|
||||||
|
($sha256, $storePath) = split ' ', $stdout;
|
||||||
|
|
||||||
|
txn_do($db, sub {
|
||||||
|
$db->resultset('CachedBazaarInputs')->create(
|
||||||
|
{ uri => $uri
|
||||||
|
, revision => $revision
|
||||||
|
, sha256hash => $sha256
|
||||||
|
, storepath => $storePath
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
{ type => $type
|
||||||
|
, uri => $uri
|
||||||
|
, storePath => $storePath
|
||||||
|
, sha256hash => $sha256
|
||||||
|
, revision => $revision
|
||||||
|
};}
|
||||||
|
|
||||||
sub fetchInputHg {
|
sub fetchInputHg {
|
||||||
my ($db, $project, $jobset, $name, $type, $value) = @_;
|
my ($db, $project, $jobset, $name, $type, $value) = @_;
|
||||||
|
|
||||||
|
@ -480,17 +551,20 @@ sub fetchInput {
|
||||||
elsif ($type eq "hg") {
|
elsif ($type eq "hg") {
|
||||||
return fetchInputHg($db, $project, $jobset, $name, $type, $value);
|
return fetchInputHg($db, $project, $jobset, $name, $type, $value);
|
||||||
}
|
}
|
||||||
|
elsif ($type eq "bzr") {
|
||||||
|
return fetchInputBazaar($db, $project, $jobset, $name, $type, $value, 0);
|
||||||
|
}
|
||||||
|
elsif ($type eq "bzr-checkout") {
|
||||||
|
return fetchInputBazaar($db, $project, $jobset, $name, $type, $value, 1);
|
||||||
|
}
|
||||||
elsif ($type eq "string") {
|
elsif ($type eq "string") {
|
||||||
die unless defined $value;
|
die unless defined $value;
|
||||||
return {type => $type, value => $value};
|
return {type => $type, value => $value};
|
||||||
}
|
}
|
||||||
|
|
||||||
elsif ($type eq "boolean") {
|
elsif ($type eq "boolean") {
|
||||||
die unless defined $value && ($value eq "true" || $value eq "false");
|
die unless defined $value && ($value eq "true" || $value eq "false");
|
||||||
return {type => $type, value => $value};
|
return {type => $type, value => $value};
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
die "Input `" . $name . "' has unknown type `$type'.";
|
die "Input `" . $name . "' has unknown type `$type'.";
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
[% inputTypes =
|
[% inputTypes =
|
||||||
{ "svn" = "Subversion export"
|
{ "svn" = "Subversion export"
|
||||||
, "svn-checkout" = "Subversion checkout"
|
, "svn-checkout" = "Subversion checkout"
|
||||||
|
, "bzr" = "Bazaar export"
|
||||||
|
, "bzr-checkout" = "Bazaar checkout"
|
||||||
, "git" = "Git checkout"
|
, "git" = "Git checkout"
|
||||||
, "tarball" = "Download of a tarball"
|
, "tarball" = "Download of a tarball"
|
||||||
, "hg" = "Mercurial checkout"
|
, "hg" = "Mercurial checkout"
|
||||||
|
|
|
@ -315,6 +315,14 @@ create table CachedSubversionInputs (
|
||||||
primary key (uri, revision)
|
primary key (uri, revision)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
create table CachedBazaarInputs (
|
||||||
|
uri text not null,
|
||||||
|
revision integer not null,
|
||||||
|
sha256hash text not null,
|
||||||
|
storePath text not null,
|
||||||
|
primary key (uri, revision)
|
||||||
|
);
|
||||||
|
|
||||||
create table CachedGitInputs (
|
create table CachedGitInputs (
|
||||||
uri text not null,
|
uri text not null,
|
||||||
branch text not null,
|
branch text not null,
|
||||||
|
@ -530,6 +538,7 @@ create index IndexBuildsOnDrvPath on Builds(drvPath);
|
||||||
create index IndexCachedHgInputsOnHash on CachedHgInputs(uri, branch, sha256hash);
|
create index IndexCachedHgInputsOnHash on CachedHgInputs(uri, branch, sha256hash);
|
||||||
create index IndexCachedGitInputsOnHash on CachedGitInputs(uri, branch, sha256hash);
|
create index IndexCachedGitInputsOnHash on CachedGitInputs(uri, branch, sha256hash);
|
||||||
create index IndexCachedSubversionInputsOnUriRevision on CachedSubversionInputs(uri, revision);
|
create index IndexCachedSubversionInputsOnUriRevision on CachedSubversionInputs(uri, revision);
|
||||||
|
create index IndexCachedBazaarInputsOnUriRevision on CachedBazaarInputs(uri, revision);
|
||||||
create index IndexJobsetEvalMembersOnBuild on JobsetEvalMembers(build);
|
create index IndexJobsetEvalMembersOnBuild on JobsetEvalMembers(build);
|
||||||
create index IndexJobsetInputAltsOnInput on JobsetInputAlts(project, jobset, input);
|
create index IndexJobsetInputAltsOnInput on JobsetInputAlts(project, jobset, input);
|
||||||
create index IndexJobsetInputAltsOnJobset on JobsetInputAlts(project, jobset);
|
create index IndexJobsetInputAltsOnJobset on JobsetInputAlts(project, jobset);
|
||||||
|
|
Loading…
Reference in a new issue