This email list is read-only.  Emails sent to this list will be discarded
----------------------------------
 debian/changelog     |    6 ++-
 gui/gui.py           |    1 +
 libs/InstallImage.py |  114 +++++++++++++++++++++++++++++++++++++++++++-------
 libs/Mkinitrd.py     |   12 +++++-
 libs/Platform.py     |    1 +
 libs/Project.py      |   15 +++++--
 libs/SDK.py          |    8 ++--
 libs/moblin_yum.py   |    4 ++
 libs/pdk_utils.py    |   11 +++++
 9 files changed, 147 insertions(+), 25 deletions(-)

New commits:
commit 0c3144e37fbc24efbc1813d782a98a17e8b4992f
Author: Prajwal Mohan <[email protected]>
Date:   Wed Jan 21 13:16:50 2009 -0800

    * Getting rid of squashfs and union fs. Using ext3 instead for live images


Diff in this email is a maximum of 400 lines.
diff --git a/debian/changelog b/debian/changelog
index 4a51309..f83aad3 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,9 +1,13 @@
 moblin-image-creator (0.49) gaston; urgency=low
 
+  [ Mitsutaka Amano ]
   * Starting new version
   * Up to version of rpm spec file
 
- -- Mitsutaka Amano <[email protected]>  Sat, 17 Jan 2009 17:20:29 +0900
+  [ Prajwal Mohan ]
+  * Getting rid of squashfs and union fs. Using ext3 instead for live images 
+
+ -- Prajwal Mohan <[email protected]>  Wed, 21 Jan 2009 13:16:22 -0800
 
 moblin-image-creator (0.48) gaston; urgency=low
 
diff --git a/gui/gui.py b/gui/gui.py
index 317a210..85bb749 100644
--- a/gui/gui.py
+++ b/gui/gui.py
@@ -881,6 +881,7 @@ class App(object):
         print >> prompt_file, "T: %s" % target.name
         prompt_file.close()
         print _("Target path: %s") % target_path
+        pdk_utils.setResolvConfFromHost(target_path)
         cmd = '/usr/bin/gnome-terminal -x /usr/sbin/chroot %s env -u SHELL 
HOME=/root su -p - &' % (target_path)
         print cmd
         if os.system(cmd) != 0:
diff --git a/libs/InstallImage.py b/libs/InstallImage.py
index f56d99d..2c79be7 100755
--- a/libs/InstallImage.py
+++ b/libs/InstallImage.py
@@ -24,6 +24,7 @@ import sys
 import tempfile
 import traceback
 import paths
+import string
 
 import Project
 import SDK
