aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/rosa/toybox.go
blob: 7ced9c32e25af22919d107cfac897cd99db940ce (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
84
85
86
87
88
89
90
91
92
package rosa

import "hakurei.app/internal/pkg"

var (
	gzip = H("gzip")

	toyboxEarly = H("toybox-early")
)

func (t Toolchain) newToybox(suffix, script string) (pkg.Artifact, string) {
	const (
		version  = "0.8.13"
		checksum = "rZ1V1ATDte2WeQZanxLVoiRGdfPXhMlEo5-exX-e-ml8cGn9qOv0ABEUVZpX3wTI"
	)
	return t.NewPackage("toybox"+suffix, version, newTar(
		"https://landley.net/toybox/downloads/toybox-"+version+".tar.gz",
		checksum,
		pkg.TarGzip,
	), &PackageAttr{
		// uses source tree as scratch space
		Writable:    true,
		EnterSource: true,

		Flag: TEarly,
	}, &MakeHelper{
		OmitDefaults:  true,
		InPlace:       true,
		SkipConfigure: true,

		ScriptMakeEarly: `
LDFLAGS="${LDFLAGS:-''} -static"

chmod +w /bin/
ln -rs "$(which bash)" /bin/ || true

chmod +w kconfig tests
rm \
	tests/du.test \
	tests/sed.test \
	tests/tar.test \
	tests/ls.test \
	tests/taskset.test

make defconfig
sed -i \
	's/^CONFIG_TOYBOX_ZHELP=y$/CONFIG_TOYBOX_ZHELP=0/' \
	.config
` + script,
		SkipCheck: t.stage.isStage0(),
		Check: []string{
			"USER=cure",
			"tests",
		},
		Install: "PREFIX=/work/system/bin make install_flat",
		Script: `
mkdir -p /work/usr/bin
ln -s ../../system/bin/env /work/usr/bin
`,
	},
		_bash,
		gzip,

		_kernelHeaders,
	), version
}
func init() {
	native.mustRegister(func(t Toolchain) (pkg.Artifact, string) {
		return t.newToybox("", "")
	}, &Metadata{
		Name:        "toybox",
		Description: "many common Linux command line utilities",
		Website:     "https://landley.net/toybox/",

		ID: 13818,
	})

	native.mustRegister(func(t Toolchain) (pkg.Artifact, string) {
		return t.newToybox("-early", `
echo '
CONFIG_EXPR=y
CONFIG_TR=y
CONFIG_AWK=y
CONFIG_DIFF=y
' >> .config
`)
	}, &Metadata{
		Name:        "toybox-early",
		Description: "a build of toybox with unfinished tools enabled to break dependency loops",
		Website:     "https://landley.net/toybox/",
	})
}