Patchwork wic: squashfs partition support

login
register
mail settings
Submitter Maciej Borzecki
Date July 23, 2014, 10:37 a.m.
Message ID <1406111837-4287-1-git-send-email-maciej.borzecki@open-rnd.pl>
Download mbox | patch
Permalink /patch/76479/
State New
Headers show

Comments

Maciej Borzecki - July 23, 2014, 10:37 a.m.
Signed-off-by: Maciej Borzecki <maciej.borzecki@open-rnd.pl>
---
 .../lib/mic/kickstart/custom_commands/partition.py | 26 ++++++++++++++++++++++
 1 file changed, 26 insertions(+)
Tom Zanussi - July 23, 2014, 8:21 p.m.
Hi, please include a description for this.

Also, it looks like this is missing the empty_partition() part?

Thanks,

Tom

On Wed, 2014-07-23 at 12:37 +0200, Maciej Borzecki wrote:
> Signed-off-by: Maciej Borzecki <maciej.borzecki@open-rnd.pl>
> ---
>  .../lib/mic/kickstart/custom_commands/partition.py | 26 ++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
> 
> diff --git a/scripts/lib/mic/kickstart/custom_commands/partition.py b/scripts/lib/mic/kickstart/custom_commands/partition.py
> index d0f1b78..c4d0113 100644
> --- a/scripts/lib/mic/kickstart/custom_commands/partition.py
> +++ b/scripts/lib/mic/kickstart/custom_commands/partition.py
> @@ -192,6 +192,10 @@ class Wic_PartData(Mic_PartData):
>              return self.prepare_rootfs_vfat(cr_workdir, oe_builddir,
>                                              rootfs_dir, native_sysroot,
>                                              pseudo)
> +        elif self.fstype.startswith("squashfs"):
> +            return self.prepare_rootfs_squashfs(cr_workdir, oe_builddir,
> +                                                rootfs_dir, native_sysroot,
> +                                                pseudo)
>  
>      def prepare_rootfs_ext(self, cr_workdir, oe_builddir, rootfs_dir,
>                             native_sysroot, pseudo):
> @@ -324,6 +328,28 @@ class Wic_PartData(Mic_PartData):
>          self.set_size(rootfs_size)
>          self.set_source_file(rootfs)
>  
> +    def prepare_rootfs_squashfs(self, cr_workdir, oe_builddir, rootfs_dir,
> +                                native_sysroot, pseudo):
> +        """
> +        Prepare content for a squashfs rootfs partition.
> +        """
> +        image_rootfs = rootfs_dir
> +        rootfs = "%s/rootfs_%s.%s" % (cr_workdir, self.label ,self.fstype)
> +
> +        squashfs_cmd = "mksquashfs %s %s -noappend" % \
> +                       (image_rootfs, rootfs)
> +        rc, out = exec_native_cmd(pseudo + squashfs_cmd, native_sysroot)
> +
> +        # get the rootfs size in the right units for kickstart (Mb)
> +        du_cmd = "du -Lbms %s" % rootfs
> +        rc, out = exec_cmd(du_cmd)
> +        rootfs_size = out.split()[0]
> +
> +        self.size = rootfs_size
> +        self.source_file = rootfs
> +
> +        return 0
> +
>      def prepare_empty_partition(self, cr_workdir, oe_builddir, native_sysroot):
>          """
>          Prepare an empty partition.
Maciej Borzecki - July 23, 2014, 8:33 p.m.
On ?ro, 2014-07-23 at 15:21 -0500, Tom Zanussi wrote:
> Hi, please include a description for this.
Ok, will update with the rest of the patches.

> 
> Also, it looks like this is missing the empty_partition() part?
That's intentional. Squashfs, being read-only, is not really useful for
a partition that is empty. You wouldn't be able to create files nor
actually use it in a meaningful manner, unless it's combined with one of
the merging filesystems like {union/au/overlay}fs. In this case the
whole fs setup would be described in fstab.

Though, it might make sense to raise a warning at least.


> 
> Thanks,
> 
> Tom
> 
> On Wed, 2014-07-23 at 12:37 +0200, Maciej Borzecki wrote:
> > Signed-off-by: Maciej Borzecki <maciej.borzecki@open-rnd.pl>
> > ---
> >  .../lib/mic/kickstart/custom_commands/partition.py | 26 ++++++++++++++++++++++
> >  1 file changed, 26 insertions(+)
> > 
> > diff --git a/scripts/lib/mic/kickstart/custom_commands/partition.py b/scripts/lib/mic/kickstart/custom_commands/partition.py
> > index d0f1b78..c4d0113 100644
> > --- a/scripts/lib/mic/kickstart/custom_commands/partition.py
> > +++ b/scripts/lib/mic/kickstart/custom_commands/partition.py
> > @@ -192,6 +192,10 @@ class Wic_PartData(Mic_PartData):
> >              return self.prepare_rootfs_vfat(cr_workdir, oe_builddir,
> >                                              rootfs_dir, native_sysroot,
> >                                              pseudo)
> > +        elif self.fstype.startswith("squashfs"):
> > +            return self.prepare_rootfs_squashfs(cr_workdir, oe_builddir,
> > +                                                rootfs_dir, native_sysroot,
> > +                                                pseudo)
> >  
> >      def prepare_rootfs_ext(self, cr_workdir, oe_builddir, rootfs_dir,
> >                             native_sysroot, pseudo):
> > @@ -324,6 +328,28 @@ class Wic_PartData(Mic_PartData):
> >          self.set_size(rootfs_size)
> >          self.set_source_file(rootfs)
> >  
> > +    def prepare_rootfs_squashfs(self, cr_workdir, oe_builddir, rootfs_dir,
> > +                                native_sysroot, pseudo):
> > +        """
> > +        Prepare content for a squashfs rootfs partition.
> > +        """
> > +        image_rootfs = rootfs_dir
> > +        rootfs = "%s/rootfs_%s.%s" % (cr_workdir, self.label ,self.fstype)
> > +
> > +        squashfs_cmd = "mksquashfs %s %s -noappend" % \
> > +                       (image_rootfs, rootfs)
> > +        rc, out = exec_native_cmd(pseudo + squashfs_cmd, native_sysroot)
> > +
> > +        # get the rootfs size in the right units for kickstart (Mb)
> > +        du_cmd = "du -Lbms %s" % rootfs
> > +        rc, out = exec_cmd(du_cmd)
> > +        rootfs_size = out.split()[0]
> > +
> > +        self.size = rootfs_size
> > +        self.source_file = rootfs
> > +
> > +        return 0
> > +
> >      def prepare_empty_partition(self, cr_workdir, oe_builddir, native_sysroot):
> >          """
> >          Prepare an empty partition.
> 
>
Tom Zanussi - July 23, 2014, 8:39 p.m.
On Wed, 2014-07-23 at 22:33 +0200, Maciek Borzecki wrote:
> On ?ro, 2014-07-23 at 15:21 -0500, Tom Zanussi wrote:
> > Hi, please include a description for this.
> Ok, will update with the rest of the patches.
> 
> > 
> > Also, it looks like this is missing the empty_partition() part?
> That's intentional. Squashfs, being read-only, is not really useful for
> a partition that is empty. You wouldn't be able to create files nor
> actually use it in a meaningful manner, unless it's combined with one of
> the merging filesystems like {union/au/overlay}fs. In this case the
> whole fs setup would be described in fstab.
> 
> Though, it might make sense to raise a warning at least.
> 

