freedomofpress / securedrop-builder

Packaging logic for building SecureDrop-related Debian packages
GNU General Public License v3.0
7 stars 11 forks source link

Check build path isn't too long #429

Closed legoktm closed 9 months ago

legoktm commented 1 year ago

https://github.com/pypa/distlib/blob/5cc90837e38db4b37a3c33474774c82233b14e90/distlib/scripts.py#L148

pip (via distlib) has behavior to use a different variation on the shebang if the build path is too long to fit in a linux shebang (see https://rosettacode.org/wiki/Multiline_shebang#Python for an explanation of how the polyglot file works).

In the most recent securedrop-client release, a build path was used that was 1 character over the limit

>>> len("#!/home/user/securedrop-builder/build/debbuild/packaging/securedrop-client/debian/securedrop-client/opt/venvs/securedrop-client\n")
128

This results in a weird diffoscope diff of:

│ │ ├── ./opt/venvs/securedrop-client/bin/alembic
│ │ │ @@ -1,10 +1,8 @@
│ │ │ -#!/bin/sh
│ │ │ -'''exec' /opt/venvs/securedrop-client/bin/python "$0" "$@"
│ │ │ -' '''
│ │ │ +#!/opt/venvs/securedrop-client/bin/python
│ │ │  # -*- coding: utf-8 -*-
│ │ │  import re
│ │ │  import sys
│ │ │  from alembic.config import main
│ │ │  if __name__ == '__main__':
│ │ │      sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
│ │ │      sys.exit(main())

We should add a check to one of the scripts to abort if the build path is too long

legoktm commented 9 months ago

As of https://github.com/freedomofpress/securedrop-client/pull/1741 builds are now done in a container that uses a fixed path that is short enough.