blob: a1639db830362b18939ece67578a9425becdec94 [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"
5LICENSE = "GPLv2"
6LIC_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 \
23 file://usbd \
24 file://share/dot.bashrc \
25 file://share/dot.profile \
26 file://licenses/GPL-2 \
27 "
28S = "${WORKDIR}"
29
30INHIBIT_DEFAULT_DEPS = "1"
31
32docdir_append = "/${P}"
33dirs1777 = "/tmp ${localstatedir}/volatile/tmp"
34dirs2775 = ""
Brad Bishop6f8dcde2018-10-16 10:47:12 +080035dirs555 = "/sys /proc"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050036dirs755 = "/boot /dev ${base_bindir} ${base_sbindir} ${base_libdir} \
37 ${sysconfdir} ${sysconfdir}/default \
Brad Bishop6f8dcde2018-10-16 10:47:12 +080038 ${sysconfdir}/skel ${nonarch_base_libdir} /mnt ${ROOT_HOME} /run \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050039 ${prefix} ${bindir} ${docdir} /usr/games ${includedir} \
40 ${libdir} ${sbindir} ${datadir} \
41 ${datadir}/common-licenses ${datadir}/dict ${infodir} \
42 ${mandir} ${datadir}/misc ${localstatedir} \
43 ${localstatedir}/backups ${localstatedir}/lib \
Brad Bishop6f8dcde2018-10-16 10:47:12 +080044 ${localstatedir}/lib/misc ${localstatedir}/spool \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050045 ${localstatedir}/volatile \
Brad Bishopd7bf8c12018-02-25 22:55:05 -050046 ${localstatedir}/${@'volatile/' if oe.types.boolean('${VOLATILE_LOG_DIR}') else ''}log \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050047 /home ${prefix}/src ${localstatedir}/local \
48 /media"
49
50dirs755-lsb = "/srv \
51 ${prefix}/local ${prefix}/local/bin ${prefix}/local/games \
52 ${prefix}/local/include ${prefix}/local/lib ${prefix}/local/sbin \
53 ${prefix}/local/share ${prefix}/local/src \
54 ${prefix}/lib/locale"
55dirs2775-lsb = "/var/mail"
56
Brad Bishopd7bf8c12018-02-25 22:55:05 -050057volatiles = "${@'log' if oe.types.boolean('${VOLATILE_LOG_DIR}') else ''} tmp"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050058conffiles = "${sysconfdir}/debian_version ${sysconfdir}/host.conf \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050059 ${sysconfdir}/issue /${sysconfdir}/issue.net \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050060 ${sysconfdir}/nsswitch.conf ${sysconfdir}/profile \
61 ${sysconfdir}/default"
62
63# By default the hostname is the machine name. If the hostname is unset then a
64# /etc/hostname file isn't written, suitable for environments with dynamic
65# hostnames.
66#
67# The hostname can be changed outside of this recipe by using
68# hostname_pn-base-files = "my-host-name".
69hostname = "${MACHINE}"
70
71BASEFILESISSUEINSTALL ?= "do_install_basefilesissue"
72
73# In previous versions of base-files, /run was a softlink to /var/run and the
74# directory was located in /var/volatlie/run. Also, /var/lock was a softlink
75# to /var/volatile/lock which is where the real directory was located. Now,
76# /run and /run/lock are the real directories. If we are upgrading, we may
77# need to remove the symbolic links first before we create the directories.
78# Otherwise the directory creation will fail and we will have circular symbolic
79# links.
80#
81pkg_preinst_${PN} () {
82 #!/bin/sh -e
83 if [ x"$D" = "x" ]; then
84 if [ -h "/var/lock" ]; then
85 # Remove the symbolic link
86 rm -f /var/lock
87 fi
88
89 if [ -h "/run" ]; then
90 # Remove the symbolic link
91 rm -f /run
92 fi
93 fi
94}
95
96do_install () {
Brad Bishop6f8dcde2018-10-16 10:47:12 +080097 for d in ${dirs555}; do
98 install -m 0555 -d ${D}$d
99 done
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500100 for d in ${dirs755}; do
101 install -m 0755 -d ${D}$d
102 done
103 for d in ${dirs1777}; do
104 install -m 1777 -d ${D}$d
105 done
106 for d in ${dirs2775}; do
107 install -m 2775 -d ${D}$d
108 done
109 for d in ${volatiles}; do
110 ln -sf volatile/$d ${D}${localstatedir}/$d
111 done
112
113 ln -snf ../run ${D}${localstatedir}/run
114 ln -snf ../run/lock ${D}${localstatedir}/lock
115
Brad Bishop19323692019-04-05 15:28:33 -0400116 install -m 0644 ${WORKDIR}/hosts ${D}${sysconfdir}/hosts
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500117 ${BASEFILESISSUEINSTALL}
118
119 rotation=`cat ${WORKDIR}/rotation`
120 if [ "$rotation" != "0" ]; then
121 install -m 0644 ${WORKDIR}/rotation ${D}${sysconfdir}/rotation
122 fi
123
124 install -m 0644 ${WORKDIR}/fstab ${D}${sysconfdir}/fstab
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500125 install -m 0644 ${WORKDIR}/usbd ${D}${sysconfdir}/default/usbd
126 install -m 0644 ${WORKDIR}/profile ${D}${sysconfdir}/profile
127 sed -i 's#ROOTHOME#${ROOT_HOME}#' ${D}${sysconfdir}/profile
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800128 sed -i 's#@BINDIR@#${bindir}#g' ${D}${sysconfdir}/profile
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500129 install -m 0644 ${WORKDIR}/shells ${D}${sysconfdir}/shells
130 install -m 0755 ${WORKDIR}/share/dot.profile ${D}${sysconfdir}/skel/.profile
131 install -m 0755 ${WORKDIR}/share/dot.bashrc ${D}${sysconfdir}/skel/.bashrc
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500132 install -m 0644 ${WORKDIR}/nsswitch.conf ${D}${sysconfdir}/nsswitch.conf
133 install -m 0644 ${WORKDIR}/host.conf ${D}${sysconfdir}/host.conf
134 install -m 0644 ${WORKDIR}/motd ${D}${sysconfdir}/motd
135
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500136 ln -sf /proc/mounts ${D}${sysconfdir}/mtab
137}
138
139DISTRO_VERSION[vardepsexclude] += "DATE"
140do_install_basefilesissue () {
141 if [ "${hostname}" ]; then
142 echo ${hostname} > ${D}${sysconfdir}/hostname
Brad Bishop19323692019-04-05 15:28:33 -0400143 echo "127.0.1.1 ${hostname}" >> ${D}${sysconfdir}/hosts
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500144 fi
145
146 install -m 644 ${WORKDIR}/issue* ${D}${sysconfdir}
147 if [ -n "${DISTRO_NAME}" ]; then
148 printf "${DISTRO_NAME} " >> ${D}${sysconfdir}/issue
149 printf "${DISTRO_NAME} " >> ${D}${sysconfdir}/issue.net
150 if [ -n "${DISTRO_VERSION}" ]; then
Brad Bishop19323692019-04-05 15:28:33 -0400151 distro_version_nodate="${@d.getVar('DISTRO_VERSION').replace('snapshot-${DATE}','snapshot').replace('${DATE}','')}"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500152 printf "%s " $distro_version_nodate >> ${D}${sysconfdir}/issue
153 printf "%s " $distro_version_nodate >> ${D}${sysconfdir}/issue.net
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500154 fi
155 printf "\\\n \\\l\n" >> ${D}${sysconfdir}/issue
156 echo >> ${D}${sysconfdir}/issue
157 echo "%h" >> ${D}${sysconfdir}/issue.net
158 echo >> ${D}${sysconfdir}/issue.net
159 fi
160}
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500161do_install_basefilesissue[vardepsexclude] += "DATE"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500162
163do_install_append_linuxstdbase() {
164 for d in ${dirs755-lsb}; do
165 install -m 0755 -d ${D}$d
166 done
167
168 for d in ${dirs2775-lsb}; do
169 install -m 2775 -d ${D}$d
170 done
171}
172
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600173SYSROOT_DIRS += "${sysconfdir}/skel"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500174
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500175PACKAGES = "${PN}-doc ${PN} ${PN}-dev ${PN}-dbg"
176FILES_${PN} = "/"
177FILES_${PN}-doc = "${docdir} ${datadir}/common-licenses"
178
179PACKAGE_ARCH = "${MACHINE_ARCH}"
180
Brad Bishop19323692019-04-05 15:28:33 -0400181CONFFILES_${PN} = "${sysconfdir}/fstab ${@['', '${sysconfdir}/hostname ${sysconfdir}/hosts'][(d.getVar('hostname') != '')]} ${sysconfdir}/shells"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500182CONFFILES_${PN} += "${sysconfdir}/motd ${sysconfdir}/nsswitch.conf ${sysconfdir}/profile"