@@ -268,6 +269,7 @@ class InstallImage(object):
         use squashfs on the device then the content will be copied out of the
         squashfs image during the install"""
         print _("Creating root file system...")
+        pdk_utils.deleteResolvConf(self.target.fs_path)
         self.target.execute_post_install_scripts()
 
         # re-create fstab every time, since user could change fstab options on
@@ -284,15 +286,45 @@ class InstallImage(object):
         self.rootfs_path = os.path.join(self.target.image_path, self.rootfs)
         if os.path.isfile(self.rootfs_path):
             os.remove(self.rootfs_path)
-        
-        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)
+      
         self.write_manifest(self.path)
         self.target.umount()
-        print _("Executing the mksquashfs program: %s") % cmd
-        self.project.chroot(cmd)
+
+        fs_path      = self.target.fs_path[len(self.project.path):]
+        cmd = "du -ks %s" % fs_path
+        print _("Caclulating FS size: %s") % cmd
+        cmdOutput = []
+        self.project.chroot(cmd, cmdOutput)
+        out_string = chr(0) * 1024
+        out_file = open(self.rootfs_path, 'w')
+        # Write the string out to the file to create file of size * kibyte in 
length
+        size = int(string.atoi(cmdOutput[0].split()[0]) * 1.1) + 40960
+        print "Rootfs size: %s" % size
+        for count in range(0, size):
+            if self.progress_callback and count % 1024 == 0:
+                self.progress_callback(None)
+            out_file.write(out_string)
+        out_file.close()       
+
+        image_path   = self.target.image_path[len(self.project.path):] 
+        image_path   = os.path.join(image_path,'rootfs.img')        
+        cmd = 'mkfs.ext3 -F %s' % image_path
+        self.project.chroot(cmd)        
+
+        temp_dir   = os.path.join(self.target.image_path,'temp')        
+        if not os.path.exists(temp_dir):
+            os.makedirs(temp_dir)
+
+        print _("Mounting rootfs.img ...")
+        cmd = "mount -o loop %s %s" % (self.rootfs_path, temp_dir)
+        pdk_utils.execCommand(cmd)        
+        print _("Copying files...")
+        cmd = "cp -a %s/. %s" % (self.target.fs_path, temp_dir)
+        pdk_utils.execCommand(cmd)        
+        print _("Unmounting...")
+        cmd = "umount %s" % (temp_dir)
+        pdk_utils.execCommand(cmd)        
+
         self.target.mount()
             
     def delete_rootfs(self):
@@ -323,13 +355,42 @@ class InstallImage(object):
         self.kernels.pop(0)
         if not os.path.exists("%s/boot/boot" % self.target.path):
             os.symlink(".", "%s/boot/boot" % self.target.path)
+
         fs_path    = self.target.fs_path[len(self.project.path):]
         fs_path    = os.path.join(fs_path, 'boot')
+
+        cmd = "du -ks %s" % fs_path
+        cmdOutput = []
+        print _("Caclulating Boot FS size: %s") % cmd
+        self.project.chroot(cmd, cmdOutput)
+        out_string = chr(0) * 1024
+        out_file = open(self.bootfs_path, 'w')
+        size = int(string.atoi(cmdOutput[0].split()[0]) * 1.1) + 10240
+        print _("Bootfs size: %s") % (size)
+        for count in range(0, size):
+            if self.progress_callback and count % 1024 == 0:
+                self.progress_callback(None)
+            out_file.write(out_string)
+        out_file.close()
         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)
+        image_path = os.path.join(image_path, 'bootfs.img')
+        cmd = 'mkfs.ext3 -F %s' % image_path
         self.project.chroot(cmd)
 
+        temp_dir   = os.path.join(self.target.image_path,'temp')        
+        if not os.path.exists(temp_dir):
+            os.makedirs(temp_dir)
+
+        print _("Mounting bootfs.img...")
+        cmd = "mount -o loop %s %s" % (self.bootfs_path, temp_dir)
+        pdk_utils.execCommand(cmd)
+        print _("Copying boot files...")
+        cmd = "cp -a %s/. %s" % (os.path.join(self.target.fs_path, 'boot'), 
temp_dir)
+        pdk_utils.execCommand(cmd)
+        print _("Unmounting...")
+        cmd = "umount %s" % (temp_dir)
+        pdk_utils.execCommand(cmd)
+
     def delete_bootfs(self):
         if self.bootfs and os.path.isfile(self.bootfs_path):
             os.remove(self.bootfs_path)
@@ -385,11 +446,16 @@ class InstallImage(object):
             self.create_initramfs("/tmp/.tmp.initrd%d" % count, kernel_version)
         self.kernels.pop(0)
 
-    def create_all_initrd(self):
+    def create_all_initrd(self, additional_files=None, target_path=None):
         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)
+        self.kernels.insert(0, self.default_kernel)
+        for count, kernel in enumerate(self.kernels):
+            kernel_version = kernel.split('vmlinuz-').pop().strip()
+            initrd_path = "/tmp/.tmp.initrd%s" % count
+            Mkinitrd.create(self.project, initrd_path, additional_files, 
target_path)
+            shutil.copy(initrd_path, os.path.join(self.target.fs_path, 
"boot/initrd%s.img-%s" % (count, kernel_version)))
+        self.kernels.pop(0)
 
     def create_initramfs(self, initrd_file, kernel_version):
         print _("Creating initramfs for kernel version: %s") % kernel_version
@@ -474,7 +540,11 @@ class LiveIsoImage(InstallImage):
     def create_image(self, fs_type='RAMFS'):
         print _("LiveCDImage: Creating Live CD Image(%s) Now...") % fs_type
         image_type = _("Live CD Image (no persistent R/W)")
-        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)
@@ -871,13 +941,16 @@ class NANDImage(InstallImage):
                raise ValueError(_("NANDImage: This platform could not support 
NAND image!"))
         print _("NANDImage: Creating NAND Image...")
 
+        additional_files = self.get_firmware_list()
+
         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_all_initrd(additional_files, self.target.fs_path)
+        self.create_fstab(False)
         self.target.umount()
         initrd_path = "/tmp/.tmp.initrd0"
+
         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'),
@@ -888,6 +961,17 @@ class NANDImage(InstallImage):
                  self.path+'.boot',
                  self.path)))
 
+    def get_firmware_list(self):
+        #Will be populated once firmware is available
+        if os.path.exists(os.path.join(self.project.platform.path, 
"firmware")):
+            print _("Firmware file found")
+            firmware_file = open(os.path.join(self.project.platform.path, 
"firmware"))            
+            firmware_list = firmware_file.readlines()            
+            firmware_file.close()
+            return firmware_list            
+        else:
+            return None
+
     def __str__(self):
         return ("<NANDImage: project=$s, target=%s, name=%s>"
                 % (self.project, self.target, self.name))
diff --git a/libs/Mkinitrd.py b/libs/Mkinitrd.py
index a67b006..d9f7907 100755
--- a/libs/Mkinitrd.py
+++ b/libs/Mkinitrd.py
@@ -56,7 +56,7 @@ class Busybox(object):
                 os.symlink("busybox", cmd)
         os.chdir(save_cwd)
 
-def create(project, initrd_file, fs_type='RAMFS'):
+def create(project, initrd_file, additional_files, target_path, 
fs_type='RAMFS'):
     """Function to create an initrd file"""
     initrd_file = os.path.abspath(os.path.expanduser(initrd_file))
 
@@ -86,6 +86,16 @@ def create(project, initrd_file, fs_type='RAMFS'):
     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)
+    #Copy additional files - firmware, scripts etc
+    if additional_files:
+        for file_path in additional_files:
+            file_path = file_path.rstrip()
+            if os.path.exists(os.path.join(target_path, file_path)):
+                folder_path = (os.path.join(scratch_path, 
file_path)).rsplit('/', 1)[0]
+                if not os.path.exists(folder_path):
+                    os.makedirs(folder_path)
+                #print "Copying: %s to %s" % (os.path.join(target_path, 
file_path), os.path.join(scratch_path, file_path))
+                shutil.copyfile(os.path.join(target_path, file_path), 
os.path.join(scratch_path, file_path))
     # Create the initrd image file
     os.chdir(scratch_path)
 
diff --git a/libs/Platform.py b/libs/Platform.py
index fe62c0b..9b9b2be 100755
--- a/libs/Platform.py
+++ b/libs/Platform.py
@@ -235,6 +235,7 @@ class Platform(object):
         print _("Exec command: %s") % cmd
         result = pdk_utils.execCommand(cmd, output = output, callback = 
callback)
         if result != 0:
+            self.__yumDoUmounts(chroot_dir)
             raise RuntimeError(_("Failed to create Yum based rootstrap"))
         # nuke all the yum cache to ensure that we get the latest greatest at 
project creation
         shutil.rmtree(os.path.join(chroot_dir, 'var', 'cache', 'yum'))
diff --git a/libs/Project.py b/libs/Project.py
index b1c2862..5747144 100755
--- a/libs/Project.py
+++ b/libs/Project.py
@@ -70,13 +70,19 @@ class FileSystem(object):
         return self.platform.pkg_manager.updateChroot(self.chroot_path,
             callback = self.progress_callback)
 
+    def createMtab(self):
+        f = open("%s/etc/mtab" % self.path, 'w')
+        f.close()
+
+
     def setHostname(self, hostname):
         self.mount()
+        pdk_utils.setResolvConfFromHost(self.path)
         # Setup copies of some useful files from the host into the chroot
-        for filename in ('etc/resolv.conf'),:
-            source_file = os.path.join(os.sep, filename)
-            target_file = os.path.join(self.chroot_path, filename)
-            pdk_utils.safeTextFileCopy(source_file, target_file)
+        #for filename in ('etc/resolv.conf'),:
+        #    source_file = os.path.join(os.sep, filename)
+        #    target_file = os.path.join(self.chroot_path, filename)
+        #    pdk_utils.safeTextFileCopy(source_file, target_file)
         f = open("%s/etc/hostname" % self.path, 'w')
         f.write("%s\n" % hostname)
         f.close()
@@ -208,6 +214,7 @@ class Project(FileSystem):
         if self.platform.config_info['package_manager'] == 'yum':
             self.mount()
             self.platform.pkg_manager.resetPackageDB(self.chroot_path, None)
+        self.createMtab()
         return super(Project, 
self).installPackages(self.platform.buildroot_packages + 
self.platform.buildroot_extras)
 
     def umount(self, directory_set = None):
diff --git a/libs/SDK.py b/libs/SDK.py
index b6cd4a7..7636f55 100755
--- a/libs/SDK.py
+++ b/libs/SDK.py
@@ -228,10 +228,10 @@ class SDK(object):
         self.status_label_callback(_("Creating Config file"))
         config_path = os.path.join(self.config_path, "%s.proj" % name)
         config_file = open(config_path, 'w')
-        config_file.write("NAME=%s\n" % (name))
-        config_file.write("PATH=%s\n" % (install_path))
-        config_file.write("DESC=%s\n" % (desc))
-        config_file.write("PLATFORM=%s\n" % (platform.name))
+        config_file.write(_("NAME=%s\n") % (name))
+        config_file.write(_("PATH=%s\n") % (install_path))
+        config_file.write(_("DESC=%s\n") % (desc))
+        config_file.write(_("PLATFORM=%s\n") % (platform.name))
         config_file.close()
         # instantiate the project
         self.status_label_callback(_("Initiating the project"))
diff --git a/libs/moblin_yum.py b/libs/moblin_yum.py
index 6827938..60583f8 100644
--- a/libs/moblin_yum.py
+++ b/libs/moblin_yum.py
@@ -40,6 +40,7 @@ class YumPackageManager(moblin_pkgbase.PackageManager):
     def installGroups(self, chroot_dir, groups_list, callback = None):
         """Install the list of groups in the chroot environement"""
         self.__yumPreRun(chroot_dir)
+        pdk_utils.setResolvConfFromHost(chroot_dir)
         if not groups_list:
             # No groups, so nothing to do
             return
@@ -84,6 +85,7 @@ class YumPackageManager(moblin_pkgbase.PackageManager):
     def installPackages(self, chroot_dir, package_list, callback = None):
         """Install the list of packages in the chroot environement"""
         self.__yumPreRun(chroot_dir)
+        pdk_utils.setResolvConfFromHost(chroot_dir)
         if not package_list:
             # No packages, so nothing to do
             return
@@ -123,6 +125,7 @@ class YumPackageManager(moblin_pkgbase.PackageManager):
 
     def updateChroot(self, chroot_dir, callback = None):
         """Update the chroot environment to have the latest packages"""
+        pdk_utils.setResolvConfFromHost(chroot_dir)
         command = "yum clean metadata"
         print _("Running 'yum update' command: %s") % (command)
         print _("\t in the chroot: %s") % (chroot_dir)
@@ -147,6 +150,7 @@ class YumPackageManager(moblin_pkgbase.PackageManager):
 
         """ due to unknown reason execChrootCommand doesn't work on wide-match 
