classes/image: write image manifest

Write a list of installed packages to a .manifest file next to the
image, so we can find out what went into the image after it has been
constructed without necessarily having to have buildhistory enabled
(although that will provide more detail.) We can make use of this for
example in the testimage class associated code that checks for installed
packages for determining whether or not to run specific tests.

Note: this replaces the previous ipk-specific manifest code with
something that works for ipk, rpm and deb, and instead of a pruned
status file, packages are listed one per line, in the following format:

<packagename> <packagearch> <version>

Tests for all three backends have shown that the performance impact of
this change is negligible (about 1.5s max).

Implements [YOCTO #5410]

(From OE-Core rev: 2978d1f2617a33e2e3a77e249d73e998d79b4ec9)

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Paul Eggleton 2013-11-26 12:09:52 +00:00 committed by Richard Purdie
parent bbbd6fc1d1
commit 960e305d9a
6 changed files with 24 additions and 20 deletions

View File

@ -179,6 +179,9 @@ ROOTFS_POSTPROCESS_COMMAND_prepend = "run_intercept_scriptlets; "
ROOTFS_POSTPROCESS_COMMAND += '${@base_contains("IMAGE_FEATURES", "debug-tweaks", "ssh_allow_empty_password; ", "",d)}' ROOTFS_POSTPROCESS_COMMAND += '${@base_contains("IMAGE_FEATURES", "debug-tweaks", "ssh_allow_empty_password; ", "",d)}'
# Enable postinst logging if debug-tweaks is enabled # Enable postinst logging if debug-tweaks is enabled
ROOTFS_POSTPROCESS_COMMAND += '${@base_contains("IMAGE_FEATURES", "debug-tweaks", "postinst_enable_logging; ", "",d)}' ROOTFS_POSTPROCESS_COMMAND += '${@base_contains("IMAGE_FEATURES", "debug-tweaks", "postinst_enable_logging; ", "",d)}'
# Write manifest
IMAGE_MANIFEST = "${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.manifest"
ROOTFS_POSTPROCESS_COMMAND =+ "write_image_manifest ; "
# Set default postinst log file # Set default postinst log file
POSTINST_LOGFILE ?= "${localstatedir}/log/postinstall.log" POSTINST_LOGFILE ?= "${localstatedir}/log/postinstall.log"
@ -381,6 +384,11 @@ fakeroot do_rootfs () {
${IMAGE_POSTPROCESS_COMMAND} ${IMAGE_POSTPROCESS_COMMAND}
${MACHINE_POSTPROCESS_COMMAND} ${MACHINE_POSTPROCESS_COMMAND}
if [ -n "${IMAGE_LINK_NAME}" -a -f "${IMAGE_MANIFEST}" ]; then
rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.manifest
ln -s ${IMAGE_NAME}.rootfs.manifest ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.manifest
fi
} }
insert_feed_uris () { insert_feed_uris () {
@ -602,12 +610,7 @@ make_zimage_symlink_relative () {
} }
write_image_manifest () { write_image_manifest () {
rootfs_${IMAGE_PKGTYPE}_write_manifest list_installed_packages ver | sort > ${IMAGE_MANIFEST}
if [ -n "${IMAGE_LINK_NAME}" ]; then
rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.manifest
ln -s ${IMAGE_NAME}.rootfs.manifest ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.manifest
fi
} }
# Make login manager(s) enable automatic login. # Make login manager(s) enable automatic login.

View File

@ -84,6 +84,8 @@ list_installed_packages() {
echo "$pkg $fullpath $pkgarch" echo "$pkg $fullpath $pkgarch"
fi fi
done done
elif [ "$1" = "ver" ] ; then
${DPKG_QUERY_COMMAND} -W -f='${Package} ${PackageArch} ${Version}\n'
else else
${DPKG_QUERY_COMMAND} -W -f='${Package}\n' ${DPKG_QUERY_COMMAND} -W -f='${Package}\n'
fi fi

View File

@ -70,6 +70,8 @@ list_installed_packages() {
echo "$pkg $fullpath $pkgarch" echo "$pkg $fullpath $pkgarch"
fi fi
done done
elif [ "$1" = "ver" ] ; then
opkg-cl ${OPKG_ARGS} status | opkg-query-helper.py -v
else else
opkg-cl ${OPKG_ARGS} list_installed | awk '{ print $1 }' opkg-cl ${OPKG_ARGS} list_installed | awk '{ print $1 }'
fi fi

View File

@ -162,6 +162,8 @@ list_installed_packages() {
${RPM_QUERY_CMD} -qa --qf "[%{NAME} %{ARCH}\n]" | translate_smart_to_oe arch ${RPM_QUERY_CMD} -qa --qf "[%{NAME} %{ARCH}\n]" | translate_smart_to_oe arch
elif [ "$1" = "file" ]; then elif [ "$1" = "file" ]; then
${RPM_QUERY_CMD} -qa --qf "[%{NAME} %{ARCH} %{PACKAGEORIGIN}\n]" | translate_smart_to_oe file ${RPM_QUERY_CMD} -qa --qf "[%{NAME} %{ARCH} %{PACKAGEORIGIN}\n]" | translate_smart_to_oe file
elif [ "$1" = "ver" ]; then
${RPM_QUERY_CMD} -qa --qf "[%{NAME} %{ARCH} %{VERSION}\n]" | translate_smart_to_oe arch
else else
${RPM_QUERY_CMD} -qa --qf "[%{NAME} %{ARCH}\n]" | translate_smart_to_oe ${RPM_QUERY_CMD} -qa --qf "[%{NAME} %{ARCH}\n]" | translate_smart_to_oe
fi fi

View File

@ -118,20 +118,6 @@ save_postinsts () {
done done
} }
rootfs_ipk_write_manifest() {
manifest=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.manifest
cp ${IMAGE_ROOTFS}${OPKGLIBDIR}/opkg/status $manifest
sed '/Depends/d' -i $manifest
sed '/Status/d' -i $manifest
sed '/Architecture/d' -i $manifest
sed '/Installed-Time/d' -i $manifest
sed '/Auto-Installed/d' -i $manifest
sed '/Recommends/d' -i $manifest
sed '/Provides/d' -i $manifest
sed '/Conflicts/d' -i $manifest
}
remove_packaging_data_files() { remove_packaging_data_files() {
rm -rf ${IMAGE_ROOTFS}${OPKGLIBDIR}/opkg rm -rf ${IMAGE_ROOTFS}${OPKGLIBDIR}/opkg
# We need the directory for the package manager lock # We need the directory for the package manager lock

View File

@ -28,6 +28,7 @@ import re
archmode = False archmode = False
filemode = False filemode = False
vermode = False
args = [] args = []
for arg in sys.argv[1:]: for arg in sys.argv[1:]:
@ -35,6 +36,8 @@ for arg in sys.argv[1:]:
archmode = True archmode = True
elif arg == '-f': elif arg == '-f':
filemode = True filemode = True
elif arg == '-v':
vermode = True
else: else:
args.append(arg) args.append(arg)
@ -60,6 +63,12 @@ for line in fileinput.input(args):
elif line.startswith("Architecture:"): elif line.startswith("Architecture:"):
arch = line.split(": ")[1] arch = line.split(": ")[1]
print("%s %s_%s_%s.ipk %s" % (pkg,pkg,ver,arch,arch)) print("%s %s_%s_%s.ipk %s" % (pkg,pkg,ver,arch,arch))
elif vermode:
if line.startswith("Version:"):
ver = line.split(": ")[1]
elif line.startswith("Architecture:"):
arch = line.split(": ")[1]
print("%s %s %s" % (pkg,arch,ver))
else: else:
if line.startswith("Depends:"): if line.startswith("Depends:"):
depval = line.split(": ")[1] depval = line.split(": ")[1]