diff mbox series

[isar-cip-core,v2,5/6] squashfs.bbclass: Fix file timestamps are not reproducible in squashfs image

Message ID 20230703062231.18183-6-venkata.pyla@toshiba-tsip.com (mailing list archive)
State Superseded
Headers show
Series [isar-cip-core,v2,1/6] .reproducible-check-ci.yml: Include swupdate artifacts in reproducible check | expand

Commit Message

Venkata Pyla July 3, 2023, 6:22 a.m. UTC
From: venkata pyla <venkata.pyla@toshiba-tsip.com>

The generated squashfs image contains non-reproducible file timestamps,
so set with value in SOURCE_DATE_EPOCH variable if it is set.

Closes: #68

Signed-off-by: venkata pyla <venkata.pyla@toshiba-tsip.com>
---
 classes/squashfs.bbclass | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Jan Kiszka July 3, 2023, 10:50 a.m. UTC | #1
On 03.07.23 08:22, venkata.pyla@toshiba-tsip.com wrote:
> From: venkata pyla <venkata.pyla@toshiba-tsip.com>
> 
> The generated squashfs image contains non-reproducible file timestamps,
> so set with value in SOURCE_DATE_EPOCH variable if it is set.
> 
> Closes: #68
> 
> Signed-off-by: venkata pyla <venkata.pyla@toshiba-tsip.com>
> ---
>  classes/squashfs.bbclass | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/classes/squashfs.bbclass b/classes/squashfs.bbclass
> index b39be0c..469cdc5 100644
> --- a/classes/squashfs.bbclass
> +++ b/classes/squashfs.bbclass
> @@ -31,6 +31,12 @@ SQUASHFS_MEMLIMIT ?= "${@int(get_free_mem() * 3/4)}"
>  SQUASHFS_CREATION_LIMITS = "-mem ${SQUASHFS_MEMLIMIT} -processors ${SQUASHFS_THREADS}"
>  
>  python __anonymous() {
> +    # Set file timestamps for reproducible builds
> +    source_date_epoch = d.getVar('SOURCE_DATE_EPOCH')
> +    if source_date_epoch:
> +       args = " -fstime {time}".format(time=source_date_epoch)
> +    d.appendVar('SQUASHFS_CREATION_ARGS', args)

Wrong indention of this line - args is undefined if source_date_epoch is
None.

> +
>      exclude_directories = d.getVar('SQUASHFS_EXCLUDE_DIRS').split()
>      if len(exclude_directories) == 0:
>          return

Jan
Venkata Pyla July 3, 2023, 12:58 p.m. UTC | #2
>-----Original Message-----
>From: cip-dev@lists.cip-project.org <cip-dev@lists.cip-project.org> On Behalf Of
>Jan Kiszka via lists.cip-project.org
>Sent: Monday, July 3, 2023 4:21 PM
>To: pyla venkata(TSIP TMIEC ODG Porting) <Venkata.Pyla@toshiba-
>tsip.com>; cip-dev@lists.cip-project.org
>Cc: dinesh kumar(TSIP TMIEC ODG Porting) <dinesh.kumar@toshiba-
>tsip.com>; hayashi kazuhiro(林 和宏 DME ○DIG□MPS○MP4)
><kazuhiro3.hayashi@toshiba.co.jp>
>Subject: Re: [cip-dev] [isar-cip-core v2 5/6] squashfs.bbclass: Fix file timestamps
>are not reproducible in squashfs image
>
>On 03.07.23 08:22, venkata.pyla@toshiba-tsip.com wrote:
>> From: venkata pyla <venkata.pyla@toshiba-tsip.com>
>>
>> The generated squashfs image contains non-reproducible file
>> timestamps, so set with value in SOURCE_DATE_EPOCH variable if it is set.
>>
>> Closes: #68
>>
>> Signed-off-by: venkata pyla <venkata.pyla@toshiba-tsip.com>
>> ---
>>  classes/squashfs.bbclass | 6 ++++++
>>  1 file changed, 6 insertions(+)
>>
>> diff --git a/classes/squashfs.bbclass b/classes/squashfs.bbclass index
>> b39be0c..469cdc5 100644
>> --- a/classes/squashfs.bbclass
>> +++ b/classes/squashfs.bbclass
>> @@ -31,6 +31,12 @@ SQUASHFS_MEMLIMIT ?= "${@int(get_free_mem() *
>3/4)}"
>>  SQUASHFS_CREATION_LIMITS = "-mem ${SQUASHFS_MEMLIMIT} -processors
>${SQUASHFS_THREADS}"
>>
>>  python __anonymous() {
>> +    # Set file timestamps for reproducible builds
>> +    source_date_epoch = d.getVar('SOURCE_DATE_EPOCH')
>> +    if source_date_epoch:
>> +       args = " -fstime {time}".format(time=source_date_epoch)
>> +    d.appendVar('SQUASHFS_CREATION_ARGS', args)
>
>Wrong indention of this line - args is undefined if source_date_epoch is None.

Thanks, the assignment should be inside the if loop, I will correct it in v3

>
>> +
>>      exclude_directories = d.getVar('SQUASHFS_EXCLUDE_DIRS').split()
>>      if len(exclude_directories) == 0:
>>          return
>
>Jan
>
>--
>Siemens AG, Technology
>Competence Center Embedded Linux
diff mbox series

Patch

diff --git a/classes/squashfs.bbclass b/classes/squashfs.bbclass
index b39be0c..469cdc5 100644
--- a/classes/squashfs.bbclass
+++ b/classes/squashfs.bbclass
@@ -31,6 +31,12 @@  SQUASHFS_MEMLIMIT ?= "${@int(get_free_mem() * 3/4)}"
 SQUASHFS_CREATION_LIMITS = "-mem ${SQUASHFS_MEMLIMIT} -processors ${SQUASHFS_THREADS}"
 
 python __anonymous() {
+    # Set file timestamps for reproducible builds
+    source_date_epoch = d.getVar('SOURCE_DATE_EPOCH')
+    if source_date_epoch:
+       args = " -fstime {time}".format(time=source_date_epoch)
+    d.appendVar('SQUASHFS_CREATION_ARGS', args)
+
     exclude_directories = d.getVar('SQUASHFS_EXCLUDE_DIRS').split()
     if len(exclude_directories) == 0:
         return