FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Fedora Design Team

 
 
LinkBack Thread Tools
 
Old 02-10-2010, 07:12 PM
Chris Lumens
 
Default Allow any add-on python module to be updated via an updates.img.

---
anaconda | 64 ++++++++++++++++++++-----------------------------------------
1 files changed, 21 insertions(+), 43 deletions(-)

diff --git a/anaconda b/anaconda
index e9b620a..6dc0a96 100755
--- a/anaconda
+++ b/anaconda
@@ -112,50 +112,28 @@ def doShutdownX11Actions():
except:
pass

-# handle updates of just a single file in a python package
def setupPythonUpdates():
- import glob
+ from distutils.sysconfig import get_python_lib
+
+ for pkg in filter(os.path.isdir, os.listdir("/tmp/updates")):
+ # See if the package exists in /usr/lib{64,}/python/?.?/site-packages.
+ # If it does, we can set it up as an update. If not, the pkg is
+ # likely a completely new directory and should not be looked at.
+ dest = "%s/%s" % (get_python_lib(), pkg)
+ if not os.access(dest, os.R_OK):
+ dest = "%s/%s" % (get_python_lib(1), pkg)
+ if not os.access(dest, os.R_OK):
+ continue

- # get the python version. first of /usr/lib/python*, strip off the
- # first 15 chars
- pyvers = glob.glob("/usr/lib/python*")
- pyver = pyvers[0][15:]
-
- try:
- os.mkdir("/tmp/updates")
- except:
- pass
+ contents = os.listdir(pkg)

- for pypkg in ("block", "yum", "rpmUtils", "urlgrabber", "pykickstart", "parted", "meh"):
- # get the libdir. *sigh*
- if os.access("/usr/lib64/python%s/site-packages/%s" %(pyver, pypkg),
- os.X_OK):
- libdir = "lib64"
- elif os.access("/usr/lib/python%s/site-packages/%s" %(pyver, pypkg),
- os.X_OK):
- libdir = "lib"
- else:
- # If the directory doesn't exist, there's nothing to link over.
- # This happens if we forgot to include one of the above packages
- # in the image, for instance.
- continue
+ # Symlink over everything that's in the python libdir but not in
+ # the updates directory.
+ for f in filter(lambda fn: fn not in contents, os.listdir(dest)):
+ if f.endswith(".pyc") or f.endswith(".pyo"):
+ continue

- if os.access("/tmp/updates/%s" %(pypkg,), os.X_OK):
- for f in os.listdir("/usr/%s/python%s/site-packages/%s" %(libdir,
- pyver,
- pypkg)):
- if os.access("/tmp/updates/%s/%s" %(pypkg, f), os.R_OK):
- continue
- elif (f.endswith(".pyc") and
- os.access("/tmp/updates/%s/%s" %(pypkg, f[:-1]),os.R_OK)):
- # dont copy .pyc files we are replacing with updates
- continue
- else:
- os.symlink("/usr/%s/python%s/site-packages/%s/%s" %(libdir,
- pyver,
- pypkg,
- f),
- "/tmp/updates/%s/%s" %(pypkg, f))
+ os.symlink("%s/%s" % (dest, f), "/tmp/updates/%s/%s" % (pkg, f))

if os.access("/tmp/updates/70-anaconda.rules", os.R_OK):
import shutil
--
1.6.5.1

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 02-10-2010, 08:10 PM
David Lehman
 
Default Allow any add-on python module to be updated via an updates.img.

A couple of little issues...

On Wed, 2010-02-10 at 15:12 -0500, Chris Lumens wrote:
> ---
> anaconda | 64 ++++++++++++++++++++-----------------------------------------
> 1 files changed, 21 insertions(+), 43 deletions(-)
>
> diff --git a/anaconda b/anaconda
> index e9b620a..6dc0a96 100755
> --- a/anaconda
> +++ b/anaconda
> @@ -112,50 +112,28 @@ def doShutdownX11Actions():
> except:
> pass
>
> -# handle updates of just a single file in a python package
> def setupPythonUpdates():
> - import glob
> + from distutils.sysconfig import get_python_lib
> +
> + for pkg in filter(os.path.isdir, os.listdir("/tmp/updates")):

This will almost always be an empty list since os.listdir returns
basenames.

> + # See if the package exists in /usr/lib{64,}/python/?.?/site-packages.
> + # If it does, we can set it up as an update. If not, the pkg is
> + # likely a completely new directory and should not be looked at.
> + dest = "%s/%s" % (get_python_lib(), pkg)
> + if not os.access(dest, os.R_OK):
> + dest = "%s/%s" % (get_python_lib(1), pkg)
> + if not os.access(dest, os.R_OK):
> + continue
>
> - # get the python version. first of /usr/lib/python*, strip off the
> - # first 15 chars
> - pyvers = glob.glob("/usr/lib/python*")
> - pyver = pyvers[0][15:]
> -
> - try:
> - os.mkdir("/tmp/updates")
> - except:
> - pass
> + contents = os.listdir(pkg)

Similar problem here -- os.listdir("/tmp/updates/" + pkg) would work,
although I expect your solution to the above will dictate how you solve
this one.

Otherwise, looks good.

Dave

