From 47dd38eb3eb604b72687afec7463c7303caac133 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Fri, 17 Jun 2016 12:56:14 -0400 Subject: [PATCH] Use #!/usr/bin/env for python scripts This is recommended for upstream, but not for downstream, like Fedora. So change /usr/bin/env to /usr/bin/python2 at RPM install time to match the ideal Fedora config. https://fedoraproject.org/wiki/Features/SystemPythonExecutablesUseSystemPython https://bugzilla.redhat.com/show_bug.cgi?id=1303282 --- tests/test_inject.py | 2 +- virt-clone | 2 +- virt-convert | 2 +- virt-install | 2 +- virt-manager | 2 +- virt-manager.spec.in | 8 ++++++++ virt-xml | 2 +- 7 files changed, 14 insertions(+), 6 deletions(-) diff --git a/tests/test_inject.py b/tests/test_inject.py index 508a82407..3b1848ac4 100755 --- a/tests/test_inject.py +++ b/tests/test_inject.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2 -tt +#!/usr/bin/env python2 -tt # Copyright (C) 2013, 2014 Red Hat, Inc. import atexit diff --git a/virt-clone b/virt-clone index 176509d9f..e0b354656 100755 --- a/virt-clone +++ b/virt-clone @@ -1,4 +1,4 @@ -#!/usr/bin/python2 -tt +#!/usr/bin/env python2 -tt # # Copyright(c) FUJITSU Limited 2007. # diff --git a/virt-convert b/virt-convert index 04371678a..5a28b504b 100755 --- a/virt-convert +++ b/virt-convert @@ -1,4 +1,4 @@ -#!/usr/bin/python2 -tt +#!/usr/bin/env python2 -tt # # Copyright 2008, 2013, 2014 Red Hat, Inc. # Joey Boggs diff --git a/virt-install b/virt-install index b48f21080..43f6cd3fd 100755 --- a/virt-install +++ b/virt-install @@ -1,4 +1,4 @@ -#!/usr/bin/python2 -tt +#!/usr/bin/env python2 -tt # # Copyright 2005-2014 Red Hat, Inc. # diff --git a/virt-manager b/virt-manager index 9f5b6ffb7..a4cf99f1f 100755 --- a/virt-manager +++ b/virt-manager @@ -1,4 +1,4 @@ -#!/usr/bin/python2 -tt +#!/usr/bin/env python2 -tt # # Copyright (C) 2006, 2014 Red Hat, Inc. # Copyright (C) 2006 Daniel P. Berrange diff --git a/virt-manager.spec.in b/virt-manager.spec.in index 0788edb8c..8c4a811ab 100644 --- a/virt-manager.spec.in +++ b/virt-manager.spec.in @@ -106,6 +106,7 @@ machine). %prep %setup -q + %build %if %{qemu_user} %global _qemu_user --qemu-user=%{qemu_user} @@ -151,6 +152,13 @@ python setup.py \ install -O1 --root=%{buildroot} %find_lang %{name} +# Replace '#!/usr/bin/env python2' with '#!/usr/bin/python2' +# The format is ideal for upstream, but not a distro. See: +# https://fedoraproject.org/wiki/Features/SystemPythonExecutablesUseSystemPython +for f in $(find %{buildroot} -type f -executable -print); do + sed -i "1 s|^#!/usr/bin/env python2|#!%{__python2}|" $f || : +done + # The conversion script was only added to virt-manager after several # Fedora cycles of using gsettings. Installing it now could convert old data # and wipe out recent settings. diff --git a/virt-xml b/virt-xml index 74762ab71..8fa951965 100755 --- a/virt-xml +++ b/virt-xml @@ -1,4 +1,4 @@ -#!/usr/bin/python2 -tt +#!/usr/bin/env python2 -tt # # Copyright 2013-2014 Red Hat, Inc. # Cole Robinson