aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/rosa/toybox.go
blob: d5e1238002c90c5ac4e3bb10b3fa7b5ecaf584cd (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
package rosa

import "hakurei.app/internal/pkg"

func (s *S) newToybox(t Toolchain, suffix, script string) (pkg.Artifact, string) {
	const (
		version  = "0.8.13"
		checksum = "rZ1V1ATDte2WeQZanxLVoiRGdfPXhMlEo5-exX-e-ml8cGn9qOv0ABEUVZpX3wTI"
	)
	return s.NewPackage(t, "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.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(&Artifact{
		f: func(t Toolchain, s *S) (pkg.Artifact, string) {
			return s.newToybox(t, "", "")
		},

		Name:        "toybox",
		Description: "many common Linux command line utilities",
		Website:     "https://landley.net/toybox/",

		ID: 13818,
	})

	native.MustRegister(&Artifact{
		f: func(t Toolchain, s *S) (pkg.Artifact, string) {
			return s.newToybox(t, "-early", `
echo '
CONFIG_EXPR=y
CONFIG_TR=y
CONFIG_AWK=y
CONFIG_DIFF=y
' >> .config
`)
		},

		Name:        "toybox-early",
		Description: "a build of toybox with unfinished tools enabled to break dependency loops",
		Website:     "https://landley.net/toybox/",
	})
}