Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | SUMMARY = "Miscellaneous files for the base system" |
| 2 | DESCRIPTION = "The base-files package creates the basic system directory structure and provides a small set of key configuration files for the system." |
| 3 | SECTION = "base" |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 4 | LICENSE = "GPL-2.0-only" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5 | LIC_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 | |
| 12 | SRC_URI = "file://rotation \ |
| 13 | file://nsswitch.conf \ |
| 14 | file://motd \ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 15 | file://hosts \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 16 | file://host.conf \ |
| 17 | file://profile \ |
| 18 | file://shells \ |
| 19 | file://fstab \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 20 | file://issue.net \ |
| 21 | file://issue \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 22 | file://share/dot.bashrc \ |
| 23 | file://share/dot.profile \ |
| 24 | file://licenses/GPL-2 \ |
| 25 | " |
Patrick Williams | ac13d5f | 2023-11-24 18:59:46 -0600 | [diff] [blame] | 26 | SRC_URI:append:libc-glibc = "${@bb.utils.contains('DISTRO_FEATURES', 'systemd systemd-resolved', ' file://0001-add-nss-resolve-to-nsswitch.patch', '', d)}" |
| 27 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 28 | S = "${WORKDIR}" |
| 29 | |
| 30 | INHIBIT_DEFAULT_DEPS = "1" |
| 31 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 32 | docdir:append = "/${P}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 33 | dirs1777 = "/tmp ${localstatedir}/volatile/tmp" |
| 34 | dirs2775 = "" |
Brad Bishop | 6f8dcde | 2018-10-16 10:47:12 +0800 | [diff] [blame] | 35 | dirs555 = "/sys /proc" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 36 | dirs755 = "/boot /dev ${base_bindir} ${base_sbindir} ${base_libdir} \ |
| 37 | ${sysconfdir} ${sysconfdir}/default \ |
Brad Bishop | 6f8dcde | 2018-10-16 10:47:12 +0800 | [diff] [blame] | 38 | ${sysconfdir}/skel ${nonarch_base_libdir} /mnt ${ROOT_HOME} /run \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 39 | ${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 Bishop | 6f8dcde | 2018-10-16 10:47:12 +0800 | [diff] [blame] | 44 | ${localstatedir}/lib/misc ${localstatedir}/spool \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 45 | ${localstatedir}/volatile \ |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 46 | ${localstatedir}/${@'volatile/' if oe.types.boolean('${VOLATILE_LOG_DIR}') else ''}log \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 47 | /home ${prefix}/src ${localstatedir}/local \ |
| 48 | /media" |
| 49 | |
| 50 | dirs755-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" |
| 55 | dirs2775-lsb = "/var/mail" |
| 56 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 57 | volatiles = "${@'log' if oe.types.boolean('${VOLATILE_LOG_DIR}') else ''} tmp" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 58 | conffiles = "${sysconfdir}/debian_version ${sysconfdir}/host.conf \ |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 59 | ${sysconfdir}/issue /${sysconfdir}/issue.net \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 60 | ${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 |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 68 | # hostname:pn-base-files = "my-host-name". |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 69 | hostname = "${MACHINE}" |
| 70 | |
| 71 | BASEFILESISSUEINSTALL ?= "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 | # |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 81 | pkg_preinst:${PN} () { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 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 | |
| 96 | do_install () { |
Brad Bishop | 6f8dcde | 2018-10-16 10:47:12 +0800 | [diff] [blame] | 97 | for d in ${dirs555}; do |
| 98 | install -m 0555 -d ${D}$d |
| 99 | done |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 100 | 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 Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 116 | install -m 0644 ${WORKDIR}/hosts ${D}${sysconfdir}/hosts |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 117 | ${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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 125 | install -m 0644 ${WORKDIR}/profile ${D}${sysconfdir}/profile |
| 126 | sed -i 's#ROOTHOME#${ROOT_HOME}#' ${D}${sysconfdir}/profile |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 127 | sed -i 's#@BINDIR@#${bindir}#g' ${D}${sysconfdir}/profile |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 128 | install -m 0644 ${WORKDIR}/shells ${D}${sysconfdir}/shells |
| 129 | install -m 0755 ${WORKDIR}/share/dot.profile ${D}${sysconfdir}/skel/.profile |
| 130 | install -m 0755 ${WORKDIR}/share/dot.bashrc ${D}${sysconfdir}/skel/.bashrc |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 131 | install -m 0644 ${WORKDIR}/host.conf ${D}${sysconfdir}/host.conf |
| 132 | install -m 0644 ${WORKDIR}/motd ${D}${sysconfdir}/motd |
| 133 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 134 | ln -sf /proc/mounts ${D}${sysconfdir}/mtab |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 135 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 136 | # deal with hostname |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 137 | if [ "${hostname}" ]; then |
| 138 | echo ${hostname} > ${D}${sysconfdir}/hostname |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 139 | echo "127.0.1.1 ${hostname}" >> ${D}${sysconfdir}/hosts |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 140 | fi |
Patrick Williams | ac13d5f | 2023-11-24 18:59:46 -0600 | [diff] [blame] | 141 | |
| 142 | if ${@bb.utils.contains('DISTRO_FEATURES', 'ipv6', 'false', 'true', d)}; then |
| 143 | sed -i '/^::1/s/ localhost//' ${D}${sysconfdir}/hosts |
| 144 | fi |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 145 | } |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 146 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 147 | do_install:append:libc-glibc () { |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 148 | install -m 0644 ${WORKDIR}/nsswitch.conf ${D}${sysconfdir}/nsswitch.conf |
| 149 | } |
| 150 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 151 | DISTRO_VERSION[vardepsexclude] += "DATE" |
| 152 | do_install_basefilesissue () { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 153 | install -m 644 ${WORKDIR}/issue* ${D}${sysconfdir} |
| 154 | if [ -n "${DISTRO_NAME}" ]; then |
| 155 | printf "${DISTRO_NAME} " >> ${D}${sysconfdir}/issue |
| 156 | printf "${DISTRO_NAME} " >> ${D}${sysconfdir}/issue.net |
| 157 | if [ -n "${DISTRO_VERSION}" ]; then |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 158 | distro_version_nodate="${@d.getVar('DISTRO_VERSION').replace('snapshot-${DATE}','snapshot').replace('${DATE}','')}" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 159 | printf "%s " $distro_version_nodate >> ${D}${sysconfdir}/issue |
| 160 | printf "%s " $distro_version_nodate >> ${D}${sysconfdir}/issue.net |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 161 | fi |
| 162 | printf "\\\n \\\l\n" >> ${D}${sysconfdir}/issue |
| 163 | echo >> ${D}${sysconfdir}/issue |
| 164 | echo "%h" >> ${D}${sysconfdir}/issue.net |
| 165 | echo >> ${D}${sysconfdir}/issue.net |
| 166 | fi |
| 167 | } |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 168 | do_install_basefilesissue[vardepsexclude] += "DATE" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 169 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 170 | do_install:append:linuxstdbase() { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 171 | for d in ${dirs755-lsb}; do |
| 172 | install -m 0755 -d ${D}$d |
| 173 | done |
| 174 | |
| 175 | for d in ${dirs2775-lsb}; do |
| 176 | install -m 2775 -d ${D}$d |
| 177 | done |
| 178 | } |
| 179 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 180 | SYSROOT_DIRS += "${sysconfdir}/skel" |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 181 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 182 | PACKAGES = "${PN}-doc ${PN} ${PN}-dev ${PN}-dbg" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 183 | FILES:${PN} = "/" |
| 184 | FILES:${PN}-doc = "${docdir} ${datadir}/common-licenses" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 185 | |
| 186 | PACKAGE_ARCH = "${MACHINE_ARCH}" |
| 187 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 188 | CONFFILES:${PN} = "${sysconfdir}/fstab ${@['', '${sysconfdir}/hostname ${sysconfdir}/hosts'][(d.getVar('hostname') != '')]} ${sysconfdir}/shells" |
| 189 | CONFFILES:${PN} += "${sysconfdir}/motd ${sysconfdir}/nsswitch.conf ${sysconfdir}/profile" |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 190 | |
| 191 | INSANE_SKIP:${PN} += "empty-dirs" |