pseudo.inc 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. # Note: Due to the bitbake wrapper script, making changes to pseudo can be
  2. # difficult. To work around the current version of the wrapper use:
  3. # BBFETCH2=True PSEUDO_BUILD=1 ../bitbake/bin/bitbake pseudo-native [-c CMD]
  4. SUMMARY = "Pseudo gives fake root capabilities to a normal user"
  5. HOMEPAGE = "http://git.yoctoproject.org/cgit/cgit.cgi/pseudo"
  6. DESCRIPTION = "The pseudo utility offers a way to run commands in a virtualized root environment."
  7. LIC_FILES_CHKSUM = "file://COPYING;md5=a1d8023a6f953ac6ea4af765ff62d574"
  8. SECTION = "base"
  9. LICENSE = "LGPL-2.1-only"
  10. DEPENDS = "sqlite3 attr"
  11. FILES:${PN} = "${prefix}/lib/pseudo/lib*/libpseudo.so ${bindir}/* ${localstatedir}/pseudo ${prefix}/var/pseudo"
  12. INSANE_SKIP:${PN} += "libdir"
  13. INSANE_SKIP:${PN}-dbg += "libdir"
  14. PROVIDES += "virtual/fakeroot"
  15. MAKEOPTS = ""
  16. MAKEOPTS:class-native = "'RPATH=-Wl,--rpath=XORIGIN/../../../sqlite3-native/usr/lib/'"
  17. inherit siteinfo pkgconfig
  18. do_configure () {
  19. :
  20. }
  21. NO32LIBS ??= "1"
  22. NO32LIBS:class-nativesdk = "1"
  23. PSEUDO_EXTRA_OPTS ?= "--enable-force-async --without-passwd-fallback --enable-epoll --enable-xattr"
  24. # Compile for the local machine arch...
  25. do_compile () {
  26. if [ "${SITEINFO_BITS}" = "64" ]; then
  27. ${S}/configure ${PSEUDO_EXTRA_OPTS} --prefix=${prefix} --libdir=${prefix}/lib/pseudo/lib${SITEINFO_BITS} --with-sqlite-lib=${baselib} --with-sqlite=${STAGING_DIR_TARGET}${exec_prefix} --cflags="${CFLAGS}" --bits=${SITEINFO_BITS} --without-rpath
  28. else
  29. ${S}/configure ${PSEUDO_EXTRA_OPTS} --prefix=${prefix} --libdir=${prefix}/lib/pseudo/lib --with-sqlite-lib=${baselib} --with-sqlite=${STAGING_DIR_TARGET}${exec_prefix} --cflags="${CFLAGS}" --bits=${SITEINFO_BITS} --without-rpath
  30. fi
  31. oe_runmake ${MAKEOPTS}
  32. }
  33. do_compile[vardepsexclude] = "SITEINFO_BITS"
  34. maybe_make32() {
  35. # We probably don't need to build 32-bit binaries.
  36. make32=false
  37. if [ "${SITEINFO_BITS}" = "64" ]; then
  38. case "${NO32LIBS}" in
  39. 0) make32=true
  40. ;;
  41. 1) make32=false
  42. ;;
  43. *) # If unset, build 32-bit if we think we can.
  44. if [ -e "/usr/include/gnu/stubs-32.h" ]; then
  45. make32=true
  46. fi
  47. ;;
  48. esac
  49. fi
  50. if $make32; then
  51. if ! [ -e "/usr/include/gnu/stubs-32.h" ]; then
  52. warn_32bit_missing
  53. else
  54. bbnote "Attempting to build 32-bit libpseudo.so for ${PN}."
  55. fi
  56. else
  57. bbnote "Building/installing only 64-bit libpseudo.so for ${PN}."
  58. bbnote "If you need to run 32-bit executables, ensure that NO32LIBS is set to 0."
  59. fi
  60. }
  61. maybe_make32[vardepsexclude] = "SITEINFO_BITS"
  62. warn_32bit_missing() {
  63. bbwarn "Can't find stubs-32.h, but usually need it to build 32-bit libpseudo."
  64. bbwarn "If the build fails, install 32-bit developer packages."
  65. bbwarn "If you are using 32-bit binaries, the 32-bit libpseudo is NOT optional."
  66. }
  67. # Two below are the same
  68. # If necessary compile for the alternative machine arch. This is only
  69. # necessary in a native build.
  70. do_compile:prepend:class-native () {
  71. maybe_make32
  72. if $make32; then
  73. # We need the 32-bit libpseudo on a 64-bit machine...
  74. # Note that this is not well-tested outside of x86/x86_64.
  75. # if we're being rebuilt due to a dependency change, we need to make sure
  76. # everything is clean before we configure and build -- if we haven't previously
  77. # built this will fail and be ignored.
  78. make ${MAKEOPTS} distclean || :
  79. ./configure ${PSEUDO_EXTRA_OPTS} --prefix=${prefix} --libdir=${prefix}/lib/pseudo/lib --with-sqlite-lib=${baselib} --with-sqlite=${STAGING_DIR_TARGET}${exec_prefix} --bits=32 --without-rpath
  80. save_traps=$(trap)
  81. trap 'warn_32bit_missing' 0
  82. oe_runmake ${MAKEOPTS} libpseudo
  83. eval "$save_traps"
  84. # prevent it from removing the lib, but remove everything else
  85. make 'LIB=foo' ${MAKEOPTS} distclean
  86. fi
  87. }
  88. do_compile:prepend:class-nativesdk () {
  89. maybe_make32
  90. if $make32; then
  91. # We need the 32-bit libpseudo on a 64-bit machine.
  92. # Note that this is not well-tested outside of x86/x86_64.
  93. ./configure ${PSEUDO_EXTRA_OPTS} --prefix=${prefix} --libdir=${prefix}/lib/pseudo/lib --with-sqlite-lib=${baselib} --with-sqlite=${STAGING_DIR_TARGET}${exec_prefix} --bits=32 --without-rpath
  94. oe_runmake ${MAKEOPTS} libpseudo
  95. # prevent it from removing the lib, but remove everything else
  96. make 'LIB=foo' ${MAKEOPTS} distclean
  97. fi
  98. }
  99. do_compile:append:class-native () {
  100. if [ '${@bb.data.inherits_class('uninative', d)}' = 'True' ]; then
  101. for i in PSEUDO_PORT_UNIX_SYNCFS PSEUDO_PORT_UIDS_GENERIC PSEUDO_PORT_LINUX_NEWCLONE PSEUDO_PORT_LINUX_XATTR PSEUDO_PORT_LINUX_STATVFS; do
  102. grep $i.1 ${S}/pseudo_ports.h
  103. if [ $? != 0 ]; then
  104. echo "$i not enabled in pseudo which is incompatible with uninative"
  105. exit 1
  106. fi
  107. done
  108. fi
  109. }
  110. do_install () {
  111. oe_runmake 'DESTDIR=${D}' ${MAKEOPTS} 'LIB=lib/pseudo/lib$(MARK64)' install
  112. }
  113. do_install:append:class-native () {
  114. chrpath ${D}${bindir}/pseudo -r `chrpath ${D}${bindir}/pseudo | cut -d = -f 2 | sed s/XORIGIN/\\$ORIGIN/`
  115. install -d ${D}${sysconfdir}
  116. # The fallback files should never be modified
  117. install -m 444 ${UNPACKDIR}/fallback-passwd ${D}${sysconfdir}/passwd
  118. install -m 444 ${UNPACKDIR}/fallback-group ${D}${sysconfdir}/group
  119. # Two native/nativesdk entries below are the same
  120. # If necessary install for the alternative machine arch. This is only
  121. # necessary in a native build.
  122. maybe_make32
  123. if $make32; then
  124. mkdir -p ${D}${prefix}/lib/pseudo/lib
  125. cp lib/pseudo/lib/libpseudo.so ${D}${prefix}/lib/pseudo/lib/.
  126. fi
  127. }
  128. do_install:append:class-nativesdk () {
  129. maybe_make32
  130. if $make32; then
  131. mkdir -p ${D}${prefix}/lib/pseudo/lib
  132. cp lib/pseudo/lib/libpseudo.so ${D}${prefix}/lib/pseudo/lib/.
  133. fi
  134. chrpath -d ${D}${prefix}/lib/pseudo/lib*/libpseudo.so
  135. }
  136. BBCLASSEXTEND = "native nativesdk"