use strict;
use Digest::MD5;
use Build::Rpm;
+use Data::Dumper;
our $expand_dbg;
our $strip_versions;
our $do_rpm;
our $do_deb;
+our $do_img;
sub import {
for (@_) {
$do_rpm = 1 if $_ eq ':rpm';
$do_deb = 1 if $_ eq ':deb';
+ $do_img = 1 if $_ eq ':img';
}
- $do_rpm = $do_deb = 1 if !$do_rpm && !$do_deb;
+ $do_rpm = $do_deb = $do_img = 1 if !$do_rpm && !$do_deb && !$do_img;
if ($do_deb) {
require Build::Deb;
}
+ if ($do_img) {
+ require Build::Kiwi;
+ }
}
sub read_config {
my ($arch, $cfile) = @_;
+# FIXME: make this an option
+ my $use_ignore = 0;
my @macros = split("\n", $std_macros.$extra_macros);
push @macros, "%define _target_cpu $arch";
push @macros, "%define _target_os linux";
next;
}
if ($l0 eq 'preinstall:' || $l0 eq 'vminstall:' || $l0 eq 'required:' || $l0 eq 'support:' || $l0 eq 'keep:' || $l0 eq 'prefer:' || $l0 eq 'ignore:' || $l0 eq 'conflict:' || $l0 eq 'runscripts:') {
+ next if ( $l0 eq 'ignore:' && $use_ignore == 0 );
my $t = substr($l0, 0, -1);
for my $l (@l) {
if ($l eq '!*') {
my ($cf, $fn, @args) = @_;
return Build::Rpm::parse($cf, $fn, @args) if $do_rpm && $fn =~ /\.spec$/;
return Build::Deb::parse($cf, $fn, @args) if $do_deb && $fn =~ /\.dsc$/;
+ return Build::Kiwi::parse($cf, $fn, @args) if $do_img && $fn =~ /config\.xml$/;
+ return Build::Kiwi::parse($cf, $fn, @args) if $do_img && $fn =~ /\.kiwi$/;
return undef;
}
}
return Build::Rpm::query($handle, %opts) if $do_rpm && $binname =~ /\.rpm$/;
return Build::Deb::query($handle, %opts) if $do_deb && $binname =~ /\.deb$/;
+ return Build::Kiwi::queryiso($handle, %opts) if $do_img && $binname =~ /\.iso$/;
return undef;
}
my ($binname) = @_;
return Build::Rpm::queryhdrmd5($binname) if $do_rpm && $binname =~ /\.rpm$/;
return Build::Deb::queryhdrmd5($binname) if $do_deb && $binname =~ /\.deb$/;
+ return Build::Kiwi::queryhdrmd5($binname) if $do_img && $binname =~ /\.iso$/;
+ return Build::Kiwi::queryhdrmd5($binname) if $do_img && $binname =~ /\.raw$/;
+ return Build::Kiwi::queryhdrmd5($binname) if $do_img && $binname =~ /\.raw.install$/;
return undef;
}
--- /dev/null
+
+package Build::Kiwi;
+
+use strict;
+use Digest::MD5;
+#use Device::Cdio::ISO9660;
+#use Device::Cdio::ISO9660::IFS;
+
+my $have_zlib;
+eval {
+ require Compress::Zlib;
+ $have_zlib = 1;
+};
+
+sub parse {
+ my ($bconf, $fn) = @_;
+ my $ret;
+ my @control;
+
+print "Build::Kiwi::parse IS NOT IMPLEMENTED ! \n";
+die();
+
+ # get arch and os from macros
+ my ($arch, $os);
+ for (@{$bconf->{'macros'} || []}) {
+ $arch = $1 if /^%define _target_cpu (\S+)/;
+ $os = $1 if /^%define _target_os (\S+)/;
+ }
+ # map to debian names
+ $os = 'linux' if !defined($os);
+ $arch = 'all' if !defined($arch) || $arch eq 'noarch';
+ $arch = 'i386' if $arch =~ /^i[456]86$/;
+ $arch = 'powerpc' if $arch eq 'ppc';
+ $arch = 'amd64' if $arch eq 'x86_64';
+
+ if (ref($fn) eq 'ARRAY') {
+ @control = @$fn;
+ } else {
+ local *F;
+ if (!open(F, '<', $fn)) {
+ $ret->{'error'} = "$fn: $!";
+ return $ret;
+ }
+ @control = <F>;
+ close F;
+ chomp @control;
+ }
+ splice(@control, 0, 3) if @control > 3 && $control[0] =~ /^-----BEGIN/;
+ my $name;
+ my $version;
+ my @deps;
+ while (@control) {
+ my $c = shift @control;
+ last if $c eq ''; # new paragraph
+ my ($tag, $data) = split(':', $c, 2);
+ next unless defined $data;
+ $tag = uc($tag);
+ while (@control && $control[0] =~ /^\s/) {
+ $data .= "\n".substr(shift @control, 1);
+ }
+ $data =~ s/^\s+//s;
+ $data =~ s/\s+$//s;
+ if ($tag eq 'VERSION') {
+ $version = $data;
+ $version =~ s/-[^-]+$//;
+ } elsif ($tag eq 'SOURCE') {
+ $name = $data;
+ } elsif ($tag eq 'BUILD-DEPENDS' || $tag eq 'BUILD-CONFLICTS' || $tag eq 'BUILD-IGNORE') {
+ my @d = split(/,\s*/, $data);
+ for my $d (@d) {
+ if ($d =~ /^(.*?)\s*\[(.*)\]$/) {
+ $d = $1;
+ my $isneg = 0;
+ my $bad;
+ for my $q (split('[\s,]', $2)) {
+ $isneg = 1 if $q =~ s/^\!//;
+ $bad = 1 if !defined($bad) && !$isneg;
+ if ($isneg) {
+ if ($q eq $arch || $q eq "$os-$arch") {
+ $bad = 1;
+ last;
+ }
+ } elsif ($q eq $arch || $q eq "$os-$arch") {
+ $bad = 0;
+ }
+ }
+ next if $bad;
+ }
+ $d =~ s/ \(([^\)]*)\)/ $1/g;
+ $d =~ s/>>/>/g;
+ $d =~ s/<</</g;
+ if ($tag eq 'BUILD-DEPENDS') {
+ push @deps, $d;
+ } else {
+ push @deps, "-$d";
+ }
+ }
+ }
+ }
+ $ret->{'name'} = $name;
+ $ret->{'version'} = $version;
+ $ret->{'deps'} = \@deps;
+ return $ret;
+}
+
+sub debq {
+ my ($fn) = @_;
+
+ print "Build::Kiwi::debq IS NOT IMPLEMENTED ! \n";
+ die();
+
+ return 1;
+}
+
+sub queryiso {
+ my ($handle, %opts) = @_;
+
+# $iso = Device::Cdio::ISO9660::IFS->new(-source=>'copying.iso');
+ my $src = '';
+ my $data = {
+ name => "DEFAULT_NAME",
+# hdrmd5 => Digest::MD5::md5_hex($handle); #FIXME create real checksum from iso
+ };
+# $data->{'source'} = $src if $src ne '';
+ if ($opts{'evra'}) {
+#FIXME find out of iso:
+ my $arch = "i586";
+ $data->{'version'} = "0.1";
+ $data->{'release'} = "1";
+ $data->{'type'} = "iso";
+ $data->{'arch'} = $arch;
+ }
+ if ($opts{'filelist'}) {
+ print ("Build::KIWI query filelist not implemented !\n");
+ die();
+# $data->{'filelist'} = $res{'FILENAMES'};
+ }
+ if ($opts{'description'}) {
+ print ("Build::KIWI query description not implemented !\n");
+ die();
+# $data->{'summary'} = $res{'SUMMARY'}->[0];
+# $data->{'description'} = $res{'DESCRIPTION'}->[0];
+ }
+ return $data;
+}
+
+sub queryhdrmd5 {
+ my ($bin) = @_;
+
+ print "Build::Kiwi::queryhdrmd5 IS NOT IMPLEMENTED ! \n";
+ die();
+
+}
+
+1;