commit:     a41100e5a1c3514bf316e5e5982c3f749e203892
Author:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Sun Aug  9 20:29:20 2015 +0000
Commit:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Sun Aug  9 20:29:20 2015 +0000
URL:        https://gitweb.gentoo.org/proj/grss.git/commit/?id=a41100e5

grs/Kernel.py: don't rebuild/reinstall a kernel if its linux-image tarball 
exists.

 grs/Kernel.py | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/grs/Kernel.py b/grs/Kernel.py
index bb76b80..7f96d91 100644
--- a/grs/Kernel.py
+++ b/grs/Kernel.py
@@ -80,9 +80,16 @@ class Kernel():
         image_dir     = os.path.join(self.kernelroot, gentoo_version)
         boot_dir      = os.path.join(image_dir, 'boot')
         modprobe_dir  = os.path.join(image_dir, 'etc/modprobe.d')
-        # TODO: modules_dir really needs $(get_libdir), eg /lib64.
-        # For example, this breaks on amd64 multilib.
         modules_dir   = os.path.join(image_dir, 'lib/modules')
+        # Prepare tarball filename and path.  If the tarball already exists,
+        # don't rebuild/reinstall it.  Note: It should have been installed to
+        # the system's portage configroot when it was first built, so no need
+        # to reinstall it.
+        linux_images = os.path.join(self.package, 'linux-images')
+        tarball_name = 'linux-image-%s.tar.xz' % gentoo_version
+        tarball_path = os.path.join(linux_images, tarball_name)
+        if os.path.isfile(tarball_path):
+            return
 
         # Remove any old kernel image directory and create a boot directory.
         # Note genkernel assumes a boot directory is present.
@@ -126,15 +133,9 @@ class Kernel():
         Execute(cmd, timeout=60, logfile=self.logfile)
 
         # Tar up the kernel image and modules and place them in 
package/linux-images
-        linux_images = os.path.join(self.package, 'linux-images')
         os.makedirs(linux_images, mode=0o755, exist_ok=True)
-        tarball_name = 'linux-image-%s.tar.xz' % gentoo_version
-        tarball_path = os.path.join(linux_images, tarball_name)
-
         cwd = os.getcwd()
         os.chdir(image_dir)
-        if os.path.isfile(tarball_path):
-            os.unlink(tarball_path)
         cmd = 'tar -Jcf %s .' % tarball_path
         Execute(cmd, timeout=600, logfile=self.logfile)
         os.chdir(cwd)

Reply via email to