From 6458eb860c4c54d9f31334b4520dd79218c7fc52 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Fri, 3 Apr 2020 13:01:27 -0700 Subject: more --- bin/buildssrht-preupload | 78 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file 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 . + 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; -- cgit v1.2.3