>
> - for pypkg in ("block", "yum", "rpmUtils", "urlgrabber", "pykickstart", "parted", "meh"):
> - # get the libdir. *sigh*
> - if os.access("/usr/lib64/python%s/site-packages/%s" %(pyver, pypkg),
> - os.X_OK):
> - libdir = "lib64"
> - elif os.access("/usr/lib/python%s/site-packages/%s" %(pyver, pypkg),
> - os.X_OK):
> - libdir = "lib"
> - else:
> - # If the directory doesn't exist, there's nothing to link over.
> - # This happens if we forgot to include one of the above packages
> - # in the image, for instance.
> - continue
> + # Symlink over everything that's in the python libdir but not in
> + # the updates directory.
> + for f in filter(lambda fn: fn not in contents, os.listdir(dest)):
> + if f.endswith(".pyc") or f.endswith(".pyo"):
> + continue
>
> - if os.access("/tmp/updates/%s" %(pypkg,), os.X_OK):
> - for f in os.listdir("/usr/%s/python%s/site-packages/%s" %(libdir,
> - pyver,
> - pypkg)):
> - if os.access("/tmp/updates/%s/%s" %(pypkg, f), os.R_OK):
> - continue
> - elif (f.endswith(".pyc") and
> - os.access("/tmp/updates/%s/%s" %(pypkg, f[:-1]),os.R_OK)):
> - # dont copy .pyc files we are replacing with updates
> - continue
> - else:
> - os.symlink("/usr/%s/python%s/site-packages/%s/%s" %(libdir,
> - pyver,
> - pypkg,
> - f),
> - "/tmp/updates/%s/%s" %(pypkg, f))
> + os.symlink("%s/%s" % (dest, f), "/tmp/updates/%s/%s" % (pkg, f))
>
> if os.access("/tmp/updates/70-anaconda.rules", os.R_OK):
> import shutil


_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 02-10-2010, 08:37 PM
Chris Lumens
 
Default Allow any add-on python module to be updated via an updates.img.

---
anaconda | 63 ++++++++++++++++++++++---------------------------------------
1 files changed, 23 insertions(+), 40 deletions(-)

diff --git a/anaconda b/anaconda
index e9b620a..38054f3 100755
--- a/anaconda
+++ b/anaconda
@@ -112,50 +112,33 @@ def doShutdownX11Actions():
except:
pass

-# handle updates of just a single file in a python package
def setupPythonUpdates():
- import glob
+ from distutils.sysconfig import get_python_lib

- # get the python version. first of /usr/lib/python*, strip off the
- # first 15 chars
- pyvers = glob.glob("/usr/lib/python*")
- pyver = pyvers[0][15:]
-
- try:
- os.mkdir("/tmp/updates")
- except:
- pass
+ for pkg in os.listdir("/tmp/updates"):
+ dir = "/tmp/updates/%s" % pkg

- for pypkg in ("block", "yum", "rpmUtils", "urlgrabber", "pykickstart", "parted", "meh"):
- # get the libdir. *sigh*
- if os.access("/usr/lib64/python%s/site-packages/%s" %(pyver, pypkg),
- os.X_OK):
- libdir = "lib64"
- elif os.access("/usr/lib/python%s/site-packages/%s" %(pyver, pypkg),
- os.X_OK):
- libdir = "lib"
- else:
- # If the directory doesn't exist, there's nothing to link over.
- # This happens if we forgot to include one of the above packages
- # in the image, for instance.
+ if not os.path.isdir(dir):
continue

- if os.access("/tmp/updates/%s" %(pypkg,), os.X_OK):
- for f in os.listdir("/usr/%s/python%s/site-packages/%s" %(libdir,
- pyver,
- pypkg)):
- if os.access("/tmp/updates/%s/%s" %(pypkg, f), os.R_OK):
- continue
- elif (f.endswith(".pyc") and
- os.access("/tmp/updates/%s/%s" %(pypkg, f[:-1]),os.R_OK)):
- # dont copy .pyc files we are replacing with updates
- continue
- else:
- os.symlink("/usr/%s/python%s/site-packages/%s/%s" %(libdir,
- pyver,
- pypkg,
- f),
- "/tmp/updates/%s/%s" %(pypkg, f))
+ # See if the package exists in /usr/lib{64,}/python/?.?/site-packages.
+ # If it does, we can set it up as an update. If not, the pkg is
+ # likely a completely new directory and should not be looked at.
+ dest = "%s/%s" % (get_python_lib(), pkg)
+ if not os.access(dest, os.R_OK):
+ dest = "%s/%s" % (get_python_lib(1), pkg)
+ if not os.access(dest, os.R_OK):
+ continue
+
+ contents = os.listdir(dir)
+
+ # Symlink over everything that's in the python libdir but not in
+ # the updates directory.
+ for f in filter(lambda fn: fn not in contents, os.listdir(dest)):
+ if f.endswith(".pyc") or f.endswith(".pyo"):
+ continue
+
+ os.symlink("%s/%s" % (dest, f), "/tmp/updates/%s/%s" % (pkg, f))

if os.access("/tmp/updates/70-anaconda.rules", os.R_OK):
import shutil
--
1.6.5.1

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 

Thread Tools




All times are GMT. The time now is 09:03 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org