symbol"""
         #FIXME
+        pdk_utils.setResolvConfFromHost(chroot_dir)
         command = "/usr/sbin/chroot %s rm -fr /var/lib/rpm/*db*" % (chroot_dir)
         print _("Running command: %s") % (command)
         os.system(command)
diff --git a/libs/pdk_utils.py b/libs/pdk_utils.py
index 459b6d4..11296c8 100755
--- a/libs/pdk_utils.py
+++ b/libs/pdk_utils.py
@@ -443,6 +443,17 @@ def safeTextFileCopy(source_file, destination_file, force 
= False):
         in_file.close()
         out_file.close()
 
+def setResolvConfFromHost(chroot_path):
+    for filename in ('etc/resolv.conf'),:
+        source_file = os.path.join(os.sep, filename)
+        target_file = os.path.join(chroot_path, filename)
+        safeTextFileCopy(source_file, target_file, True)
+
+def deleteResolvConf(chroot_path):
+    if os.path.exists(os.path.join(chroot_path, 'etc/resolv.conf')):
+        os.unlink(os.path.join(chroot_path, 'etc/resolv.conf'))
+
+
 def mountList(mount_list, chroot_dir):
     """Mount the items specified in the mount list.  Return back a list of what
     got mounted"""
_______________________________________________
Commits mailing list
[email protected]
https://lists.moblin.org/mailman/listinfo/commits

Reply via email to