Two remarks below...

Met vriendelijke groet / kind regards,

Mike Looijmans
System Expert


TOPIC Embedded Products B.V.
Materiaalweg 4, 5681 RJ Best
The Netherlands

T: +31 (0) 499 33 69 69
E: mike.looijm...@topicproducts.com
W: www.topic.nl

Please consider the environment before printing this e-mail
On 22-03-2021 16:45, Anton Kachalov via lists.openembedded.org wrote:
From: "Anton D. Kachalov" <gmo...@google.com>

When running on read-only rootfs backed with overlayfs, the processed scripts
are being marked as deleted on upperdir of overlayfs. When it comes to
upgrade the main read-only image, it might contain new postinst scripts that
are different from the already processed. Introduced suffix (sha256 of
the content) allows to distinct updated scripts of the same package.

So your usecase is that you have a read-only rootfs with an overlay on top, and then just replace the rootfs. And then expect things to still work?

That doesn't sound valid to me - normally I'd wipe the overlay clean when updating the underlying read-only part. I'd be very interested in what you're actually trying to accomplish here?

And further, I don't think appending 64 characters to filenames is going to make anyone happy.

In your case, I'd opt for a script that just resets the postinst scripts (and maybe more?) in the overlay. Or have 3 overlays. Whenever the package manager runs, activate the second layer. The "user" stuff in the third layer is normally active. Then when you upgrade the system, wipe the second layer, to get rid of obsolete packages. Or something like that. Again, tell us what you're really building...



Signed-off-by: Anton D. Kachalov <gmo...@google.com>
---
  meta/lib/oe/package_manager/deb/rootfs.py   | 11 ++++++++++-
  meta/lib/oe/package_manager/ipk/rootfs.py   | 11 ++++++++++-
  meta/lib/oe/package_manager/rpm/__init__.py |  4 +++-
  3 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/meta/lib/oe/package_manager/deb/rootfs.py 
b/meta/lib/oe/package_manager/deb/rootfs.py
index 8fbaca11d6..704d213626 100644
--- a/meta/lib/oe/package_manager/deb/rootfs.py
+++ b/meta/lib/oe/package_manager/deb/rootfs.py
@@ -4,6 +4,7 @@
import re
  import shutil
+from hashlib import sha256
  from oe.rootfs import Rootfs
  from oe.manifest import Manifest
  from oe.utils import execute_pre_post_process
@@ -115,8 +116,16 @@ class DpkgOpkgRootfs(Rootfs):
              bb.utils.mkdirhier(dst_postinst_dir)
if os.path.exists(os.path.join(src_postinst_dir, p + ".postinst")):
+                csum = sha256()
+                with open(src_postinst_dir, p + ".postinst", "rb") as f:
+                    while True:
+                        data = f.read(65536)
+                        if not data:
+                            break
+                        csum.update(data)
+
                  shutil.copy(os.path.join(src_postinst_dir, p + ".postinst"),
-                            os.path.join(dst_postinst_dir, "%03d-%s" % (num, 
p)))
+                            os.path.join(dst_postinst_dir, "%03d-%s.%s" % 
(num, p, csum.hexdigest())))
num += 1 diff --git a/meta/lib/oe/package_manager/ipk/rootfs.py b/meta/lib/oe/package_manager/ipk/rootfs.py
index 26dbee6f6a..6ead6ddef3 100644
--- a/meta/lib/oe/package_manager/ipk/rootfs.py
+++ b/meta/lib/oe/package_manager/ipk/rootfs.py
@@ -5,6 +5,7 @@
  import re
  import filecmp
  import shutil
+from hashlib import sha256
  from oe.rootfs import Rootfs
  from oe.manifest import Manifest
  from oe.utils import execute_pre_post_process
@@ -116,8 +117,16 @@ class DpkgOpkgRootfs(Rootfs):
              bb.utils.mkdirhier(dst_postinst_dir)
if os.path.exists(os.path.join(src_postinst_dir, p + ".postinst")):
+                csum = sha256()
+                with open(src_postinst_dir, p + ".postinst", "rb") as f:
+                    while True:
+                        data = f.read(65536)
+                        if not data:
+                            break
+                        csum.update(data)
+
                  shutil.copy(os.path.join(src_postinst_dir, p + ".postinst"),
-                            os.path.join(dst_postinst_dir, "%03d-%s" % (num, 
p)))
+                            os.path.join(dst_postinst_dir, "%03d-%s.%s" % 
(num, p, csum.hexdigest())))
num += 1 diff --git a/meta/lib/oe/package_manager/rpm/__init__.py b/meta/lib/oe/package_manager/rpm/__init__.py
index 6df0092281..4746e96ce8 100644
--- a/meta/lib/oe/package_manager/rpm/__init__.py
+++ b/meta/lib/oe/package_manager/rpm/__init__.py
@@ -4,6 +4,7 @@
import shutil
  import subprocess
+from hashlib import sha256
  from oe.package_manager import *
class RpmIndexer(Indexer):
@@ -359,7 +360,8 @@ class RpmPM(PackageManager):
          target_path = oe.path.join(self.target_rootfs, 
self.d.expand('${sysconfdir}/rpm-postinsts/'))
          bb.utils.mkdirhier(target_path)
          num = self._script_num_prefix(target_path)
-        saved_script_name = oe.path.join(target_path, "%d-%s" % (num, pkg))
+        csum = sha256(output.encode("utf-8")).hexdigest()
+        saved_script_name = oe.path.join(target_path, "%d-%s.%s" % (num, pkg, 
csum))
          open(saved_script_name, 'w').write(output)
          os.chmod(saved_script_name, 0o755)



--
Mike Looijmans

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#149787): 
https://lists.openembedded.org/g/openembedded-core/message/149787
Mute This Topic: https://lists.openembedded.org/mt/81527936/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to