This email list is read-only.  Emails sent to this list will be discarded
----------------------------------
 debian/changelog     |    7 ++-
 gui/gui.py           |   12 +++---
 libs/InstallImage.py |   84 ++++++++++++++++++++++++++++++++----
 libs/Mkinitrd.py     |  115 ++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 200 insertions(+), 18 deletions(-)

New commits:
commit c6d9f4b2bdce784d06b31702596315b459f4047e
Author: Prajwal Mohan <[EMAIL PROTECTED]>
Date:   Tue Jul 29 16:11:28 2008 -0700

    Making changes to Install Image to handle yum based platforms


Diff in this email is a maximum of 400 lines.
diff --git a/debian/changelog b/debian/changelog
index 1e84702..bea01e3 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -77,9 +77,12 @@ moblin-image-creator (0.45) UNRELEASED; urgency=low
 
   [ Mitsutaka Amano ]
   * Updated rpm spec file for 0.45.
-  * Added dist parametor on rpm spec file. 
+  * Added dist parametor on rpm spec file.
 
- -- Mitsutaka Amano <[EMAIL PROTECTED]>  Tue, 29 Jul 2008 12:21:38 +0900
+  [ Prajwal Mohan ]
+  * Making changes to Install Image to handle yum based platforms
+
+ -- Prajwal Mohan <[EMAIL PROTECTED]>  Tue, 29 Jul 2008 16:09:42 -0700
 
 moblin-image-creator (0.44) gaston; urgency=low
 
diff --git a/gui/gui.py b/gui/gui.py
index 7c05d2b..b3015e3 100644
--- a/gui/gui.py
+++ b/gui/gui.py
@@ -1569,14 +1569,14 @@ class AddNewProject(object):
             if self.sdk.platforms[pname].config_info != None:
                 pdesc = " - (%s)" % 
self.sdk.platforms[pname].config_info['description']
                 packageManagerDesc = 
self.sdk.platforms[pname].config_info['package_manager']
-            if packageManager == packageManagerDesc:
+            #if packageManager == packageManagerDesc:
                 #platform_entry_box.append([pname + pdesc])
-                platform_entry_box.append([pname])
-                added = True
-            elif packageManagerDesc == "":
+            platform_entry_box.append([pname])
+            added = True
+            #elif packageManagerDesc == "":
                 #platform_entry_box.append([pname + pdesc])
-                platform_entry_box.append([pname])
-                added = True
+            #    platform_entry_box.append([pname])
+            #    added = True
             # If previously selected an entry, select it again
             if added:
                 if  (pname + pdesc) == platform:
diff --git a/libs/InstallImage.py b/libs/InstallImage.py
index 41d247d..b9a8f92 100755
--- a/libs/InstallImage.py
+++ b/libs/InstallImage.py
@@ -28,6 +28,7 @@ import Project
 import SDK
 import mic_cfg
 import pdk_utils
+import Mkinitrd
 
 debug = False
 if mic_cfg.config.has_option('general', 'debug'):
@@ -242,7 +243,8 @@ class InstallImage(object):
         else:
             swap = False
         self.create_fstab(swap)
-        self.create_modules_dep()
+        if self.project.platform.config_info['package_manager'] == 'apt':
+            self.create_modules_dep()
         self.rootfs = 'rootfs.img'
         self.rootfs_path = os.path.join(self.target.image_path, self.rootfs)
         if os.path.isfile(self.rootfs_path):
@@ -251,7 +253,10 @@ class InstallImage(object):
         fs_path      = self.target.fs_path[len(self.project.path):]
         image_path   = self.target.image_path[len(self.project.path):]
         image_path   = os.path.join(image_path,'rootfs.img')
-        cmd          = "mksquashfs %s %s -no-progress -ef %s" % (fs_path, 
image_path, self.exclude_file)
+        if self.project.platform.config_info['package_manager'] == 'apt':
+            cmd          = "mksquashfs %s %s -no-progress -ef %s" % (fs_path, 
image_path, self.exclude_file)
+        if self.project.platform.config_info['package_manager'] == 'yum':
+           cmd          = "/sbin/mksquashfs %s %s -info -ef %s" % (fs_path, 
image_path, self.exclude_file)
         self.write_manifest(self.path)
         self.target.umount()
         print _("Executing the mksquashfs program: %s") % cmd
@@ -285,7 +290,10 @@ class InstallImage(object):
         fs_path    = os.path.join(fs_path, 'boot')
         image_path = self.target.image_path[len(self.project.path):]
         image_path = os.path.join(image_path,'bootfs.img')
-        cmd        = "mksquashfs %s %s -no-progress" % (fs_path, image_path)
+        if self.project.platform.config_info['package_manager'] == 'apt':
+            cmd        = "mksquashfs %s %s -no-progress" % (fs_path, 
image_path)
+        if self.project.platform.config_info['package_manager'] == 'yum':
+            cmd        = "/sbin/mksquashfs %s %s -no-progress" % (fs_path, 
image_path)
         self.project.chroot(cmd)
 
     def delete_bootfs(self):
