blob: 18ce9f92596296dc8de670ffd0af68b4c65edb81 [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"
7LIC_FILES_CHKSUM = "file://COPYING;md5=243b725d71bb5df4a1e5920b344b86ad"
8SECTION = "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 = ""
19
20inherit siteinfo
21
22do_configure () {
23 :
24}
25
26NO32LIBS ??= "1"
27NO32LIBS_class-nativesdk = "1"
28
Patrick Williamsc0f7c042017-02-23 20:41:17 -060029PSEUDO_EXTRA_OPTS ?= "--enable-force-async --without-passwd-fallback"
30
Patrick Williamsc124f4f2015-09-15 14:41:29 -050031# Compile for the local machine arch...
32do_compile () {
33 if [ "${SITEINFO_BITS}" = "64" ]; then
34 ${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} --enable-static-sqlite --without-rpath
35 else
36 ${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} --enable-static-sqlite --without-rpath
37 fi
38 oe_runmake ${MAKEOPTS}
39}
40do_compile[vardepsexclude] = "SITEINFO_BITS"
41
42maybe_make32() {
43 # We probably don't need to build 32-bit binaries.
44 make32=false
45 if [ "${SITEINFO_BITS}" = "64" ]; then
46 case "${NO32LIBS}" in
47 0) make32=true
48 ;;
49 1) make32=false
50 ;;
51 *) # If unset, build 32-bit if we think we can.
52 if [ -e "/usr/include/gnu/stubs-32.h" ]; then
53 make32=true
54 fi
55 ;;
56 esac
57 fi
58 if $make32; then
59 if ! [ -e "/usr/include/gnu/stubs-32.h" ]; then
60 warn_32bit_missing
61 else
62 bbnote "Attempting to build 32-bit libpseudo.so for ${PN}."
63 fi
64 else
65 bbnote "Building/installing only 64-bit libpseudo.so for ${PN}."
66 bbnote "If you need to run 32-bit executables, ensure that NO32LIBS is set to 0."
67 fi
68}
69maybe_make32[vardepsexclude] = "SITEINFO_BITS"
70
71warn_32bit_missing() {
72 bbwarn "Can't find stubs-32.h, but usually need it to build 32-bit libpseudo."
73 bbwarn "If the build fails, install 32-bit developer packages."
74 bbwarn "If you are using 32-bit binaries, the 32-bit libpseudo is NOT optional."
75}
76
77# Two below are the same
78# If necessary compile for the alternative machine arch. This is only
79# necessary in a native build.
80do_compile_prepend_class-native () {
81 maybe_make32
82 if $make32; then
83 # We need the 32-bit libpseudo on a 64-bit machine...
84 # Note that this is not well-tested outside of x86/x86_64.
85
86 # if we're being rebuilt due to a dependency change, we need to make sure
87 # everything is clean before we configure and build -- if we haven't previously
88 # built this will fail and be ignored.
89 make ${MAKEOPTS} distclean || :
90
91 ./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
92 save_traps=$(trap)
93 trap 'warn_32bit_missing' 0
94 oe_runmake ${MAKEOPTS} libpseudo
95 eval "$save_traps"
96 # prevent it from removing the lib, but remove everything else
97 make 'LIB=foo' ${MAKEOPTS} distclean
98 fi
99}
100
101do_compile_prepend_class-nativesdk () {
102 maybe_make32
103 if $make32; then
104 # We need the 32-bit libpseudo on a 64-bit machine.
105 # Note that this is not well-tested outside of x86/x86_64.
106 ./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
107 oe_runmake ${MAKEOPTS} libpseudo
108 # prevent it from removing the lib, but remove everything else
109 make 'LIB=foo' ${MAKEOPTS} distclean
110 fi
111}
112
113do_install () {
114 oe_runmake 'DESTDIR=${D}' ${MAKEOPTS} 'LIB=lib/pseudo/lib$(MARK64)' install
115}
116
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500117do_install_append_class-native () {
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600118 install -d ${D}${sysconfdir}
119 # The fallback files should never be modified
120 install -m 444 ${WORKDIR}/fallback-passwd ${D}${sysconfdir}/passwd
121 install -m 444 ${WORKDIR}/fallback-group ${D}${sysconfdir}/group
122
123 # Two native/nativesdk entries below are the same
124 # If necessary install for the alternative machine arch. This is only
125 # necessary in a native build.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500126 maybe_make32
127 if $make32; then
128 mkdir -p ${D}${prefix}/lib/pseudo/lib
129 cp lib/pseudo/lib/libpseudo.so ${D}${prefix}/lib/pseudo/lib/.
130 fi
131}
132
133do_install_append_class-nativesdk () {
134 maybe_make32
135 if $make32; then
136 mkdir -p ${D}${prefix}/lib/pseudo/lib
137 cp lib/pseudo/lib/libpseudo.so ${D}${prefix}/lib/pseudo/lib/.
138 fi
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600139 chrpath -d ${D}${prefix}/lib/pseudo/lib*/libpseudo.so
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500140}
141
142BBCLASSEXTEND = "native nativesdk"