Custom build w/ timestamp in the filename

While I’m somewhat versed in configuring Buildroot to create images for Kirkwood SoC’s and a few more, I’m greener when it comes to using the Openwrt setup.

I want to define EXTRA_IMAGE_NAME that will resolve to: dg-custom-built_2026-03-16-1612 for instance. I was able to do this easily in Buildroot, with :

BR2_TARGET_GENERIC_ISSUE="Kirkwood SoC Rescue/EntwareHost - built $(date \"+%m-%d-%Y %H:%M:%S %Z\")"

… but here it seems unwilling to resolve anything correctly… such as…

CONFIG_EXTRA_IMAGE_NAME="dg-custom-built $(date \"+%m-%d-%Y  %H:%M:%S %Z\")" 

Interestingly, the above CONFIG line resolves in menuconfig as :
(dg-custom-built $(date "+%m-%d-%Y %H:%M:%S %Z")) Extra image filename

I’ve got a feeling that I need to escape (single or nested…) but can’t get anything to work.

Any pointers?

Ok, so that's in your .config? I think that's just static text, isn't it?

You might need to do something like this to make it dynamic.

alias make='make EXTRA_IMAGE_NAME="dg-$(date ...)"'
1 Like

maybe something like ...

$(shell date +%Y%m%d)

it works for a pakage ...

PKG_DATE:=$(shell date +%Y-%m-%d)
PKG_SOURCE_DATE= $(PKG_DATE) #2026-03-16


...
luaJson-2026.03.16~1984f2e3.tar.zst
1 Like

Thank you @efahl and @Hostle ... Every time I post, I learn something.

I'll try both, for kicks.

try this ..

store it in a var first

# Define the timestamp variable
PKG_DATE:= $(shell date +%m-%d-%Y_%H-%M-%S)

# Define the custom image name using the timestamp
EXTRA_IMAGE_NAME:= dg-custom-built_$(PKG_DATE).bin

# Example usage in a build command
build:
	@echo "Building image: $(EXTRA_IMAGE_NAME)"
	make image PROFILE="your_profile" BIN_DIR="./bin" EXTRA_IMAGE_NAME="$(EXTRA_IMAGE_NAME)"

or something to that effect.

EDIT

Just to be clear and for future reference, the above solution is for a makefile, not for a one liner. Hence the no quotes, which may cause issues if used in a makefile like your timestamp.

1 Like

All good ideas... right now I got TIMESTAMP=$(date +"%Y%m%d%H%M-%Z"); make -j 4 EXTRA_IMAGE_NAME="dg-custom-${TIMESTAMP}" to work nicely.

I will explore with the shell idea also.

Again, thanks both!

2 Likes

All good ideas... right now I got TIMESTAMP=$(date +"%Y%m%d%H%M-%Z"); make -j 4 EXTRA_IMAGE_NAME="dg-custom-${TIMESTAMP}" to work nicely.

I will explore with the shell idea also.

Again, thanks both!

================

@Hostle , I eventually got this to work in the .config file:

CONFIG_EXTRA_IMAGE_NAME="DG-$(shell TZ=/etc/localtime ; date +%m%d%Y_%H%M%S%^Z)"

...yields...

openwrt-25.12.0-dg-03162026-193811cdt-qualcommax-ipq60xx-linksys_mr7350-squashfs-sysupgrade.bin

There are two directives that it seems to (stubbornly) refuse to honor: (1) underscore character in the extra_image_filename and (2) capitals... I tried to get a capital DG and and underscore between the date_time, but caps were smallified and underscored "dashed". Also, CDT becomes cdt, even though I invoked the ^Z.

Thanks for helping me solve this.

1 Like

Oh, that's good to know!

you'll likely need to escape the _ to use them like that

CONFIG_EXTRA_IMAGE_NAME="DG-$(shell TZ=/etc/localtime ; date +%m%d%Y\_%H%M%S\_%^Z)"

EDIT
Just a few things more things to consider ..

The command TZ=/etc/localtime may not work as expected ..TZ usually expects a timezone string (like UTC or EST5EDT) ... rather than a path to a file.

On most build hosts, you can simply use

  • date +%m%d%Y_%H%M%S_%Z (for the host's current local time)
  • date -u +%m%d%Y_%H%M%S_UTC (for UTC, which is recommended for Deterministic Builds)

Instead of putting directly in .config, it is much more reliable to define it in your include/image.mk or a local Makefile tweak.

for example, you can you do in your target/linux/<arch>/image/Makefile (or similar).

EXTRA_IMAGE_NAME := DG-$(shell date +%m%d%Y_%H%M%S_%Z)

if you are against the makefile, I would just use it in the make command

make -j $(nproc) CONFIG_EXTRA_IMAGE_NAME="DG-$(date +%m%d%Y_%H%M%S_%Z)" V=s

to each their own :wink:

good luck

Project for tomorrow. Merci Beaucoup.

1 Like

You can find this in make menuconfig/nconfig

  • Enter base-system menu and select base-files
  • Esc back and select Image configuration
  • Enter Image configuration menu

This will expose: the Extra image filename as well as Preinit/Init options and Version configuration options.

I use the Version configuration options in my builds for Version Control AKA:

openwrt-one---build-016-r33240+5-296b286a67-02-28-2026-snapshot-6.12-mediatek-filogic-openwrt_one-nor-factory.bin
openwrt-one---build-016-r33240+5-296b286a67-02-28-2026-snapshot-6.12-mediatek-filogic-openwrt_one-squashfs-sysupgrade.itb

These options allow to override the version information embedded in the /etc/openwrt_version, /etc/openwrt_release, /etc/banner, /etc/opkg.conf, and /etc/os-release files. Usually there is no need to set these, but they're useful for release builds or custom OpenWrt redistributions that should carry custom version tags.

1 Like