- if ! file --mime bin/$binfile |grep -q binary; then
- # Not a binary file
- if [[ "$binfile" =~ ^activate(.csh|.fish|)$ ]]; then
- # these 'activate' scripts need special treatment
- sed -i "s/VIRTUAL_ENV=\".*\"/VIRTUAL_ENV=\"\/usr\/share\/$python\/dist\/$PYTHON_PKG\"/" bin/$binfile
- sed -i "s/VIRTUAL_ENV \".*\"/VIRTUAL_ENV \"\/usr\/share\/$python\/dist\/$PYTHON_PKG\"/" bin/$binfile
- else
- if grep -q -E '^#!.*/bin/python\d?' bin/$binfile; then
- # Replace shebang line
- sed -i "1 s/^.*$/#!\/usr\/share\/$python\/dist\/$PYTHON_PKG\/bin\/python/" bin/$binfile
- fi
- fi
+ if file --mime "bin/$binfile" | grep -q binary; then
+ : # Nothing to do for binary files
+ elif [[ "$binfile" =~ ^activate(.csh|.fish|)$ ]]; then
+ sed -ri "s@VIRTUAL_ENV(=| )\".*\"@VIRTUAL_ENV\\1\"/$sys_venv_dir\"@" "bin/$binfile"
+ else
+ # Replace shebang line
+ sed -ri "1 s@^#\![^[:space:]]+/bin/python[0-9.]*@#\!/$sys_venv_py@" "bin/$binfile"