util-linux_2.36.bb 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. SUMMARY = "A suite of basic system administration utilities"
  2. HOMEPAGE = "https://en.wikipedia.org/wiki/Util-linux"
  3. DESCRIPTION = "Util-linux includes a suite of basic system administration utilities \
  4. commonly found on most Linux systems. Some of the more important utilities include \
  5. disk partitioning, kernel message management, filesystem creation, and system login."
  6. SECTION = "base"
  7. LICENSE = "GPLv2+ & LGPLv2.1+ & BSD-3-Clause & BSD-4-Clause"
  8. LICENSE_${PN}-libblkid = "LGPLv2.1+"
  9. LICENSE_${PN}-libfdisk = "LGPLv2.1+"
  10. LICENSE_${PN}-libmount = "LGPLv2.1+"
  11. LICENSE_${PN}-libsmartcols = "LGPLv2.1+"
  12. LICENSE_${PN}-libuuid = "BSD-3-Clause"
  13. LIC_FILES_CHKSUM = "file://README.licensing;md5=0fd5c050c6187d2bf0a4492b7f4e33da \
  14. file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
  15. file://Documentation/licenses/COPYING.GPL-2.0-or-later;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
  16. file://Documentation/licenses/COPYING.LGPL-2.1-or-later;md5=4fbd65380cdd255951079008b364516c \
  17. file://Documentation/licenses/COPYING.BSD-3-Clause;md5=58dcd8452651fc8b07d1f65ce07ca8af \
  18. file://Documentation/licenses/COPYING.BSD-4-Clause-UC;md5=263860f8968d8bafa5392cab74285262 \
  19. file://libuuid/COPYING;md5=6d2cafc999feb2c2de84d4d24b23290c \
  20. file://libmount/COPYING;md5=7c7e39fb7d70ffe5d693a643e29987c2 \
  21. file://libblkid/COPYING;md5=693bcbbe16d3a4a4b37bc906bc01cc04 \
  22. file://libfdisk/COPYING;md5=693bcbbe16d3a4a4b37bc906bc01cc04 \
  23. file://libsmartcols/COPYING;md5=693bcbbe16d3a4a4b37bc906bc01cc04 \
  24. "
  25. #gtk-doc is not enabled as it requires xmlto which requires util-linux
  26. inherit autotools gettext manpages pkgconfig systemd update-alternatives python3-dir bash-completion ptest
  27. DEPENDS = "libcap-ng ncurses virtual/crypt zlib"
  28. MAJOR_VERSION = "${@'.'.join(d.getVar('PV').split('.')[0:2])}"
  29. SRC_URI = "${KERNELORG_MIRROR}/linux/utils/${BPN}/v${MAJOR_VERSION}/${BP}.tar.xz \
  30. file://configure-sbindir.patch \
  31. file://runuser.pamd \
  32. file://runuser-l.pamd \
  33. file://ptest.patch \
  34. file://run-ptest \
  35. file://display_testname_for_subtest.patch \
  36. file://avoid_parallel_tests.patch \
  37. "
  38. SRC_URI[sha256sum] = "9e4b1c67eb13b9b67feb32ae1dc0d50e08ce9e5d82e1cccd0ee771ad2fa9e0b1"
  39. PACKAGES =+ "${PN}-swaponoff"
  40. PACKAGES += "${@bb.utils.contains('PACKAGECONFIG', 'pylibmount', '${PN}-pylibmount', '', d)}"
  41. python util_linux_binpackages () {
  42. def pkg_hook(f, pkg, file_regex, output_pattern, modulename):
  43. pn = d.getVar('PN')
  44. d.appendVar('RRECOMMENDS_%s' % pn, ' %s' % pkg)
  45. if d.getVar('ALTERNATIVE_' + pkg):
  46. return
  47. if d.getVarFlag('ALTERNATIVE_LINK_NAME', modulename):
  48. d.setVar('ALTERNATIVE_' + pkg, modulename)
  49. bindirs = sorted(list(set(d.expand("${base_sbindir} ${base_bindir} ${sbindir} ${bindir}").split())))
  50. for dir in bindirs:
  51. do_split_packages(d, root=dir,
  52. file_regex=r'(.*)', output_pattern='${PN}-%s',
  53. description='${PN} %s',
  54. hook=pkg_hook, extra_depends='')
  55. # There are some symlinks for some binaries which we have ignored
  56. # above. Add them to the package owning the binary they are
  57. # pointing to
  58. extras = {}
  59. dvar = d.getVar('PKGD')
  60. for root in bindirs:
  61. for walkroot, dirs, files in os.walk(dvar + root):
  62. for f in files:
  63. file = os.path.join(walkroot, f)
  64. if not os.path.islink(file):
  65. continue
  66. pkg = os.path.basename(os.readlink(file))
  67. extras[pkg] = extras.get(pkg, '') + ' ' + file.replace(dvar, '', 1)
  68. pn = d.getVar('PN')
  69. for pkg, links in extras.items():
  70. of = d.getVar('FILES_' + pn + '-' + pkg)
  71. links = of + links
  72. d.setVar('FILES_' + pn + '-' + pkg, links)
  73. }
  74. # we must execute before update-alternatives PACKAGE_PREPROCESS_FUNCS
  75. PACKAGE_PREPROCESS_FUNCS =+ "util_linux_binpackages "
  76. python util_linux_libpackages() {
  77. do_split_packages(d, root=d.getVar('UTIL_LINUX_LIBDIR'), file_regex=r'^lib(.*)\.so\..*$',
  78. output_pattern='${PN}-lib%s',
  79. description='${PN} lib%s',
  80. extra_depends='', prepend=True, allow_links=True)
  81. }
  82. PACKAGESPLITFUNCS =+ "util_linux_libpackages"
  83. PACKAGES_DYNAMIC = "^${PN}-.*"
  84. CACHED_CONFIGUREVARS += "scanf_cv_alloc_modifier=ms"
  85. UTIL_LINUX_LIBDIR = "${libdir}"
  86. UTIL_LINUX_LIBDIR_class-target = "${base_libdir}"
  87. EXTRA_OECONF = "\
  88. --enable-libuuid --enable-libblkid \
  89. \
  90. --enable-fsck --enable-kill --enable-last --enable-mesg \
  91. --enable-mount --enable-partx --enable-raw --enable-rfkill \
  92. --enable-unshare --enable-write \
  93. \
  94. --disable-bfs --disable-chfn-chsh --disable-login \
  95. --disable-makeinstall-chown --disable-minix --disable-newgrp \
  96. --disable-use-tty-group --disable-vipw \
  97. \
  98. --without-udev \
  99. \
  100. usrsbin_execdir='${sbindir}' \
  101. --libdir='${UTIL_LINUX_LIBDIR}' \
  102. "
  103. EXTRA_OECONF_append_class-target = " --enable-setpriv"
  104. EXTRA_OECONF_append_class-native = " --without-cap-ng --disable-setpriv"
  105. EXTRA_OECONF_append_class-nativesdk = " --without-cap-ng --disable-setpriv"
  106. EXTRA_OECONF_append = " --disable-hwclock-gplv3"
  107. # enable pcre2 for native/nativesdk to match host distros
  108. # this helps to keep same expectations when using the SDK or
  109. # build host versions during development
  110. #
  111. PACKAGECONFIG ?= "pcre2"
  112. PACKAGECONFIG_class-target ?= "${@bb.utils.filter('DISTRO_FEATURES', 'pam', d)}"
  113. # inherit manpages requires this to be present, however util-linux does not have
  114. # configuration options, and installs manpages always
  115. PACKAGECONFIG[manpages] = ""
  116. PACKAGECONFIG[pam] = "--enable-su --enable-runuser,--disable-su --disable-runuser, libpam,"
  117. # Respect the systemd feature for uuidd
  118. PACKAGECONFIG[systemd] = "--with-systemd --with-systemdsystemunitdir=${systemd_system_unitdir}, --without-systemd --without-systemdsystemunitdir,systemd"
  119. # Build python bindings for libmount
  120. PACKAGECONFIG[pylibmount] = "--with-python=3 --enable-pylibmount,--without-python --disable-pylibmount,python3"
  121. # Readline support
  122. PACKAGECONFIG[readline] = "--with-readline,--without-readline,readline"
  123. # PCRE support in hardlink
  124. PACKAGECONFIG[pcre2] = ",,libpcre2"
  125. EXTRA_OEMAKE = "ARCH=${TARGET_ARCH} CPU= CPUOPT= 'OPT=${CFLAGS}'"
  126. ALLOW_EMPTY_${PN} = "1"
  127. FILES_${PN} = ""
  128. FILES_${PN}-doc += "${datadir}/getopt/getopt-*.*"
  129. FILES_${PN}-dev += "${PYTHON_SITEPACKAGES_DIR}/libmount/pylibmount.la"
  130. FILES_${PN}-mount = "${sysconfdir}/default/mountall"
  131. FILES_${PN}-runuser = "${sysconfdir}/pam.d/runuser*"
  132. FILES_${PN}-su = "${sysconfdir}/pam.d/su-l"
  133. CONFFILES_${PN}-su = "${sysconfdir}/pam.d/su-l"
  134. FILES_${PN}-pylibmount = "${PYTHON_SITEPACKAGES_DIR}/libmount/pylibmount.so \
  135. ${PYTHON_SITEPACKAGES_DIR}/libmount/__init__.* \
  136. ${PYTHON_SITEPACKAGES_DIR}/libmount/__pycache__/*"
  137. # Util-linux' blkid replaces the e2fsprogs one
  138. RCONFLICTS_${PN}-blkid = "${MLPREFIX}e2fsprogs-blkid"
  139. RREPLACES_${PN}-blkid = "${MLPREFIX}e2fsprogs-blkid"
  140. RRECOMMENDS_${PN}_class-native = ""
  141. RRECOMMENDS_${PN}_class-nativesdk = ""
  142. RDEPENDS_${PN}_class-native = ""
  143. RDEPENDS_${PN}_class-nativesdk = ""
  144. RPROVIDES_${PN}-dev = "${PN}-libblkid-dev ${PN}-libmount-dev ${PN}-libuuid-dev"
  145. RDEPENDS_${PN}-bash-completion += "${PN}-lsblk"
  146. RDEPENDS_${PN}-ptest += "bash bc btrfs-tools coreutils e2fsprogs grep iproute2 kmod mdadm procps sed socat which xz"
  147. RRECOMMENDS_${PN}-ptest += "kernel-module-scsi-debug"
  148. RDEPENDS_${PN}-swaponoff = "${PN}-swapon ${PN}-swapoff"
  149. ALLOW_EMPTY_${PN}-swaponoff = "1"
  150. #SYSTEMD_PACKAGES = "${PN}-uuidd ${PN}-fstrim"
  151. SYSTEMD_SERVICE_${PN}-uuidd = "uuidd.socket uuidd.service"
  152. SYSTEMD_AUTO_ENABLE_${PN}-uuidd = "disable"
  153. SYSTEMD_SERVICE_${PN}-fstrim = "fstrim.timer fstrim.service"
  154. SYSTEMD_AUTO_ENABLE_${PN}-fstrim = "disable"
  155. do_install () {
  156. # with ccache the timestamps on compiled files may
  157. # end up earlier than on their inputs, this allows
  158. # for the resultant compilation in the install step.
  159. oe_runmake 'CC=${CC}' 'LD=${LD}' \
  160. 'LDFLAGS=${LDFLAGS}' 'DESTDIR=${D}' install
  161. mkdir -p ${D}${base_bindir}
  162. sbinprogs="agetty ctrlaltdel cfdisk vipw vigr"
  163. sbinprogs_a="pivot_root hwclock mkswap losetup swapon swapoff fdisk fsck blkid blockdev fstrim sulogin switch_root nologin"
  164. binprogs_a="dmesg getopt kill more umount mount login su mountpoint"
  165. if [ "${base_sbindir}" != "${sbindir}" ]; then
  166. mkdir -p ${D}${base_sbindir}
  167. for p in $sbinprogs $sbinprogs_a; do
  168. if [ -f "${D}${sbindir}/$p" ]; then
  169. mv "${D}${sbindir}/$p" "${D}${base_sbindir}/$p"
  170. fi
  171. done
  172. fi
  173. if [ "${base_bindir}" != "${bindir}" ]; then
  174. mkdir -p ${D}${base_bindir}
  175. for p in $binprogs_a; do
  176. if [ -f "${D}${bindir}/$p" ]; then
  177. mv "${D}${bindir}/$p" "${D}${base_bindir}/$p"
  178. fi
  179. done
  180. fi
  181. install -d ${D}${sysconfdir}/default/
  182. echo 'MOUNTALL="-t nonfs,nosmbfs,noncpfs"' > ${D}${sysconfdir}/default/mountall
  183. rm -f ${D}${bindir}/chkdupexe
  184. }
  185. do_install_append_class-target () {
  186. if [ "${@bb.utils.filter('PACKAGECONFIG', 'pam', d)}" ]; then
  187. install -d ${D}${sysconfdir}/pam.d
  188. install -m 0644 ${WORKDIR}/runuser.pamd ${D}${sysconfdir}/pam.d/runuser
  189. install -m 0644 ${WORKDIR}/runuser-l.pamd ${D}${sysconfdir}/pam.d/runuser-l
  190. # Required for "su -" aka "su --login" because
  191. # otherwise it uses "other", which has "auth pam_deny.so"
  192. # and thus prevents the operation.
  193. ln -s su ${D}${sysconfdir}/pam.d/su-l
  194. fi
  195. }
  196. # nologin causes a conflict with shadow-native
  197. # kill causes a conflict with coreutils-native (if ${bindir}==${base_bindir})
  198. do_install_append_class-native () {
  199. rm -f ${D}${base_sbindir}/nologin
  200. rm -f ${D}${base_bindir}/kill
  201. }
  202. ALTERNATIVE_PRIORITY = "80"
  203. ALTERNATIVE_LINK_NAME[blkid] = "${base_sbindir}/blkid"
  204. ALTERNATIVE_LINK_NAME[blockdev] = "${base_sbindir}/blockdev"
  205. ALTERNATIVE_LINK_NAME[cal] = "${bindir}/cal"
  206. ALTERNATIVE_LINK_NAME[chrt] = "${bindir}/chrt"
  207. ALTERNATIVE_LINK_NAME[dmesg] = "${base_bindir}/dmesg"
  208. ALTERNATIVE_LINK_NAME[eject] = "${bindir}/eject"
  209. ALTERNATIVE_LINK_NAME[fallocate] = "${bindir}/fallocate"
  210. ALTERNATIVE_LINK_NAME[fdisk] = "${base_sbindir}/fdisk"
  211. ALTERNATIVE_LINK_NAME[flock] = "${bindir}/flock"
  212. ALTERNATIVE_LINK_NAME[fsck] = "${base_sbindir}/fsck"
  213. ALTERNATIVE_LINK_NAME[fsfreeze] = "${sbindir}/fsfreeze"
  214. ALTERNATIVE_LINK_NAME[fstrim] = "${base_sbindir}/fstrim"
  215. ALTERNATIVE_LINK_NAME[getopt] = "${base_bindir}/getopt"
  216. ALTERNATIVE_${PN}-agetty = "getty"
  217. ALTERNATIVE_LINK_NAME[getty] = "${base_sbindir}/getty"
  218. ALTERNATIVE_TARGET[getty] = "${base_sbindir}/agetty"
  219. ALTERNATIVE_LINK_NAME[hexdump] = "${bindir}/hexdump"
  220. ALTERNATIVE_LINK_NAME[hwclock] = "${base_sbindir}/hwclock"
  221. ALTERNATIVE_LINK_NAME[ionice] = "${bindir}/ionice"
  222. ALTERNATIVE_LINK_NAME[kill] = "${base_bindir}/kill"
  223. ALTERNATIVE_${PN}-last = "last lastb"
  224. ALTERNATIVE_LINK_NAME[last] = "${bindir}/last"
  225. ALTERNATIVE_LINK_NAME[lastb] = "${bindir}/lastb"
  226. ALTERNATIVE_LINK_NAME[logger] = "${bindir}/logger"
  227. ALTERNATIVE_LINK_NAME[losetup] = "${base_sbindir}/losetup"
  228. ALTERNATIVE_LINK_NAME[mesg] = "${bindir}/mesg"
  229. ALTERNATIVE_LINK_NAME[mkswap] = "${base_sbindir}/mkswap"
  230. ALTERNATIVE_LINK_NAME[mcookie] = "${bindir}/mcookie"
  231. ALTERNATIVE_LINK_NAME[more] = "${base_bindir}/more"
  232. ALTERNATIVE_LINK_NAME[mount] = "${base_bindir}/mount"
  233. ALTERNATIVE_LINK_NAME[mountpoint] = "${base_bindir}/mountpoint"
  234. ALTERNATIVE_LINK_NAME[nologin] = "${base_sbindir}/nologin"
  235. ALTERNATIVE_LINK_NAME[nsenter] = "${bindir}/nsenter"
  236. ALTERNATIVE_LINK_NAME[pivot_root] = "${base_sbindir}/pivot_root"
  237. ALTERNATIVE_LINK_NAME[prlimit] = "${bindir}/prlimit"
  238. ALTERNATIVE_LINK_NAME[readprofile] = "${sbindir}/readprofile"
  239. ALTERNATIVE_LINK_NAME[renice] = "${bindir}/renice"
  240. ALTERNATIVE_LINK_NAME[rev] = "${bindir}/rev"
  241. ALTERNATIVE_LINK_NAME[rfkill] = "${sbindir}/rfkill"
  242. ALTERNATIVE_LINK_NAME[rtcwake] = "${sbindir}/rtcwake"
  243. ALTERNATIVE_LINK_NAME[setpriv] = "${bindir}/setpriv"
  244. ALTERNATIVE_LINK_NAME[setsid] = "${bindir}/setsid"
  245. ALTERNATIVE_LINK_NAME[su] = "${base_bindir}/su"
  246. ALTERNATIVE_LINK_NAME[sulogin] = "${base_sbindir}/sulogin"
  247. ALTERNATIVE_LINK_NAME[swapoff] = "${base_sbindir}/swapoff"
  248. ALTERNATIVE_LINK_NAME[swapon] = "${base_sbindir}/swapon"
  249. ALTERNATIVE_LINK_NAME[switch_root] = "${base_sbindir}/switch_root"
  250. ALTERNATIVE_LINK_NAME[taskset] = "${bindir}/taskset"
  251. ALTERNATIVE_LINK_NAME[umount] = "${base_bindir}/umount"
  252. ALTERNATIVE_LINK_NAME[unshare] = "${bindir}/unshare"
  253. ALTERNATIVE_LINK_NAME[utmpdump] = "${bindir}/utmpdump"
  254. ALTERNATIVE_LINK_NAME[uuidgen] = "${bindir}/uuidgen"
  255. ALTERNATIVE_LINK_NAME[wall] = "${bindir}/wall"
  256. ALTERNATIVE_${PN}-doc = "\
  257. blkid.8 eject.1 findfs.8 fsck.8 kill.1 last.1 lastb.1 libblkid.3 logger.1 mesg.1 \
  258. mountpoint.1 nologin.8 rfkill.8 sulogin.8 utmpdump.1 uuid.3 wall.1\
  259. "
  260. ALTERNATIVE_${PN}-doc += "${@bb.utils.contains('PACKAGECONFIG', 'pam', 'su.1', '', d)}"
  261. ALTERNATIVE_LINK_NAME[blkid.8] = "${mandir}/man8/blkid.8"
  262. ALTERNATIVE_LINK_NAME[eject.1] = "${mandir}/man1/eject.1"
  263. ALTERNATIVE_LINK_NAME[findfs.8] = "${mandir}/man8/findfs.8"
  264. ALTERNATIVE_LINK_NAME[fsck.8] = "${mandir}/man8/fsck.8"
  265. ALTERNATIVE_LINK_NAME[kill.1] = "${mandir}/man1/kill.1"
  266. ALTERNATIVE_LINK_NAME[last.1] = "${mandir}/man1/last.1"
  267. ALTERNATIVE_LINK_NAME[lastb.1] = "${mandir}/man1/lastb.1"
  268. ALTERNATIVE_LINK_NAME[libblkid.3] = "${mandir}/man3/libblkid.3"
  269. ALTERNATIVE_LINK_NAME[logger.1] = "${mandir}/man1/logger.1"
  270. ALTERNATIVE_LINK_NAME[mesg.1] = "${mandir}/man1/mesg.1"
  271. ALTERNATIVE_LINK_NAME[mountpoint.1] = "${mandir}/man1/mountpoint.1"
  272. ALTERNATIVE_LINK_NAME[nologin.8] = "${mandir}/man8/nologin.8"
  273. ALTERNATIVE_LINK_NAME[rfkill.8] = "${mandir}/man8/rfkill.8"
  274. ALTERNATIVE_LINK_NAME[setpriv.1] = "${mandir}/man1/setpriv.1"
  275. ALTERNATIVE_LINK_NAME[su.1] = "${mandir}/man1/su.1"
  276. ALTERNATIVE_LINK_NAME[sulogin.8] = "${mandir}/man8/sulogin.8"
  277. ALTERNATIVE_LINK_NAME[utmpdump.1] = "${mandir}/man1/utmpdump.1"
  278. ALTERNATIVE_LINK_NAME[uuid.3] = "${mandir}/man3/uuid.3"
  279. ALTERNATIVE_LINK_NAME[wall.1] = "${mandir}/man1/wall.1"
  280. BBCLASSEXTEND = "native nativesdk"
  281. PTEST_BINDIR = "1"
  282. do_compile_ptest() {
  283. oe_runmake buildtest-TESTS
  284. }
  285. do_install_ptest() {
  286. mkdir -p ${D}${PTEST_PATH}/tests/ts
  287. find . -name 'test*' -maxdepth 1 -type f -perm -111 -exec cp {} ${D}${PTEST_PATH} \;
  288. find ./.libs -name 'sample*' -maxdepth 1 -type f -perm -111 -exec cp {} ${D}${PTEST_PATH} \;
  289. find ./.libs -name 'test*' -maxdepth 1 -type f -perm -111 -exec cp {} ${D}${PTEST_PATH} \;
  290. cp ${S}/tests/*.sh ${D}${PTEST_PATH}/tests/
  291. cp -pR ${S}/tests/expected ${D}${PTEST_PATH}/tests/expected
  292. cp -pR ${S}/tests/ts ${D}${PTEST_PATH}/tests/
  293. cp ${WORKDIR}/build/config.h ${D}${PTEST_PATH}
  294. # The original paths of executables to be tested point to a local folder containing
  295. # the executables. We want to test the installed executables, not the local copies.
  296. # So strip the paths, the executables will be located via "which"
  297. sed -i \
  298. -e '/^TS_CMD/ s|$top_builddir/||g' \
  299. -e '/^TS_HELPER/ s|$top_builddir|${PTEST_PATH}|g' \
  300. ${D}${PTEST_PATH}/tests/commands.sh
  301. # Change 'if [ ! -x "$1" ]' to 'if [ ! -x "`which $1 2>/dev/null`"]'
  302. sed -i -e \
  303. '/^\tif[[:space:]]\[[[:space:]]![[:space:]]-x[[:space:]]"$1"/s|$1|`which $1 2>/dev/null`|g' \
  304. ${D}${PTEST_PATH}/tests/functions.sh
  305. # Running "kill" without the the complete path would use the shell's built-in kill
  306. sed -i -e \
  307. '/^TS_CMD_KILL/ s|kill|${PTEST_PATH}/bin/kill|g' \
  308. ${D}${PTEST_PATH}/tests/commands.sh
  309. sed -i 's|@base_sbindir@|${base_sbindir}|g' ${D}${PTEST_PATH}/run-ptest
  310. }