Adding a still very incomplete method to generate builds from releases.
This commit is contained in:
parent
dfa0948149
commit
a2cf90ca29
2
Build.PL
2
Build.PL
@ -18,6 +18,8 @@ my $build = Module::Build->new(
|
|||||||
'Test::MockObject' => 0,
|
'Test::MockObject' => 0,
|
||||||
'Test::MockModule' => 0,
|
'Test::MockModule' => 0,
|
||||||
'Test::Pod::Coverage' => 0,
|
'Test::Pod::Coverage' => 0,
|
||||||
|
'JSON' => 0,
|
||||||
|
'YAML' => 0,
|
||||||
},
|
},
|
||||||
install_path => {
|
install_path => {
|
||||||
'templates' => "$HOME/.local/share/peace/template",
|
'templates' => "$HOME/.local/share/peace/template",
|
||||||
|
@ -7,6 +7,10 @@ use warnings;
|
|||||||
|
|
||||||
use Params::ValidationCompiler qw/validation_for/;
|
use Params::ValidationCompiler qw/validation_for/;
|
||||||
use Types::Standard qw/InstanceOf Str HasMethods/;
|
use Types::Standard qw/InstanceOf Str HasMethods/;
|
||||||
|
use Path::Tiny;
|
||||||
|
use File::pushd;
|
||||||
|
use YAML;
|
||||||
|
use JSON;
|
||||||
|
|
||||||
{
|
{
|
||||||
my $validator = validation_for(
|
my $validator = validation_for(
|
||||||
@ -36,6 +40,64 @@ use Types::Standard qw/InstanceOf Str HasMethods/;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
my $validator = validation_for(
|
||||||
|
params => {
|
||||||
|
arch => { type => Str },
|
||||||
|
}
|
||||||
|
);
|
||||||
|
sub generate_build {
|
||||||
|
my $self = shift;
|
||||||
|
my %params = $validator->(@_);
|
||||||
|
my $application = $self->application;
|
||||||
|
my $flatpak_builder_file = $application->flatpak_builder_file;
|
||||||
|
my $arch = $params{arch};
|
||||||
|
my $dir = Path::Tiny->tempdir;
|
||||||
|
my $clone_dir = Path::Tiny->tempdir;
|
||||||
|
my $output_dir = Path::Tiny->new($ENV{HOME})->child('.peace-apps');
|
||||||
|
local $ENV{HOME} = $dir;
|
||||||
|
say $dir;
|
||||||
|
system 'git', 'clone', $application->git_repo, $clone_dir;
|
||||||
|
my $current_dir = pushd $clone_dir;
|
||||||
|
my $flatpak_data = $self->_parse_flatpak_builder_file;
|
||||||
|
my $app_id = $flatpak_data->{"app-id"};
|
||||||
|
my $sdk = $flatpak_data->{sdk};
|
||||||
|
my $runtime = $flatpak_data->{runtime};
|
||||||
|
|
||||||
|
system 'flatpak', '--user', 'list';
|
||||||
|
system 'flatpak', '--user', 'remote-add', '--if-not-exists', 'remote', $application->flatpak_repo;
|
||||||
|
say $sdk;
|
||||||
|
system 'flatpak', '--user', 'install', '--arch', $arch, '-y', "$sdk";
|
||||||
|
say $runtime;
|
||||||
|
system 'flatpak', '--user', 'install', '--arch', $arch, '-y', "$runtime";
|
||||||
|
system 'flatpak-builder', '--arch', $arch, '--install', '--user', 'build', $application->flatpak_builder_file, $app_id;
|
||||||
|
$output_dir = $output_dir->child($self->uuid);
|
||||||
|
$output_dir->mkpath;
|
||||||
|
system 'flatpak', 'build-bundle', '--arch', $arch, $dir->child('.local/share/flatpak/repo/'), $output_dir->child($arch), $app_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub _parse_flatpak_builder_file {
|
||||||
|
my $self = shift;
|
||||||
|
my $application = $self->application;
|
||||||
|
my $flatpak_builder_file = $application->flatpak_builder_file;
|
||||||
|
my $path = Path::Tiny->new($flatpak_builder_file);
|
||||||
|
my $payload = $path->slurp_utf8;
|
||||||
|
my $structure;
|
||||||
|
eval {
|
||||||
|
$structure = decode_json($payload);
|
||||||
|
};
|
||||||
|
if (!defined $structure) {
|
||||||
|
eval {
|
||||||
|
($structure) = Load($payload);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (!defined $structure) {
|
||||||
|
die "Unable to parse flatpak builder file.";
|
||||||
|
}
|
||||||
|
return $structure;
|
||||||
|
}
|
||||||
|
|
||||||
sub _dbh {
|
sub _dbh {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
return $self->{dbh};
|
return $self->{dbh};
|
||||||
|
@ -9,6 +9,8 @@ use Test::MockModule;
|
|||||||
use Peace::Model::Application;
|
use Peace::Model::Application;
|
||||||
use Peace::Model::Developer;
|
use Peace::Model::Developer;
|
||||||
|
|
||||||
|
use Peace::Test::Mock::Model::Developer;
|
||||||
|
|
||||||
use DBI;
|
use DBI;
|
||||||
|
|
||||||
BEGIN {
|
BEGIN {
|
||||||
|
34
web_tests/000001-release-model.t
Normal file
34
web_tests/000001-release-model.t
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
|
use v5.30.0;
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
use Peace::Test::Mock::Model::Developer;
|
||||||
|
use Peace::Model::Application;
|
||||||
|
use Peace::Model::Release;
|
||||||
|
|
||||||
|
{
|
||||||
|
my $developer = Peace::Test::Mock::Model::Developer->new;
|
||||||
|
my $application = Peace::Model::Application->new(
|
||||||
|
name => 'OpenMG',
|
||||||
|
description => 'Stub',
|
||||||
|
url => 'https://gitea.sergiotarxz.freemyip.com/sergiotarxz/mangareader',
|
||||||
|
developer => $developer,
|
||||||
|
price => '99',
|
||||||
|
git_repo =>
|
||||||
|
'https://gitea.sergiotarxz.freemyip.com/sergiotarxz/mangareader',
|
||||||
|
flatpak_builder_file => 'me.sergiotarxz.openmg.json',
|
||||||
|
flatpak_repo => 'https://nightly.gnome.org/gnome-nightly.flatpakrepo',
|
||||||
|
verified => 1,
|
||||||
|
);
|
||||||
|
my $uuid = 'random-uuid';
|
||||||
|
my $release = Peace::Model::Release->new(
|
||||||
|
uuid => $uuid,
|
||||||
|
application => $application,
|
||||||
|
tag => 'main',
|
||||||
|
name => 'test',
|
||||||
|
);
|
||||||
|
$release->generate_build( arch => 'x86_64' );
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user