Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow reproducible builds #2

Closed
wants to merge 1 commit into from
Closed

Conversation

micmac1
Copy link

@micmac1 micmac1 commented Feb 13, 2022

siproxd sets the current time as BUILDDATE, but then it cannot be built
reproducibly.

This commit adds a configure arg that will forces BUILDDATE to
"unknown", allowing builds to be reproducible.

Default is no, so status quo remains unchanged.

Signed-off-by: Sebastian Kemper sebastian_ml@gmx.net

siproxd sets the current time as BUILDDATE, but then it cannot be built
reproducibly.

This commit adds a configure arg that will forces BUILDDATE to
"unknown", allowing builds to be reproducible.

Default is no, so status quo remains unchanged.

Signed-off-by: Sebastian Kemper <sebastian_ml@gmx.net>
@micmac1
Copy link
Author

micmac1 commented Feb 13, 2022

Hello!

We have an open issue at OpenWrt about siproxd not building reproducibly with the SDKs.

Kindly check this pull request if it's acceptable. Happy to make changes to it.

Thanks!
Seb

@micmac1
Copy link
Author

micmac1 commented Feb 13, 2022

Here's what it looks like when built with --enable-reproducible-build:

root@hank2:/tmp# siproxd -h
siproxd-0.8.3-3452
Build date: unknown
Plattform:  mips-openwrt-linux-gnu
(c) 2002-2016 Thomas Ries

Usage: siproxd [options]

options:
       -h, --help                 help
       -d, --debug <pattern>      set debug-pattern
       -c, --config <cfgfile>     use the specified config file
       -p, --pid-file <pidfile>   create pid file <pidfile>
root@hank2:/tmp#
root@hank2:/tmp# logread |grep siprox
Sun Feb 13 17:33:59 2022 daemon.notice siproxd[16388]: siproxd.c:245 INFO:siproxd-0.8.3-3452 unknown mips-openwrt-linux-gnu starting up
Sun Feb 13 17:33:59 2022 daemon.notice siproxd[16388]: rtpproxy_relay.c:121 INFO:Current thread stacksize is 128 kB
Sun Feb 13 17:33:59 2022 daemon.notice siproxd[16388]: sock.c:131 INFO:bound to port 5060
Sun Feb 13 17:33:59 2022 daemon.notice siproxd[16388]: siproxd.c:352 INFO:siproxd-0.8.3-3452 unknown mips-openwrt-linux-gnu started
Sun Feb 13 17:34:56 2022 daemon.notice siproxd[16388]: siproxd.c:677 INFO:properly terminating siproxd
root@hank2:/tmp#

@bmwiedemann
Copy link

bmwiedemann commented Feb 15, 2022

Filed https://sourceforge.net/p/siproxd/bugs/65/

I just made two alternate patches:

--- siproxd-0.8.3.orig/src/Makefile.am
+++ siproxd-0.8.3/src/Makefile.am
@@ -22,7 +22,7 @@
 AM_CFLAGS = -D_GNU_SOURCE $(LTDLDEF) \
             -Werror-implicit-function-declaration \
             -DBUILDSTR="\"`cat .buildno`\"" \
-            -DBUILDDATE="\"`date -u '+%Y-%m-%dT%H:%M:%S'`\""
+            -DBUILDDATE="\"`date -r ../ChangeLog -u '+%Y-%m-%dT%H:%M:%S'`\""
 #&&&INCLUDES = $(LTDLINCL)
 AM_CPPFLAGS = $(LTDLINCL)

and

--- siproxd-0.8.3.orig/src/Makefile.am
+++ siproxd-0.8.3/src/Makefile.am
@@ -22,7 +22,7 @@
 AM_CFLAGS = -D_GNU_SOURCE $(LTDLDEF) \
             -Werror-implicit-function-declaration \
             -DBUILDSTR="\"`cat .buildno`\"" \
-            -DBUILDDATE="\"`date -u '+%Y-%m-%dT%H:%M:%S'`\""
+            -DBUILDDATE="\"`date -d @$${SOURCE_DATE_EPOCH:-$$(date +%s)} -u '+%Y-%m-%dT%H:%M:%S'`\""
 #&&&INCLUDES = $(LTDLINCL)
 AM_CPPFLAGS = $(LTDLINCL)
 

this last one has the disadvantage that it only works with GNU date

But both have the advantage to be reproducible by default for people who want it and thus set SOURCE_DATE_EPOCH.

@micmac1
Copy link
Author

micmac1 commented Feb 15, 2022

Thanks! Nice idea taking the date from the Changelog!

I guess the Changelog idea would make the BUILDDATE a bit of a misnomer. But for OpenWrt purposes this would be fine.

You mentioned that the other patch would depend on GNU date. So I guess that's not very portable.

I could understand if you didn't want to incorporate any of this upstream, though. So in that case I'd likely take the "Changelog patch" and keep it locally in our repository.

Let me know what you want to do. I'll just follow your lead.

Kind regards,
Seb

@hb9xar
Copy link
Owner

hb9xar commented Feb 17, 2022

I actually like the first version (using "unknown" datestring for reproducible builds). In addition, it might make sense to also eliminate/ignore the BUILDSTR (build number from .buildno file) when doing reproducible builds.
I'll look into it and make the required changes.

best regards,
/Thomas

@micmac1
Copy link
Author

micmac1 commented Feb 17, 2022 via email

@hb9xar
Copy link
Owner

hb9xar commented Feb 17, 2022

Using "unknown" does clearly indicate that the build date has been omitted on purpose. If using the Changelog file date, it is not visible if the BULDDATE does actually contain the real build date, or some estimated/guessed date string that is not related to the time of build at all.

@hb9xar
Copy link
Owner

hb9xar commented Feb 18, 2022

Please check f47a3e0
It does set static values for reproducible builds:
BUILDDATE="unknown"
BUILDSTR="none"

@hb9xar
Copy link
Owner

hb9xar commented Feb 18, 2022

check also 4750bea, implements support for SOURCE_DATE_EPOCH
(https://reproducible-builds.org/specs/source-date-epoch/)

@micmac1
Copy link
Author

micmac1 commented Feb 19, 2022

Hello Tom,

both commits work fine, siproxd builds are reproducible.

Do you want to leave it like this? Then it'd just add the two commits as patches to our package.

Thanks!
Seb

@hb9xar
Copy link
Owner

hb9xar commented Feb 19, 2022

Hello Seb,
yes, these 2 commits will make it into the next release.

Regards,
/Thomas

@micmac1
Copy link
Author

micmac1 commented Feb 20, 2022

Thanks for this! Will update OpenWrt package accordingly.

@micmac1 micmac1 closed this Feb 20, 2022
@micmac1 micmac1 deleted the repro-build branch February 20, 2022 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants