summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2020-04-03 13:01:27 -0700
committerSean Whitton <spwhitton@spwhitton.name>2020-04-03 15:19:43 -0700
commit6458eb860c4c54d9f31334b4520dd79218c7fc52 (patch)
treeac94c0b212ad2124632bb406421ca1f37339758d
parent59a96d7a3af1be66deba1d84276e1559417e238d (diff)
downloaddotfiles-6458eb860c4c54d9f31334b4520dd79218c7fc52.tar.gz
more
-rwxr-xr-xbin/buildssrht-preupload78
1 files changed, 72 insertions, 6 deletions
diff --git a/bin/buildssrht-preupload b/bin/buildssrht-preupload
index 65417053..5fa456c4 100755
--- a/bin/buildssrht-preupload
+++ b/bin/buildssrht-preupload
@@ -1,12 +1,79 @@
#!/usr/bin/perl
+# Copyright (C) 2020 Sean Whitton
+#
+# This program 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 5.028;
use strict;
use warnings;
use JSON;
+use YAML;
+$YAML::UseBlock = 1;
use REST::Client;
use API::GitForge qw(forge_access_token);
+use Getopt::Long;
+use Git::Wrapper;
+use Cwd;
+
+my $user = "~spwhitton"; # TODO could fetch from API
+my $dist = "unstable";
+my $remote = "origin";
+my $quilt = "auto";
+GetOptions
+ "distribution|d=s" => \$dist,
+ "remote=s" => \$remote,
+ "quilt=s" => \$quilt;
+
+my $git = Git::Wrapper->new(getcwd);
+my ($clone_uri) = $git->remote("get-url", $remote);
+
+chomp(my $source = `dpkg-parsechangelog -SSource`);
+chomp(my $version = `dpkg-parsechangelog -SVersion`);
+my $note = "Pre-upload checks for $source $version";
+
+my $chroot = "$dist-amd64-sbuild";
+my $changes = "${source}_${version}_multi.changes";
+
+my $manifest->{image} = "debian/unstable";
+$manifest->{sources} = [$clone_uri];
+$manifest->{packages}
+ = ["autopkgtest", "devscripts", "dgit", "lintian", "piuparts", "sbuild"];
+$manifest->{tasks} = [{
+ setup => join "\n",
+ "cd $source",
+ "git deborig || origtargz",
+ join(
+ " ",
+ qw(sudo
+ sbuild-createchroot
+ --command-prefix=eatmydata
+ --include=eatmydata),
+ $dist,
+ "/srv/chroot/$chroot"
+ ),
+ ""
+ },
+ { build => "cd $source\ndgit --quilt=$quilt sbuild -d $dist\n" },
+ { lintian => "lintian $changes\n" },
+ {
+ piuparts => "sudo piuparts --schroot $chroot foo $changes\n"
+ },
+ {
+ autopkgtest => "sudo autopkgtest $changes -- schroot $chroot\n"
+ }];
my $client = REST::Client->new;
$client->setHost("https://builds.sr.ht");
@@ -14,18 +81,17 @@ $client->addHeader("Authorization", "token " . forge_access_token "sr.ht");
$client->addHeader("Content-Type", "application/json");
$client->addHeader("charset", "UTF-8");
-# TODO here set $manifest & $note
-
$client->POST(
"/api/jobs",
encode_json {
note => $note,
- manifest => $manifest,
- "access:read" => ["~spwhitton"] });
-my $resp = decode_json $client->responseContent;
+ "access:read" => [$user],
+ manifest => YAML::Dump $manifest
+ });
+my $resp = decode_json $client->responseContent;
my $job_id = $resp->{id};
-system "xdg-open", "https://builds.sr.ht/~spwhitton/job/$job_id#bottom";
+system "xdg-open", "https://builds.sr.ht/$user/job/$job_id#bottom";
# $client->GET("/api/jobs");
# my $jobs = decode_json $client->responseContent;