OpenStack in a snap!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.2 KiB

"""Update LD_LIBRARY_PATH and PATH snapcraft.yaml in the current
working directory.
Editing the lines in question directly in snapcraft.yaml is pretty
terrible, as the lines are long, and we cannot break them up into a
normal yaml string w/ a | and still get snapcraft's variable
expansion. (Or, if we can, I don't know what magic invocation will do
This script will not check in the new snapcraft.yaml. You should
inspect the updates and check in the file yourself!
import os
import shutil
import sys
PATH = (
def main():
"""Replace PATH and LD_LIBRARY_PATH with lists above.
This is dead simple code that relies on there being one setting
for LD_LIBRARY_PATH and PATH. It needs to be updated to be made
smarter if more instances are added.
Note that it would be nice if we could just read and write the
yaml, but we'd chomp comments if we did so. And we like our
if not os.path.isfile('./snapcraft.yaml'):
print('Cannot file snapcraft.yaml in the current working dir!')
print('snapcraft.yaml found in the current working dir. '
'Updating LD_LIBRARY_PATH and PATH ...')
libs = ':'.join(LD_LIBRARY_PATH)
path_ = ':'.join(PATH)
with open('./snapcraft.yaml', 'r') as source:
with open('./snapcraft.yaml.updated', 'w') as dest:
lines = source.readlines()
for line in lines:
if line.startswith(' LD_LIBRARY_PATH: '):
line = ' LD_LIBRARY_PATH: {}\n'.format(libs)
if line.startswith(' PATH: '):
line = ' PATH: {}\n'.format(path_)
shutil.move('./snapcraft.yaml.updated', './snapcraft.yaml')
print('File updated! Please manually inspect the changes '
'and commit them via git.')
if __name__ == '__main__':