Skip to content

Commit

Permalink
[backend] support "staticlinks" for build results in publisher. Allow…
Browse files Browse the repository at this point in the history
…s to create static links to packages or appliances without versions or release/build numbers.
  • Loading branch information
adrianschroeter committed Oct 15, 2012
1 parent f46212f commit f691618
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/backend/bs_publish
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,47 @@ sub deleterepo_arch {

##########################################################################

sub createrepo_staticlinks {
my ($extrep, $projid, $repoid, $signargs, $pubkey, $repoinfo, $options) = @_;

my $versioned = grep {$_ eq 'versioned'} @{$options || []};
for my $arch ('.', ls($extrep)) {
next unless -d "$extrep/$arch";
for (ls("$extrep/$arch")) {
next unless -f "$extrep/$arch/$_";
my $link;
if (/^(.*)-([^-]*)-[^-]*\.rpm$/s) {
$link = "$1.rpm";
$link = "$1-$2.rpm" if $versioned;
} elsif (/^(.*)_([^_]*)-[^_]*\.deb$/s) {
$link = "$1.deb";
$link = "${1}_$2.deb" if $versioned;
} elsif (/^(.*)-(\d+\.\d+\.\d+)-Build\d+\.\d+([-\.].*\.(gz|bz2|xz))$/s) {
$link = "$1$3";
$link = "$1-$2$3" if $versioned;
} elsif (/^(.*)-(\d+\.\d+\.\d+)-Build\d+\.\d+(\.(raw|iso|qcow2))$/s) {
$link = "$1$3";
$link = "$1-$2$3" if $versioned;
}
next unless $link;
symlink($_, "$extrep/$arch/$link");
}
}
}

sub deleterepo_staticlinks {
my ($extrep) = @_;
for my $arch ('.', ls($extrep)) {
next unless -d "$extrep/$arch";
for (ls("$extrep/$arch")) {
next unless -l "$extrep/$arch/$_";
unlink("$extrep/$arch/$_");
}
}
}

##########################################################################

sub createpatterns_rpmmd {
my ($extrep, $projid, $repoid, $signargs, $pubkey, $repoinfo, $patterns) = @_;

Expand Down Expand Up @@ -1528,6 +1569,11 @@ sub publish {
} else {
deleterepo_arch($extrep, $projid, $xrepoid, $signargs, $pubkey, $repoinfo);
}
if ($repotype{'staticlinks'}) {
createrepo_staticlinks($extrep, $projid, $xrepoid, $signargs, $pubkey, $repoinfo, $repotype{'staticlinks'});
} else {
deleterepo_staticlinks($extrep, $projid, $xrepoid, $signargs, $pubkey, $repoinfo, $repotype{'staticlinks'});
}

if ($patterntype{'ymp'}) {
createpatterns_ymp($extrep, $projid, $xrepoid, $signargs, $pubkey, $repoinfo, $patterns);
Expand Down

0 comments on commit f691618

Please sign in to comment.