generic-poky/meta/classes/rootfs_ipk.bbclass

184 lines
5.5 KiB
Plaintext
Raw Normal View History

#
# Creates a root filesystem out of IPKs
#
# This rootfs can be mounted via root-nfs or it can be put into an cramfs/jffs etc.
# See image.bbclass for a usage of this.
#
EXTRAOPKGCONFIG ?= ""
ROOTFS_PKGMANAGE = "opkg opkg-collateral ${EXTRAOPKGCONFIG}"
ROOTFS_PKGMANAGE_BOOTSTRAP = "run-postinsts"
do_rootfs[depends] += "opkg-native:do_populate_sysroot opkg-utils-native:do_populate_sysroot"
do_rootfs[recrdeptask] += "do_package_write_ipk"
rootfs_ipk_do_rootfs[vardepsexclude] += "BUILDNAME"
do_rootfs[lockfiles] += "${WORKDIR}/ipk.lock"
OPKG_PREPROCESS_COMMANDS = "package_update_index_ipk; package_generate_ipkg_conf"
Rework installation of dev, dbg, doc, and locale packages Use a similar mechanism that was previously used to install locales at rootfs generation time to install other "complementary" packages (e.g. *-dev packages) - i.e. install all of the explicitly requested packages and their dependencies, then get a list of the packages that were installed, and use that list to install the complementary packages. This has been implemented by using a list of globs which should make it easier to extend in future. The previous locale package installation code assumed that the locale packages did not have any dependencies that were not already installed; now that we are installing non-locale packages this is no longer correct. In practice only the rpm backend actually made use of this assumption, so it needed to be changed to call into the existing package backend code to do the complementary package installation rather than calling rpm directly. This fixes the doc-pkgs IMAGE_FEATURES feature to work correctly, and also ensures that all dev/dbg packages get installed for dev-pkgs/dbg-pkgs respectively even if the dependency chains between those packages was not ensuring that already. The code has also been adapted to work correctly with the new SDK-from-image functionality. To that end, an SDKIMAGE_FEATURES variable has been added to allow specifying what extra image features should go into the SDK (extra, because by virtue of installing all of the packages in the image into the target part of the SDK, we already include all of IMAGE_FEATURES) with a default value of "dev-pkgs dbg-pkgs". Fixes [YOCTO #2614]. (From OE-Core rev: 72d1048a8381fa4a8c4c0d082047536727b4be47) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-07-09 13:15:08 +00:00
OPKG_POSTPROCESS_COMMANDS = "ipk_insert_feed_uris; "
OPKGLIBDIR = "${localstatedir}/lib"
MULTILIBRE_ALLOW_REP = "${OPKGLIBDIR}/opkg"
fakeroot rootfs_ipk_do_rootfs () {
#set -x
rm -f ${IPKGCONF_TARGET}
touch ${IPKGCONF_TARGET}
${OPKG_PREPROCESS_COMMANDS}
mkdir -p ${T}/
export INSTALL_CONF_IPK="${IPKGCONF_TARGET}"
export INSTALL_ROOTFS_IPK="${IMAGE_ROOTFS}"
STATUS=${IMAGE_ROOTFS}${OPKGLIBDIR}/opkg/status
mkdir -p ${IMAGE_ROOTFS}${OPKGLIBDIR}/opkg
opkg-cl ${OPKG_ARGS} update
# prime the status file with bits that we don't want
for i in ${BAD_RECOMMENDATIONS}; do
pkginfo="`opkg-cl ${OPKG_ARGS} info $i`"
if [ ! -z "$pkginfo" ]; then
# Take just the first package stanza as otherwise only
# the last one will have the right Status line.
echo "$pkginfo" | awk "/^Package:/ { print } \
/^Architecture:/ { print } \
/^Version:/ { print } \
/^$/ { exit } \
END { print \"Status: deinstall hold not-installed\n\" }" - >> $STATUS
else
echo "Requested ignored recommendation $i is not a package"
fi
done
#install
export INSTALL_PACKAGES_ATTEMPTONLY_IPK="${PACKAGE_INSTALL_ATTEMPTONLY}"
export INSTALL_PACKAGES_LINGUAS_IPK="${LINGUAS_INSTALL}"
export INSTALL_TASK_IPK="rootfs"
export INSTALL_PACKAGES_IPK="${PACKAGE_INSTALL}"
#post install
export D=${IMAGE_ROOTFS}
export OFFLINE_ROOT=${IMAGE_ROOTFS}
export IPKG_OFFLINE_ROOT=${IMAGE_ROOTFS}
export OPKG_OFFLINE_ROOT=${IPKG_OFFLINE_ROOT}
export INTERCEPT_DIR=${WORKDIR}/intercept_scripts
export NATIVE_ROOT=${STAGING_DIR_NATIVE}
opkg: Update svn 625 -> 633 and fix preinst issues There is a major issue with opkg images at the moment as preinst functions are not being executed before their dependencies are installed and this is leading to corruption of images containing avahi/dbus in particular. There are various changes in upstream opkg in the last 8 revisions which make changes in this area but sadly these aren't enough to get things working for us. I've updated to the latest svn revision with this patch since it makes sense to pull in those changes first and then supplement them with the attached patches. There is a full description of the patches in the patch headers but in summary they: a) Ensure preinst functions execute with their dependencies installed. This is a pretty invasive change as it changes the package install ordering in general. b) Ensure opkg sets $D, not $PKG_ROOT which we don't use c) Change opkg to allow execution of postinstall functions which fail resulting in execution on the target device as rootfs_ipk.bbclass currently does manually. The remaining changes interface this with the rest of the OE build infrastructure, adding in the option to tell opkg to run the preinst and postinst functions, ensure the correct environment is present for the postinst scripts and removing the now unneeded rootfs_ipk class code which opkg now does itself. [YOCTO #1711] (From OE-Core rev: 2feba313c991170747381c7cf821a45c2cd04632) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-12-15 21:08:49 +00:00
package_install_internal_ipk
# Distro specific packages should create this
#mkdir -p ${IMAGE_ROOTFS}/etc/opkg/
#grep "^arch" ${IPKGCONF_TARGET} >${IMAGE_ROOTFS}/etc/opkg/arch.conf
Rework installation of dev, dbg, doc, and locale packages Use a similar mechanism that was previously used to install locales at rootfs generation time to install other "complementary" packages (e.g. *-dev packages) - i.e. install all of the explicitly requested packages and their dependencies, then get a list of the packages that were installed, and use that list to install the complementary packages. This has been implemented by using a list of globs which should make it easier to extend in future. The previous locale package installation code assumed that the locale packages did not have any dependencies that were not already installed; now that we are installing non-locale packages this is no longer correct. In practice only the rpm backend actually made use of this assumption, so it needed to be changed to call into the existing package backend code to do the complementary package installation rather than calling rpm directly. This fixes the doc-pkgs IMAGE_FEATURES feature to work correctly, and also ensures that all dev/dbg packages get installed for dev-pkgs/dbg-pkgs respectively even if the dependency chains between those packages was not ensuring that already. The code has also been adapted to work correctly with the new SDK-from-image functionality. To that end, an SDKIMAGE_FEATURES variable has been added to allow specifying what extra image features should go into the SDK (extra, because by virtue of installing all of the packages in the image into the target part of the SDK, we already include all of IMAGE_FEATURES) with a default value of "dev-pkgs dbg-pkgs". Fixes [YOCTO #2614]. (From OE-Core rev: 72d1048a8381fa4a8c4c0d082047536727b4be47) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-07-09 13:15:08 +00:00
rootfs_install_complementary
${OPKG_POSTPROCESS_COMMANDS}
${ROOTFS_POSTINSTALL_COMMAND}
install -d ${IMAGE_ROOTFS}/${sysconfdir}
echo ${BUILDNAME} > ${IMAGE_ROOTFS}/${sysconfdir}/version
${ROOTFS_POSTPROCESS_COMMAND}
if ${@base_contains("IMAGE_FEATURES", "read-only-rootfs", "true", "false" ,d)}; then
if [ -n "$(delayed_postinsts)" ]; then
bberror "Some packages could not be configured offline and rootfs is read-only."
exit 1
fi
fi
rm -f ${IMAGE_ROOTFS}${OPKGLIBDIR}/opkg/lists/*
log_check rootfs
}
rootfs_ipk_do_rootfs[vardeps] += "delayed_postinsts"
delayed_postinsts () {
cat ${STATUS}|grep -e "^Package:" -e "^Status:"|sed -ne 'N;s/Package: \(.*\)\nStatus:.*unpacked/\1/p'
}
save_postinsts () {
for p in $(delayed_postinsts); do
install -d ${IMAGE_ROOTFS}${sysconfdir}/ipk-postinsts
cp ${IMAGE_ROOTFS}${OPKGLIBDIR}/opkg/info/$p.postinst ${IMAGE_ROOTFS}${sysconfdir}/ipk-postinsts/$p
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() {
rm -rf ${IMAGE_ROOTFS}${OPKGLIBDIR}/opkg
# We need the directory for the package manager lock
mkdir ${IMAGE_ROOTFS}${OPKGLIBDIR}/opkg
}
rootfs_install_packages() {
opkg-cl ${OPKG_ARGS} install `cat $1`
}
rootfs_uninstall_packages() {
opkg-cl ${OPKG_ARGS} --force-depends remove $@
}
ipk_insert_feed_uris () {
echo "Building from feeds activated!"
for line in ${IPK_FEED_URIS}
do
# strip leading and trailing spaces/tabs, then split into name and uri
line_clean="`echo "$line"|sed 's/^[ \t]*//;s/[ \t]*$//'`"
feed_name="`echo "$line_clean" | sed -n 's/\(.*\)##\(.*\)/\1/p'`"
feed_uri="`echo "$line_clean" | sed -n 's/\(.*\)##\(.*\)/\2/p'`"
echo "Added $feed_name feed with URL $feed_uri"
# insert new feed-sources
echo "src/gz $feed_name $feed_uri" >> ${IPKGCONF_TARGET}
done
# Allow to use package deploy directory contents as quick devel-testing
# feed. This creates individual feed configs for each arch subdir of those
# specified as compatible for the current machine.
# NOTE: Development-helper feature, NOT a full-fledged feed.
if [ -n "${FEED_DEPLOYDIR_BASE_URI}" ]; then
for arch in ${PACKAGE_ARCHS}
do
echo "src/gz local-$arch ${FEED_DEPLOYDIR_BASE_URI}/$arch" >> ${IMAGE_ROOTFS}/etc/opkg/local-$arch-feed.conf
done
fi
}
python () {
if d.getVar('BUILD_IMAGES_FROM_FEEDS', True):
flags = d.getVarFlag('do_rootfs', 'recrdeptask')
flags = flags.replace("do_package_write_ipk", "")
flags = flags.replace("do_deploy", "")
flags = flags.replace("do_populate_sysroot", "")
d.setVarFlag('do_rootfs', 'recrdeptask', flags)
d.setVar('OPKG_PREPROCESS_COMMANDS', "package_generate_archlist\nipk_insert_feed_uris")
d.setVar('OPKG_POSTPROCESS_COMMANDS', '')
}