Yeah, makes sense, please do add a warning in that case.

Thanks,

Tom

> 
> > 
> > Thanks,
> > 
> > Tom
> > 
> > On Wed, 2014-07-23 at 12:37 +0200, Maciej Borzecki wrote:
> > > Signed-off-by: Maciej Borzecki <maciej.borzecki@open-rnd.pl>
> > > ---
> > >  .../lib/mic/kickstart/custom_commands/partition.py | 26 ++++++++++++++++++++++
> > >  1 file changed, 26 insertions(+)
> > > 
> > > diff --git a/scripts/lib/mic/kickstart/custom_commands/partition.py b/scripts/lib/mic/kickstart/custom_commands/partition.py
> > > index d0f1b78..c4d0113 100644
> > > --- a/scripts/lib/mic/kickstart/custom_commands/partition.py
> > > +++ b/scripts/lib/mic/kickstart/custom_commands/partition.py
> > > @@ -192,6 +192,10 @@ class Wic_PartData(Mic_PartData):
> > >              return self.prepare_rootfs_vfat(cr_workdir, oe_builddir,
> > >                                              rootfs_dir, native_sysroot,
> > >                                              pseudo)
> > > +        elif self.fstype.startswith("squashfs"):
> > > +            return self.prepare_rootfs_squashfs(cr_workdir, oe_builddir,
> > > +                                                rootfs_dir, native_sysroot,
> > > +                                                pseudo)
> > >  
> > >      def prepare_rootfs_ext(self, cr_workdir, oe_builddir, rootfs_dir,
> > >                             native_sysroot, pseudo):
> > > @@ -324,6 +328,28 @@ class Wic_PartData(Mic_PartData):
> > >          self.set_size(rootfs_size)
> > >          self.set_source_file(rootfs)
> > >  
> > > +    def prepare_rootfs_squashfs(self, cr_workdir, oe_builddir, rootfs_dir,
> > > +                                native_sysroot, pseudo):
> > > +        """
> > > +        Prepare content for a squashfs rootfs partition.
> > > +        """
> > > +        image_rootfs = rootfs_dir
> > > +        rootfs = "%s/rootfs_%s.%s" % (cr_workdir, self.label ,self.fstype)
> > > +
> > > +        squashfs_cmd = "mksquashfs %s %s -noappend" % \
> > > +                       (image_rootfs, rootfs)
> > > +        rc, out = exec_native_cmd(pseudo + squashfs_cmd, native_sysroot)
> > > +
> > > +        # get the rootfs size in the right units for kickstart (Mb)
> > > +        du_cmd = "du -Lbms %s" % rootfs
> > > +        rc, out = exec_cmd(du_cmd)
> > > +        rootfs_size = out.split()[0]
> > > +
> > > +        self.size = rootfs_size
> > > +        self.source_file = rootfs
> > > +
> > > +        return 0
> > > +
> > >      def prepare_empty_partition(self, cr_workdir, oe_builddir, native_sysroot):
> > >          """
> > >          Prepare an empty partition.
> > 
> > 
> 
>

Patch

diff --git a/scripts/lib/mic/kickstart/custom_commands/partition.py b/scripts/lib/mic/kickstart/custom_commands/partition.py
index d0f1b78..c4d0113 100644
--- a/scripts/lib/mic/kickstart/custom_commands/partition.py
+++ b/scripts/lib/mic/kickstart/custom_commands/partition.py
@@ -192,6 +192,10 @@  class Wic_PartData(Mic_PartData):
             return self.prepare_rootfs_vfat(cr_workdir, oe_builddir,
                                             rootfs_dir, native_sysroot,
                                             pseudo)
+        elif self.fstype.startswith("squashfs"):
+            return self.prepare_rootfs_squashfs(cr_workdir, oe_builddir,
+                                                rootfs_dir, native_sysroot,
+                                                pseudo)
 
     def prepare_rootfs_ext(self, cr_workdir, oe_builddir, rootfs_dir,
                            native_sysroot, pseudo):
@@ -324,6 +328,28 @@  class Wic_PartData(Mic_PartData):
         self.set_size(rootfs_size)
         self.set_source_file(rootfs)
 
+    def prepare_rootfs_squashfs(self, cr_workdir, oe_builddir, rootfs_dir,
+                                native_sysroot, pseudo):
+        """
+        Prepare content for a squashfs rootfs partition.
+        """
+        image_rootfs = rootfs_dir
+        rootfs = "%s/rootfs_%s.%s" % (cr_workdir, self.label ,self.fstype)
+
+        squashfs_cmd = "mksquashfs %s %s -noappend" % \
+                       (image_rootfs, rootfs)
+        rc, out = exec_native_cmd(pseudo + squashfs_cmd, native_sysroot)
+
+        # get the rootfs size in the right units for kickstart (Mb)
+        du_cmd = "du -Lbms %s" % rootfs
+        rc, out = exec_cmd(du_cmd)
+        rootfs_size = out.split()[0]
+
+        self.size = rootfs_size
+        self.source_file = rootfs
+
+        return 0
+
     def prepare_empty_partition(self, cr_workdir, oe_builddir, native_sysroot):
         """
         Prepare an empty partition.