xref: /OK3568_Linux_fs/buildroot/docs/manual/customize-post-image.txt (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun// -*- mode:doc; -*-
2*4882a593Smuzhiyun// vim: set syntax=asciidoc:
3*4882a593Smuzhiyun
4*4882a593Smuzhiyun=== Customization _after_ the images have been created
5*4882a593Smuzhiyun
6*4882a593SmuzhiyunWhile post-build scripts (xref:rootfs-custom[]) are run _before_
7*4882a593Smuzhiyunbuilding the filesystem image, kernel and bootloader, *post-image
8*4882a593Smuzhiyunscripts* can be used to perform some specific actions _after_ all images
9*4882a593Smuzhiyunhave been created.
10*4882a593Smuzhiyun
11*4882a593SmuzhiyunPost-image scripts can for example be used to automatically extract your
12*4882a593Smuzhiyunroot filesystem tarball in a location exported by your NFS server, or
13*4882a593Smuzhiyunto create a special firmware image that bundles your root filesystem and
14*4882a593Smuzhiyunkernel image, or any other custom action required for your project.
15*4882a593Smuzhiyun
16*4882a593SmuzhiyunTo enable this feature, specify a space-separated list of post-image
17*4882a593Smuzhiyunscripts in config option +BR2_ROOTFS_POST_IMAGE_SCRIPT+ (in the +System
18*4882a593Smuzhiyunconfiguration+ menu). If you specify a relative path, it will be
19*4882a593Smuzhiyunrelative to the root of the Buildroot tree.
20*4882a593Smuzhiyun
21*4882a593SmuzhiyunJust like post-build scripts, post-image scripts are run with the main
22*4882a593SmuzhiyunBuildroot tree as current working directory. The path to the +images+
23*4882a593Smuzhiyunoutput directory is passed as the first argument to each script. If the
24*4882a593Smuzhiyunconfig option +BR2_ROOTFS_POST_SCRIPT_ARGS+ is not empty, these
25*4882a593Smuzhiyunarguments will be passed to the script too. All the scripts will be
26*4882a593Smuzhiyunpassed the exact same set of arguments, it is not possible to pass
27*4882a593Smuzhiyundifferent sets of arguments to each script.
28*4882a593Smuzhiyun
29*4882a593SmuzhiyunAgain just like for the post-build scripts, the scripts have access to
30*4882a593Smuzhiyunthe environment variables +BR2_CONFIG+, +HOST_DIR+, +STAGING_DIR+,
31*4882a593Smuzhiyun+TARGET_DIR+, +BUILD_DIR+, +BINARIES_DIR+, +CONFIG_DIR+ and
32*4882a593Smuzhiyun+BASE_DIR+.
33*4882a593Smuzhiyun
34*4882a593SmuzhiyunThe post-image scripts will be executed as the user that executes
35*4882a593SmuzhiyunBuildroot, which should normally _not_ be the root user. Therefore, any
36*4882a593Smuzhiyunaction requiring root permissions in one of these scripts will require
37*4882a593Smuzhiyunspecial handling (usage of fakeroot or sudo), which is left to the
38*4882a593Smuzhiyunscript developer.
39