blob: 50e30064bdeb0b557963f9d410658c5e546bd91b [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001# 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
5SUMMARY = "Pseudo gives fake root capabilities to a normal user"
6HOMEPAGE = "http://git.yoctoproject.org/cgit/cgit.cgi/pseudo"
Brad Bishop08902b02019-08-20 09:16:51 -04007LIC_FILES_CHKSUM = "file://COPYING;md5=a1d8023a6f953ac6ea4af765ff62d574"
Patrick Williamsc124f4f2015-09-15 14:41:29 -05008SECTION = "base"
9LICENSE = "LGPL2.1"
10DEPENDS = "sqlite3 attr"
11
12FILES_${PN} = "${prefix}/lib/pseudo/lib*/libpseudo.so ${bindir}/* ${localstatedir}/pseudo ${prefix}/var/pseudo"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050013INSANE_SKIP_${PN} += "libdir"
14INSANE_SKIP_${PN}-dbg += "libdir"
15
16PROVIDES += "virtual/fakeroot"
17
18MAKEOPTS = ""
Andrew Geissler82c905d2020-04-13 13:39:40 -050019MAKEOPTS_class-native = "'RPATH=-Wl,--rpath=XORIGIN/../../../sqlite3-native/usr/lib/'"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050020
Brad Bishop19323692019-04-05 15:28:33 -040021inherit siteinfo pkgconfig
Patrick Williamsc124f4f2015-09-15 14:41:29 -050022
23do_configure () {
24 :
25}
26
27NO32LIBS ??= "1"
28NO32LIBS_class-nativesdk = "1"
29
Brad Bishop316dfdd2018-06-25 12:45:53 -040030PSEUDO_EXTRA_OPTS ?= "--enable-force-async --without-passwd-fallback --enable-epoll --enable-xattr"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060031
Patrick Williamsc124f4f2015-09-15 14:41:29 -050032# Compile for the local machine arch...
33do_compile () {
34 if [ "${SITEINFO_BITS}" = "64" ]; then
Brad Bishop1d80a2e2019-11-15 16:35:03 -050035 ${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 Williamsc124f4f2015-09-15 14:41:29 -050036 else
Brad Bishop1d80a2e2019-11-15 16:35:03 -050037 ${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 Williamsc124f4f2015-09-15 14:41:29 -050038 fi
39 oe_runmake ${MAKEOPTS}
40}
41do_compile[vardepsexclude] = "SITEINFO_BITS"
42
43maybe_make32() {
44 # We probably don't need to build 32-bit binaries.
45 make32=false
46 if [ "${SITEINFO_BITS}" = "64" ]; then
47 case "${NO32LIBS}" in
48 0) make32=true
49 ;;
50 1) make32=false
51 ;;
52 *) # If unset, build 32-bit if we think we can.
53 if [ -e "/usr/include/gnu/stubs-32.h" ]; then
54 make32=true
55 fi
56 ;;
57 esac
58 fi
59 if $make32; then
60 if ! [ -e "/usr/include/gnu/stubs-32.h" ]; then
61 warn_32bit_missing
62 else
63 bbnote "Attempting to build 32-bit libpseudo.so for ${PN}."
64 fi
65 else
66 bbnote "Building/installing only 64-bit libpseudo.so for ${PN}."
67 bbnote "If you need to run 32-bit executables, ensure that NO32LIBS is set to 0."
68 fi
69}
70maybe_make32[vardepsexclude] = "SITEINFO_BITS"
71
72warn_32bit_missing() {
73 bbwarn "Can't find stubs-32.h, but usually need it to build 32-bit libpseudo."
74 bbwarn "If the build fails, install 32-bit developer packages."
75 bbwarn "If you are using 32-bit binaries, the 32-bit libpseudo is NOT optional."
76}
77
78# Two below are the same
79# If necessary compile for the alternative machine arch. This is only
80# necessary in a native build.
81do_compile_prepend_class-native () {
82 maybe_make32
83 if $make32; then
84 # We need the 32-bit libpseudo on a 64-bit machine...
85 # Note that this is not well-tested outside of x86/x86_64.
86
87 # if we're being rebuilt due to a dependency change, we need to make sure
88 # everything is clean before we configure and build -- if we haven't previously
89 # built this will fail and be ignored.
90 make ${MAKEOPTS} distclean || :
91
92 ./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
93 save_traps=$(trap)
94 trap 'warn_32bit_missing' 0
95 oe_runmake ${MAKEOPTS} libpseudo
96 eval "$save_traps"
97 # prevent it from removing the lib, but remove everything else
98 make 'LIB=foo' ${MAKEOPTS} distclean
99 fi
100}
101
102do_compile_prepend_class-nativesdk () {
103 maybe_make32
104 if $make32; then
105 # We need the 32-bit libpseudo on a 64-bit machine.
106 # Note that this is not well-tested outside of x86/x86_64.
107 ./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
108 oe_runmake ${MAKEOPTS} libpseudo
109 # prevent it from removing the lib, but remove everything else
110 make 'LIB=foo' ${MAKEOPTS} distclean
111 fi
112}
113
114do_install () {
115 oe_runmake 'DESTDIR=${D}' ${MAKEOPTS} 'LIB=lib/pseudo/lib$(MARK64)' install
116}
117
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500118do_install_append_class-native () {
Andrew Geissler82c905d2020-04-13 13:39:40 -0500119 chrpath ${D}${bindir}/pseudo -r `chrpath ${D}${bindir}/pseudo | cut -d = -f 2 | sed s/XORIGIN/\\$ORIGIN/`
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600120 install -d ${D}${sysconfdir}
121 # The fallback files should never be modified
122 install -m 444 ${WORKDIR}/fallback-passwd ${D}${sysconfdir}/passwd
123 install -m 444 ${WORKDIR}/fallback-group ${D}${sysconfdir}/group
124
125 # Two native/nativesdk entries below are the same
126 # If necessary install for the alternative machine arch. This is only
127 # necessary in a native build.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500128 maybe_make32
129 if $make32; then
130 mkdir -p ${D}${prefix}/lib/pseudo/lib
131 cp lib/pseudo/lib/libpseudo.so ${D}${prefix}/lib/pseudo/lib/.
132 fi
133}
134
135do_install_append_class-nativesdk () {
136 maybe_make32
137 if $make32; then
138 mkdir -p ${D}${prefix}/lib/pseudo/lib
139 cp lib/pseudo/lib/libpseudo.so ${D}${prefix}/lib/pseudo/lib/.
140 fi
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600141 chrpath -d ${D}${prefix}/lib/pseudo/lib*/libpseudo.so
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500142}
143
144BBCLASSEXTEND = "native nativesdk"