summaryrefslogtreecommitdiff
path: root/functions/bootloaders.sh
blob: a6883a67fa36b66e191a971013c6ec6e1d129c2f (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
#!/bin/sh

## live-build(7) - System Build Scripts
## Copyright (C) 2016-2020 The Debian Live team
## Copyright (C) 2016 Adrian Gibanel Lopez <adrian15sgd@gmail.com>
##
## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
## This is free software, and you are welcome to redistribute it
## under certain conditions; see COPYING for details.

Is_Requested_Bootloader ()
{
	local BOOTLOADER
	for BOOTLOADER in ${LB_BOOTLOADERS}; do
		if [ "${BOOTLOADER}" = "${1}" ]; then
			return 0
		fi
	done
	return 1
}

Is_First_Bootloader ()
{
	if [ "${LB_FIRST_BOOTLOADER}" != "${1}" ]; then
		return 1
	fi
	return 0
}

Is_Extra_Bootloader ()
{
	if Is_First_Bootloader "${1}"; then
		return 1
	fi
	if ! Is_Requested_Bootloader "${1}"; then
		return 1
	fi
	return 0
}

Check_Non_First_Bootloader ()
{
	if Is_First_Bootloader "${1}"; then
		Echo_error "Bootloader: \`${1}\` is not supported as a first bootloader."
		exit 1
	fi
}

Check_Non_Extra_Bootloader ()
{
	if Is_Extra_Bootloader "${1}"; then
		Echo_error "Bootloader: \`${1}\` is not supported as a extra bootloader."
		exit 1
	fi
}

Check_First_Bootloader_Role ()
{
	Check_Non_Extra_Bootloader "${1}"

	if ! Is_First_Bootloader "${1}"; then
		exit 0
	fi
}

Check_Extra_Bootloader_Role ()
{
	Check_Non_First_Bootloader "${1}"

	if ! Is_Extra_Bootloader "${1}"; then
		exit 0
	fi
}

Check_Any_Bootloader_Role ()
{
	if ! Is_Requested_Bootloader "${1}"; then
		exit 0
	fi
}