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

[Feature] Remove timestamp from header to make script builds reproducible #672

Open
Thesola10 opened this issue Feb 7, 2025 · 5 comments
Labels
enhancement New feature or request

Comments

@Thesola10
Copy link

Thesola10 commented Feb 7, 2025

Is your feature request related to a problem? Please describe.
Currently, as a default, Amber adds a comment that looks like this to the top of a compiled file:

#!/usr/bin/env bash
# Written in [Amber](https://amber-lang.com/)
# version: 0.4.0-alpha
# date: 2025-02-07 15:51:45

The outstanding issue here is the date entry, which specifies when the script has been built, down to the second. Fundamentally, this breaks reproducible builds -- i.e. the guarantee that you will get the exact same output given the exact same input.

Describe the solution you'd like
To aid in reproducibility efforts ongoing on several Linux distributions, it would be nice to have an option to disable adding a timestamp to built scripts.

This could be an environment variable, such as AMBER_NO_TIMESTAMP.

Describe alternatives you've considered
Wrapping the compiler in a program that simulates a zero timestamp would be too cumbersome, and introduce fragility into an otherwise simple build process.

Post-processing the script to remove the date field would be even more fragile.

@Thesola10 Thesola10 added the enhancement New feature or request label Feb 7, 2025
@github-project-automation github-project-automation bot moved this to 🆕 New in Amber Project Feb 7, 2025
@Thesola10 Thesola10 changed the title [Feature] [Feature] Remove timestamp from header to make script builds reproducible Feb 7, 2025
@Mte90
Copy link
Member

Mte90 commented Feb 7, 2025

if I am not wrong we added a way to customize the header in the script but I don't remember right now.

@Thesola10
Copy link
Author

It was discussed in #344 but right now it looks to me like header generation is hardcoded:

amber/src/compiler.rs

Lines 199 to 203 in d3ceda3

let now = Local::now().format("%Y-%m-%d %H:%M:%S").to_string();
let header = include_str!("header.sh")
.replace("{{ version }}", env!("CARGO_PKG_VERSION"))
.replace("{{ date }}", now.as_str());
Ok(format!("{}{}", header, result))

@b1ek
Copy link
Member

b1ek commented Feb 10, 2025

i wouldn't change the current header, but rather add an option to use a custom template for the header. probably add some more variables that could be used. im pretty sure that's been discussed before and honestly shouldn't be very hard to implement

@Mte90
Copy link
Member

Mte90 commented Feb 18, 2025

I think that:

  • AMBER_HEADER = "path to header.sh"

Can be the best option, if that variable is not set use the default one. In this way we can improve it without adding too many parameters in the code and the user can do whatevery he wants.

I think too that isn't very difficult to implement.
Also can be used to inject BASH code if the user need it, like to import stuff.

@Mte90
Copy link
Member

Mte90 commented Feb 18, 2025

I want to add also #635 so we can do both in a single PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants