mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-07 13:06:59 +02:00
build_image_util: generate package license list for each image
There isn't a sane way for users to know the licenses of individual packages in CoreOS images in built images. The information is hidden away back in the original ebuilds. This extends our existing package list with a new file that also includes licenses: ``` app-admin/flannel-0.3.0-r3::coreos Apache-2.0 app-admin/fleet-0.9.1::coreos Apache-2.0 app-admin/locksmith-0.2.3::coreos Apache-2.0 app-admin/sdnotify-proxy-0.1.0::coreos Apache-2.0 app-admin/sudo-1.8.10_p2::portage-stable ISC BSD app-admin/toolbox-0.0.0-r4::coreos Apache-2.0 app-arch/bzip2-1.0.6-r6::portage-stable BZIP2 app-arch/gzip-1.5::portage-stable GPL-3 app-arch/tar-1.27.1-r2::portage-stable GPL-3+ ... ```
This commit is contained in:
parent
e235fb5f9f
commit
3b8cf7d1fb
@ -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"
|
||||
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() {
|
||||
|
@ -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}"
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user