summaryrefslogtreecommitdiff
path: root/meta-phosphor/recipes-phosphor/initrdscripts/phosphor-static-norootfs-init.bb
blob: fd7a9bf190032e44e452c19fc9d396e20aa6e019 (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
SUMMARY = "Phosphor OpenBMC pre-init scripts for static-norootfs layout"
DESCRIPTION = "Phosphor OpenBMC filesystem mount implementation for static-norootfs"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
PR = "r1"

SOURCE_FILES = "\
    init \
    10-early-mounts \
    20-udev \
    21-factory-reset \
    30-ubiattach-or-format \
    50-mount-persistent \
    "
SRC_URI += "\
    ${@' '.join(\
        [ 'file://' + x for x in d.getVar('SOURCE_FILES', True).split()])} \
    "

S = "${WORKDIR}"

NOROOTFS_PERSISTENT_DIRS = "\
    var \
    etc \
    home \
    ${@ bb.utils.contains('ROOT_HOME', '/home/root', '', d.getVar('ROOT_HOME')[1:], d)} \
    "

inherit allarch
inherit update-alternatives

PKG_INSTALL_DIR="${libexecdir}/${BPN}"
FILES:${PN} += "${PKG_INSTALL_DIR}"

do_install() {
    install -d ${D}${PKG_INSTALL_DIR}

    for f in ${SOURCE_FILES} ; do
        install -m 0755 ${S}/$f ${D}${PKG_INSTALL_DIR}/$f
    done

    # Create persistent mount points and add to mount script.
    for mountpoint in ${NOROOTFS_PERSISTENT_DIRS} ; do
        mkdir -p ${D}/$mountpoint
        touch ${D}/$mountpoint/.keep.mount-persistent
    done
    sed -i "s#@NOROOTFS_PERSISTENT_DIRS@#${NOROOTFS_PERSISTENT_DIRS}#" \
        ${D}${PKG_INSTALL_DIR}/50-mount-persistent
}

RDEPENDS:${PN} += " \
    ${@d.getVar('PREFERRED_PROVIDER_u-boot-fw-utils', True) or \
        'u-boot-fw-utils'} \
    ${VIRTUAL-RUNTIME_base-utils} \
    mtd-utils-ubifs \
    udev \
"

FILES:${PN}:append = " ${@ " ".join([ '/' + x + '/.keep.mount-persistent' for x in d.getVar('NOROOTFS_PERSISTENT_DIRS').split() ])}"

ALTERNATIVE_LINK_NAME[init] = "${base_sbindir}/init"
# Use a number higher than the systemd init alternative so that
# ours is enabled instead.
ALTERNATIVE_PRIORITY[init] ?= "400"

ALTERNATIVE:${PN} = "init"
ALTERNATIVE_TARGET[init] = "${PKG_INSTALL_DIR}/init"