mirror of
https://github.com/jupyterhub/the-littlest-jupyterhub.git
synced 2025-12-18 21:54:05 +08:00
Write out deb line only if it already doesn't exist
This commit is contained in:
@@ -26,11 +26,11 @@ def add_source(name, source_url, section):
|
|||||||
"""
|
"""
|
||||||
# lsb_release is not installed in most docker images by default
|
# 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()
|
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:
|
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
|
# 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.write(line)
|
||||||
f.truncate()
|
f.truncate()
|
||||||
utils.run_subprocess(['apt-get', 'update', '--yes'])
|
utils.run_subprocess(['apt-get', 'update', '--yes'])
|
||||||
|
|||||||
Reference in New Issue
Block a user