#6419 Unnecessary generation of epel-release-latest-* symlinks
Closed: Fixed None Opened 7 years ago by tibbs.

There are a couple of errors in fedora-epel-push which cause the /pub/epel/epel-release-latest-* symlinks to be regenerated each time the script runs even though the script tries to avoid doing this.

First, DEST is defined with a trailing directory separator, which means some strings have a doubled slash. This isn't a problem except when you want to compare those strings against what's on the filesystem.

It appears that each use of $DEST is followed by a trailing slash, so it should be safe to remove it from the definition.

Secondly, the comparison on line 101 never succeeds. Relative links are explicitly created, and so the readlink call returns a relative path, but CANDIDATE is a full path. Also, candidate has a doubled slash in it due to the first issue.

You can't just use -ef to compare the two paths, because that will never match unless the current directory happens to be $DEST.

Solutions:

Remove trailing slash from $DEST definition and use readlink -e to get the link as a full path.

pushd to $DEST before making any comparisons.

I will attach a patch for each option.


Patch implementing the first option
patch1

Patch actually implementing the first option.
patch2

OK, to recap:

  • patch1 - pushd to $DEST and use the -ef comparison to see if the link points to the same file.

  • patch2 - Remove trailing slash from $DEST definition and Use readlink -e to get the full path. If the link is dangling, readlink -e returns nothing, so quote the variables in the comparison.

There are other ways to do this: don't pushd but use readlink -e, or don't remove trailing shash and use use -ef. But I've had enough fun for today.

These do appear to work for me in testing on a local mirror.

Applied patch2 (mostly at random, I don't care which solution)

Thanks!

Metadata Update from @tibbs:
- Issue set to the milestone: Fedora 24 Alpha

7 years ago

Login to comment on this ticket.

Metadata