package rosa

import "hakurei.app/internal/pkg"

func (t Toolchain) newMksh() (pkg.Artifact, string) {
	const (
		version  = "59c"
		checksum = "0Zj-k4nXEu3IuJY4lvwD2OrC2t27GdZj8SPy4DoaeuBRH1padWb7oREpYgwY8JNq"
	)
	scriptTest := "./test.sh -C regress:no-ctty\n"
	if presetOpts&OptSkipCheck != 0 {
		scriptTest = ""
	}
	return t.New("mksh-"+version, 0, t.AppendPresets(nil,
		Perl,
		Coreutils,
	), nil, []string{
		"LDSTATIC=-static",
		"CPPFLAGS=-DMKSH_DEFAULT_PROFILEDIR=\\\"/system/etc\\\"",
	}, `
cd "$(mktemp -d)"
sh /usr/src/mksh/Build.sh -r
CPPFLAGS="${CPPFLAGS} -DMKSH_BINSHPOSIX -DMKSH_BINSHREDUCED" \
sh /usr/src/mksh/Build.sh -r -L
`+scriptTest+`
mkdir -p /work/system/bin/
cp -v mksh /work/system/bin/
cp -v lksh /work/system/bin/sh

mkdir -p /work/bin/
ln -vs ../system/bin/sh /work/bin/
`, pkg.Path(AbsUsrSrc.Append("mksh"), false, newTar(
		"https://mbsd.evolvis.org/MirOS/dist/mir/mksh/mksh-R"+version+".tgz",
		checksum,
		pkg.TarGzip,
	))), version
}
func init() {
	artifactsM[Mksh] = Metadata{
		f: Toolchain.newMksh,

		Name:        "mksh",
		Description: "MirBSD Korn Shell",
		Website:     "https://www.mirbsd.org/mksh",

		ID: 5590,
	}
}
