Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 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 | |
| 5 | SUMMARY = "Pseudo gives fake root capabilities to a normal user" |
| 6 | HOMEPAGE = "http://git.yoctoproject.org/cgit/cgit.cgi/pseudo" |
Andrew Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 7 | DESCRIPTION = "The pseudo utility offers a way to run commands in a virtualized root environment." |
Brad Bishop | 08902b0 | 2019-08-20 09:16:51 -0400 | [diff] [blame] | 8 | LIC_FILES_CHKSUM = "file://COPYING;md5=a1d8023a6f953ac6ea4af765ff62d574" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9 | SECTION = "base" |
| 10 | LICENSE = "LGPL2.1" |
| 11 | DEPENDS = "sqlite3 attr" |
| 12 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 13 | FILES:${PN} = "${prefix}/lib/pseudo/lib*/libpseudo.so ${bindir}/* ${localstatedir}/pseudo ${prefix}/var/pseudo" |
| 14 | INSANE_SKIP:${PN} += "libdir" |
| 15 | INSANE_SKIP:${PN}-dbg += "libdir" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 16 | |
| 17 | PROVIDES += "virtual/fakeroot" |
| 18 | |
| 19 | MAKEOPTS = "" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 20 | MAKEOPTS:class-native = "'RPATH=-Wl,--rpath=XORIGIN/../../../sqlite3-native/usr/lib/'" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 21 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 22 | inherit siteinfo pkgconfig |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 23 | |
| 24 | do_configure () { |
| 25 | : |
| 26 | } |
| 27 | |
| 28 | NO32LIBS ??= "1" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 29 | NO32LIBS:class-nativesdk = "1" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 30 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 31 | PSEUDO_EXTRA_OPTS ?= "--enable-force-async --without-passwd-fallback --enable-epoll --enable-xattr" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 32 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 33 | # Compile for the local machine arch... |
| 34 | do_compile () { |
| 35 | if [ "${SITEINFO_BITS}" = "64" ]; then |
Brad Bishop | 1d80a2e | 2019-11-15 16:35:03 -0500 | [diff] [blame] | 36 | ${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 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 37 | else |
Brad Bishop | 1d80a2e | 2019-11-15 16:35:03 -0500 | [diff] [blame] | 38 | ${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 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 39 | fi |
| 40 | oe_runmake ${MAKEOPTS} |
| 41 | } |
| 42 | do_compile[vardepsexclude] = "SITEINFO_BITS" |
| 43 | |
| 44 | maybe_make32() { |
| 45 | # We probably don't need to build 32-bit binaries. |
| 46 | make32=false |
| 47 | if [ "${SITEINFO_BITS}" = "64" ]; then |
| 48 | case "${NO32LIBS}" in |
| 49 | 0) make32=true |
| 50 | ;; |
| 51 | 1) make32=false |
| 52 | ;; |
| 53 | *) # If unset, build 32-bit if we think we can. |
| 54 | if [ -e "/usr/include/gnu/stubs-32.h" ]; then |
| 55 | make32=true |
| 56 | fi |
| 57 | ;; |
| 58 | esac |
| 59 | fi |
| 60 | if $make32; then |
| 61 | if ! [ -e "/usr/include/gnu/stubs-32.h" ]; then |
| 62 | warn_32bit_missing |
| 63 | else |
| 64 | bbnote "Attempting to build 32-bit libpseudo.so for ${PN}." |
| 65 | fi |
| 66 | else |
| 67 | bbnote "Building/installing only 64-bit libpseudo.so for ${PN}." |
| 68 | bbnote "If you need to run 32-bit executables, ensure that NO32LIBS is set to 0." |
| 69 | fi |
| 70 | } |
| 71 | maybe_make32[vardepsexclude] = "SITEINFO_BITS" |
| 72 | |
| 73 | warn_32bit_missing() { |
| 74 | bbwarn "Can't find stubs-32.h, but usually need it to build 32-bit libpseudo." |
| 75 | bbwarn "If the build fails, install 32-bit developer packages." |
| 76 | bbwarn "If you are using 32-bit binaries, the 32-bit libpseudo is NOT optional." |
| 77 | } |
| 78 | |
| 79 | # Two below are the same |
| 80 | # If necessary compile for the alternative machine arch. This is only |
| 81 | # necessary in a native build. |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 82 | do_compile:prepend:class-native () { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 83 | maybe_make32 |
| 84 | if $make32; then |
| 85 | # We need the 32-bit libpseudo on a 64-bit machine... |
| 86 | # Note that this is not well-tested outside of x86/x86_64. |
| 87 | |
| 88 | # if we're being rebuilt due to a dependency change, we need to make sure |
| 89 | # everything is clean before we configure and build -- if we haven't previously |
| 90 | # built this will fail and be ignored. |
| 91 | make ${MAKEOPTS} distclean || : |
| 92 | |
| 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 | save_traps=$(trap) |
| 95 | trap 'warn_32bit_missing' 0 |
| 96 | oe_runmake ${MAKEOPTS} libpseudo |
| 97 | eval "$save_traps" |
| 98 | # prevent it from removing the lib, but remove everything else |
| 99 | make 'LIB=foo' ${MAKEOPTS} distclean |
| 100 | fi |
| 101 | } |
| 102 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 103 | do_compile:prepend:class-nativesdk () { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 104 | maybe_make32 |
| 105 | if $make32; then |
| 106 | # We need the 32-bit libpseudo on a 64-bit machine. |
| 107 | # Note that this is not well-tested outside of x86/x86_64. |
| 108 | ./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 |
| 109 | oe_runmake ${MAKEOPTS} libpseudo |
| 110 | # prevent it from removing the lib, but remove everything else |
| 111 | make 'LIB=foo' ${MAKEOPTS} distclean |
| 112 | fi |
| 113 | } |
| 114 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 115 | do_compile:append:class-native () { |
Andrew Geissler | 5f35090 | 2021-07-23 13:09:54 -0400 | [diff] [blame] | 116 | if [ '${@bb.data.inherits_class('uninative', d)}' = 'True' ]; then |
| 117 | for i in PSEUDO_PORT_UNIX_SYNCFS PSEUDO_PORT_UIDS_GENERIC PSEUDO_PORT_LINUX_NEWCLONE PSEUDO_PORT_LINUX_XATTR PSEUDO_PORT_LINUX_STATVFS; do |
| 118 | grep $i.1 ${S}/pseudo_ports.h |
| 119 | if [ $? != 0 ]; then |
| 120 | echo "$i not enabled in pseudo which is incompatible with uninative" |
| 121 | exit 1 |
| 122 | fi |
| 123 | done |
| 124 | fi |
| 125 | } |
| 126 | |
| 127 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 128 | do_install () { |
| 129 | oe_runmake 'DESTDIR=${D}' ${MAKEOPTS} 'LIB=lib/pseudo/lib$(MARK64)' install |
| 130 | } |
| 131 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 132 | do_install:append:class-native () { |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 133 | chrpath ${D}${bindir}/pseudo -r `chrpath ${D}${bindir}/pseudo | cut -d = -f 2 | sed s/XORIGIN/\\$ORIGIN/` |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 134 | install -d ${D}${sysconfdir} |
| 135 | # The fallback files should never be modified |
| 136 | install -m 444 ${WORKDIR}/fallback-passwd ${D}${sysconfdir}/passwd |
| 137 | install -m 444 ${WORKDIR}/fallback-group ${D}${sysconfdir}/group |
| 138 | |
| 139 | # Two native/nativesdk entries below are the same |
| 140 | # If necessary install for the alternative machine arch. This is only |
| 141 | # necessary in a native build. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 142 | maybe_make32 |
| 143 | if $make32; then |
| 144 | mkdir -p ${D}${prefix}/lib/pseudo/lib |
| 145 | cp lib/pseudo/lib/libpseudo.so ${D}${prefix}/lib/pseudo/lib/. |
| 146 | fi |
| 147 | } |
| 148 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 149 | do_install:append:class-nativesdk () { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 150 | maybe_make32 |
| 151 | if $make32; then |
| 152 | mkdir -p ${D}${prefix}/lib/pseudo/lib |
| 153 | cp lib/pseudo/lib/libpseudo.so ${D}${prefix}/lib/pseudo/lib/. |
| 154 | fi |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 155 | chrpath -d ${D}${prefix}/lib/pseudo/lib*/libpseudo.so |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | BBCLASSEXTEND = "native nativesdk" |