[master 23/30] Update python-deps for python3 (#1014220)

M4rtinK installerbot-noreply at redhat.com
Mon Jun 1 14:04:40 UTC 2015


From: "Brian C. Lane" <bcl at redhat.com>

python-deps should print the unique list of files

Add site.py and sysconfig.py dependencies to python-deps

Make sure to pick up any dependencies they have by running them through
modulefinder.

Add PYTHONHASHSEED to python-deps call

When creating boot images dracut is run in a minimal chroot with no
/dev/urandom, setting PYTHONHASHSEED lets python3 run without it. The
seed is used for hashing object ids. It is not used for anything
requiring security.
---
 dracut/module-setup.sh |  2 +-
 dracut/python-deps     | 36 ++++++++++++++++++++++++++----------
 2 files changed, 27 insertions(+), 11 deletions(-)

diff --git a/dracut/module-setup.sh b/dracut/module-setup.sh
index 287a61e..ee92f69 100755
--- a/dracut/module-setup.sh
+++ b/dracut/module-setup.sh
@@ -55,7 +55,7 @@ install() {
     # rpm configuration file (needed by dd_extract)
     inst "/usr/lib/rpm/rpmrc"
     # python deps for parse-kickstart. DOUBLE WOOOO
-    $moddir/python-deps $moddir/parse-kickstart $moddir/driver-updates | while read dep; do
+    PYTHONHASHSEED=42 $moddir/python-deps $moddir/parse-kickstart $moddir/driver-updates | while read dep; do
         case "$dep" in
             *.so) inst_library $dep ;;
             *.py) inst_simple $dep ;;
diff --git a/dracut/python-deps b/dracut/python-deps
index 05a48e3..1828cbc 100755
--- a/dracut/python-deps
+++ b/dracut/python-deps
@@ -1,16 +1,32 @@
-#!/usr/bin/python2
+#!/usr/bin/python3
 # python-deps - find the dependencies of a given python script.
-
+#
+# Copyright (C) 2012-2015 by Red Hat, Inc.  All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+# Author(s): Will Woods <wwoods at redhat.com>
+#
 import copy
 import os, sys
 from modulefinder import ModuleFinder
-# pylint: disable=wildcard-import
-from distutils.sysconfig import *
+from distutils.sysconfig import get_python_lib, get_config_var, get_makefile_filename, get_config_h_filename
 
 sitedir = get_python_lib()
 libdir = get_config_var('LIBDEST')
 
-alsoNeeded = { libdir+"/urllib.py": libdir+"/urllib2.py" }
+alsoNeeded = dict()
 
 # A couple helper functions...
 def moduledir(pyfile):
@@ -35,13 +51,15 @@ mods = []
 deps = []
 
 scripts = copy.copy(sys.argv[1:])
+scripts.append(os.path.join(libdir,'site.py'))
+scripts.append(os.path.join(libdir,'sysconfig.py'))
 
 while scripts:
     script = scripts.pop()
 
     finder = ModuleFinder()
     finder.run_script(script) # parse the script
-    for mod in finder.modules.itervalues():
+    for mod in finder.modules.values():
         if not mod.__file__: # this module is builtin, so we can skip it
             continue
 
@@ -59,9 +77,7 @@ while scripts:
 # Include some bits that the python install itself needs
 print(get_makefile_filename())
 print(get_config_h_filename())
-print(os.path.join(libdir,'site.py'))
-print(os.path.join(libdir,'sysconfig.py'))
 
-# And print the list of deps.
-for d in deps:
+# And print the list of unique deps.
+for d in set(deps):
     print(d)


-- 
To view this commit on github, visit https://github.com/rhinstaller/anaconda/commit/a31442fea13fdebbf0171b0265e0a36f5d35fdde


More information about the anaconda-patches mailing list