cancel
Showing results for 
Search instead for 
Did you mean: 

Time stamp of /etc/version of distribution image is weird

MaxPeng
Associate

I follow the instruction of Building the OpenSTLinux distribution to build the distribution image, /etc/version in the image is 20180309123456. Furthermore, the years of most of the directories and files of root filesystem are 2008. If I am correct, it should be the date/time when I built the image.

Why do I ask this? When I tried the built image with the SD card and saw the year of directories and files are 2008, I wondered whether I flashed correct image to the SD card.

2 REPLIES 2
mleo
Senior II

Hi @MaxPeng​ ,

I can provide you thorough information from expert how the value in /etc/version is generated:

*************************************************************************************************************************

  The date put on /etc/version are get from the git commit from openembedded-core:

         REPRODUCIBLE_TIMESTAMP_ROOTFS=`git -C "/mnt/internal_storage/oetest/oe_openstlinux_dunfell/layers/openembedded-core" log -1 --pretty=%ct 2>/dev/null`

         sformatted=`date -u -d @${REPRODUCIBLE_TIMESTAMP_ROOTFS} +%4Y%2m%2d%2H%2M%2S`

         echo $sformatted > ${IMAGE_ROOTFS}/etc/version

   The date issue come from the time reference because the option %ct return a "%ct: committer date, UNIX timestamp".

   the UNIX timestamp are not the same as the pc time

*************************************************************************************************************************

To see if you flashed the correct image you can check e.g. the kernel version.

Hope this helps

Milan

MaxPeng
Associate

Hi Milan,

After reading your explanation, I search the recipes and get these:

meta/classes/image.bbclass-653-reproducible_final_image_task () {
meta/classes/image.bbclass-654-    if [ "${BUILD_REPRODUCIBLE_BINARIES}" = "1" ]; then
meta/classes/image.bbclass:655:        if [ "$REPRODUCIBLE_TIMESTAMP_ROOTFS" = "" ]; then
meta/classes/image.bbclass:656:            REPRODUCIBLE_TIMESTAMP_ROOTFS=`git -C "${COREBASE}" log -1 --pretty=%ct 2>/dev/null` || true
meta/classes/image.bbclass:657:            if [ "${REPRODUCIBLE_TIMESTAMP_ROOTFS}" = "" ]; then
meta/classes/image.bbclass:658:                REPRODUCIBLE_TIMESTAMP_ROOTFS=`stat -c%Y ${@bb.utils.which(d.getVar("BBPATH"), "conf/bitbake.conf")}`
meta/classes/image.bbclass-659-            fi
meta/classes/image.bbclass-660-        fi
--
meta/classes/reproducible_build_simple.bbclass-6-export PERL_HASH_SEED = "0"
meta/classes/reproducible_build_simple.bbclass-7-export SOURCE_DATE_EPOCH ??= "1520598896"
meta/classes/reproducible_build_simple.bbclass-8-
meta/classes/reproducible_build_simple.bbclass:9:REPRODUCIBLE_TIMESTAMP_ROOTFS ??= "1520598896"
 

The epoch time 1520598896 equals to March 9, 2018 12:34:56PM -> 20180309123456 stored in /etc/version

The conf/local.conf contains this:

# Setup environment for builds binary reproducibility
INHERIT += "reproducible_build"

I understand the purpose of it is to generate "Reproducible Builds". But instead of using meaningless timestamp 20180309123456. Why not set it to a specific date for a release? For example:

# Setup environment for builds binary reproducibility
# GMT: Thursday, July 9, 2020 11:28:10 PM -> 1594337290
BUILD_REPRODUCIBLE_BINARIES = "1"
export SOURCE_DATE_EPOCH = "1594337290"
REPRODUCIBLE_TIMESTAMP_ROOTFS = "1594337290"
INHERIT += "reproducible_build"

Thanks!