talos/cmd/installer/pkg/epoch.go
Andrey Smirnov faecae44fd feat: make ISO builds reproducible
This relies on changes in GRUB and other utilities to respect
`SOURCE_DATE_EPOCH`.

Variable `SOURCE_DATE_EPOCH` is set to the timestamp of the last git
commit which makes it deterministic, but still changes for each
release/commit.

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
2021-08-11 09:20:07 -07:00

26 lines
562 B
Go

// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
package pkg
import (
"os"
"strconv"
)
// SourceDateEpoch returns parsed value of SOURCE_DATE_EPOCH.
func SourceDateEpoch() (int64, bool, error) {
epoch, ok := os.LookupEnv("SOURCE_DATE_EPOCH")
if !ok {
return 0, false, nil
}
epochInt, err := strconv.ParseInt(epoch, 10, 64)
if err != nil {
return 0, false, err
}
return epochInt, true, nil
}