Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion Build.pm
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ our $do_rpm;
our $do_deb;
our $do_kiwi;
our $do_arch;
our $do_archsrcinfo;
our $do_collax;
our $do_livebuild;
our $do_snapcraft;
Expand All @@ -53,6 +54,7 @@ sub import {
$do_rpm = 1 if $_ eq ':rpm';
$do_deb = 1 if $_ eq ':deb';
$do_kiwi = 1 if $_ eq ':kiwi';
$do_archsrcinfo = 1 if $_ eq ':archsrcinfo';
$do_arch = 1 if $_ eq ':arch';
$do_collax = 1 if $_ eq ':collax';
$do_livebuild = 1 if $_ eq ':livebuild';
Expand All @@ -67,14 +69,17 @@ sub import {
$do_apk = 1 if $_ eq ':apk';
$do_none = 1 if $_ eq ':none';
}
$do_rpm = $do_deb = $do_kiwi = $do_productcompose = $do_arch = $do_collax = $do_livebuild = $do_snapcraft = $do_appimage = $do_docker = $do_fissile = $do_helm = $do_flatpak = $do_mkosi = $do_apk = 1 if !$do_rpm && !$do_deb && !$do_kiwi && !$do_arch && !$do_collax && !$do_livebuild && !$do_snapcraft && !$do_appimage && !$do_docker && !$do_fissile && !$do_helm && !$do_flatpak && !$do_mkosi && !$do_productcompose && !$do_apk && !$do_none;
$do_rpm = $do_deb = $do_kiwi = $do_productcompose = $do_arch = $do_archsrcinfo = $do_collax = $do_livebuild = $do_snapcraft = $do_appimage = $do_docker = $do_fissile = $do_helm = $do_flatpak = $do_mkosi = $do_apk = 1 if !$do_rpm && !$do_deb && !$do_kiwi && !$do_arch && !$do_archsrcinfo && !$do_collax && !$do_livebuild && !$do_snapcraft && !$do_appimage && !$do_docker && !$do_fissile && !$do_helm && !$do_flatpak && !$do_mkosi && !$do_productcompose && !$do_apk && !$do_none;

if ($do_deb) {
require Build::Deb;
}
if ($do_kiwi) {
require Build::Kiwi;
}
if ($do_archsrcinfo) {
require Build::Archsrcinfo;
}
if ($do_arch) {
require Build::Arch;
}
Expand Down Expand Up @@ -573,6 +578,7 @@ sub read_config {
if (!$config->{'binarytype'}) {
$config->{'binarytype'} = 'rpm' if $config->{'type'} eq 'spec';
$config->{'binarytype'} = 'deb' if $config->{'type'} eq 'dsc' || $config->{'type'} eq 'collax' || $config->{'type'} eq 'livebuild';
$config->{'binarytype'} = 'arch' if $config->{'type'} eq 'archsrcinfo';
$config->{'binarytype'} = 'arch' if $config->{'type'} eq 'arch';
$config->{'binarytype'} = 'apk' if $config->{'type'} eq 'apk';
if (grep {$_ eq $config->{'type'}} qw{snapcraft appimage docker fissile kiwi mkosi}){
Expand Down Expand Up @@ -1273,6 +1279,7 @@ sub recipe2buildtype {
return $1 if $recipe =~ /\.(spec|dsc|kiwi|productcompose|livebuild)$/;
$recipe =~ s/.*\///;
$recipe =~ s/^_service:.*://;
return 'archsrcinfo' if $recipe eq 'SRCINFO';
return 'arch' if $recipe eq 'PKGBUILD';
return 'apk' if $recipe eq 'APKBUILD';
return 'collax' if $recipe eq 'build.collax';
Expand Down Expand Up @@ -1346,6 +1353,7 @@ sub parse_typed {
return Build::Docker::parse($cf, $fn, @args) if $do_docker && $buildtype eq 'docker';
return Build::Fissile::parse($cf, $fn, @args) if $do_fissile && $buildtype eq 'fissile';
return parse_simpleimage($cf, $fn, @args) if $buildtype eq 'simpleimage';
return Build::Archsrcinfo::parse($cf, $fn, @args) if $do_archsrcinfo && $buildtype eq 'archsrcinfo';
return Build::Arch::parse($cf, $fn, @args) if $do_arch && $buildtype eq 'arch';
return Build::Apk::parse($cf, $fn, @args) if $do_apk && $buildtype eq 'apk';
return Build::Collax::parse($cf, $fn, @args) if $do_collax && $buildtype eq 'collax';
Expand All @@ -1368,6 +1376,8 @@ sub query {
return Build::Kiwi::queryiso($handle, %opts) if $do_kiwi && $binname =~ /\.iso$/;
return Build::Arch::query($handle, %opts) if $do_arch && $binname =~ /\.pkg\.tar(?:\.gz|\.xz|\.zst)?$/;
return Build::Arch::query($handle, %opts) if $do_arch && $binname =~ /\.arch$/;
return Build::Arch::query($handle, %opts) if $do_archsrcinfo && $binname =~ /\.pkg\.tar(?:\.gz|\.xz|\.zst)?$/;
return Build::Arch::query($handle, %opts) if $do_archsrcinfo && $binname =~ /\.arch$/;
return Build::Apk::query($handle, %opts) if $do_arch && $binname =~ /\.apk$/;
return undef;
}
Expand Down Expand Up @@ -1399,6 +1409,8 @@ sub queryhdrmd5 {
return Build::Kiwi::queryhdrmd5(@_) if $do_kiwi && $binname =~ /\.raw.install$/;
return Build::Arch::queryhdrmd5(@_) if $do_arch && $binname =~ /\.pkg\.tar(?:\.gz|\.xz|\.zst)?$/;
return Build::Arch::queryhdrmd5(@_) if $do_arch && $binname =~ /\.arch$/;
return Build::Arch::queryhdrmd5(@_) if $do_archsrcinfo && $binname =~ /\.pkg\.tar(?:\.gz|\.xz|\.zst)?$/;
return Build::Arch::queryhdrmd5(@_) if $do_archsrcinfo && $binname =~ /\.arch$/;
return Build::Apk::queryhdrmd5(@_) if $do_apk && $binname =~ /\.apk$/;
return undef;
}
Expand Down
132 changes: 132 additions & 0 deletions Build/Archsrcinfo.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
################################################################
#
# Copyright (c) 1995-2014 SUSE Linux Products GmbH
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or 3 as
# published by the Free Software Foundation.
#
# 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 (see the file COPYING); if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#
################################################################

package Build::Archsrcinfo;

use strict;
use warnings;

sub _get_srcinfo_assets {
my ($vars, $asuf) = @_;

my @sources = @{ $vars->{"source$asuf"} || [] };
return () unless @sources;

my @digests;
for my $digest_type ('sha512', 'sha384', 'sha256', 'sha224', 'sha1', 'md5') {
my $sums_key = "${digest_type}sums$asuf";
if (exists $vars->{$sums_key} && @{$vars->{$sums_key}}) {
@digests = map { $_ eq 'SKIP' ? $_ : "$digest_type:$_" } @{ $vars->{$sums_key} };
last;
}
}

my @assets;
for my $i (0 .. $#sources) {
my $source_entry = $sources[$i];

# parse filename::URL formats
my $url = $source_entry;
if ($source_entry =~ /::/) {
($url) = (split /::/, $source_entry, 2)[1];
}

# parse http/https/ftp protocols only
next unless $url =~ /^(https?|ftp):\/\//;

my $asset = { 'url' => $url };
my $digest = $digests[$i];

if ($digest && $digest ne 'SKIP') {
$asset->{'digest'} = $digest;
}

push @assets, $asset;
}

return @assets;
}

sub parse {
my ($config, $srcinfo_file) = @_;

my $ret = {};
my $fh;
unless (open($fh, '<', $srcinfo_file)) {
$ret->{'error'} = "$srcinfo_file: $!";
return $ret;
}

my %vars;
while (my $line = <$fh>) {
chomp $line;
# newline / comment
next if $line =~ /^\s*(#.*)?$/;

if ($line =~ /^\s*([^=\s]+)\s*=\s*(.*)\s*$/) {
my ($key, $value) = ($1, $2);
push @{ $vars{$key} }, $value;
}
}
close $fh;

$ret->{'name'} = $vars{'pkgname'}->[0] if exists $vars{'pkgname'};
if (exists $vars{'pkgver'} && exists $vars{'pkgrel'}) {
$ret->{'version'} = $vars{'pkgver'}->[0] . '-' . $vars{'pkgrel'}->[0];
} elsif (exists $vars{'pkgver'}) {
$ret->{'version'} = $vars{'pkgver'}->[0];
}

$ret->{'deps'} = [];
my @dep_types = qw(depends makedepends checkdepends);
foreach my $dep_type (@dep_types) {
push @{ $ret->{'deps'} }, @{ $vars{$dep_type} || [] };
}

# i*86
my ($arch) = Build::gettargetarchos($config);
$arch = 'i686' if $arch =~ /^i[345]86$/;
foreach my $dep_type (@dep_types) {
my $arch_dep_key = "${dep_type}_$arch";
push @{ $ret->{'deps'} }, @{ $vars{$arch_dep_key} || [] };
}

# extract remote assets
$ret->{'remoteassets'} = [];
for my $asuf ('', "_$arch") {
my @assets = _get_srcinfo_assets(\%vars, $asuf);
push @{ $ret->{'remoteassets'} }, @assets if @assets;
}

if (exists $vars{'arch'} && !grep { $_ eq 'any' } @{ $vars{'arch'} }) {
my %supported_arches = map { $_ => 1 } @{ $vars{'arch'} };

if (exists $supported_arches{'i686'}) {
$supported_arches{'i386'} = $supported_arches{'i486'} = $supported_arches{'i586'} = 1;
}

$ret->{'exclarch'} = [ sort keys %supported_arches ];
}

return $ret;
}


1;
8 changes: 7 additions & 1 deletion Build/Repo.pm
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use strict;
our $do_rpmmd;
our $do_deb;
our $do_arch;
our $do_archsrcinfo;
our $do_susetags;
our $do_mdk;
our $do_apk;
Expand All @@ -33,12 +34,13 @@ sub import {
for (@_) {
$do_rpmmd = 1 if $_ eq ':rpmmd';
$do_deb = 1 if $_ eq ':deb';
$do_archsrcinfo = 1 if $_ eq ':archsrcinfo';
$do_arch = 1 if $_ eq ':arch';
$do_susetags = 1 if $_ eq ':susetags';
$do_mdk = 1 if $_ eq ':mdk';
$do_apk = 1 if $_ eq ':apk';
}
$do_rpmmd = $do_deb = $do_arch = $do_susetags = $do_mdk = $do_apk = 1 unless $do_rpmmd || $do_deb || $do_arch || $do_susetags || $do_mdk || $do_apk;
$do_rpmmd = $do_deb = $do_arch = $do_archsrcinfo = $do_susetags = $do_mdk = $do_apk = 1 unless $do_rpmmd || $do_deb || $do_arch || $do_susetags || $do_mdk || $do_apk;
if ($do_rpmmd) {
require Build::Rpmmd;
}
Expand All @@ -51,6 +53,9 @@ sub import {
if ($do_arch) {
require Build::Archrepo;
}
if ($do_archsrcinfo) {
require Build::Archrepo;
}
if ($do_mdk) {
require Build::Mdkrepo;
}
Expand All @@ -64,6 +69,7 @@ sub parse {
return Build::Rpmmd::parse(@args) if $do_rpmmd && $type eq 'rpmmd';
return Build::Susetags::parse(@args) if $do_susetags && $type eq 'susetags';
return Build::Debrepo::parse(@args) if $do_deb && $type eq 'deb';
return Build::Archrepo::parse(@args) if $do_archsrcinfo && $type eq 'archsrcinfo';
return Build::Archrepo::parse(@args) if $do_arch && $type eq 'arch';
return Build::Mdkrepo::parse(@args) if $do_arch && $type eq 'mdk';
return Build::Apkrepo::parse(@args) if $do_apk && $type eq 'apk';
Expand Down
1 change: 1 addition & 0 deletions PBuild/Job.pm
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ sub collect_result {
@d = map {"DEBS/$_"} sort(PBuild::Util::ls("$buildroot/.build.packages/DEBS")); # assume debbuild
push @d, 'SDEBS';
}
@d = ('ARCHPKGS') if $p->{'recipe'} =~ /SRCINFO$/;
@d = ('ARCHPKGS') if $p->{'recipe'} =~ /PKGBUILD$/;
@d = ('APKS') if $p->{'recipe'} =~ /APKBUILD$/;
@d = ('KIWI') if $p->{'recipe'} =~ /\.kiwi$/;
Expand Down
2 changes: 2 additions & 0 deletions PBuild/Recipe.pm
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ sub find_recipe {
return $files{'fissile.yml'} if $type eq 'fissile' && $files{'fissile.yml'};
return $files{'Chart.yaml'} if $type eq 'helm' && $files{'Chart.yaml'};
return (grep {/flatpak\.(?:ya?ml|json)$/} sort keys %files)[0] if $type eq 'flatpak';
return $files{'SRCINFO'} if $type eq 'archsrcinfo' && $files{'SRCINFO'};
return $files{'PKGBUILD'} if $type eq 'arch' && $files{'PKGBUILD'};
return $files{'APKBUILD'} if $type eq 'apk' && $files{'APKBUILD'};
my $pkg = $p->{'pkg'};
Expand Down Expand Up @@ -219,6 +220,7 @@ sub looks_like_packagedir {
return 1 if $file =~ /^(?:Dockerfile|mkosi)\./;
return 1 if $file eq 'snapcraft.yaml' || $file eq 'appimage.yml';
return 1 if $file eq 'Dockerfile' || $file eq 'fissile.yml' || $file eq 'Chart.yml';
return 1 if $file eq 'SRCINFO';
return 1 if $file eq 'PKGBUILD';
return 1 if $file eq 'APKBUILD';
}
Expand Down
1 change: 1 addition & 0 deletions build-recipe
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ recipe_set_buildtype() {
*.dsc) BUILDTYPE=dsc ;;
*.kiwi) BUILDTYPE=kiwi ;;
*.productcompose) BUILDTYPE=productcompose ;;
SRCINFO) BUILDTYPE=arch ;;
PKGBUILD) BUILDTYPE=arch ;;
APKBUILD) BUILDTYPE=apk ;;
snapcraft.yaml) BUILDTYPE=snapcraft ;;
Expand Down