aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/rosa/hakurei.go
blob: c5f364da23f38b305d9aedf37e8eeed48a2d71fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package rosa

import (
	"hakurei.app/internal/pkg"
)

func (t Toolchain) newHakurei() pkg.Artifact {
	const (
		version  = "0.3.3"
		checksum = "iMN9qzDB000noZ6dOHh_aSdrhRZPopjyWHd0KFVjxjQLQstAOvLYZEZ74btlL0pu"
	)
	return t.New("hakurei-"+version, false, []pkg.Artifact{
		t.Load(Go),
		t.Load(PkgConfig),

		t.Load(KernelHeaders),
		t.Load(Libseccomp),
		t.Load(ACL),
		t.Load(Attr),

		t.Load(Xproto),
		t.Load(LibXau),
		t.Load(XCBProto),
		t.Load(XCB),

		t.Load(Libffi),
		t.Load(Libexpat),
		t.Load(Libxml2),
		t.Load(Wayland),
		t.Load(WaylandProtocols),
	}, nil, []string{
		"GOCACHE=/tmp/gocache",
		"CC=clang -O3 -Werror",
	}, `
echo '# Building test helper (hostname).'
go build -v -o /bin/hostname /usr/src/hostname/main.go
echo

chmod -R +w /usr/src/hakurei
cd /usr/src/hakurei
mkdir -p /work/system/{bin,libexec/hakurei}

echo '# Building hakurei.'
go generate -v ./...
go build -trimpath -v -o /work/system/libexec/hakurei -ldflags="-s -w
	-buildid=
	-extldflags=-static
	-X hakurei.app/internal/info.buildVersion='v`+version+`'
	-X hakurei.app/internal/info.hakureiPath=/system/bin/hakurei
	-X hakurei.app/internal/info.hsuPath=/system/bin/hsu
	-X main.hakureiPath=/system/bin/hakurei" ./...
echo

echo '# Testing hakurei.'
go test -ldflags='-buildid= -extldflags=-static' ./...
echo

mv \
	/work/system/libexec/hakurei/{hakurei,hpkg} \
	/work/system/bin
`, pkg.Path(AbsUsrSrc.Append("hakurei"), true, pkg.NewHTTPGetTar(
		nil, "https://git.gensokyo.uk/security/hakurei/archive/"+
			"v"+version+".tar.gz",
		mustDecode(checksum),
		pkg.TarGzip,
	)), pkg.Path(AbsUsrSrc.Append("hostname", "main.go"), false, pkg.NewFile(
		"hostname.go",
		[]byte(`
package main

import "os"

func main() {
	if name, err := os.Hostname(); err != nil {
		panic(err)
	} else {
		os.Stdout.WriteString(name)
	}
}
`),
	)))
}
func init() { artifactsF[Hakurei] = Toolchain.newHakurei }