Skip to content

Commit

Permalink
Fixes bug where go-slug would not build on 32 bit linux
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonc committed Nov 9, 2023
1 parent eb823de commit d3c0d14
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
28 changes: 28 additions & 0 deletions internal/unpackinfo/lchtimes_linux32.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//go:build (linux && amd) || (linux && arm)
// +build linux,amd linux,arm

package unpackinfo

import (
"golang.org/x/sys/unix"
)

// Lchtimes modifies the access and modified timestamps on a target path
// This capability is only available on Linux and Darwin as of now.
func (i UnpackInfo) Lchtimes() error {
return unix.Lutimes(i.Path, []unix.Timeval{
{Sec: i.OriginalAccessTime.Unix(), Usec: int32(i.OriginalAccessTime.Nanosecond() / 1e6 % 1e6)},
{Sec: i.OriginalModTime.Unix(), Usec: int32(i.OriginalModTime.Nanosecond() / 1e6 % 1e6)}},
)
}

// CanMaintainSymlinkTimestamps determines whether is is possible to change
// timestamps on symlinks for the the current platform. For regular files
// and directories, attempts are made to restore permissions and timestamps
// after extraction. But for symbolic links, go's cross-platform
// packages (Chmod and Chtimes) are not capable of changing symlink info
// because those methods follow the symlinks. However, a platform-dependent option
// is provided for linux and darwin (see Lchtimes)
func CanMaintainSymlinkTimestamps() bool {
return true
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build linux
// +build linux
//go:build (linux && amd64) || (linux && arm64)
// +build linux,amd64 linux,arm64

package unpackinfo

Expand Down
4 changes: 2 additions & 2 deletions internal/unpackinfo/lchtimes_others.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build !(linux || darwin)
// +build !linux,!darwin
//go:build !darwin || (linux && !amd64) || (linux && !arm64) || (linux && !amd) || (linux && !arm)
// +build !darwin linux,!amd64 linux,!arm64 linux,!amd linux,!arm

package unpackinfo

Expand Down

0 comments on commit d3c0d14

Please sign in to comment.