xref: /openbmc/openbmc/poky/meta/recipes-core/base-files/base-files_3.0.14.bb (revision c9537f57ab488bf5d90132917b0184e2527970a5)
1SUMMARY = "Miscellaneous files for the base system"
2DESCRIPTION = "The base-files package creates the basic system directory structure and provides a small set of key configuration files for the system."
3SECTION = "base"
4LICENSE = "GPL-2.0-only"
5LIC_FILES_CHKSUM = "file://licenses/GPL-2;md5=94d55d512a9ba36caa9b7df079bae19f"
6# Removed all license related tasks in this recipe as license.bbclass
7# now deals with this. In order to get accurate licensing on to the image:
8# Set COPY_LIC_MANIFEST to just copy just the license.manifest to the image
9# For the manifest and the license text for each package:
10# Set COPY_LIC_MANIFEST and COPY_LIC_DIRS
11
12SRC_URI = "file://rotation \
13           file://nsswitch.conf \
14           file://nsswitch-resolved.conf \
15           file://motd \
16           file://hosts \
17           file://host.conf \
18           file://profile \
19           file://shells \
20           file://fstab \
21           file://issue.net \
22           file://issue \
23           file://share/dot.bashrc \
24           file://share/dot.profile \
25           file://licenses/GPL-2 \
26           "
27
28S = "${WORKDIR}/sources"
29UNPACKDIR = "${S}"
30
31INHIBIT_DEFAULT_DEPS = "1"
32
33docdir:append = "/${P}"
34dirs1777 = "/tmp ${localstatedir}/${@bb.utils.contains('FILESYSTEM_PERMS_TABLES', 'files/fs-perms-volatile-tmp.txt', 'volatile/', '', d)}tmp"
35dirs2775 = ""
36dirs555 = "/sys /proc"
37dirs755 = "/boot /dev ${base_bindir} ${base_sbindir} ${base_libdir} \
38           ${sysconfdir} ${sysconfdir}/default \
39           ${sysconfdir}/skel ${nonarch_base_libdir} /mnt ${ROOT_HOME} /run \
40           ${prefix} ${bindir} ${docdir} /usr/games ${includedir} \
41           ${libdir} ${sbindir} ${datadir} \
42           ${datadir}/common-licenses ${datadir}/dict ${infodir} \
43           ${mandir} ${datadir}/misc ${localstatedir} \
44           ${localstatedir}/backups ${localstatedir}/lib \
45           ${localstatedir}/lib/misc ${localstatedir}/spool \
46           ${localstatedir}/volatile \
47           ${localstatedir}/${@bb.utils.contains('FILESYSTEM_PERMS_TABLES', 'files/fs-perms-volatile-log.txt', 'volatile/', '', d)}log \
48           /home ${prefix}/src ${localstatedir}/local \
49           /media"
50
51dirs755-lsb = "/srv  \
52               ${prefix}/local ${prefix}/local/bin ${prefix}/local/games \
53               ${prefix}/local/include ${prefix}/local/lib ${prefix}/local/sbin \
54               ${prefix}/local/share ${prefix}/local/src \
55               ${prefix}/lib/locale"
56dirs2775-lsb = "/var/mail"
57
58volatiles = "${@bb.utils.contains('FILESYSTEM_PERMS_TABLES', 'files/fs-perms-volatile-log.txt', 'log', '', d)} \
59             ${@bb.utils.contains('FILESYSTEM_PERMS_TABLES', 'files/fs-perms-volatile-tmp.txt', 'tmp', '', d)}"
60conffiles = "${sysconfdir}/debian_version ${sysconfdir}/host.conf \
61             ${sysconfdir}/issue /${sysconfdir}/issue.net \
62             ${sysconfdir}/nsswitch.conf ${sysconfdir}/profile \
63             ${sysconfdir}/default"
64
65# By default the hostname is the machine name. If the hostname is unset then a
66# /etc/hostname file isn't written, suitable for environments with dynamic
67# hostnames.
68#
69# The hostname can be changed outside of this recipe by using
70# hostname:pn-base-files = "my-host-name".
71hostname = "${MACHINE}"
72
73BASEFILESISSUEINSTALL ?= "do_install_basefilesissue"
74
75do_install () {
76	for d in ${dirs555}; do
77		install -m 0555 -d ${D}$d
78	done
79	for d in ${dirs755}; do
80		install -m 0755 -d ${D}$d
81	done
82	for d in ${dirs1777}; do
83		install -m 1777 -d ${D}$d
84	done
85	for d in ${dirs2775}; do
86		install -m 2775 -d ${D}$d
87	done
88	for d in ${volatiles}; do
89		ln -sf volatile/$d ${D}${localstatedir}/$d
90	done
91
92	ln -snf ../run ${D}${localstatedir}/run
93	ln -snf ../run/lock ${D}${localstatedir}/lock
94
95	install -m 0644 ${S}/hosts ${D}${sysconfdir}/hosts
96	${BASEFILESISSUEINSTALL}
97
98	rotation=`cat ${S}/rotation`
99	if [ "$rotation" != "0" ]; then
100 		install -m 0644 ${S}/rotation ${D}${sysconfdir}/rotation
101	fi
102
103	install -m 0644 ${S}/fstab ${D}${sysconfdir}/fstab
104	install -m 0644 ${S}/profile ${D}${sysconfdir}/profile
105	sed -i 's#ROOTHOME#${ROOT_HOME}#' ${D}${sysconfdir}/profile
106        sed -i 's#@BINDIR@#${bindir}#g' ${D}${sysconfdir}/profile
107	install -m 0644 ${S}/shells ${D}${sysconfdir}/shells
108	install -m 0755 ${S}/share/dot.profile ${D}${sysconfdir}/skel/.profile
109	install -m 0755 ${S}/share/dot.bashrc ${D}${sysconfdir}/skel/.bashrc
110	install -m 0644 ${S}/host.conf ${D}${sysconfdir}/host.conf
111	install -m 0644 ${S}/motd ${D}${sysconfdir}/motd
112
113	ln -sf /proc/mounts ${D}${sysconfdir}/mtab
114
115	# deal with hostname
116	if [ "${hostname}" ]; then
117		echo ${hostname} > ${D}${sysconfdir}/hostname
118		echo "127.0.1.1 ${hostname}" >> ${D}${sysconfdir}/hosts
119	fi
120
121	if ${@bb.utils.contains('DISTRO_FEATURES', 'ipv6', 'false', 'true', d)}; then
122		sed -i '/^::1/s/ localhost//' ${D}${sysconfdir}/hosts
123	fi
124}
125
126do_install:append:libc-glibc () {
127	install -m 0644 ${S}/${@bb.utils.contains('DISTRO_FEATURES', 'systemd systemd-resolved', 'nsswitch-resolved.conf', 'nsswitch.conf', d)} ${D}${sysconfdir}/nsswitch.conf
128}
129
130DISTRO_VERSION[vardepsexclude] += "DATE"
131do_install_basefilesissue () {
132	install -m 644 ${S}/issue*  ${D}${sysconfdir}
133        if [ -n "${DISTRO_NAME}" ]; then
134		printf "${DISTRO_NAME} " >> ${D}${sysconfdir}/issue
135		printf "${DISTRO_NAME} " >> ${D}${sysconfdir}/issue.net
136		if [ -n "${DISTRO_VERSION}" ]; then
137			distro_version_nodate="${@d.getVar('DISTRO_VERSION').replace('snapshot-${DATE}','snapshot').replace('${DATE}','')}"
138			printf "%s " $distro_version_nodate >> ${D}${sysconfdir}/issue
139			printf "%s " $distro_version_nodate >> ${D}${sysconfdir}/issue.net
140		fi
141		printf "\\\n \\\l\n" >> ${D}${sysconfdir}/issue
142		echo >> ${D}${sysconfdir}/issue
143		echo "%h"    >> ${D}${sysconfdir}/issue.net
144		echo >> ${D}${sysconfdir}/issue.net
145 	fi
146}
147do_install_basefilesissue[vardepsexclude] += "DATE"
148
149do_install:append:linuxstdbase() {
150	for d in ${dirs755-lsb}; do
151                install -m 0755 -d ${D}$d
152        done
153
154	for d in ${dirs2775-lsb}; do
155                install -m 2775 -d ${D}$d
156        done
157}
158
159SYSROOT_DIRS += "${sysconfdir}/skel"
160
161PACKAGES = "${PN}-doc ${PN} ${PN}-dev ${PN}-dbg"
162FILES:${PN} = "/"
163FILES:${PN}-doc = "${docdir} ${datadir}/common-licenses"
164
165PACKAGE_ARCH = "${MACHINE_ARCH}"
166
167CONFFILES:${PN} = "${sysconfdir}/fstab ${@['', '${sysconfdir}/hostname ${sysconfdir}/hosts'][(d.getVar('hostname') != '')]} ${sysconfdir}/shells"
168CONFFILES:${PN} += "${sysconfdir}/motd ${sysconfdir}/nsswitch.conf ${sysconfdir}/profile"
169
170INSANE_SKIP:${PN} += "empty-dirs"
171