Skip to content

Commit

Permalink
Improve parsing of kiwi's derived_from attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
mlschroe committed Apr 5, 2018
1 parent 62f4f09 commit b17de80
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions Build/Kiwi.pm
Original file line number Diff line number Diff line change
Expand Up @@ -144,25 +144,28 @@ sub kiwiparse {
if ($type->{'derived_from'}) {
my $derived = $type->{'derived_from'};
my ($name, $prp);
if ($derived =~ /^obs:\/{1,3}([^\/]+)\/([^\/]+)\/(.*)(?:#([^\#\/]+))$/) {
$name = defined($4) ? "$3:$4" : "$3";
if ($derived =~ /^obs:\/{1,3}([^\/]+)\/([^\/]+)\/(.*?)(?:#([^\#\/]+))?$/) {
$name = defined($4) ? "$3:$4" : "$3:latest";
$prp = "$1/$2";
} elsif ($derived =~ /^obsrepositories:\/{1,3}([^\/].*)(?:#([^\#\/]+))$/) {
$name = defined($2) ? "$1:$2" : "$1";
} elsif ($derived !~ /^file:/ && $derived =~ /^(.*)\/([^\/]+)(?:#([^\#\/]+))$/) {
} elsif ($derived =~ /^obsrepositories:\/{1,3}([^\/].*?)(?:#([^\#\/]+))?$/) {
$name = defined($2) ? "$1:$2" : "$1:latest";
} elsif ($derived =~ /^file:/) {
next; # just ignore and hope
} elsif ($derived =~ /^(.*)\/([^\/]+?)(?:#([^\#\/]+))?$/) {
my $url = $1;
$name = defined($3) ? "$2:$3" : "$2";
$name = defined($3) ? "$2:$3" : "$2:latest";
$prp = $urlmapper->($url) if $urlmapper;
# try again with one element moved from url to name
if (!$prp && $derived =~ /^(.*)\/([^\/]+\/[^\/]+)(?:#([^\#\/]+))$/) {
if (!$prp && $derived =~ /^(.*)\/([^\/]+\/[^\/]+?)(?:#([^\#\/]+))?$/) {
$url = $1;
$name = defined($3) ? "$2:$3" : "$2";
$name = defined($3) ? "$2:$3" : "$2:latest";
$prp = $urlmapper->($url) if $urlmapper;
}
die("derived_from url not using obs:/ scheme: $derived\n") unless $prp;
undef $name unless $prp;
}
push @packages, "container:$name" if defined $name;
push @containerrepos, $prp if $prp;
die("derived_from url not using obs:/ scheme: $derived\n") unless defined $name;
push @packages, "container:$name";
push @containerrepos, $prp if $prp;
}

push @packages, "kiwi-filesystem:$type->{'filesystem'}" if $type->{'filesystem'};
Expand Down

0 comments on commit b17de80

Please sign in to comment.