docs: add more info

Signed-off-by: James Elliott <james-d-elliott@users.noreply.github.com>
pull/5232/head
James Elliott 2023-05-01 20:08:35 +10:00
parent 9f136efe6d
commit b585dfa57c
No known key found for this signature in database
GPG Key ID: 0F1C4A096E857E49
3 changed files with 39 additions and 9 deletions

View File

@ -2,6 +2,7 @@ package cmd
import ( import (
"fmt" "fmt"
"io"
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
@ -240,12 +241,41 @@ func buildCmdPrint(cmd *exec.Cmd) {
b.WriteString(fmt.Sprintf("cd %s\n", cmd.Dir)) b.WriteString(fmt.Sprintf("cd %s\n", cmd.Dir))
} }
if len(cmd.Env) != 0 { buildCmdWriteCmd(b, cmd)
b.WriteString(strings.Join(cmd.Env, " "))
b.WriteString(" ")
}
b.WriteString(cmd.String())
fmt.Println(b.String()) fmt.Println(b.String())
} }
func buildCmdWriteCmd(wr io.StringWriter, cmd *exec.Cmd) {
buildCmdWriteEnv(wr, cmd)
_, _ = wr.WriteString(cmd.Path)
for _, arg := range cmd.Args[1:] {
_, _ = wr.WriteString(" ")
if strings.Contains(arg, " ") {
_, _ = wr.WriteString(fmt.Sprintf(`"%s"`, arg))
} else {
_, _ = wr.WriteString(arg)
}
}
}
func buildCmdWriteEnv(wr io.StringWriter, cmd *exec.Cmd) {
n := len(cmd.Env)
if n == 0 {
return
}
envs := make([]string, n)
for i, env := range cmd.Env {
parts := strings.SplitN(env, "=", 2)
envs[i] = fmt.Sprintf(`%s="%s"`, parts[0], parts[1])
}
_, _ = wr.WriteString(strings.Join(envs, " "))
_, _ = wr.WriteString(" ")
}

View File

@ -144,8 +144,8 @@ go build -ldflags "-linkmode=external -s -w" -trimpath -buildmode=pie -o autheli
*__Please Note:__ The reproducibility instructions only apply for v4.38.0 or above. Users interested in reproducibility *__Please Note:__ The reproducibility instructions only apply for v4.38.0 or above. Users interested in reproducibility
of previous versions will have to carefully modify the linker flags to match the values outputted from the of previous versions will have to carefully modify the linker flags to match the values outputted from the
`authelia build-info` command. In particular the Build Date was set as the actual time previously rather than the `authelia build-info` command. In particular the Build Date was set as the actual time previously rather than the
commit time. If you have trouble reproducing a build please let us know so we can figure it out, assist you, and commit time. In addition to this the ability to print the commands did not exist until just before this tag. If you have
document it.* trouble reproducing a build please let us know so we can figure it out, assist you, and document it.*
Authelia allows production of reproducible builds that were built using our pipeline. The only variables injected into Authelia allows production of reproducible builds that were built using our pipeline. The only variables injected into
a build are from commit information other than the exceptions listed in this section. This means that we can provide the a build are from commit information other than the exceptions listed in this section. This means that we can provide the

View File

@ -51,7 +51,7 @@ func (s *CLISuite) TestShouldPrintBuildInformation() {
output, err := s.Exec("authelia-backend", []string{"authelia", "build-info"}) output, err := s.Exec("authelia-backend", []string{"authelia", "build-info"})
s.Assert().NoError(err) s.Assert().NoError(err)
r := regexp.MustCompile(`^Last Tag: v\d+\.\d+\.\d+\nState: (tagged|untagged) (clean|dirty)\nBranch: [^\s\n]+\nCommit: [0-9a-f]{40}\nCommit Date: (Sun|Mon|Tue|Wed|Thu|Fri|Sat), \d{2} (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} \d{2}:\d{2}:\d{2} \+0000\nBuild Number: \d+\nBuild OS: (linux|darwin|windows|freebsd)\nBuild Arch: (amd64|arm|arm64)\nBuild Go Version: go\d+\.\d+(\.\d+)?\nExtra:`) r := regexp.MustCompile(`^Last Tag: v\d+\.\d+\.\d+\nState: (tagged|untagged) (clean|dirty)\nBranch: [^\s\n]+\nCommit: [0-9a-f]{40}\nCommit Date: (Sun|Mon|Tue|Wed|Thu|Fri|Sat), \d{2} (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} \d{2}:\d{2}:\d{2} UTC\nBuild Number: \d+\nBuild OS: (linux|darwin|windows|freebsd)\nBuild Arch: (amd64|arm|arm64)\nBuild Go Version: go\d+\.\d+(\.\d+)?\nExtra:`)
s.Assert().Regexp(r, output) s.Assert().Regexp(r, output)
} }