Skip to contentSkip to conversation

Empty-image functionality

PATCH Superseded Alex Franco 5 participants 9 messages Aug 26, 2015 – Sep 11, 2015

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Empty-image functionality

Enable creation of core-empty-image (a recipe that inherits image without any extra packages) or similar empty images, whether RPM, DEB or IPK packaging is selected.

[YOCTO #7664]

Alex Franco (3):
Empty image: core-image-empty recipe, Rootfs fix Empty image: package list splitting and iteration Empty image: filesystem allocation

 meta/classes/image_types.bbclass             | 10 +++++++++-
 meta/classes/license.bbclass                 |  2 +-
 meta/lib/oe/package_manager.py               |  5 +++--
 meta/lib/oe/rootfs.py                        |  8 ++++++--
 meta/recipes-core/images/core-image-empty.bb |  7 +++++++
 5 files changed, 26 insertions(+), 6 deletions(-)
 create mode 100644 meta/recipes-core/images/core-image-empty.bb
Signature · 1 line
2.5.0
#1 lore raw

PATCH 1/3 Empty image: core-image-empty recipe, Rootfs fix

Added a core-image-empty recipe, as well as a DpkgOpkgRootfs test which skips the package post installs step, if PACKAGE_INSTALL is empty.

[YOCTO #7664]

---
 meta/lib/oe/rootfs.py                        | 6 +++++-
 meta/recipes-core/images/core-image-empty.bb | 7 +++++++
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 meta/recipes-core/images/core-image-empty.bb
meta/lib/oe/rootfs.py +5 -1
index 8c8244c..f8cc6eb 100644
@@ -585,7 +585,11 @@ class DpkgOpkgRootfs(Rootfs):
 
         pkg_list = []
 
-        pkgs = self._get_pkgs_postinsts(status_file)
+        pkgs = None
+        if not self.d.getVar('PACKAGE_INSTALL', True).strip():
+            bb.note("Building empty image")
+        else:
+            pkgs = self._get_pkgs_postinsts(status_file)
         if pkgs:
             root = "__packagegroup_postinst__"
             pkgs[root] = pkgs.keys()
meta/recipes-core/images/core-image-empty.bb new file +7 -0
new file mode 100644
index 0000000..550567c
@@ -0,0 +1,7 @@
+SUMMARY = "An empty image."
+IMAGE_INSTALL = ""
+IMAGE_LINGUAS = ""
+PACKAGE_INSTALL = ""
+LICENSE = "MIT"
+
+inherit image
Signature · 1 line
2.5.0
#2 lore raw

Re: [PATCH 1/3] Empty image: core-image-empty recipe, Rootfs fix

Hi Alex,

Quoted 36 lines · On Wednesday 26 August 2015 16:57:33 Alex Franco wrote:

Added a core-image-empty recipe, as well as a DpkgOpkgRootfs test which skips the package post installs step, if PACKAGE_INSTALL is empty.

[YOCTO #7664]

---
 meta/lib/oe/rootfs.py                        | 6 +++++-
 meta/recipes-core/images/core-image-empty.bb | 7 +++++++
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 meta/recipes-core/images/core-image-empty.bb
meta/lib/oe/rootfs.py +5 -1
index 8c8244c..f8cc6eb 100644
@@ -585,7 +585,11 @@ class DpkgOpkgRootfs(Rootfs):
 
         pkg_list = []
 
-        pkgs = self._get_pkgs_postinsts(status_file)
+        pkgs = None
+        if not self.d.getVar('PACKAGE_INSTALL', True).strip():
+            bb.note("Building empty image")
+        else:
+            pkgs = self._get_pkgs_postinsts(status_file)
         if pkgs:
             root = "__packagegroup_postinst__"
             pkgs[root] = pkgs.keys()
(quoted diff) +0 -0

b/meta/recipes-core/images/core-image-empty.bb new file mode 100644 index 0000000..550567c

meta/recipes-core/images/core-image-empty.bb line 7

Quoted 7 lines
meta/recipes-core/images/core-image-empty.bb new file +7 -0
@@ -0,0 +1,7 @@
+SUMMARY = "An empty image."
+IMAGE_INSTALL = ""
+IMAGE_LINGUAS = ""
+PACKAGE_INSTALL = ""
+LICENSE = "MIT"
+
+inherit image

Could you please put this image recipe into meta-selftest instead (call it oe- selftest-empty-image.bb) and add an oe-selftest test to ensure it builds and is empty?

Thanks,
Paul

Signature · 2 lines
Paul Eggleton
Intel Open Source Technology Centre
#3 lore raw

Re: [PATCH 1/3] Empty image: core-image-empty recipe, Rootfs fix

Yes indeed! Sorry, I didn't see this before!

Alex

Quoted 53 lines · Paul Eggleton

Hi Alex,

Quoted 36 lines · On Wednesday 26 August 2015 16:57:33 Alex Franco wrote:

Added a core-image-empty recipe, as well as a DpkgOpkgRootfs test which skips the package post installs step, if PACKAGE_INSTALL is empty.

[YOCTO #7664]

---
  meta/lib/oe/rootfs.py                        | 6 +++++-
  meta/recipes-core/images/core-image-empty.bb | 7 +++++++
  2 files changed, 12 insertions(+), 1 deletion(-)

create mode 100644 meta/recipes-core/images/core-image-empty.bb

meta/lib/oe/rootfs.py +5 -1
index 8c8244c..f8cc6eb 100644
@@ -585,7 +585,11 @@ class DpkgOpkgRootfs(Rootfs):
 
          pkg_list = []
 
-        pkgs = self._get_pkgs_postinsts(status_file)
+        pkgs = None
+        if not self.d.getVar('PACKAGE_INSTALL', True).strip():
+            bb.note("Building empty image")
+        else:
+            pkgs = self._get_pkgs_postinsts(status_file)
          if pkgs:
              root = "__packagegroup_postinst__"
              pkgs[root] = pkgs.keys()
(quoted diff) +0 -0

b/meta/recipes-core/images/core-image-empty.bb new file mode 100644 index 0000000..550567c

meta/recipes-core/images/core-image-empty.bb line 7

Quoted 7 lines
meta/recipes-core/images/core-image-empty.bb new file +7 -0
@@ -0,0 +1,7 @@
+SUMMARY = "An empty image."
+IMAGE_INSTALL = ""
+IMAGE_LINGUAS = ""
+PACKAGE_INSTALL = ""
+LICENSE = "MIT"
+
+inherit image

Could you please put this image recipe into meta-selftest instead (call it oe- selftest-empty-image.bb) and add an oe-selftest test to ensure it builds and is empty?

Thanks,
Paul

#4 lore raw

PATCH 2/3 Empty image: package list splitting and iteration

In reply to Alex Franco

A few short fixes to splitting/iteration done over package lists in license.bbclass, package_manager.py and rootfs.py.

[YOCTO #7664]

---
 meta/classes/license.bbclass   | 2 +-
 meta/lib/oe/package_manager.py | 5 +++--
 meta/lib/oe/rootfs.py          | 2 +-
 3 files changed, 5 insertions(+), 4 deletions(-)
meta/classes/license.bbclass +1 -1
index 32e172a..c616a20 100644
@@ -39,7 +39,7 @@ python license_create_manifest() {
         return 0
 
     pkg_dic = {}
-    for pkg in image_list_installed_packages(d).split("\n"):
+    for pkg in image_list_installed_packages(d).splitlines():
         pkg_info = os.path.join(d.getVar('PKGDATA_DIR', True),
                                 'runtime-reverse', pkg)
         pkg_name = os.path.basename(os.readlink(pkg_info))
meta/lib/oe/package_manager.py +3 -2
index 2ab1d78..ef917f1 100644
@@ -995,9 +995,10 @@ class RpmPM(PackageManager):
     '''
     def install(self, pkgs, attempt_only=False):
 
-        bb.note("Installing the following packages: %s" % ' '.join(pkgs))
-        if attempt_only and len(pkgs) == 0:
+        if not pkgs:
+            bb.note("There are no packages to install")
             return
+        bb.note("Installing the following packages: %s" % ' '.join(pkgs))
         pkgs = self._pkg_translate_oe_to_smart(pkgs, attempt_only)
 
         if not attempt_only:
meta/lib/oe/rootfs.py +1 -1
index f8cc6eb..0bfc217 100644
@@ -235,7 +235,7 @@ class Rootfs(object):
                 installed_pkgs_dir = self.d.expand('${WORKDIR}/installed_pkgs.txt')
                 pkgs_to_remove = list()
                 with open(installed_pkgs_dir, "r+") as installed_pkgs:
-                    pkgs_installed = installed_pkgs.read().split('\n')
+                    pkgs_installed = installed_pkgs.read().splitlines()
                     for pkg_installed in pkgs_installed[:]:
                         pkg = pkg_installed.split()[0]
                         if pkg in ["update-rc.d",
Signature · 1 line
2.5.0
#5 lore raw

PATCH 3/3 Empty image: filesystem allocation

In reply to Alex Franco

Increase sparse image block size when ROOTFS_SIZE is smaller than the minimum needed for ext4 to fit into it.

[YOCTO #7664]

---
 meta/classes/image_types.bbclass | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
meta/classes/image_types.bbclass +9 -1
index 35ceb7b..61ce222 100644
@@ -49,8 +49,16 @@ oe_mkext234fs () {
 		extra_imagecmd=$@
 	fi
 
+	# If generating an empty image the size of the sparse block should be large
+	# enough to allocate an ext4 filesystem using 4096 bytes per inode, this is
+	# about 60K, so dd needs a minimum count of 60, with bs=1024 (bytes per IO)
+	eval local COUNT=\"0\"
+	eval local MIN_COUNT=\"60\"
+	if [ $ROOTFS_SIZE -lt $MIN_COUNT ]; then
+		eval COUNT=\"$MIN_COUNT\"
+	fi
 	# Create a sparse image block
-	dd if=/dev/zero of=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.$fstype seek=$ROOTFS_SIZE count=0 bs=1k
+	dd if=/dev/zero of=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.$fstype seek=$ROOTFS_SIZE count=$COUNT bs=1024
 	mkfs.$fstype -F $extra_imagecmd ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.$fstype -d ${IMAGE_ROOTFS}
 }
 
Signature · 1 line
2.5.0
#6 lore raw

Re: [PATCH 3/3] Empty image: filesystem allocation

Hi Alejandro,

Quoted 35 lines · Alex Franco

Increase sparse image block size when ROOTFS_SIZE is smaller than the minimum needed for ext4 to fit into it.

[YOCTO #7664]

---
 meta/classes/image_types.bbclass | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
meta/classes/image_types.bbclass +1 -0
index 35ceb7b..61ce222 100644
@@ -49,8 +49,16 @@ oe_mkext234fs () {
 		extra_imagecmd=$@
 	fi
 
+	# If generating an empty image the size of the sparse block

should be large

meta/classes/image_types.bbclass +1 -0
+	# enough to allocate an ext4 filesystem using 4096 bytes per

inode, this is

meta/classes/image_types.bbclass +1 -0
+	# about 60K, so dd needs a minimum count of 60, with bs=1024

(bytes per IO)

meta/classes/image_types.bbclass +5 -1
+	eval local COUNT=\"0\"
+	eval local MIN_COUNT=\"60\"
+	if [ $ROOTFS_SIZE -lt $MIN_COUNT ]; then
+		eval COUNT=\"$MIN_COUNT\"
+	fi
 	# Create a sparse image block
-	dd if=/dev/zero

of=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.$fstype seek=$ROOTFS_SIZE count=0 bs=1k

meta/classes/image_types.bbclass +1 -0
+	dd if=/dev/zero
Quoted 2 lines

of=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.$fstype seek=$ROOTFS_SIZE count=$COUNT bs=1024

Variable references enclosed in {} are less prone to misinterpretation.

Quoted 7 lines

mkfs.$fstype -F $extra_imagecmd
${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.$fstype -d ${IMAGE_ROOTFS}
}

Signature · 1 line
2.5.0
#7 lore raw

Re: [PATCH 3/3] Empty image: filesystem allocation

Quoted 33 lines · Benjamin Esquivel

Hi Alejandro,

Quoted 30 lines · Alex Franco

Increase sparse image block size when ROOTFS_SIZE is smaller than the minimum needed for ext4 to fit into it.

[YOCTO #7664]

---
 meta/classes/image_types.bbclass | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
meta/classes/image_types.bbclass +1 -0
index 35ceb7b..61ce222 100644
@@ -49,8 +49,16 @@ oe_mkext234fs () {
 		extra_imagecmd=$@
 	fi
 
+	# If generating an empty image the size of the sparse block

should be large

meta/classes/image_types.bbclass +1 -0
+	# enough to allocate an ext4 filesystem using 4096 bytes per

inode, this is

meta/classes/image_types.bbclass +1 -0
+	# about 60K, so dd needs a minimum count of 60, with bs=1024

(bytes per IO)

meta/classes/image_types.bbclass +5 -0
+	eval local COUNT=\"0\"
+	eval local MIN_COUNT=\"60\"
+	if [ $ROOTFS_SIZE -lt $MIN_COUNT ]; then
+		eval COUNT=\"$MIN_COUNT\"
+	fi
Quoted 8 lines
Quoted 7 lines
meta/classes/image_types.bbclass +0 -1
 	# Create a sparse image block
-	dd if=/dev/zero

of=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.$fstype seek=$ROOTFS_SIZE count=0 bs=1k

meta/classes/image_types.bbclass +1 -0
+	dd if=/dev/zero

of=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.$fstype seek=$ROOTFS_SIZE count=$COUNT bs=1024

Variable references enclosed in {} are less prone to misinterpretation.

They are however more likely to get expanded by bitbake before you'd expect them to be unfortunately :(

Cheers,

Richard

Quoted 7 lines
Quoted 7 lines

mkfs.$fstype -F $extra_imagecmd
${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.$fstype -d ${IMAGE_ROOTFS}
}

Signature · 1 line
2.5.0
Acked-by on the v1 series
#8 lore raw
In reply to Alex Franco
Quoted 19 lines · Alex Franco

Enable creation of core-empty-image (a recipe that inherits image without any extra packages) or similar empty images, whether RPM, DEB or IPK packaging is selected.

[YOCTO #7664]

Alex Franco (3):
Empty image: core-image-empty recipe, Rootfs fix Empty image: package list splitting and iteration Empty image: filesystem allocation

  meta/classes/image_types.bbclass             | 10 +++++++++-
  meta/classes/license.bbclass                 |  2 +-
  meta/lib/oe/package_manager.py               |  5 +++--
  meta/lib/oe/rootfs.py                        |  8 ++++++--
  meta/recipes-core/images/core-image-empty.bb |  7 +++++++
  5 files changed, 26 insertions(+), 6 deletions(-)

create mode 100644 meta/recipes-core/images/core-image-empty.bb