[yocto] [bitbake-devel] Yocto: Add custom user to custom group in bitbake recipe

Parthiban Nallathambi pn at denx.de
Fri Mar 2 04:58:35 PST 2018


Hi Maxim,

space.bb --> chromium recipe in 
https://github.com/OSSystems/meta-browser/tree/master/recipes-browser/chromium

app.bb --> http-server.bb attached

I have created a group "www" in http-server_0.10.0.bb and trying to add 
"chromium" user to this group in chromium-x11_%.bbappend.

But the useradd command is failed: group 'www' does not exit.


On 03/02/2018 01:29 PM, Maxin B. John wrote:
> Hi Parthiban,
> 
> On Fri, Mar 02, 2018 at 12:29:25PM +0100, Parthiban Nallathambi wrote:
>> Hello All,
>>
>> I have created a custom group e.g "grp1" in my application recipe say
>> "app.bb".
>>
>> GROUPADD_PARAM_${PN} = "grp1"
>>
>> I am trying add my custom user e.g: "user1" to this group "grp1" in
>> "space.bb".
>>
>> USERADD_PARAM_${PN} = "-d ${localstatedir}/lib/space/ -s /bin/false -G grp1
>> -U user1"
>>
>> The useradd command failed saying the "useradd: group 'grp1' does not
>> exist". I have also tried adding DEPENDS_${PN} = "app" in space.bb, but it
>> doesn't help.
>>
>> How can I add my custom user to my custom group in bitbake recipe?
> 
> Please share your sample recipes here. It will be helpful to debug the problem.
> 
>> Question in Stackoverflow: https://stackoverflow.com/questions/49068076/yocto-add-custom-user-to-custom-group
>>
>> -- 
>> Thanks,
>> Parthiban Nallathambi
> 
> Best Regards,
> Maxin
> 

-- 
Thanks,
Parthiban Nallathambi

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
-------------- next part --------------
inherit systemd
inherit useradd

# skip runtime dependency on bash
# since we don't use the wrapper script
RDEPENDS_${PN}_remove = "bash"

FILESEXTRAPATHS_append := "${THISDIR}/files:"

SRC_URI += " \
     file://chromium-start \
     file://chromium.service \
     file://chromium-tty.rules \
     "

do_install_append() {

    install -d ${D}${systemd_unitdir}/system
    install -m 755 ${WORKDIR}/chromium-start  ${D}${bindir}/
    install -m 644 ${WORKDIR}/chromium.service ${D}${systemd_unitdir}/system

    install -d ${D}${sysconfdir}/udev/rules.d
    install -m 644 ${WORKDIR}/chromium-tty.rules ${D}${sysconfdir}/udev/rules.d

    rm ${D}${libdir}/chromium/chromium-wrapper
    rm ${D}${bindir}/chromium
    ln -s ${libdir}/chromium/chromium-bin ${D}${bindir}/chromium
}

SYSTEMD_SERVICE_${PN} = "chromium.service"
FILES_${PN} += " ${bindir}/chromium-start ${sysconfdir}/udev/rules.d/chromium-tty.rules"

USERADD_PACKAGES = "${PN}"
USERADD_PARAM_${PN} = "-d ${localstatedir}/lib/chromium -s /bin/false -G tty,video,input,www,www-data -U chromium"
-------------- next part --------------
SUMMARY = "http-server: a command-line http server"
DESCRIPTION = "http-server is a simple, zero-configuration command-line \
http server. It is powerful enough for production usage, but it's simple \
and hackable enough to be used for testing, local development, and learning.\
"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE;md5=8805b6f8b8c4f6ceff520f4c3aaa8094"

SRC_URI = "npm://registry.npmjs.org;name=http-server;version=${PV} \
	file://http-server.service \
	file://ssc_gen.sh \
	"
inherit npm
# Must be set after inherit npm since that itself sets S
S = "${WORKDIR}/npmpkg"
DEPENDS_${PN} = "nodejs-npm"
RDEPENDS_${PN}-ecstatic = "bash"

LICENSE_${PN} = "MIT"

inherit systemd
inherit useradd
do_install_append() {

    install -d ${D}${systemd_unitdir}/system
    install -m 644 ${WORKDIR}/http-server.service ${D}${systemd_unitdir}/system
    install -m 755 ${WORKDIR}/ssc_gen.sh ${D}${bindir}
}

SYSTEMD_SERVICE_${PN} = "http-server.service"
USERADD_PACKAGES = "${PN}"
GROUPADD_PARAM_${PN} = "www"
USERADD_PARAM_${PN} = "-d ${localstatedir}/lib/chromium -s /bin/false -G www-data -U www"


More information about the yocto mailing list