@@ -339,6 +347,12 @@ class InstallImage(object):
             self.create_initramfs("/tmp/.tmp.initrd%d" % count, kernel_version)
         self.kernels.pop(0)
 
+    def create_all_initrd(self):
+        cfg_filename = os.path.join(self.project.path, 
"etc/moblin-initramfs.cfg")
+        self.writeShellConfigFile(cfg_filename)
+        initrd_path = "/tmp/.tmp.initrd0"
+        Mkinitrd.create(self.project, initrd_path)
+
     def create_initramfs(self, initrd_file, kernel_version):
         print _("Creating initramfs for kernel version: %s") % kernel_version
         # copy the platform initramfs stuff into /etc/initramfs-tools/ in the 
target
@@ -387,7 +401,10 @@ class InstallImage(object):
 
     def write_manifest(self, image_path):
         all_packages = []
-        self.target.chroot("dpkg-query --show", output = all_packages)
+        if self.project.platform.config_info['package_manager'] == 'apt':
+            self.target.chroot("dpkg-query --show", output = all_packages)
+        if self.project.platform.config_info['package_manager'] == 'yum':
+            self.target.chroot("rpm  -qa", output = all_packages)
         manifest = open(image_path.rstrip('.img') + '.manifest', 'w')
         print >>manifest, "\n".join(all_packages)
         manifest.close()
@@ -460,7 +477,11 @@ class BaseUsbImage(InstallImage):
             out_file.write(out_string)
         out_file.close()
 
-        cmd_line = "mkfs.vfat %s" % self.path
+        if self.project.platform.config_info['package_manager'] == 'apt':
+            cmd_line = "mkfs.vfat %s" % self.path
+        if self.project.platform.config_info['package_manager'] == 'yum':
+            cmd_line = "/sbin/mkfs.vfat %s" % self.path
+
         result = pdk_utils.execCommand(cmd_line, callback = 
self.progress_callback)
         if result:
             print >> sys.stderr, _("Error running command: %s") % cmd_line
@@ -481,7 +502,11 @@ class BaseUsbImage(InstallImage):
             out_file.write(out_string)
         out_file.close()
 
-        cmd_line = "mkfs.ext3 %s -F" % path
+        if self.project.platform.config_info['package_manager'] == 'apt':
+            cmd_line = "mkfs.ext3 %s -F" % path
+        if self.project.platform.config_info['package_manager'] == 'yum':
+            cmd_line = "/sbin/mkfs.ext3 %s -F" % path
+
         result = pdk_utils.execCommand(cmd_line, callback = 
self.progress_callback)
         if result:
             print >> sys.stderr, _("Error running command: %s") % cmd_line
@@ -515,7 +540,12 @@ class LiveUsbImage(BaseUsbImage):
             image_type = _("Live USB Image (no persistent R/W)")
         # How big to make the ext3 File System on the Live RW USB image, in 
megabytes
         ext3fs_fs_size = int(mic_cfg.config.get(self.section, "ext3fs_size"))
-        self.create_all_initramfs()
+
+        if self.project.platform.config_info['package_manager'] == 'apt':
+            self.create_all_initramfs()
+        if self.project.platform.config_info['package_manager'] == 'yum':
+            self.create_all_initrd()
+
         self.create_rootfs()
         initrd_stat_result = os.stat('/tmp/.tmp.initrd0')
         rootfs_stat_result = os.stat(self.rootfs_path)
