Skip to content

Commit

Permalink
Docker: Support #!BuildName directive to set the name
Browse files Browse the repository at this point in the history
The name defines how the container will be known in the OBS
:full tree.
  • Loading branch information
mlschroe committed Oct 28, 2020
1 parent 0371f04 commit 11b3ff7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Build/Docker.pm
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ sub parse {

my @lines = split(/\r?\n/, $dockerfile_data);
my $ret = {
'name' => 'docker',
'deps' => [],
'path' => [],
'imagerepos' => [],
Expand All @@ -193,6 +192,9 @@ sub parse {
my @tags = split(' ', $1);
push @{$ret->{'containertags'}}, @tags if @tags;
}
if ($line =~ /^#!BuildName:\s*(\S+)\s*$/) {
$ret->{'name'} = $1;
}
if ($line =~ /^#!BuildVersion:\s*(\S+)\s*$/) {
$ret->{'version'} = $1;
}
Expand Down Expand Up @@ -297,6 +299,7 @@ sub parse {
s/<VERSION>/$version/g if defined $version;
s/<RELEASE>/$release/g if defined $release;
}
$ret->{'name'} = 'docker' if !defined($ret->{'name'}) && !$cf->{'__dockernoname'};
$ret->{'path'} = [ { 'project' => '_obsrepositories', 'repository' => '' } ] if $useobsrepositories;
$ret->{'basecontainer'} = $basecontainer if $basecontainer;
$ret->{'nosquash'} = 1 if $nosquash;
Expand All @@ -316,7 +319,7 @@ sub showcontainerinfo {
}
my ($fn, $image, $taglist, $annotationfile) = @ARGV;
local $Build::Kiwi::urlmapper = sub { return $_[0] };
my $cf = {};
my $cf = { '__dockernoname' => 1 };
$cf->{'buildrelease'} = $release if defined $release;
my $d = {};
$d = parse($cf, $fn) if $fn;
Expand Down Expand Up @@ -352,6 +355,7 @@ sub showcontainerinfo {
$containerinfo->{'repos'} = \@repos if @repos;
$containerinfo->{'file'} = $image if defined $image;
$containerinfo->{'disturl'} = $disturl if defined $disturl;
$containerinfo->{'name'} = $d->{'name'} if defined $d->{'name'};
$containerinfo->{'version'} = $d->{'version'} if defined $d->{'version'};
$containerinfo->{'release'} = $release if defined $release;
$containerinfo->{'milestone'} = $d->{'milestone'} if defined $d->{'milestone'};
Expand Down

0 comments on commit 11b3ff7

Please sign in to comment.