Skip to content

Commit

Permalink
Merge pull request #449 from GeorgianaElena/fix_445
Browse files Browse the repository at this point in the history
Write out deb line only if it already doesn't exist
  • Loading branch information
yuvipanda authored Oct 22, 2019
2 parents 5290b01 + 1956f11 commit 91c1420
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tljh/apt.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ def add_source(name, source_url, section):
"""
# lsb_release is not installed in most docker images by default
distro = subprocess.check_output(['/bin/bash', '-c', 'source /etc/os-release && echo ${VERSION_CODENAME}'], stderr=subprocess.STDOUT).decode().strip()
line = f'deb {source_url} {distro} {section}'
line = f'deb {source_url} {distro} {section}\n'
with open(os.path.join('/etc/apt/sources.list.d/', name + '.list'), 'a+') as f:
# Write out deb line only if it already doesn't exist
if f.read() != line:
f.seek(0)
f.seek(0)
if line not in f.read():
f.write(line)
f.truncate()
utils.run_subprocess(['apt-get', 'update', '--yes'])
Expand Down

0 comments on commit 91c1420

Please sign in to comment.