Merge pull request #385 from marineam/licenses

build_image_util: generate package license list for each image
This commit is contained in:
Michael Marineau 2015-03-24 18:37:46 -07:00
commit 5be55a6898
3 changed files with 32 additions and 6 deletions

View File

@ -142,16 +142,38 @@ write_contents() {
popd >/dev/null
}
# Generate a list of packages installed in an image.
# Usage: image_packages /image/root
image_packages() {
local profile="${BUILD_DIR}/configroot/etc/portage/profile"
ROOT="$1" PORTAGE_CONFIGROOT="${BUILD_DIR}"/configroot \
equery --no-color list --format '$cpv::$repo' '*'
# In production images GCC libraries are extracted manually.
if [[ -f "${profile}/package.provided" ]]; then
xargs --arg-file="${profile}/package.provided" \
equery-${BOARD} --no-color list --format '$cpv::$repo'
fi
}
# Generate a list of installed packages in the format:
# sys-apps/systemd-212-r8::coreos
write_packages() {
local profile="${BUILD_DIR}/configroot/etc/portage/profile"
info "Writing ${2##*/}"
ROOT="$1" PORTAGE_CONFIGROOT="${BUILD_DIR}"/configroot \
equery --no-color list '*' --format '$cpv::$repo' > "$2"
if [[ -f "${profile}/package.provided" ]]; then
cat "${profile}/package.provided" >> "$2"
fi
image_packages "$1" | sort > "$2"
}
# Generate a list of packages w/ their licenses in the format:
# sys-apps/systemd-212-r8::coreos GPL-2 LGPL-2.1 MIT public-domain
write_licenses() {
info "Writing ${2##*/}"
local vdb=$(portageq-${BOARD} vdb_path)
local pkg lic
for pkg in $(image_packages "$1" | sort); do
lic="$vdb/${pkg%%:*}/LICENSE"
if [[ -f "$lic" ]]; then
echo "$pkg $(< "$lic")"
fi
done > "$2"
}
extract_docs() {

View File

@ -84,12 +84,14 @@ create_dev_image() {
local root_fs_dir="${BUILD_DIR}/rootfs"
local image_contents="${image_name%.bin}_contents.txt"
local image_packages="${image_name%.bin}_packages.txt"
local image_licenses="${image_name%.bin}_licenses.txt"
start_image "${image_name}" "${disk_layout}" "${root_fs_dir}" "${update_group}"
set_image_profile dev
emerge_to_image "${root_fs_dir}" @system coreos-base/coreos-dev
write_packages "${root_fs_dir}" "${BUILD_DIR}/${image_packages}"
write_licenses "${root_fs_dir}" "${BUILD_DIR}/${image_licenses}"
# Setup portage for emerge and gmerge
configure_dev_portage "${root_fs_dir}" "${devserver}"

View File

@ -39,6 +39,7 @@ create_prod_image() {
local root_fs_dir="${BUILD_DIR}/rootfs"
local image_contents="${image_name%.bin}_contents.txt"
local image_packages="${image_name%.bin}_packages.txt"
local image_licenses="${image_name%.bin}_licenses.txt"
start_image "${image_name}" "${disk_layout}" "${root_fs_dir}" "${update_group}"
@ -47,6 +48,7 @@ create_prod_image() {
extract_prod_gcc "${root_fs_dir}"
emerge_to_image "${root_fs_dir}" "${base_pkg}"
write_packages "${root_fs_dir}" "${BUILD_DIR}/${image_packages}"
write_licenses "${root_fs_dir}" "${BUILD_DIR}/${image_licenses}"
extract_docs "${root_fs_dir}"
# Assert that if this is supposed to be an official build that the