Workflow for persistent data across updates (internal golden updates)

Developers are working on a new internal golden image (NO MENDER). They have a place where user data files exists and persist. How do they make the transition from golden image (NO MENDER CLIENT or /data directory) to a Mender golden image?

Are they to create a /data directory in the internal golden image? Will that stay when making a mender golden image?

I guess the basic question can be summed up by asking… Where do developers write persistent data to on a NON MENDER image?

Ryan

Hi @ryanbedford if you put the files in /data in your non-mender golden image, mender-convert will arrange for them to be in the /data partition of the converted image.
Drew

Awesome @drewmoseley! Makes sense, thank you!

@drewmoseley So if I put a /data directory in the rootfs overlay, will files in there get deployed out as well?

Indeed it should @ryanbedford

Hi,

How do you add the persistent config files to /data?

I did this …

do_install_append () {

 install -d ${D}${sysconfdir}/init.d
 install -m 0755  ${WORKDIR}/canstartup.sh	${D}${sysconfdir}/init.d
 install -m 0755  ${WORKDIR}/seccwifiAPsetup.sh	${D}${sysconfdir}/init.d
 install -m 0755  ${WORKDIR}/nvm.sh	        ${D}${sysconfdir}/init.d

 install -d ${D}${sysconfdir}/emmc
 install -m 0755  ${WORKDIR}/install_emmc.sh	${D}${sysconfdir}/emmc

 install -d ${D}${sysconfdir}/json
 install -m 0755 ${WORKDIR}/config.json ${D}${sysconfdir}/json
 install -m 0755 ${WORKDIR}/productionData.json ${D}${sysconfdir}/json

 install -d ${D}/data
 ln -s ${D}${sysconfdir}/json ${D}/data/json

 update-rc.d -r ${D} nvm.sh start 50 5 .		
 update-rc.d -r ${D} canstartup.sh start 51 5 .
 update-rc.d -r ${D} seccwifiAPsetup.sh start 52 5 .
}

FILES_${PN} += "${D}/data \
		${D}/data/json \
"

But, I got this error:

ERROR: initscripts-1.0-r155 do_package: QA Issue: initscripts: Files/directories were installed but not shipped in any package:
  /data
  /data/json
Please set FILES such that these items are packaged. Alternatively if they are unneeded, avoid installing them or delete them within do_install.
initscripts: 2 installed and not shipped files. [installed-vs-shipped]
ERROR: initscripts-1.0-r155 do_package: Fatal QA errors found, failing task.
ERROR: Logfile of failure stored in: /home/herodev/hero-yocto-mender/build/tmp/work/hero_secc-poky-linux-gnueabi/initscripts/1.0-r155/temp/log.do_package.16886
ERROR: Task (/home/herodev/hero-yocto-mender/sources/poky/meta/recipes-core/initscripts/initscripts_1.0.bb:do_package) failed with exit code '1'

The FILES variable does not use ${D}. Just remove it, and you should be fine.

1 Like

Thank you very much for your quick reply! :slightly_smiling_face:

I think this should be the proper implementation:

SRC_URI += " file://config.json \
             file://productionData.json \
"

FILES_${PN} = "/var/lib/hero-secc/factorydata \
               /var/lib/hero-secc/userdata \
               /data/hero-secc/factorydata \
               /data/hero-secc/userdata \		        
"

do_install() {
	install -d -m 755 ${D}/data/hero-secc/factorydata
	install -m 755 ${WORKDIR}/productionData.json ${D}/data/hero-secc/factorydata
	install -d -m 755 ${D}/var/lib/hero-secc/factorydata
	ln -s /data/hero-secc/factorydata ${D}/var/lib/hero-secc/factorydata

	install -d -m 755 ${D}/data/hero-secc/userdata
	install -m 755 ${WORKDIR}/config.json ${D}/data/hero-secc/userdata
	install -d -m 755 ${D}/var/lib/hero-secc/userdata
	ln -s /data/hero-secc/userdata ${D}/var/lib/hero-secc/userdata
}