For version identification purposes, I want to be able to retrieve a timestamp indicating when the root filesystem image was built. It needs to be retrievable on the board itself at runtime.
I'm using The Ångström Distribution, branch angstrom-v2013.12-yocto1.5, which uses OpenEmbedded for building the rootfs (root filesystem).
The kernel is built separately for this board, so I can't use uname -v
for this purpose since that just reads out the kernel build timestamp, not the rootfs build timestamp.
Does a rootfs build timestamp get added to the rootfs image some place where it can be retrieved at runtime?
BitBake makes it easy to use Python code in variable expansion with the following syntax:
VARIABLE = "${@python-command}"
This gives huge flexibility to the user, as can be seen in the following example:
DATE = "${@time.strftime('%Y%m%d',time.gmtime())}"
This results in the DATE variable containing today's date.
When an Image is build, there is a time stamp that stored in /etc/timestamp, Example HERE
rootfs_update_timestamp () {
date "+%m%d%H%M%Y" >${IMAGE_ROOTFS}/etc/timestamp
}
You could take a look at this recipe that implement the days and time and put a file into the rootfs
DESCRIPTION = "Simple helloworld application"
SECTION = "hio-version"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
PR = "r0"
DEPENDS = "core-image-minimal"
SRC_URI = "file://version "
S = "${WORKDIR}"
INSANE_SKIP_${PN} = "installed-vs-shipped"
FILES_${PN} += " /"
do_install() {
echo "------------------------"
echo "------------------------"
#version
#echo hio-board-dl-v1.00 > ${WORKDIR}/version
#date >> ${WORKDIR}/version
#install -m 0644 ${WORKDIR}/version ${D}/
date_version_1=hio-board-dl-
date_version_2=$(date "+%Y%m%d%H%M%S")
date_version_3=-R1.00
echo $date_version_1$date_version_2$date_version_3 > ${WORKDIR}/version
install -m 0644 ${WORKDIR}/version ${D}/
}