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

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

var _earlyInit = H("earlyinit")

func init() {
	meta := Metadata{
		Name:        "earlyinit",
		Description: "Rosa OS initramfs init program",
		Version:     Unversioned,
	}
	native.MustRegister(meta.Name, func(t Toolchain) (*Metadata, pkg.Artifact) {
		return &meta, t.newHakurei("-early-init", `
mkdir -p /work/system/libexec/hakurei/

echo '# Building earlyinit.'
go build -trimpath -v -o /work/system/libexec/hakurei -ldflags="-s -w
	-buildid=
	-linkmode external
	-extldflags=-static
	-X hakurei.app/internal/info.buildVersion=${HAKUREI_VERSION}
" ./cmd/earlyinit
echo
`, "", "", false)
	})
}

func init() {
	meta := Metadata{
		Name:        "system-image",
		Description: "Rosa OS system image",
		Version:     Unversioned,
	}
	native.MustRegister(meta.Name, func(t Toolchain) (*Metadata, pkg.Artifact) {
		return &meta, t.New("system.img", TNoToolchain, t.Append(nil,
			H("squashfs-tools"),
		), nil, nil, `
mksquashfs /mnt/system /work/system.img
`, pkg.Path(fhs.AbsRoot.Append("mnt"), false, t.Append(nil,
			_musl,
			Mksh,
			Toybox,

			H("kmod"),
			H("kernel"),
			H("firmware"),
		)...))
	})
}

func init() {
	meta := Metadata{
		Name:        "initramfs-image",
		Description: "Rosa OS initramfs image",
		Version:     Unversioned,
	}
	native.MustRegister(meta.Name, func(t Toolchain) (*Metadata, pkg.Artifact) {
		return &meta, t.New("initramfs", TNoToolchain, t.Append(nil,
			_zstd,
			_earlyInit,
			H("gen_init_cpio"),
		), nil, nil, `
gen_init_cpio -t 4294967295 -c /usr/src/initramfs | zstd > /work/initramfs.zst
`, pkg.Path(AbsUsrSrc.Append("initramfs"), false, pkg.NewFile("initramfs", []byte(`
dir /dev 0755 0 0
nod /dev/null 0666 0 0 c 1 3
nod /dev/console 0600 0 0 c 5 1
file /init /system/libexec/hakurei/earlyinit 0555 0 0
`))))
	})
}