Bitbake recipe not able to create new directory in /var/lib/

This is the postgresql_9.6.17.bb recipe I tried building into my custom image which is based on torizon-core-docker (dunfell-5.x.y)

SUMMARY = "PostgreSQL is a powerful, open source relational database system."
DESCRIPTION = "\
    PostgreSQL is an advanced Object-Relational database management system \
    (DBMS) that supports almost all SQL constructs (including \
    transactions, subselects and user-defined types and functions). The \
    postgresql package includes the client programs and libraries that \
    you'll need to access a PostgreSQL DBMS server.  These PostgreSQL \
    client programs are programs that directly manipulate the internal \
    structure of PostgreSQL databases on a PostgreSQL server. These client \
    programs can be located on the same machine with the PostgreSQL \
    server, or may be on a remote machine which accesses a PostgreSQL \
    server over a network connection. This package contains the docs \
    in HTML for the whole package, as well as command-line utilities for \
    managing PostgreSQL databases on a PostgreSQL server. \
    \
    If you want to manipulate a PostgreSQL database on a local or remote \
    PostgreSQL server, you need this package. You also need to install \
    this package if you're installing the postgresql-server package. \
"
HOMEPAGE = "http://www.postgresql.com"
LICENSE = "BSD"
LIC_FILES_CHKSUM = "file://COPYRIGHT;md5=fc4ce21960f0c561460d750bc270d11f"
DEPENDS = "zlib readline tzcode-native"

ARM_INSTRUCTION_SET = "arm"

SRC_URI = "http://ftp.postgresql.org/pub/source/v${PV}/${BP}.tar.bz2 \
    file://postgresql.init \
"
SRC_URI[md5sum] = "4a12dd9e2afe140a8d2d4366471b075f"
SRC_URI[sha256sum] = "f6e1e32d32545f97c066f3c19f4d58dfab1205c01252cf85c5c92294ace1a0c2"

inherit autotools useradd

USERADD_PACKAGES = "${PN}"

USERADD_PARAM_${PN} = "postgres"

EXTRA_OECONF += "--enable-thread-safety --disable-rpath \
    --datadir=${datadir}/${BPN} \
    --sysconfdir=${sysconfdir}/${BPN}/9.6/main \
"

do_install_append() {
    # /etc/init.d
    install -d ${D}${sysconfdir}/init.d
    
    # copy postgresql.init to /etc/init.d/postgresql
    install -m 0755 ${WORKDIR}/${BPN}.init ${D}${sysconfdir}/init.d/${BPN}

    # /etc/postgresql/9.6/main
    install -d -m 700 ${D}${sysconfdir}/${BPN}/9.6/main

    # data directory - /var/lib/postgresql/9.6/main
    install -d -m 700 ${D}${localstatedir}/lib/${BPN}/9.6/main
    chown -R postgres:postgres ${D}${localstatedir}/lib/${BPN}/9.6/main   
}

FILES_${PN} += "${localstatedir}/lib/${BPN}/9.6/main \
"

The recipe gets built successfully and the package is available in the final image as well.

The only problem is that it is not able to create a new directory /var/lib/postgresql/9.6/main in the final rootfs of the image. This is verified after updating the final image in the toradex module using ostree as mentioned in OSTree Update From a Local TorizonCore Build.

Also note that the install command to create directory /etc/init.d and /etc/postgresql/9.6/main works fine as these directories are present in the updated rootfs.

Hi Dishant,

Can you pease tell us why you need to build Torizon with postgresql.

With Torizon, to ease out development effort it is recommended to use postgresql from docker. In such condition you do not need to build/compile full image by yourself, saving lot of time for you. As this is already supported in docker for arm.

Please check below link

https://hub.docker.com/_/postgres

Best Regards

Ritesh Kumar