mirror of
https://github.com/siderolabs/talos.git
synced 2025-10-28 06:51:34 +01:00
Use `Progress`, and options to pass around the way messages are written. Fixed some tiny issues in the code, but otherwise no functional changes. To make colored output work with `docker run`, switched back image generation to use volume mount for output (old mode is still functioning, but it's not the default, and it works when docker is not running on the same host). Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
37 lines
799 B
Go
37 lines
799 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 utils
|
|
|
|
import (
|
|
"io/fs"
|
|
"os"
|
|
"path/filepath"
|
|
"time"
|
|
)
|
|
|
|
// TouchFiles updates mtime for all the files under root if SOURCE_DATE_EPOCH is set.
|
|
func TouchFiles(printf func(string, ...any), root string) error {
|
|
epochInt, ok, err := SourceDateEpoch()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if !ok {
|
|
return nil
|
|
}
|
|
|
|
timestamp := time.Unix(epochInt, 0)
|
|
|
|
printf("changing timestamps under %q to %s", root, timestamp)
|
|
|
|
return filepath.WalkDir(root, func(path string, d fs.DirEntry, err error) error {
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return os.Chtimes(path, timestamp, timestamp)
|
|
})
|
|
}
|