<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>14019</bug_id>
          
          <creation_ts>2020-08-21 12:19:51 +0000</creation_ts>
          <short_desc>Default the target time to the time of the build host</short_desc>
          <delta_ts>2025-12-03 07:30:29 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>Runtime</product>
          <component>build-appliance</component>
          <version>unspecified</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium</priority>
          <bug_severity>enhancement</bug_severity>
          <target_milestone>5.3</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Mingde (Matthew) Zeng">matthewzmd</reporter>
          <assigned_to name="Mingli Yu">mingli.yu</assigned_to>
          <cc>bunk</cc>
    
    <cc>louis.rannou</cc>
    
    <cc>matthewzmd</cc>
    
    <cc>randy.macleod</cc>
    
    <cc>richard.purdie</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>No (bug/feature does not impact docs)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>88008</commentid>
    <comment_count>0</comment_count>
    <who name="Mingde (Matthew) Zeng">matthewzmd</who>
    <bug_when>2020-08-21 12:19:51 +0000</bug_when>
    <thetext>This bug is discovered in WR Linux built with meta-qt5 on a rpi4.

The current behavior is, when building on a hardware target (rpi4 &amp; intel-x86-64 in my case), the system time gets defaulted to some time in the past. 

It impacted meta-qt5&apos;s qtcreator, as some of the files in /usr/lib64/mkspecs/common/* have a modification date from the build host, therefore resulting make complaining: `make: Warning: File &apos;/usr/lib64/mkspecs/common/gcc-base.conf&apos; has modification time Xs in the future.`

It also makes a general sense to have the target sharing the same system time with the build host.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88009</commentid>
    <comment_count>1</comment_count>
    <who name="Mingde (Matthew) Zeng">matthewzmd</who>
    <bug_when>2020-08-21 12:21:18 +0000</bug_when>
    <thetext>I&apos;ll also confirm that it happens on poky + meta-qt5 when I have time.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88010</commentid>
    <comment_count>2</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2020-08-21 12:35:51 +0000</bug_when>
    <thetext>The idea is that near the end of image construction on the build host, we&apos;d touch a file in the target FS being built. Then on the target, check on first boot that the target time is later than the reference file&apos;s timestamp. Timezones for the build host and deployed target may be different and that could be a problem but we&apos;ll see if we can handle that. I&apos;d assume that we are using UTC and GMT when building but I haven&apos;t checked.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88016</commentid>
    <comment_count>3</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2020-08-22 07:24:46 +0000</bug_when>
    <thetext>Have a look at meta/classes/rootfs-postcommands.bbclass:ROOTFS_POSTPROCESS_COMMAND += &quot;rootfs_update_timestamp; &quot; and /etc/timestamp

also:

meta/recipes-core/initscripts/initscripts-1.0/save-rtc.sh:TIMESTAMP_FILE=/etc/timestamp
meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh:TIMESTAMP_FILE=/etc/timestamp</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88017</commentid>
    <comment_count>4</comment_count>
    <who name="Adrian Bunk">bunk</who>
    <bug_when>2020-08-22 07:37:06 +0000</bug_when>
    <thetext>(In reply to comment #2)
&gt; The idea is that near the end of image construction on the build host, we&apos;d
&gt; touch a file in the target FS being built. Then on the target, check on
&gt; first boot that the target time is later than the reference file&apos;s
&gt; timestamp.

I assume you are talking about non-systemd distributions?
systemd does this already.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88018</commentid>
    <comment_count>5</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2020-08-22 11:01:03 +0000</bug_when>
    <thetext>Systemd is the init system in this case. 

The RPI4 doesn&apos;t have a battery-backed clock unless you buy an extra part. 

Matthew will use the meta-rpi layer rather than the WR BSP to see if the problem still happens and we can debug from there.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88019</commentid>
    <comment_count>6</comment_count>
    <who name="Adrian Bunk">bunk</who>
    <bug_when>2020-08-22 11:11:31 +0000</bug_when>
    <thetext>(In reply to comment #5)
&gt; Systemd is the init system in this case. 
&gt; 
&gt; The RPI4 doesn&apos;t have a battery-backed clock unless you buy an extra part. 
&gt; 
&gt; Matthew will use the meta-rpi layer rather than the WR BSP to see if the
&gt; problem still happens and we can debug from there.

He should get one of these two messages logged:
https://github.com/systemd/systemd/blob/master/src/core/main.c#L1582-L1586</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>94992</commentid>
    <comment_count>7</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2023-02-23 15:25:27 +0000</bug_when>
    <thetext>Url is now https://github.com/systemd/systemd/blob/main/src/core/main.c#L1634</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>94994</commentid>
    <comment_count>8</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2023-02-23 15:28:59 +0000</bug_when>
    <thetext>We need to ensure the timestamp of https://github.com/systemd/systemd/blob/main/src/shared/clock-util.c#L134 i.e. 
#define EPOCH_FILE &quot;/usr/lib/clock-epoch&quot; is correct</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>102279</commentid>
    <comment_count>9</comment_count>
    <who name="Louis Rannou">louis.rannou</who>
    <bug_when>2025-06-17 12:42:52 +0000</bug_when>
    <thetext>I think this is resolved by https://git.openembedded.org/openembedded-core/commit/meta/recipes-core/systemd/?id=0f51fee4a5408c17cbaf827053f13d6c3b9dbc2c</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>102292</commentid>
    <comment_count>10</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2025-06-18 19:21:30 +0000</bug_when>
    <thetext>Louis, 

That seems like a good patch for systemd.
Can you check sysvinit since that&apos;s still our default init?

../Randy</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>103465</commentid>
    <comment_count>11</comment_count>
    <who name="Mingli Yu">mingli.yu</who>
    <bug_when>2025-12-03 07:30:29 +0000</bug_when>
    <thetext>With systemd:
https://git.openembedded.org/openembedded-core/commit/meta/recipes-core/systemd/?id=0f51fee4a5408c17cbaf827053f13d6c3b9dbc2c

With sysvinit:
we can set below logic in conf/local.conf
REPRODUCIBLE_TIMESTAMP_ROOTFS = &quot;&quot;

And then the target will get a more reasonable sane time based on below logic.
# Can be used to create /etc/timestamp during image construction to give a reasonably
# sane default time setting
rootfs_update_timestamp () {
    if [ &quot;${REPRODUCIBLE_TIMESTAMP_ROOTFS}&quot; != &quot;&quot; ]; then
        # Convert UTC into %4Y%2m%2d%2H%2M%2S
        sformatted=`date -u -d @${REPRODUCIBLE_TIMESTAMP_ROOTFS} +%4Y%2m%2d%2H%2M%2S`
    else
        sformatted=`date -u +%4Y%2m%2d%2H%2M%2S`
    fi  
    echo $sformatted &gt; ${IMAGE_ROOTFS}/etc/timestamp
    bbnote &quot;rootfs_update_timestamp: set /etc/timestamp to $sformatted&quot;
}</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>