From 45173ccdb5ea2f0b2835cf9adcc966b96009a97a Mon Sep 17 00:00:00 2001 From: Lucas Alvares Gomes Date: Mon, 15 Apr 2013 11:31:04 +0100 Subject: [PATCH] Adds support for post-install scripts. Post install scripts are useful because they can perform tasks you want to handle after the OS/application install but before the first boot of the image. e.g: Clean the cache left by the package manager reducing the size of the image. Change-Id: I03e77f602192bbdce29c02999d1b57fac8051ddc Fixes: Bug #1145786 --- README.md | 6 ++++++ bin/disk-image-create | 1 + elements/dpkg/post-install.d/99-clean-up-cache | 6 ++++++ 3 files changed, 13 insertions(+) create mode 100755 elements/dpkg/post-install.d/99-clean-up-cache diff --git a/README.md b/README.md index 72e35b2ff..bc77e361d 100644 --- a/README.md +++ b/README.md @@ -156,6 +156,12 @@ part of the process you need to customise: install packages, chain into configuration management tools or do other image specific operations. +* post-install.d: Run code in the chroot. This is a good place to perform + tasks you want to handle after the OS/application install but before the + first boot of the image. Some examples of use would be: Run chkconfig + to disable unneeded services and clean the cache left by the package + manager to reduce the size of the image. + * first-boot.d: Runs inside the image before rc.local. Scripts from here are good for doing per-instance configuration based on cloud metadata. diff --git a/bin/disk-image-create b/bin/disk-image-create index 86ecdf1f0..aa1eddb55 100755 --- a/bin/disk-image-create +++ b/bin/disk-image-create @@ -117,6 +117,7 @@ run_d_in_target pre-install do_extra_package_install # Call install scripts to pull in the software users want. run_d_in_target install +run_d_in_target post-install prepare_first_boot finalise_base unmount_image diff --git a/elements/dpkg/post-install.d/99-clean-up-cache b/elements/dpkg/post-install.d/99-clean-up-cache new file mode 100755 index 000000000..2457f78d3 --- /dev/null +++ b/elements/dpkg/post-install.d/99-clean-up-cache @@ -0,0 +1,6 @@ +#!/bin/bash +# Do an apt-get clean. This will free some space. + +set -e + +apt-get clean