mirror of
https://git.yoctoproject.org/poky
synced 2026-06-01 13:09:50 +00:00
classes/image: implement generic locale package installation
Let each package-specific rootfs implementation provide basic functions to query the existence of a package and install a list of packages and then have a generic install function so this logic is in one place. Note: unlike previous versions of this code in OE-Core this uses the IMAGE_LINGUAS variable and not IMAGE_LOCALES - note that IMAGE_LINGUAS was what was used in OE-Classic and it is already used in OE-Core in order to install locale-base-*. This will mean that if IMAGE_LINGUAS is left at the default you will now get more packages installed. If you don't want these language support packages then you should set IMAGE_LINGUAS explicitly. This restores locale installation to the same state as OE-Classic, only we now support all the packaging backends. (From OE-Core rev: c0fc36f8629a6abb9a7b542df8a2857526547a31) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
8a77467fe8
commit
38c2f66ea7
@@ -255,6 +255,43 @@ multilib_sanity_check() {
|
|||||||
echo $@ | python ${MULTILIB_CHECK_FILE}
|
echo $@ | python ${MULTILIB_CHECK_FILE}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_split_linguas() {
|
||||||
|
for translation in ${IMAGE_LINGUAS}; do
|
||||||
|
translation_split=$(echo ${translation} | awk -F '-' '{print $1}')
|
||||||
|
echo ${translation}
|
||||||
|
echo ${translation_split}
|
||||||
|
done | sort | uniq
|
||||||
|
}
|
||||||
|
|
||||||
|
rootfs_install_all_locales() {
|
||||||
|
# Generate list of installed packages for which additional locale packages might be available
|
||||||
|
INSTALLED_PACKAGES=`list_installed_packages | egrep -v -- "(-locale-|^locale-base-|-dev$|-doc$|^kernel|^glibc|^ttf|^task|^perl|^python)"`
|
||||||
|
|
||||||
|
# Generate a list of locale packages that exist
|
||||||
|
SPLIT_LINGUAS=`get_split_linguas`
|
||||||
|
PACKAGES_TO_INSTALL=""
|
||||||
|
for lang in $SPLIT_LINGUAS; do
|
||||||
|
for pkg in $INSTALLED_PACKAGES; do
|
||||||
|
existing_pkg=`rootfs_check_package_exists $pkg-locale-$lang`
|
||||||
|
if [ "$existing_pkg" != "" ]; then
|
||||||
|
PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL $existing_pkg"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
|
# Install the packages, if any
|
||||||
|
if [ "$PACKAGES_TO_INSTALL" != "" ]; then
|
||||||
|
rootfs_install_packages $PACKAGES_TO_INSTALL
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Workaround for broken shell function dependencies
|
||||||
|
if false ; then
|
||||||
|
get_split_linguas
|
||||||
|
list_installed_packages
|
||||||
|
rootfs_check_package_exists
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# set '*' as the root password so the images
|
# set '*' as the root password so the images
|
||||||
# can decide if they want it or not
|
# can decide if they want it or not
|
||||||
zap_root_password () {
|
zap_root_password () {
|
||||||
|
|||||||
@@ -8,8 +8,18 @@ ROOTFS_PKGMANAGE_BOOTSTRAP = "run-postinsts"
|
|||||||
do_rootfs[depends] += "dpkg-native:do_populate_sysroot apt-native:do_populate_sysroot"
|
do_rootfs[depends] += "dpkg-native:do_populate_sysroot apt-native:do_populate_sysroot"
|
||||||
do_rootfs[recrdeptask] += "do_package_write_deb"
|
do_rootfs[recrdeptask] += "do_package_write_deb"
|
||||||
|
|
||||||
|
DEB_POSTPROCESS_COMMANDS = "rootfs_install_all_locales; "
|
||||||
|
|
||||||
opkglibdir = "${localstatedir}/lib/opkg"
|
opkglibdir = "${localstatedir}/lib/opkg"
|
||||||
|
|
||||||
|
deb_package_setflag() {
|
||||||
|
sed -i -e "/^Package: $2\$/{n; s/Status: install ok .*/Status: install ok $1/;}" ${IMAGE_ROOTFS}/var/lib/dpkg/status
|
||||||
|
}
|
||||||
|
|
||||||
|
deb_package_getflag() {
|
||||||
|
cat ${IMAGE_ROOTFS}/var/lib/dpkg/status | sed -n -e "/^Package: $2\$/{n; s/Status: install ok .*/$1/; p}"
|
||||||
|
}
|
||||||
|
|
||||||
fakeroot rootfs_deb_do_rootfs () {
|
fakeroot rootfs_deb_do_rootfs () {
|
||||||
set +e
|
set +e
|
||||||
|
|
||||||
@@ -28,25 +38,18 @@ fakeroot rootfs_deb_do_rootfs () {
|
|||||||
export INSTALL_TASK_DEB="rootfs"
|
export INSTALL_TASK_DEB="rootfs"
|
||||||
|
|
||||||
package_install_internal_deb
|
package_install_internal_deb
|
||||||
|
${DEB_POSTPROCESS_COMMANDS}
|
||||||
|
|
||||||
export D=${IMAGE_ROOTFS}
|
export D=${IMAGE_ROOTFS}
|
||||||
export OFFLINE_ROOT=${IMAGE_ROOTFS}
|
export OFFLINE_ROOT=${IMAGE_ROOTFS}
|
||||||
export IPKG_OFFLINE_ROOT=${IMAGE_ROOTFS}
|
export IPKG_OFFLINE_ROOT=${IMAGE_ROOTFS}
|
||||||
export OPKG_OFFLINE_ROOT=${IMAGE_ROOTFS}
|
export OPKG_OFFLINE_ROOT=${IMAGE_ROOTFS}
|
||||||
|
|
||||||
_flag () {
|
|
||||||
sed -i -e "/^Package: $2\$/{n; s/Status: install ok .*/Status: install ok $1/;}" ${IMAGE_ROOTFS}/var/lib/dpkg/status
|
|
||||||
}
|
|
||||||
_getflag () {
|
|
||||||
cat ${IMAGE_ROOTFS}/var/lib/dpkg/status | sed -n -e "/^Package: $2\$/{n; s/Status: install ok .*/$1/; p}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Attempt to run preinsts
|
# Attempt to run preinsts
|
||||||
# Mark packages with preinst failures as unpacked
|
# Mark packages with preinst failures as unpacked
|
||||||
for i in ${IMAGE_ROOTFS}/var/lib/dpkg/info/*.preinst; do
|
for i in ${IMAGE_ROOTFS}/var/lib/dpkg/info/*.preinst; do
|
||||||
if [ -f $i ] && ! sh $i; then
|
if [ -f $i ] && ! sh $i; then
|
||||||
_flag unpacked `basename $i .preinst`
|
deb_package_setflag unpacked `basename $i .preinst`
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -54,7 +57,7 @@ fakeroot rootfs_deb_do_rootfs () {
|
|||||||
# Mark packages with postinst failures as unpacked
|
# Mark packages with postinst failures as unpacked
|
||||||
for i in ${IMAGE_ROOTFS}/var/lib/dpkg/info/*.postinst; do
|
for i in ${IMAGE_ROOTFS}/var/lib/dpkg/info/*.postinst; do
|
||||||
if [ -f $i ] && ! sh $i configure; then
|
if [ -f $i ] && ! sh $i configure; then
|
||||||
_flag unpacked `basename $i .postinst`
|
deb_package_setflag unpacked `basename $i .postinst`
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -104,3 +107,17 @@ list_package_depends() {
|
|||||||
list_package_recommends() {
|
list_package_recommends() {
|
||||||
${DPKG_QUERY_COMMAND} -s $1 | grep ^Recommends | sed -e 's/^Recommends: //' -e 's/,//g' -e 's:([=<>]* [0-9a-zA-Z.~\-]*)::g'
|
${DPKG_QUERY_COMMAND} -s $1 | grep ^Recommends | sed -e 's/^Recommends: //' -e 's/,//g' -e 's:([=<>]* [0-9a-zA-Z.~\-]*)::g'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rootfs_check_package_exists() {
|
||||||
|
if [ `apt-cache showpkg $1 | wc -l` -gt 2 ]; then
|
||||||
|
echo $1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
rootfs_install_packages() {
|
||||||
|
${STAGING_BINDIR_NATIVE}/apt-get install $@ --force-yes --allow-unauthenticated
|
||||||
|
|
||||||
|
for pkg in $@ ; do
|
||||||
|
deb_package_setflag installed $pkg
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ IPKG_ARGS = "-f ${IPKGCONF_TARGET} -o ${IMAGE_ROOTFS} --force-overwrite"
|
|||||||
|
|
||||||
OPKG_PREPROCESS_COMMANDS = "package_update_index_ipk; package_generate_ipkg_conf"
|
OPKG_PREPROCESS_COMMANDS = "package_update_index_ipk; package_generate_ipkg_conf"
|
||||||
|
|
||||||
OPKG_POSTPROCESS_COMMANDS = "ipk_insert_feed_uris"
|
OPKG_POSTPROCESS_COMMANDS = "ipk_insert_feed_uris; rootfs_install_all_locales; "
|
||||||
|
|
||||||
opkglibdir = "${localstatedir}/lib/opkg"
|
opkglibdir = "${localstatedir}/lib/opkg"
|
||||||
|
|
||||||
@@ -148,26 +148,14 @@ list_package_recommends() {
|
|||||||
opkg-cl ${IPKG_ARGS} info $1 | grep ^Recommends | sed -e 's/^Recommends: //' -e 's/,//g' -e 's:([=<>]* [0-9a-zA-Z.~\-]*)::g'
|
opkg-cl ${IPKG_ARGS} info $1 | grep ^Recommends | sed -e 's/^Recommends: //' -e 's/,//g' -e 's:([=<>]* [0-9a-zA-Z.~\-]*)::g'
|
||||||
}
|
}
|
||||||
|
|
||||||
install_all_locales() {
|
rootfs_check_package_exists() {
|
||||||
|
if [ `opkg-cl ${IPKG_ARGS} info $1 | wc -l` -gt 2 ]; then
|
||||||
|
echo $1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
PACKAGES_TO_INSTALL=""
|
rootfs_install_packages() {
|
||||||
|
opkg-cl ${IPKG_ARGS} install $PACKAGES_TO_INSTALL
|
||||||
INSTALLED_PACKAGES=`list_installed_packages | egrep -v -- "(-locale-|-dev$|-doc$|^kernel|^glibc|^ttf|^task|^perl|^python)"`
|
|
||||||
|
|
||||||
for pkg in $INSTALLED_PACKAGES
|
|
||||||
do
|
|
||||||
for lang in ${IMAGE_LOCALES}
|
|
||||||
do
|
|
||||||
if [ `opkg-cl ${IPKG_ARGS} info $pkg-locale-$lang | wc -l` -gt 2 ]
|
|
||||||
then
|
|
||||||
PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL $pkg-locale-$lang"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
done
|
|
||||||
if [ "$PACKAGES_TO_INSTALL" != "" ]
|
|
||||||
then
|
|
||||||
opkg-cl ${IPKG_ARGS} install $PACKAGES_TO_INSTALL
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ipk_insert_feed_uris () {
|
ipk_insert_feed_uris () {
|
||||||
|
|||||||
@@ -21,12 +21,7 @@ do_rootfs[depends] += "opkg-native:do_populate_sysroot"
|
|||||||
do_rootfs[recrdeptask] += "do_package_write_rpm"
|
do_rootfs[recrdeptask] += "do_package_write_rpm"
|
||||||
|
|
||||||
RPM_PREPROCESS_COMMANDS = "package_update_index_rpm; package_generate_rpm_conf; "
|
RPM_PREPROCESS_COMMANDS = "package_update_index_rpm; package_generate_rpm_conf; "
|
||||||
RPM_POSTPROCESS_COMMANDS = ""
|
RPM_POSTPROCESS_COMMANDS = "rootfs_install_all_locales; "
|
||||||
|
|
||||||
# To test the install_all_locales.. enable the following...
|
|
||||||
#RPM_POSTPROCESS_COMMANDS = "install_all_locales; "
|
|
||||||
#
|
|
||||||
#IMAGE_LOCALES="en-gb"
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Allow distributions to alter when [postponed] package install scripts are run
|
# Allow distributions to alter when [postponed] package install scripts are run
|
||||||
@@ -198,24 +193,16 @@ list_package_recommends() {
|
|||||||
${RPM_QUERY_CMD} -q --suggests $1
|
${RPM_QUERY_CMD} -q --suggests $1
|
||||||
}
|
}
|
||||||
|
|
||||||
install_all_locales() {
|
rootfs_check_package_exists() {
|
||||||
PACKAGES_TO_INSTALL=""
|
resolve_package_rpm ${RPMCONF_TARGET_BASE}-base_archs.conf $1
|
||||||
|
}
|
||||||
|
|
||||||
# Generate list of installed packages...
|
rootfs_install_packages() {
|
||||||
INSTALLED_PACKAGES=`list_installed_packages | egrep -v -- "(-locale-|-dev$|-doc$|^kernel|^glibc|^ttf|^task|^perl|^python)"`
|
for pkg in $@; do
|
||||||
|
${RPM} --root ${IMAGE_ROOTFS} -D "_dbpath ${rpmlibdir}" \
|
||||||
# This would likely be faster if we did it in one transaction
|
-D "__dbi_txn create nofsync private" \
|
||||||
# but this should be good enough for the few users of this function...
|
--noscripts --notriggers --noparentdirs --nolinktos \
|
||||||
for pkg in $INSTALLED_PACKAGES; do
|
-Uhv $pkg || true
|
||||||
for lang in ${IMAGE_LOCALES}; do
|
|
||||||
pkg_name=$(resolve_package_rpm $pkg-locale-$lang ${RPMCONF_TARGET_BASE}.conf)
|
|
||||||
if [ -n "$pkg_name" ]; then
|
|
||||||
${RPM} --root ${IMAGE_ROOTFS} -D "_dbpath ${rpmlibdir}" \
|
|
||||||
-D "__dbi_txn create nofsync private" \
|
|
||||||
--noscripts --notriggers --noparentdirs --nolinktos \
|
|
||||||
-Uhv $pkg_name || true
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user