From 4077c90216e145e26750363f8a58590f72a94efc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Petr=20P=C3=ADsa=C5=99?= Date: Thu, 16 Jan 2014 17:15:04 +0100 Subject: [PATCH] Remove stray symlinks in local repository The repository of built packages contains symlinks into tree with package sources. If one removes a source subtree, a dangling symlink will remain and createrepo will die on that. This patch removes stray symlinks before updating the repository. --- lib/Fedora/Rebuild/Repository.pm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/Fedora/Rebuild/Repository.pm b/lib/Fedora/Rebuild/Repository.pm index 4dfd15c..46647d5 100644 --- a/lib/Fedora/Rebuild/Repository.pm +++ b/lib/Fedora/Rebuild/Repository.pm @@ -82,7 +82,23 @@ sub insert { # This updates YUM metadata. sub update { my $self = shift; + print "Updating YUM repository of already rebuilt packages...\n"; + + # Remove stray symlinks first, createrepo dies on that. + opendir(my $dir, $self->path) or + croak("Could not open `" . $self->path . "' directory: $!\n"); + for my $file (readdir($dir)) { + $file = File::Spec->catfile($self->path, $file); + if (-l $file and !-e $file) { + print "Removing stray symlink `", $file, "'\n"; + unlink $file or croak("Could not remove stray symlink `" . $file . + "': $!\n"); + } + } + closedir($dir); + + # Update the repository if (!Fedora::Rebuild::Execute->new->do( $self->path, 'createrepo', '--update', '.')) { croak("Could not update repository.\n"); -- 2.11.4.GIT