Quellcode durchsuchen

Custom shebangs for applications entrypoint

Valentin Niess vor 5 Jahren
Ursprung
Commit
70aaa05f4e

+ 1 - 0
applications/xonsh/entrypoint.sh

@@ -1 +1,2 @@
+#! /bin/bash -i
 {{ python-executable }} -u "${APPDIR}/opt/python{{ python-version }}/bin/xonsh" "$@"
 {{ python-executable }} -u "${APPDIR}/opt/python{{ python-version }}/bin/xonsh" "$@"

+ 1 - 0
python_appimage/appimage/relocate.py

@@ -296,6 +296,7 @@ def relocate_python(python=None, appdir=None):
         entrypoint_path = PREFIX + '/data/entrypoint.sh'
         entrypoint_path = PREFIX + '/data/entrypoint.sh'
         entrypoint = load_template(entrypoint_path, python=PYTHON_X_Y)
         entrypoint = load_template(entrypoint_path, python=PYTHON_X_Y)
         dictionary = {'entrypoint': entrypoint,
         dictionary = {'entrypoint': entrypoint,
+                      'shebang': '#! /bin/bash',
                       'tcltk-env': tcltk_env_string(PYTHON_PKG)}
                       'tcltk-env': tcltk_env_string(PYTHON_PKG)}
         _copy_template('apprun.sh', apprun, **dictionary)
         _copy_template('apprun.sh', apprun, **dictionary)
 
 

+ 7 - 0
python_appimage/commands/build/app.py

@@ -247,10 +247,17 @@ def execute(appdir, name=None, python_version=None, linux_tag=None,
         if entrypoint_path:
         if entrypoint_path:
             entrypoint_path = entrypoint_path[0]
             entrypoint_path = entrypoint_path[0]
             log('BUNDLE', os.path.basename(entrypoint_path))
             log('BUNDLE', os.path.basename(entrypoint_path))
+
+            with open(entrypoint_path) as f:
+                shebang = f.readline().strip()
+            if not shebang.startswith('#!'):
+                shebang = '#! /bin/bash'
+
             entrypoint = load_template(entrypoint_path, **dictionary)
             entrypoint = load_template(entrypoint_path, **dictionary)
             python_pkg = 'AppDir/opt/python{0:}/lib/python{0:}'.format(
             python_pkg = 'AppDir/opt/python{0:}/lib/python{0:}'.format(
                 python_version)
                 python_version)
             dictionary = {'entrypoint': entrypoint,
             dictionary = {'entrypoint': entrypoint,
+                          'shebang': shebang,
                           'tcltk-env': tcltk_env_string(python_pkg)}
                           'tcltk-env': tcltk_env_string(python_pkg)}
             copy_template(PREFIX + '/data/apprun.sh', 'AppDir/AppRun',
             copy_template(PREFIX + '/data/apprun.sh', 'AppDir/AppRun',
                           **dictionary)
                           **dictionary)

+ 1 - 1
python_appimage/data/apprun.sh

@@ -1,4 +1,4 @@
-#! /bin/bash
+{{ shebang }}
 
 
 # Export APPRUN if running from an extracted image
 # Export APPRUN if running from an extracted image
 self="$(readlink -f -- $0)"
 self="$(readlink -f -- $0)"