3 exec env LC_CTYPE=iso-8859-1 python "$0" ${1+"$@"}
6 from __future__ import absolute_import, print_function
7 from tempfile import NamedTemporaryFile
10 if sys.version_info[0] >= 3:
11 from shlex import quote
13 from pipes import quote
15 src_path, dest_path = sys.argv[1:]
17 with open(b'config/config.var/bup-python', 'rb') as src:
20 with NamedTemporaryFile() as tmp:
21 # Replace the section between "Here to end..." and the end of the
22 # preamble with the correct 'exec PYTHON "$0"'.
23 with open(src_path, 'rb') as src:
25 if line.startswith(b'# Here to end of preamble replaced during install'):
31 tmp.write(b'exec %s "$0"\n' % python)
36 shutil.copy(tmp.name, dest_path)
37 os.chmod(dest_path, 0o755)