updated update_epel_release_latest function to create or update symbolic links for epel-release, latest and next, packages

This commit is contained in:
Pedro Moura 2021-11-26 13:49:01 -03:00 committed by kevin
parent 6231d8fd25
commit 2e7473fdbd

View file

@ -431,19 +431,44 @@ def sync_single_release(release):
return needssync
def update_epel_release_latest(releases):
"""
This function, creates or updates a symbolic links for epel-release, latest and next, packages.
Creates or updates a symbolic link pointing to the latest release of the epel-release package and
another pointing to the next release of the epel-release package.
The symbolic link will be created or updated if:
- There isn't a symbolic link for the latest package;
- Current symbolic link is pointing to an outdated package;
- Current symbolic link is broken;
- There is a file that isn't a link with the same name of the symbolic link.
If the symbolic link is pointing to the latest release already, this function will do nothing.
Parameters:
releases (dict): contains similar information of global variable RELEASES
"""
for release in releases:
if 'epel' in release:
for path in Path(RELEASES[release]['repos']['epel']['to'][0]['dest']).rglob('epel-release*noarch*'):
for path in Path(RELEASES[release]['repos']['epel']['to'][0]['dest']).rglob('epel-*release*noarch*'):
if 'Packages' in str(path) and 'x86_64' in str(path):
dest = '/pub/epel/epel-release-latest-' + release[4]+ '.noarch.rpm'
if os.path.lexists(dest):
if not os.path.islink(dest) or not os.path.exists(os.path.join(EPELDEST,os.readlink(dest))):
os.remove(dest)
os.symlink(os.path.relpath(path, os.path.dirname(dest)), dest)
break
if "next" in str(path):
dest = 'pub/epel/epel-next-release-latest-' + release[4] + '.noarch.rpm'
else:
os.symlink(os.path.relpath(path, os.path.dirname(dest)), dest)
break
dest = 'pub/epel/epel-release-latest-' + release[4] + '.noarch.rpm'
pkg_relpath = os.path.relpath(path,EPELDEST)
if os.path.lexists(dest) and os.path.islink(dest):
origin_dest = os.path.join(EPELDEST,os.readlink(dest))
if origin_dest != str(path):
os.remove(dest)
os.symlink(pkg_relpath, dest)
elif os.path.lexists(dest) and not os.path.islink(dest):
os.remove(dest)
os.symlink(pkg_relpath, dest)
else:
os.symlink(pkg_relpath, dest)
def main():
parser = argparse.ArgumentParser()