public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
* [PATCH 1/2] remove conditional SDE paths
@ 2024-04-22 18:58 Felix Moessbauer
  2024-04-22 18:58 ` [PATCH 2/2] do not log clamped file mtimes Felix Moessbauer
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Felix Moessbauer @ 2024-04-22 18:58 UTC (permalink / raw)
  To: isar-users; +Cc: venkata.pyla, quirin.gylstorff, Felix Moessbauer

The SOURCE_DATE_EPOCH variable is now always available, both as bitbake
variable, as well as as env-var. By that, we can remove all conditional
paths that checked if the variable is available. Also, manual exports of
the bitbake variable into the env is no longer required.

Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
---
 meta/classes/dpkg-source.bbclass              |  3 ---
 meta/classes/image-account-extension.bbclass  | 13 +++------
 meta/classes/image.bbclass                    | 27 +++++--------------
 meta/classes/imagetypes_wic.bbclass           |  3 ---
 meta/classes/initramfs.bbclass                |  5 ----
 meta/classes/rootfs-add-files.bbclass         |  4 ---
 .../isar-bootstrap/isar-bootstrap.inc         |  4 ---
 7 files changed, 10 insertions(+), 49 deletions(-)

diff --git a/meta/classes/dpkg-source.bbclass b/meta/classes/dpkg-source.bbclass
index 7e3868f6..7fd5d2ed 100644
--- a/meta/classes/dpkg-source.bbclass
+++ b/meta/classes/dpkg-source.bbclass
@@ -11,9 +11,6 @@ do_dpkg_source() {
     # Create a .dsc file from source directory to use it with sbuild
     DEB_SOURCE_NAME=$(dpkg-parsechangelog --show-field Source --file ${WORKDIR}/${PPS}/debian/changelog)
     find ${WORKDIR} -name "${DEB_SOURCE_NAME}*.dsc" -maxdepth 1 -delete
-    if [ ! -z "${SOURCE_DATE_EPOCH}" ]; then
-        export SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH}"
-    fi
     sh -c "cd ${WORKDIR}; dpkg-source ${DPKG_SOURCE_EXTRA_ARGS} -b ${PPS}"
 }
 addtask dpkg_source after do_prepare_build before do_dpkg_build
diff --git a/meta/classes/image-account-extension.bbclass b/meta/classes/image-account-extension.bbclass
index 3d4e1d1d..b63fff5c 100644
--- a/meta/classes/image-account-extension.bbclass
+++ b/meta/classes/image-account-extension.bbclass
@@ -114,11 +114,10 @@ def image_create_users(d: "DataSmart") -> None:
                 # chpasswd adds a random salt when running against a clear-text password.
                 # For reproducible images, we manually generate the password and use the
                 # SOURCE_DATE_EPOCH to generate the salt in a deterministic way.
-                source_date_epoch = d.getVar("SOURCE_DATE_EPOCH") or ""
-                if source_date_epoch:
-                    command.append("-e")
-                    salt = hashlib.sha256("{}\n".format(source_date_epoch).encode()).hexdigest()[0:15]
-                    password = bb.process.run('openssl passwd -6 --salt {} {}'.format(salt, password))[0].strip()
+                source_date_epoch = d.getVar("SOURCE_DATE_EPOCH")
+                command.append("-e")
+                salt = hashlib.sha256("{}\n".format(source_date_epoch).encode()).hexdigest()[0:15]
+                password = bb.process.run('openssl passwd -6 --salt {} {}'.format(salt, password))[0].strip()
 
             else:
                 command.append("-e")
@@ -131,10 +130,6 @@ def image_create_users(d: "DataSmart") -> None:
 
 ROOTFS_POSTPROCESS_COMMAND += "image_postprocess_accounts"
 python image_postprocess_accounts() {
-    import os
-    if d.getVar("SOURCE_DATE_EPOCH") != None:
-        os.environ["SOURCE_DATE_EPOCH"] = d.getVar("SOURCE_DATE_EPOCH")
- 
     image_create_groups(d)
     image_create_users(d)
 }
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 98741da0..34faa6af 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -289,18 +289,6 @@ python() {
     d.appendVar('IMAGER_BUILD_DEPS', ' ' + ' '.join(sorted(imager_build_deps)))
 }
 
-
-# make generation of initramfs reproducible
-# note: this function is shared across multiple rootfs, but we only want to make the
-#       image rootfs reproducible. Otherwise changes of SOURCE_DATE_EPOCH would
-#       invalidate the SSTATE entries for most packages, even if they don't use the
-#       global SOURCE_DATE_EPOCH variable.
-rootfs_install_pkgs_install:prepend() {
-    if [ ! -z "${SOURCE_DATE_EPOCH}" ]; then
-        export SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH}"
-    fi
-}
-
 # here we call a command that should describe your whole build system,
 # this could be "git describe" or something similar.
 # set ISAR_RELEASE_CMD to customize, or override do_mark_rootfs to do something
@@ -451,17 +439,14 @@ EOSUDO
 
     # Set same time-stamps to the newly generated file/folders in the
     # rootfs image for the purpose of reproducible builds.
-    if [ -n "${SOURCE_DATE_EPOCH}" ]; then
-        fn="${DEPLOY_DIR_IMAGE}/files.modified_timestamps"
-        if sudo find ${ROOTFSDIR} -newermt "$(date -d@${SOURCE_DATE_EPOCH} '+%Y-%m-%d %H:%M:%S')" \
-            -printf "%y %p\n" -exec touch '{}' -h -d@${SOURCE_DATE_EPOCH} ';' | egrep ^f >"$fn"; then
-            if [ -e "$fn" ]; then
-                bbwarn "modified timestamp (${SOURCE_DATE_EPOCH}) of $(cat "$fn" | wc -l) files for image reproducibly." \
-                       "List of files modified can be found in: .${DEPLOY_DIR_IMAGE}/files.modified_timestamps"
-            fi
+    fn="${DEPLOY_DIR_IMAGE}/files.modified_timestamps"
+    if sudo find ${ROOTFSDIR} -newermt "$(date -d@${SOURCE_DATE_EPOCH} '+%Y-%m-%d %H:%M:%S')" \
+        -printf "%y %p\n" -exec touch '{}' -h -d@${SOURCE_DATE_EPOCH} ';' | egrep ^f >"$fn"; then
+        if [ -e "$fn" ]; then
+            bbwarn "modified timestamp (${SOURCE_DATE_EPOCH}) of $(cat "$fn" | wc -l) files for image reproducibly." \
+                    "List of files modified can be found in: .${DEPLOY_DIR_IMAGE}/files.modified_timestamps"
         fi
     fi
-
 }
 do_rootfs_finalize[network] = "${TASK_USE_SUDO}"
 addtask rootfs_finalize before do_rootfs after do_rootfs_postprocess
diff --git a/meta/classes/imagetypes_wic.bbclass b/meta/classes/imagetypes_wic.bbclass
index bce881ed..3b697cdd 100644
--- a/meta/classes/imagetypes_wic.bbclass
+++ b/meta/classes/imagetypes_wic.bbclass
@@ -157,9 +157,6 @@ generate_wic_image() {
     export FAKEROOTCMD=${FAKEROOTCMD}
     export BUILDDIR=${TOPDIR}
     export MTOOLS_SKIP_CHECK=1
-    if [ ! -z "${SOURCE_DATE_EPOCH}" ]; then
-        export SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH}"
-    fi
     mkdir -p ${IMAGE_ROOTFS}/../pseudo
     touch ${IMAGE_ROOTFS}/../pseudo/files.db
 
diff --git a/meta/classes/initramfs.bbclass b/meta/classes/initramfs.bbclass
index 925c3f6d..5b5943f2 100644
--- a/meta/classes/initramfs.bbclass
+++ b/meta/classes/initramfs.bbclass
@@ -38,11 +38,6 @@ do_generate_initramfs() {
     rootfs_do_mounts
     rootfs_do_qemu
 
-    # generate reproducible initrd if requested
-    if [ ! -z "${SOURCE_DATE_EPOCH}" ]; then
-        export SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH}"
-    fi
-
     sudo -E chroot "${INITRAMFS_ROOTFS}" sh -c '\
         export kernel_version=$(basename /boot/vmlinu[xz]* | cut -d'-' -f2-); \
         if [ -n "$kernel_version" ]; then \
diff --git a/meta/classes/rootfs-add-files.bbclass b/meta/classes/rootfs-add-files.bbclass
index 4125caf5..8ebd25cb 100644
--- a/meta/classes/rootfs-add-files.bbclass
+++ b/meta/classes/rootfs-add-files.bbclass
@@ -16,10 +16,6 @@ ROOTFS_ADDITIONAL_FILES ??= ""
 
 
 python rootfs_add_files() {
-    import os
-    if d.getVar("SOURCE_DATE_EPOCH") != None:
-        os.environ["SOURCE_DATE_EPOCH"] = d.getVar("SOURCE_DATE_EPOCH")
-
     postprocess_additional_files = d.getVar('ROOTFS_ADDITIONAL_FILES').split()
     rootfsdir = d.getVar("ROOTFSDIR")
 
diff --git a/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc b/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc
index b1567d7b..faf22a50 100644
--- a/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc
+++ b/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc
@@ -310,10 +310,6 @@ do_bootstrap() {
     sudo rm -rf --one-file-system "${ROOTFSDIR}"
     deb_dl_dir_import "${ROOTFSDIR}" "${BOOTSTRAP_BASE_DISTRO}-${BASE_DISTRO_CODENAME}"
 
-    if [ -n "${SOURCE_DATE_EPOCH}" ]; then
-        export SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH}"
-    fi
-
     sudo -E -s <<'EOSUDO'
         set -e
         if [ "${BOOTSTRAP_FOR_HOST}" = "0" ]; then
-- 
2.39.2


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-04-30  7:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-22 18:58 [PATCH 1/2] remove conditional SDE paths Felix Moessbauer
2024-04-22 18:58 ` [PATCH 2/2] do not log clamped file mtimes Felix Moessbauer
2024-04-23 19:49 ` [PATCH 1/2] remove conditional SDE paths Uladzimir Bely
2024-04-24  7:24   ` MOESSBAUER, Felix
2024-04-24  7:51     ` Uladzimir Bely
2024-04-30  7:03 ` Uladzimir Bely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox