Skip to content

feat: ✨ try openbsd #200

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

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ var viewFlag = []cli.Flag{
},
&cli.StringSliceFlag{
Name: "time-type",
Usage: "time type, mod(default), create, access, all, birth[macOS only]",
Usage: "time type, mod(default), create, access, all, birth[macOS/openbsd/freebsd]",
EnvVars: []string{"TIME_TYPE"},
Action: func(context *cli.Context, ss []string) error {
timeType = make([]string, 0, len(ss))
Expand Down Expand Up @@ -113,7 +113,7 @@ var viewFlag = []cli.Flag{
},
&cli.BoolFlag{
Name: "birth",
Usage: "birth time[macOS only]",
Usage: "birth time[macOS/openbsd/freebsd]",
DisableDefaultText: true,
Action: func(context *cli.Context, b bool) error {
if b {
Expand Down
2 changes: 1 addition & 1 deletion cached/cachedmaps.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build linux || darwin
//go:build unix

package cached

Expand Down
43 changes: 37 additions & 6 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,46 @@
latest := `git describe --abbrev=0 --tags | sed 's/v//'`
ldflags := "-ldflags='-s -w'"

# build binaries for all platforms
build:
# build the binary in build/
# Linux macOS Windows
# 386 amd64 arm arm64
mkdir -p build
linux:
CGO_ENABLED=0 GOOS=linux GOARCH=386 go build {{ldflags}} -o build/g-linux-386
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build {{ldflags}} -o build/g-linux-amd64
CGO_ENABLED=0 GOOS=linux GOARCH=arm go build {{ldflags}} -o build/g-linux-arm
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build {{ldflags}} -o build/g-linux-arm64

darwin:
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build {{ldflags}} -o build/g-darwin-amd64
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build {{ldflags}} -o build/g-darwin-arm64

freebsd:
CGO_ENABLED=0 GOOS=freebsd GOARCH=386 go build {{ldflags}} -o build/g-freebsd-386
CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build {{ldflags}} -o build/g-freebsd-amd64
CGO_ENABLED=0 GOOS=freebsd GOARCH=arm go build {{ldflags}} -o build/g-freebsd-arm
CGO_ENABLED=0 GOOS=freebsd GOARCH=arm64 go build {{ldflags}} -o build/g-freebsd-arm64

openbsd:
CGO_ENABLED=0 GOOS=openbsd GOARCH=386 go build {{ldflags}} -o build/g-openbsd-386
CGO_ENABLED=0 GOOS=openbsd GOARCH=amd64 go build {{ldflags}} -o build/g-openbsd-amd64
CGO_ENABLED=0 GOOS=openbsd GOARCH=arm go build {{ldflags}} -o build/g-openbsd-arm
CGO_ENABLED=0 GOOS=openbsd GOARCH=arm64 go build {{ldflags}} -o build/g-openbsd-arm64

windows:
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build {{ldflags}} -o build/g-windows-amd64.exe
CGO_ENABLED=0 GOOS=windows GOARCH=386 go build {{ldflags}} -o build/g-windows-386.exe
CGO_ENABLED=0 GOOS=windows GOARCH=arm64 go build {{ldflags}} -o build/g-windows-arm64.exe
CGO_ENABLED=0 GOOS=windows GOARCH=arm go build {{ldflags}} -o build/g-windows-arm.exe

# build binaries for all platforms
build:
# build the binary in build/
# Linux macOS Windows
# 386 amd64 arm arm64
mkdir -p build
just linux
just darwin
just freebsd
just openbsd
just windows

upx build/g-linux-386
upx build/g-linux-amd64
upx build/g-linux-arm
Expand All @@ -40,6 +61,16 @@ compress:
tar -zcvf build/g-Darwin-amd64.tar.gz build/g-darwin-amd64
tar -zcvf build/g-Darwin-arm64.tar.gz build/g-darwin-arm64

tar -zcvf build/g-FreeBSD-386.tar.gz build/g-freebsd-386
tar -zcvf build/g-FreeBSD-amd64.tar.gz build/g-freebsd-amd64
tar -zcvf build/g-FreeBSD-arm.tar.gz build/g-freebsd-arm
tar -zcvf build/g-FreeBSD-arm64.tar.gz build/g-freebsd-arm64

tar -zcvf build/g-OpenBSD-386.tar.gz build/g-openbsd-386
tar -zcvf build/g-OpenBSD-amd64.tar.gz build/g-openbsd-amd64
tar -zcvf build/g-OpenBSD-arm.tar.gz build/g-openbsd-arm
tar -zcvf build/g-OpenBSD-arm64.tar.gz build/g-openbsd-arm64

zip -r build/g-Windows-amd64.zip build/g-windows-amd64.exe
zip -r build/g-Windows-386.zip build/g-windows-386.exe
zip -r build/g-Windows-arm64.zip build/g-windows-arm64.exe
Expand Down
34 changes: 0 additions & 34 deletions osbased/filedetail_darwin.go

This file was deleted.

2 changes: 1 addition & 1 deletion osbased/filedetail_linux.go → osbased/filedetail_unix.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build linux
//go:build unix

package osbased

Expand Down
28 changes: 28 additions & 0 deletions osbased/time_freebsd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//go:build freebsd

package osbased

import (
"os"
"syscall"
"time"
)

func ModTime(a os.FileInfo) time.Time {
return a.ModTime()
}

func AccessTime(a os.FileInfo) time.Time {
atim := a.Sys().(*syscall.Stat_t).Atimespec
return time.Unix(int64(atim.Sec), int64(atim.Nsec))
}

func CreateTime(a os.FileInfo) time.Time {
ctim := a.Sys().(*syscall.Stat_t).Ctimespec
return time.Unix(int64(ctim.Sec), int64(ctim.Nsec))
}

func BirthTime(a os.FileInfo) time.Time {
btim := a.Sys().(*syscall.Stat_t).Birthtimespec
return time.Unix(int64(btim.Sec), int64(btim.Nsec))
}
2 changes: 1 addition & 1 deletion osbased/time_linux_32.go → osbased/time_linux.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build (arm || 386) && linux
//go:build linux

package osbased

Expand Down
9 changes: 5 additions & 4 deletions osbased/time_linux_64.go → osbased/time_openbsd.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build (amd64 || arm64) && linux
//go:build openbsd

package osbased

Expand All @@ -14,14 +14,15 @@ func ModTime(a os.FileInfo) time.Time {

func AccessTime(a os.FileInfo) time.Time {
atim := a.Sys().(*syscall.Stat_t).Atim
return time.Unix(atim.Sec, atim.Nsec)
return time.Unix(int64(atim.Sec), int64(atim.Nsec))
}

func CreateTime(a os.FileInfo) time.Time {
ctim := a.Sys().(*syscall.Stat_t).Ctim
return time.Unix(ctim.Sec, ctim.Nsec)
return time.Unix(int64(ctim.Sec), int64(ctim.Nsec))
}

func BirthTime(a os.FileInfo) time.Time {
return CreateTime(a)
btim := a.Sys().(*syscall.Stat_t).X__st_birthtim
return time.Unix(int64(btim.Sec), int64(btim.Nsec))
}
27 changes: 0 additions & 27 deletions osbased/usergroup_darwin.go

This file was deleted.

2 changes: 2 additions & 0 deletions osbased/usergroup_linux.go → osbased/usergroup_unix.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build unix

package osbased

import (
Expand Down