summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Schroeder <mls@suse.de>2014-10-09 12:06:57 (GMT)
committerMichael Schroeder <mls@suse.de>2014-10-09 12:41:25 (GMT)
commit03cbe99986faf4379fb758b46e40ecd746d3ef60 (patch)
tree8b67b078d798b86c48bd847f396b5a74d0848978
parent7cb8c73770ae8ce154edd68297ec37b88ec17352 (diff)
downloadobs-build-03cbe99986faf4379fb758b46e40ecd746d3ef60.tar.gz
obs-build-03cbe99986faf4379fb758b46e40ecd746d3ef60.tar.xz
Add support for Debian repositories
-rw-r--r--Build.pm14
-rw-r--r--Build/Deb.pm20
-rw-r--r--Makefile1
-rwxr-xr-xcreatedebdeps118
-rwxr-xr-xexpanddeps49
-rwxr-xr-xinit_buildsystem2
6 files changed, 180 insertions, 24 deletions
diff --git a/Build.pm b/Build.pm
index 2bf18dd..43021fe 100644
--- a/Build.pm
+++ b/Build.pm
@@ -598,15 +598,11 @@ sub readdeps {
next;
}
push @ss, shift @s;
- while (@s) {
- if ($s[0] =~ /^[\(<=>|]/) {
- $ss[-1] .= " $s[0] $s[1]";
- $ss[-1] =~ s/ \((.*)\)/ $1/;
- $ss[-1] =~ s/(<|>){2}/$1/;
- splice(@s, 0, 2);
- } else {
- last;
- }
+ while (@s && $s[0] =~ /^[\(<=>|]/) {
+ $ss[-1] .= " $s[0] $s[1]";
+ $ss[-1] =~ s/ \((.*)\)/ $1/;
+ $ss[-1] =~ s/(<|>){2}/$1/;
+ splice(@s, 0, 2);
}
}
my %ss;
diff --git a/Build/Deb.pm b/Build/Deb.pm
index f534c24..7f1f7ec 100644
--- a/Build/Deb.pm
+++ b/Build/Deb.pm
@@ -29,6 +29,18 @@ eval {
$have_zlib = 1;
};
+sub basearch {
+ my ($arch) = @_;
+ $arch = 'all' if !defined($arch) || $arch eq 'noarch';
+ $arch = 'i386' if $arch =~ /^i[456]86$/;
+ $arch = 'powerpc' if $arch eq 'ppc';
+ $arch = 'ppc64el' if $arch eq 'ppc64le';
+ $arch = 'amd64' if $arch eq 'x86_64';
+ $arch = 'armel' if $arch =~ /^armv[4567]l$/;
+ $arch = 'armhf' if $arch eq 'armv7hl';
+ return $arch;
+}
+
sub parse {
my ($bconf, $fn) = @_;
my $ret;
@@ -42,13 +54,7 @@ sub parse {
}
# 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 = 'ppc64el' if $arch eq 'ppc64le';
- $arch = 'amd64' if $arch eq 'x86_64';
- $arch = 'armel' if $arch =~ /^armv[4567]l$/;
- $arch = 'armhf' if $arch eq 'armv7hl';
+ $arch = basearch($arch);
if (ref($fn) eq 'ARRAY') {
@control = @$fn;
diff --git a/Makefile b/Makefile
index fd3ec66..7879945 100644
--- a/Makefile
+++ b/Makefile
@@ -49,6 +49,7 @@ install:
mkdrpms \
createzyppdeps \
createarchdeps \
+ createdebdeps \
createrepomddeps \
createyastdeps \
changelog2spec \
diff --git a/createdebdeps b/createdebdeps
new file mode 100755
index 0000000..20b924a
--- /dev/null
+++ b/createdebdeps
@@ -0,0 +1,118 @@
+#!/usr/bin/perl -w
+
+BEGIN {
+ unshift @INC, ($::ENV{"BUILD_DIR"} || "/usr/lib/build");
+}
+
+use strict;
+use Digest::MD5;
+use File::Path;
+use Getopt::Long;
+use Build::Deb;
+
+Getopt::Long::Configure("no_ignore_case");
+
+my $cachedir = "/var/cache/build";
+my $archpath;
+
+sub getreponame {
+ my ($url) = @_;
+ return $1 if "/$url/" =~ /.*\/([^\/]+)\/os\//;
+ return undef;
+}
+
+my $pkgnum = 0;
+
+sub printpkginfo {
+ my ($d, $repourl) = @_;
+
+ for (qw{package version filename architecture}) {
+ return unless defined $d->{$_};
+ }
+ $pkgnum++;
+ my $id = "$d->{'package'}.$d->{'architecture'}-$pkgnum/0/0";
+ print "F:$id: $repourl$d->{'filename'}\n";
+ if (defined $d->{'provides'}) {
+ $d->{'provides'} =~ s/,\s+/ /g;
+ print "P:$id: $d->{'provides'} $d->{'package'} (= $d->{'version'})\n";
+ } else {
+ print "P:$id: $d->{'package'} (= $d->{'version'})\n";
+ }
+ if (defined $d->{'depends'}) {
+ $d->{'depends'} =~ s/,\s+/ /g;
+ print "R:$id: $d->{'depends'}\n";
+ }
+ print "I:$id: $d->{package}-$d->{'version'} 0\n";
+}
+
+GetOptions('cachedir=s' => \$cachedir, 'archpath=s' => \$archpath) or exit(1);
+
+if (!$archpath) {
+ $archpath = `uname -p` || 'unknown';
+ chomp $archpath;
+}
+my $basearch = $archpath;
+$basearch =~ s/:.*//;
+$basearch = Build::Deb::basearch($basearch);
+
+for my $url (@ARGV) {
+ die("Not an remote debian repo") unless $url =~ /^(:?ftps?|https?):\/\/([^\/]*)\/?/;
+ my $reponame = getreponame($url);
+ my $repoid = Digest::MD5::md5_hex($url);
+ my $dir = "$cachedir/$repoid";
+
+ my @components;
+ my $baseurl = $url;
+
+ if ($url =~ /^(.*\/)\.(\/.*)?$/) {
+ # flat repo
+ $baseurl = $1;
+ @components = ('.');
+ $url = defined($2) ? "$1$2" : $1;
+ $url .= '/' unless $url =~ /\/$/;
+ } else {
+ if ($url =~ /([^\/]+)$/) {
+ @components = split(/[,+]/, $1);
+ $url =~ s/([^\/]+)$//;
+ }
+ push @components, 'main' unless @components;
+ $url .= '/' unless $url =~ /\/$/;
+ $url =~ s/([^\/]+\/)$/dists\/$1/;
+ }
+
+ File::Path::mkpath($dir);
+ for my $component (@components) {
+ unlink("$dir/Packages.gz");
+ if ($component eq '.') {
+ system($INC[0]."/download", $dir, "${url}Packages.gz");
+ die("Packages.gz missing\n") unless -s "$dir/Packages.gz";
+ } else {
+ system($INC[0]."/download", $dir, "$url$component/binary-$basearch/Packages.gz");
+ die("Packages.gz missing for basearch $basearch, component $component\n") unless -s "$dir/Packages.gz";
+ }
+ open(F, "-|", 'gunzip', '-dc', "$dir/Packages.gz") || die("$dir/Packages.gz: $!\n");
+ my $pkg = {};
+ my $tag;
+ while (<F>) {
+ chomp;
+ if ($_ eq '') {
+ printpkginfo($pkg, $baseurl);
+ $pkg = {};
+ next;
+ }
+ if (/^\s/) {
+ next unless $tag;
+ $pkg->{$tag} .= "\n".substr($_, 1);
+ next;
+ }
+ my $data;
+ ($tag, $data) = split(':', $_, 2);
+ next unless defined $data;
+ $tag = lc($tag);
+ $data =~ s/^\s*//;
+ $pkg->{$tag} = $data;
+ }
+ close(F) || die("gunzip: $!\n");
+ printpkginfo($pkg, $baseurl);
+ }
+}
diff --git a/expanddeps b/expanddeps
index 4ce4df3..fc9da3f 100755
--- a/expanddeps
+++ b/expanddeps
@@ -94,11 +94,25 @@ for my $arg (@ARGV) {
push @extradeps, $arg;
}
}
+
+my $binarytype;
my @archs = split(':', $archs);
if ($recipe =~ /(^|\/)PKGBUILD$/) {
push @archs, 'any' unless grep {$_ eq 'any'} @archs;
+ $binarytype = 'arch';
+} elsif ($recipe =~ /\.dsc$/) {
+ push @archs, 'all' unless grep {$_ eq 'noarch'} @archs;
+ $binarytype = 'deb';
} else {
push @archs, 'noarch' unless grep {$_ eq 'noarch'} @archs;
+ $binarytype = 'rpm';
+}
+
+# read dist if we can
+my $cf;
+if (defined($dist) && $dist ne '') {
+ $cf = Build::read_config_dist($dist, $archs[0], $configdir);
+ $binarytype = $cf->{'binarytype'} if $cf->{'binarytype'} && $cf->{'binarytype'} ne 'UNDEFINED';
}
my (%fn, %prov, %req);
@@ -112,6 +126,16 @@ my %packs_done;
open(F, '<', $rpmdeps) || die("$rpmdeps: $!\n");
# WARNING: the following code assumes that the 'I' tag comes last
my ($pkgF, $pkgP, $pkgR);
+
+my $verscmp = \&Build::Rpm::verscmp;
+
+if ($binarytype && $binarytype eq 'deb') {
+ $verscmp = \&Build::Deb::verscmp;
+ for my $arch (@archs) {
+ $arch = Build::Deb::basearch($arch) unless $arch =~ /^i[456]86$/;
+ }
+}
+
while(<F>) {
chomp;
if (/^F:(.*?)-\d+\/\d+\/\d+: (.*)$/) {
@@ -123,18 +147,16 @@ while(<F>) {
push @{$packs_arch{$2}}, $1;
} elsif (/^P:(.*?)-\d+\/\d+\/\d+: (.*)$/) {
$pkgP = $2;
- next if $prov{$1};
- $prov{$1} = $2;
+ $prov{$1} ||= $2;
} elsif (/^R:(.*?)-\d+\/\d+\/\d+: (.*)$/) {
$pkgR = $2;
- next if $req{$1};
- $req{$1} = $2;
+ $req{$1} ||= $2;
} elsif (/^I:(.*?)-\d+\/\d+\/\d+: (.*)$/) {
if ($ids{$1} && !$packs_done{$1} && defined($pkgF) && defined($pkgP) && defined($pkgR)) {
my $i = $1;
my $oldid = $ids{$1};
my $newid = $2;
- if (Build::Rpm::verscmp($oldid, $newid) < 0) {
+ if ($verscmp->($oldid, $newid) < 0) {
$ids{$i} = $newid;
$fn{$i} = $pkgF;
$prov{$i} = $pkgP;
@@ -184,10 +206,11 @@ if (!defined($dist) || $dist eq '') {
print STDERR "Warning: distribution not specified, assuming '$dist' (see $configdir).\n";
}
-my $cf = Build::read_config_dist($dist, $archs[0], $configdir);
+$cf ||= Build::read_config_dist($dist, $archs[0], $configdir);
$cf->{'warnings'} = 1;
my $dofileprovides = %{$cf->{'fileprovides'}};
+$dofileprovides = 1 if ($binarytype || 'rpm') ne 'rpm';
for my $pack (keys %packs) {
my $r = {};
@@ -201,7 +224,12 @@ for my $pack (keys %packs) {
next;
}
push @pr, $s;
- splice(@s, 0, 2) if @s && $s[0] =~ /^[<=>]/;
+ while (@s && $s[0] =~ /^[\(<=>|]/) {
+ $pr[-1] .= " $s[0] $s[1]";
+ $pr[-1] =~ s/ \((.*)\)/ $1/;
+ $pr[-1] =~ s/(<|>){2}/$1/;
+ splice(@s, 0, 2);
+ }
}
@s = split(' ', $req{$packs{$pack}} || '');
while (@s) {
@@ -212,7 +240,12 @@ for my $pack (keys %packs) {
next;
}
push @re, $s;
- splice(@s, 0, 2) if @s && $s[0] =~ /^[<=>]/;
+ while (@s && $s[0] =~ /^[\(<=>|]/) {
+ $re[-1] .= " $s[0] $s[1]";
+ $re[-1] =~ s/ \((.*)\)/ $1/;
+ $re[-1] =~ s/(<|>){2}/$1/;
+ splice(@s, 0, 2);
+ }
}
$r->{'provides'} = \@pr;
$r->{'requires'} = \@re;
diff --git a/init_buildsystem b/init_buildsystem
index 3e2a57b..f61df56 100755
--- a/init_buildsystem
+++ b/init_buildsystem
@@ -327,6 +327,8 @@ create_cache_file() {
mkdir -p "$(getcachedir "$SRC")"
if test "$BINTYPE" = arch ; then
set -- $BUILD_DIR/createarchdeps --cachedir="$CACHE_DIR" "$SRC"
+ elif test "$BINTYPE" = deb ; then
+ set -- $BUILD_DIR/createdebdeps --cachedir="$CACHE_DIR" --archpath "$BUILD_ARCH" "$SRC"
else
set -- $BUILD_DIR/createrepomddeps --cachedir="$CACHE_DIR" "$SRC"
fi