rfjakob / gocryptfs

Encrypted overlay filesystem written in Go

Home Page:https://nuetzlich.net/gocryptfs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The second call to date in build.bash fails on Mac OS

GaelC92 opened this issue · comments

the date binary of Os X is not fully compliant with gnu date, and build fails.
as quick fix, one can install gdate with brew install coreutils, and patch the build.bash formula with brew edit.

here is my full formula for those willing to try the 2.0b4

class Gocryptfs < Formula
desc "Encrypted overlay filesystem written in Go"
homepage "https://nuetzlich.net/gocryptfs/"
url "https://github.com/rfjakob/gocryptfs/releases/download/v2.0-beta4/gocryptfs_v2.0-beta4_src-deps.tar.gz"
sha256 "d28c6b6a749e9f66745bd9a595b853b1ffde7ca3b2e82e0a41e9b3c40e7ebddd"
license "MIT"

depends_on "go" => :build
depends_on "pkg-config" => :build
depends_on "openssl@1.1"

on_macos do
end

on_linux do
depends_on "libfuse"
end

def install
inreplace "./build.bash",
"date ",
"/usr/local/bin/gdate "

ENV["GOPATH"] = buildpath
(buildpath/"src/github.com/rfjakob/gocryptfs").install buildpath.children
cd "src/github.com/rfjakob/gocryptfs" do
  system "./build.bash"
  bin.install "gocryptfs"
  prefix.install_metafiles
end

end

test do
(testpath/"encdir").mkpath
pipe_output("#{bin}/gocryptfs -init #{testpath}/encdir", "password", 0)
assert_predicate testpath/"encdir/gocryptfs.conf", :exist?
end
end

I see two date calls in build.bash:

1:

date +%Y-%m-%d

2:

date --utc --date="@${SOURCE_DATE_EPOCH}" +%Y-%m-%d

Number (2) fails? Could you show the error? Also, (2) should only be called if SOURCE_DATE_EPOCH is set.

(2) is definitely GNU-only -- Apple's BSD date doesn't have a --date= at all. BTW, you could replace those with bash builtins if you have a guarantee of bash 4.3 or later (but that won't be available out-of-the-box on MacOS, where the default is 3.2; OTOH, if we're being built by MacPorts, it can certainly provide a newer one).

Aforementioned builtins:

printf '%(%Y-%m-%d)T' -1

TZ=UTC printf '%(%Y-%m-%d)T' "$SOURCE_DATE_EPOCH"

I confirm that the second line is the culprit. The first is ok.

date --utc --date="@${SOURCE_DATE_EPOCH}" +%Y-%m-%d
date: illegal option -- -
usage: date [-jnRu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ...
[-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]

Ok, but, who sets $SOURCE_DATE_EPOCH ?

I have no clue :) – it is definitely not me, so probably somewhere in the build process.

yes. it might be set by cmake.

Hello @rfjakob ,

I was able to build it successfully from the source :

./gocryptfs -version
gocryptfs [unknown]; go-fuse v2.1.1-0.20210825171523-3ab5d95a30ae; 2021-09-26 go1.17.1 darwin/amd64

Thanks for testing! Merged to master.