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" |
| 7 | LIC_FILES_CHKSUM = "file://COPYING;md5=243b725d71bb5df4a1e5920b344b86ad" |
| 8 | SECTION = "base" |
| 9 | LICENSE = "LGPL2.1" |
| 10 | DEPENDS = "sqlite3 attr" |
| 11 | |
| 12 | FILES_${PN} = "${prefix}/lib/pseudo/lib*/libpseudo.so ${bindir}/* ${localstatedir}/pseudo ${prefix}/var/pseudo" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13 | INSANE_SKIP_${PN} += "libdir" |
| 14 | INSANE_SKIP_${PN}-dbg += "libdir" |
| 15 | |
| 16 | PROVIDES += "virtual/fakeroot" |
| 17 | |
| 18 | MAKEOPTS = "" |
| 19 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 20 | inherit siteinfo pkgconfig |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 21 | |
| 22 | do_configure () { |
| 23 | : |
| 24 | } |
| 25 | |
| 26 | NO32LIBS ??= "1" |
| 27 | NO32LIBS_class-nativesdk = "1" |
| 28 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 29 | 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] | 30 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 31 | # Compile for the local machine arch... |
| 32 | do_compile () { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 33 | SQLITE_LDADD='$(SQLITE)/$(SQLITE_LIB)/libsqlite3.a' |
| 34 | for sqlite_link_opt in $(pkg-config sqlite3 --libs --static) |
| 35 | do |
| 36 | case "$sqlite_link_opt" in |
| 37 | -lsqlite3) |
| 38 | ;; |
| 39 | -l*) |
| 40 | SQLITE_LDADD="${SQLITE_LDADD} ${sqlite_link_opt}" |
| 41 | ;; |
| 42 | *) |
| 43 | ;; |
| 44 | esac |
| 45 | done |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 46 | if [ "${SITEINFO_BITS}" = "64" ]; then |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 47 | ${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} --with-static-sqlite="$SQLITE_LDADD" --without-rpath |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 48 | else |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 49 | ${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} --with-static-sqlite="$SQLITE_LDADD" --without-rpath |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 50 | fi |
| 51 | oe_runmake ${MAKEOPTS} |
| 52 | } |
| 53 | do_compile[vardepsexclude] = "SITEINFO_BITS" |
| 54 | |
| 55 | maybe_make32() { |
| 56 | # We probably don't need to build 32-bit binaries. |
| 57 | make32=false |
| 58 | if [ "${SITEINFO_BITS}" = "64" ]; then |
| 59 | case "${NO32LIBS}" in |
| 60 | 0) make32=true |
| 61 | ;; |
| 62 | 1) make32=false |
| 63 | ;; |
| 64 | *) # If unset, build 32-bit if we think we can. |
| 65 | if [ -e "/usr/include/gnu/stubs-32.h" ]; then |
| 66 | make32=true |
| 67 | fi |
| 68 | ;; |
| 69 | esac |
| 70 | fi |
| 71 | if $make32; then |
| 72 | if ! [ -e "/usr/include/gnu/stubs-32.h" ]; then |
| 73 | warn_32bit_missing |
| 74 | else |
| 75 | bbnote "Attempting to build 32-bit libpseudo.so for ${PN}." |
| 76 | fi |
| 77 | else |
| 78 | bbnote "Building/installing only 64-bit libpseudo.so for ${PN}." |
| 79 | bbnote "If you need to run 32-bit executables, ensure that NO32LIBS is set to 0." |
| 80 | fi |
| 81 | } |
| 82 | maybe_make32[vardepsexclude] = "SITEINFO_BITS" |
| 83 | |
| 84 | warn_32bit_missing() { |
| 85 | bbwarn "Can't find stubs-32.h, but usually need it to build 32-bit libpseudo." |
| 86 | bbwarn "If the build fails, install 32-bit developer packages." |
| 87 | bbwarn "If you are using 32-bit binaries, the 32-bit libpseudo is NOT optional." |
| 88 | } |
| 89 | |
| 90 | # Two below are the same |
| 91 | # If necessary compile for the alternative machine arch. This is only |
| 92 | # necessary in a native build. |
| 93 | do_compile_prepend_class-native () { |
| 94 | maybe_make32 |
| 95 | if $make32; then |
| 96 | # We need the 32-bit libpseudo on a 64-bit machine... |
| 97 | # Note that this is not well-tested outside of x86/x86_64. |
| 98 | |
| 99 | # if we're being rebuilt due to a dependency change, we need to make sure |
| 100 | # everything is clean before we configure and build -- if we haven't previously |
| 101 | # built this will fail and be ignored. |
| 102 | make ${MAKEOPTS} distclean || : |
| 103 | |
| 104 | ./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 |
| 105 | save_traps=$(trap) |
| 106 | trap 'warn_32bit_missing' 0 |
| 107 | oe_runmake ${MAKEOPTS} libpseudo |
| 108 | eval "$save_traps" |
| 109 | # prevent it from removing the lib, but remove everything else |
| 110 | make 'LIB=foo' ${MAKEOPTS} distclean |
| 111 | fi |
| 112 | } |
| 113 | |
| 114 | do_compile_prepend_class-nativesdk () { |
| 115 | maybe_make32 |
| 116 | if $make32; then |
| 117 | # We need the 32-bit libpseudo on a 64-bit machine. |
| 118 | # Note that this is not well-tested outside of x86/x86_64. |
| 119 | ./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 |
| 120 | oe_runmake ${MAKEOPTS} libpseudo |
| 121 | # prevent it from removing the lib, but remove everything else |
| 122 | make 'LIB=foo' ${MAKEOPTS} distclean |
| 123 | fi |
| 124 | } |
| 125 | |
| 126 | do_install () { |
| 127 | oe_runmake 'DESTDIR=${D}' ${MAKEOPTS} 'LIB=lib/pseudo/lib$(MARK64)' install |
| 128 | } |
| 129 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 130 | do_install_append_class-native () { |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 131 | install -d ${D}${sysconfdir} |
| 132 | # The fallback files should never be modified |
| 133 | install -m 444 ${WORKDIR}/fallback-passwd ${D}${sysconfdir}/passwd |
| 134 | install -m 444 ${WORKDIR}/fallback-group ${D}${sysconfdir}/group |
| 135 | |
| 136 | # Two native/nativesdk entries below are the same |
| 137 | # If necessary install for the alternative machine arch. This is only |
| 138 | # necessary in a native build. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 139 | maybe_make32 |
| 140 | if $make32; then |
| 141 | mkdir -p ${D}${prefix}/lib/pseudo/lib |
| 142 | cp lib/pseudo/lib/libpseudo.so ${D}${prefix}/lib/pseudo/lib/. |
| 143 | fi |
| 144 | } |
| 145 | |
| 146 | do_install_append_class-nativesdk () { |
| 147 | maybe_make32 |
| 148 | if $make32; then |
| 149 | mkdir -p ${D}${prefix}/lib/pseudo/lib |
| 150 | cp lib/pseudo/lib/libpseudo.so ${D}${prefix}/lib/pseudo/lib/. |
| 151 | fi |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 152 | chrpath -d ${D}${prefix}/lib/pseudo/lib*/libpseudo.so |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 153 | } |
| 154 | |
| 155 | BBCLASSEXTEND = "native nativesdk" |