feat(build_image): Generate lists of image contents

Index contents by file and package.
This commit is contained in:
Michael Marineau 2014-06-08 16:18:34 -04:00
parent 388220cfad
commit bb3d751e6f
3 changed files with 35 additions and 2 deletions

View File

@ -117,6 +117,26 @@ systemd_enable() {
sudo ln -sf "../${unit_file}" "${wants_dir}/${unit_alias}"
}
# Generate a ls-like listing of a directory tree.
# The ugly printf is used to predictable time format and size in bytes.
write_contents() {
info "Writing ${2##*/}"
pushd "$1" >/dev/null
sudo TZ=UTC find -printf \
'%M %2n %-7u %-7g %7s %TY-%Tm-%Td %TH:%TM ./%P -> %l\n' \
| sed -e 's/ -> $//' > "$2"
popd >/dev/null
}
# Generate a list of installed packages in the format:
# sys-apps/systemd-212-r8::coreos
write_packages() {
info "Writing ${2##*/}"
ROOT="$1" equery-$BOARD --no-color \
list '*' --format '$cpv::$repo' \
> "$2"
}
start_image() {
local image_name="$1"
local disk_layout="$2"
@ -152,6 +172,7 @@ start_image() {
finish_image() {
local disk_layout="$1"
local root_fs_dir="$2"
local image_contents="$3"
# Record directories installed to the state partition.
# Explicitly ignore entries covered by existing configs.
@ -182,6 +203,8 @@ finish_image() {
"user-cloudinit@.path" "user-cloudinit@${unit_path}.path"
fi
write_contents "${root_fs_dir}" "${BUILD_DIR}/${image_contents}"
# Zero all fs free space to make it more compressible so auto-update
# payloads become smaller, not fatal since it won't work on linux < 3.2
sudo fstrim "${root_fs_dir}" || true

View File

@ -66,10 +66,13 @@ create_dev_image() {
info "Building developer image ${image_name}"
local root_fs_dir="${BUILD_DIR}/rootfs"
local image_contents="${image_name%.bin}_contents.txt"
local image_packages="${image_name%.bin}_packages.txt"
start_image "${image_name}" "${disk_layout}" "${root_fs_dir}" "${update_group}"
emerge_to_image "${root_fs_dir}" coreos-base/coreos-dev
write_packages "${root_fs_dir}" "${BUILD_DIR}/${image_packages}"
# Setup portage for emerge and gmerge
configure_dev_portage "${root_fs_dir}" "${devserver}"
@ -92,7 +95,9 @@ EOF
# The remount services are provided by coreos-base/coreos-init
systemd_enable "${root_fs_dir}" "local-fs.target" "remount-usr.service"
finish_image "${disk_layout}" "${root_fs_dir}"
finish_image "${disk_layout}" "${root_fs_dir}" "${image_contents}"
upload_image -d "${BUILD_DIR}/${image_name}.bz2.DIGESTS" \
"${BUILD_DIR}/${image_contents}" \
"${BUILD_DIR}/${image_packages}" \
"${BUILD_DIR}/${image_name}"
}

View File

@ -32,12 +32,15 @@ create_prod_image() {
info "Building production image ${image_name}"
local root_fs_dir="${BUILD_DIR}/rootfs"
local image_contents="${image_name%.bin}_contents.txt"
local image_packages="${image_name%.bin}_packages.txt"
start_image "${image_name}" "${disk_layout}" "${root_fs_dir}" "${update_group}"
# Install minimal GCC (libs only) and then everything else
emerge_prod_gcc "${root_fs_dir}"
emerge_to_image "${root_fs_dir}" coreos-base/coreos
write_packages "${root_fs_dir}" "${BUILD_DIR}/${image_packages}"
# clean-ups of things we do not need
sudo rm ${root_fs_dir}/etc/csh.env
@ -69,7 +72,7 @@ EOF
disable_read_write=${FLAGS_FALSE}
fi
finish_image "${disk_layout}" "${root_fs_dir}"
finish_image "${disk_layout}" "${root_fs_dir}" "${image_contents}"
# Make the filesystem un-mountable as read-write.
if [[ ${disable_read_write} -eq ${FLAGS_TRUE} ]]; then
@ -78,5 +81,7 @@ EOF
fi
upload_image -d "${BUILD_DIR}/${image_name}.bz2.DIGESTS" \
"${BUILD_DIR}/${image_contents}" \
"${BUILD_DIR}/${image_packages}" \
"${BUILD_DIR}/${image_name}"
}