@@ -547,9 +577,14 @@ class InstallUsbImage(BaseUsbImage):
     def create_image(self):
         print _("InstallUsbImage: Creating InstallUSB Image...")
         image_type = _("Install USB Image.  This will DESTROY all content on 
your hard drive!!")
-        self.create_all_initramfs()
-        self.create_grub_menu()
-        self.apply_hd_kernel_cmdline()
+        if self.project.platform.config_info['package_manager'] == 'apt':
+            self.create_all_initramfs()
+            self.create_grub_menu()
+            self.apply_hd_kernel_cmdline()
+        if self.project.platform.config_info['package_manager'] == 'yum':
+            self.create_all_initrd()
+            self.create_grub_menu_temp()
+
         self.create_bootfs()
         self.create_rootfs()
         initrd_stat_result = os.stat('/tmp/.tmp.initrd0')
@@ -603,6 +638,35 @@ class HddImage(InstallImage):
         return ("<HddImage: project=%s, target=%s, name=%s>"
                 % (self.project, self.target, self.name))
 
+
+class NANDImage(InstallImage):
+    def create_image(self):
+        print os.path.join(self.project.platform.path, "nand.sh")
+        if not os.path.isfile(os.path.join(self.project.platform.path, 
"nand.sh")):
+               raise ValueError("NANDImage: This platform could not support 
NAND image!")
+        print _("NANDImage: Creating NAND Image...")
+
+        if self.project.platform.config_info['package_manager'] == 'apt':
+            self.create_all_initramfs()
+        if self.project.platform.config_info['package_manager'] == 'yum':
+            self.create_all_initrd()
+
+        self.target.umount()
+        os.system(os.path.join(self.project.platform.path, "nand.sh %s %s %s 
%s %s %s %s %s" 
+              % (os.path.join(self.target.config_path, 'nand_kernel_cmdline'),
+                 os.path.join(self.target.fs_path, 'boot/bootstub'),
+                 os.path.join(self.target.fs_path, 'boot',self.default_kernel),
+                 initrd_path,
+                 self.target.fs_path,
+                 int(mic_cfg.config.get(self.section, "nand_image_size")),
+                 self.path+'.boot',
+                 self.path)))
+
+    def __str__(self):
+        return ("<NANDImage: project=$s, target=%s, name=%s>"
+                % (self.project, self.target, self.name))
+
+
 def print_exc_plus():
     # From Python Cookbook 2nd Edition.  FIXME: Will need to remove this at
     # some point, or give attribution.
diff --git a/libs/Mkinitrd.py b/libs/Mkinitrd.py
new file mode 100755
index 0000000..4bce06e
--- /dev/null
+++ b/libs/Mkinitrd.py
@@ -0,0 +1,115 @@
+#!/usr/bin/python -tt
+# vim: ai ts=4 sts=4 et sw=4
+
+import os
+import re
+import shutil
+import sys
+import tempfile
+import time
+
+import SDK
+
+class Busybox(object):
+    def __init__(self, cmd_path, bin_path):
+        self.cmd_path = os.path.abspath(os.path.expanduser(cmd_path))
+        self.bin_path = os.path.abspath(os.path.expanduser(bin_path))
+        self.cmds = []
+
+        # Extract the list of supported busybox commands
+        #
+        # This is far from ideal, but this method doesn't require
+        # modifying the original Busybox RPM package and capturing
+        # symlinks w/ a "make install" of the Busybox sources
+        buf = ""
+        flag = 0
+        bf = os.popen(cmd_path)
+        for line in bf:
+            if (flag == 0):
+                if re.search(r'^Currently defined functions:', line):
+                    flag = 1
+                continue
+            else:
+                # strip off the new-line & white-space 
+                line = line.strip()
+                # Delete all spaces inside the line
+                line = re.sub(r'\s+', '', line)
+
+                if line:
+                    buf = buf + line
+
+        buf = re.sub(r'busybox,', '', buf)
+        self.cmds = buf.split(',')
+
+    def create(self):
+        if not os.path.isdir(self.bin_path):
+            os.makedirs(self.bin_path)
+
+        save_cwd = os.getcwd()
+        os.chdir(self.bin_path)
+
+        if not os.path.exists('busybox'):
+            shutil.copy(self.cmd_path, 'busybox')
+
+        for cmd in self.cmds:
+            print cmd
+            if not os.path.exists(cmd):
+                os.symlink("busybox", cmd)
+        time.sleep(20)
+        os.chdir(save_cwd)
+
+def create(project, initrd_file, fs_type='RAMFS'):
+    """Function to create an initrd file"""
+    initrd_file = os.path.abspath(os.path.expanduser(initrd_file))
+
+    save_cwd = os.getcwd()
+    # Create scratch area for creating files
+    scratch_path = tempfile.mkdtemp('','pdk-', '/tmp')
+    
+    # Setup initrd directory tree
+    bin_path = os.path.join(scratch_path, 'bin')
+
+    # Create directories
+    dirs = [ 'bin', 'boot', 'etc', 'dev', 'lib', 'mnt', \
+             'proc', 'sys', 'sysroot', 'tmp', 'usr/bin' ]
+    for dirname in dirs:
+        os.makedirs(os.path.join(scratch_path, dirname))
+
+    os.symlink('init', os.path.join(scratch_path, 'linuxrc'))
+    os.symlink('bin', os.path.join(scratch_path, 'sbin'))
+
+    # Setup Busybox in the initrd
+    cmd_path = os.path.join(project.path, 'sbin/busybox')
+    bb = Busybox(cmd_path, bin_path)
+    bb.create()
+    #Setup moblin-initramfs.cfg file
+    shutil.copy(os.path.join(project.path, 'etc/moblin-initramfs.cfg'), 
os.path.join(scratch_path, 'etc'))
+    # Setup init script
+    names = os.listdir(os.path.join(project.platform.path, 'initramfs'))
+    for name in names:
+        shutil.copy(os.path.join(project.platform.path, 'initramfs', name), 
scratch_path)
+
+    # Create the initrd image file
+    os.chdir(scratch_path)
+    cmd_string = "find -print | cpio --quiet -c -o | gzip -9 -c > " + 
initrd_file
+    os.system(cmd_string)
+    os.chdir(save_cwd)
+
+    # Clean-up and remove scratch area
+    shutil.rmtree(scratch_path)
+
+class Callback:
+    def iteration(process):
+        return
+
+if __name__ == '__main__':
+    if len(sys.argv) != 3:
+        print >> sys.stderr, "USAGE: %s PROJECT INITRD_FILE" % (sys.argv[0])
+        sys.exit(1)
+
+    project_name = sys.argv[1]
+    initrd_file = sys.argv[2]
+
+    proj = SDK.SDK(Callback()).projects[project_name]
+
+    create(proj, initrd_file)
_______________________________________________
Commits mailing list
[email protected]
https://www.moblin.org/mailman/listinfo/commits

Reply via email to