blob: ff83567bd9192a8547abf5bc0eb7fa9631e9baea [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001SUMMARY = "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"
4PR = "r89"
Andrew Geissler7e0e3c02022-02-25 20:34:39 +00005LICENSE = "GPL-2.0-only"
Patrick Williamsc124f4f2015-09-15 14:41:29 -05006LIC_FILES_CHKSUM = "file://licenses/GPL-2;md5=94d55d512a9ba36caa9b7df079bae19f"
7# Removed all license related tasks in this recipe as license.bbclass
8# now deals with this. In order to get accurate licensing on to the image:
9# Set COPY_LIC_MANIFEST to just copy just the license.manifest to the image
10# For the manifest and the license text for each package:
11# Set COPY_LIC_MANIFEST and COPY_LIC_DIRS
12
13SRC_URI = "file://rotation \
14 file://nsswitch.conf \
15 file://motd \
Brad Bishop19323692019-04-05 15:28:33 -040016 file://hosts \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050017 file://host.conf \
18 file://profile \
19 file://shells \
20 file://fstab \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050021 file://issue.net \
22 file://issue \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050023 file://share/dot.bashrc \
24 file://share/dot.profile \
25 file://licenses/GPL-2 \
26 "
27S = "${WORKDIR}"
28
29INHIBIT_DEFAULT_DEPS = "1"
30
Patrick Williams213cb262021-08-07 19:21:33 -050031docdir:append = "/${P}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050032dirs1777 = "/tmp ${localstatedir}/volatile/tmp"
33dirs2775 = ""
Brad Bishop6f8dcde2018-10-16 10:47:12 +080034dirs555 = "/sys /proc"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050035dirs755 = "/boot /dev ${base_bindir} ${base_sbindir} ${base_libdir} \
36 ${sysconfdir} ${sysconfdir}/default \
Brad Bishop6f8dcde2018-10-16 10:47:12 +080037 ${sysconfdir}/skel ${nonarch_base_libdir} /mnt ${ROOT_HOME} /run \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050038 ${prefix} ${bindir} ${docdir} /usr/games ${includedir} \
39 ${libdir} ${sbindir} ${datadir} \
40 ${datadir}/common-licenses ${datadir}/dict ${infodir} \
41 ${mandir} ${datadir}/misc ${localstatedir} \
42 ${localstatedir}/backups ${localstatedir}/lib \
Brad Bishop6f8dcde2018-10-16 10:47:12 +080043 ${localstatedir}/lib/misc ${localstatedir}/spool \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050044 ${localstatedir}/volatile \
Brad Bishopd7bf8c12018-02-25 22:55:05 -050045 ${localstatedir}/${@'volatile/' if oe.types.boolean('${VOLATILE_LOG_DIR}') else ''}log \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050046 /home ${prefix}/src ${localstatedir}/local \
47 /media"
48
49dirs755-lsb = "/srv \
50 ${prefix}/local ${prefix}/local/bin ${prefix}/local/games \
51 ${prefix}/local/include ${prefix}/local/lib ${prefix}/local/sbin \
52 ${prefix}/local/share ${prefix}/local/src \
53 ${prefix}/lib/locale"
54dirs2775-lsb = "/var/mail"
55
Brad Bishopd7bf8c12018-02-25 22:55:05 -050056volatiles = "${@'log' if oe.types.boolean('${VOLATILE_LOG_DIR}') else ''} tmp"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050057conffiles = "${sysconfdir}/debian_version ${sysconfdir}/host.conf \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050058 ${sysconfdir}/issue /${sysconfdir}/issue.net \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050059 ${sysconfdir}/nsswitch.conf ${sysconfdir}/profile \
60 ${sysconfdir}/default"
61
62# By default the hostname is the machine name. If the hostname is unset then a
63# /etc/hostname file isn't written, suitable for environments with dynamic
64# hostnames.
65#
66# The hostname can be changed outside of this recipe by using
Patrick Williams213cb262021-08-07 19:21:33 -050067# hostname:pn-base-files = "my-host-name".
Patrick Williamsc124f4f2015-09-15 14:41:29 -050068hostname = "${MACHINE}"
69
70BASEFILESISSUEINSTALL ?= "do_install_basefilesissue"
71
72# In previous versions of base-files, /run was a softlink to /var/run and the
73# directory was located in /var/volatlie/run. Also, /var/lock was a softlink
74# to /var/volatile/lock which is where the real directory was located. Now,
75# /run and /run/lock are the real directories. If we are upgrading, we may
76# need to remove the symbolic links first before we create the directories.
77# Otherwise the directory creation will fail and we will have circular symbolic
78# links.
79#
Patrick Williams213cb262021-08-07 19:21:33 -050080pkg_preinst:${PN} () {
Patrick Williamsc124f4f2015-09-15 14:41:29 -050081 #!/bin/sh -e
82 if [ x"$D" = "x" ]; then
83 if [ -h "/var/lock" ]; then
84 # Remove the symbolic link
85 rm -f /var/lock
86 fi
87
88 if [ -h "/run" ]; then
89 # Remove the symbolic link
90 rm -f /run
91 fi
92 fi
93}
94
95do_install () {
Brad Bishop6f8dcde2018-10-16 10:47:12 +080096 for d in ${dirs555}; do
97 install -m 0555 -d ${D}$d
98 done
Patrick Williamsc124f4f2015-09-15 14:41:29 -050099 for d in ${dirs755}; do
100 install -m 0755 -d ${D}$d
101 done
102 for d in ${dirs1777}; do
103 install -m 1777 -d ${D}$d
104 done
105 for d in ${dirs2775}; do
106 install -m 2775 -d ${D}$d
107 done
108 for d in ${volatiles}; do
109 ln -sf volatile/$d ${D}${localstatedir}/$d
110 done
111
112 ln -snf ../run ${D}${localstatedir}/run
113 ln -snf ../run/lock ${D}${localstatedir}/lock
114
Brad Bishop19323692019-04-05 15:28:33 -0400115 install -m 0644 ${WORKDIR}/hosts ${D}${sysconfdir}/hosts
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500116 ${BASEFILESISSUEINSTALL}
117
118 rotation=`cat ${WORKDIR}/rotation`
119 if [ "$rotation" != "0" ]; then
120 install -m 0644 ${WORKDIR}/rotation ${D}${sysconfdir}/rotation
121 fi
122
123 install -m 0644 ${WORKDIR}/fstab ${D}${sysconfdir}/fstab
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500124 install -m 0644 ${WORKDIR}/profile ${D}${sysconfdir}/profile
125 sed -i 's#ROOTHOME#${ROOT_HOME}#' ${D}${sysconfdir}/profile
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800126 sed -i 's#@BINDIR@#${bindir}#g' ${D}${sysconfdir}/profile
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500127 install -m 0644 ${WORKDIR}/shells ${D}${sysconfdir}/shells
128 install -m 0755 ${WORKDIR}/share/dot.profile ${D}${sysconfdir}/skel/.profile
129 install -m 0755 ${WORKDIR}/share/dot.bashrc ${D}${sysconfdir}/skel/.bashrc
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500130 install -m 0644 ${WORKDIR}/host.conf ${D}${sysconfdir}/host.conf
131 install -m 0644 ${WORKDIR}/motd ${D}${sysconfdir}/motd
132
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500133 ln -sf /proc/mounts ${D}${sysconfdir}/mtab
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500134
Brad Bishopc342db32019-05-15 21:57:59 -0400135 # deal with hostname
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500136 if [ "${hostname}" ]; then
137 echo ${hostname} > ${D}${sysconfdir}/hostname
Brad Bishop19323692019-04-05 15:28:33 -0400138 echo "127.0.1.1 ${hostname}" >> ${D}${sysconfdir}/hosts
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500139 fi
Brad Bishopc342db32019-05-15 21:57:59 -0400140}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500141
Patrick Williams213cb262021-08-07 19:21:33 -0500142do_install:append:libc-glibc () {
Brad Bishop79641f22019-09-10 07:20:22 -0400143 install -m 0644 ${WORKDIR}/nsswitch.conf ${D}${sysconfdir}/nsswitch.conf
144}
145
Brad Bishopc342db32019-05-15 21:57:59 -0400146DISTRO_VERSION[vardepsexclude] += "DATE"
147do_install_basefilesissue () {
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500148 install -m 644 ${WORKDIR}/issue* ${D}${sysconfdir}
149 if [ -n "${DISTRO_NAME}" ]; then
150 printf "${DISTRO_NAME} " >> ${D}${sysconfdir}/issue
151 printf "${DISTRO_NAME} " >> ${D}${sysconfdir}/issue.net
152 if [ -n "${DISTRO_VERSION}" ]; then
Brad Bishop19323692019-04-05 15:28:33 -0400153 distro_version_nodate="${@d.getVar('DISTRO_VERSION').replace('snapshot-${DATE}','snapshot').replace('${DATE}','')}"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500154 printf "%s " $distro_version_nodate >> ${D}${sysconfdir}/issue
155 printf "%s " $distro_version_nodate >> ${D}${sysconfdir}/issue.net
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500156 fi
157 printf "\\\n \\\l\n" >> ${D}${sysconfdir}/issue
158 echo >> ${D}${sysconfdir}/issue
159 echo "%h" >> ${D}${sysconfdir}/issue.net
160 echo >> ${D}${sysconfdir}/issue.net
161 fi
162}
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500163do_install_basefilesissue[vardepsexclude] += "DATE"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500164
Patrick Williams213cb262021-08-07 19:21:33 -0500165do_install:append:linuxstdbase() {
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500166 for d in ${dirs755-lsb}; do
167 install -m 0755 -d ${D}$d
168 done
169
170 for d in ${dirs2775-lsb}; do
171 install -m 2775 -d ${D}$d
172 done
173}
174
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600175SYSROOT_DIRS += "${sysconfdir}/skel"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500176
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500177PACKAGES = "${PN}-doc ${PN} ${PN}-dev ${PN}-dbg"
Patrick Williams213cb262021-08-07 19:21:33 -0500178FILES:${PN} = "/"
179FILES:${PN}-doc = "${docdir} ${datadir}/common-licenses"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500180
181PACKAGE_ARCH = "${MACHINE_ARCH}"
182
Patrick Williams213cb262021-08-07 19:21:33 -0500183CONFFILES:${PN} = "${sysconfdir}/fstab ${@['', '${sysconfdir}/hostname ${sysconfdir}/hosts'][(d.getVar('hostname') != '')]} ${sysconfdir}/shells"
184CONFFILES:${PN} += "${sysconfdir}/motd ${sysconfdir}/nsswitch.conf ${sysconfdir}/profile"
Andrew Geissler595f6302022-01-24 19:11:47 +0000185
186INSANE_SKIP:${PN} += "empty-dirs"