summaryrefslogtreecommitdiffstats
path: root/meta/classes
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2011-12-22 14:46:32 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-01-03 12:14:26 +0000
commit38c2f66ea79f3ee3fed1757160340548e7687181 (patch)
tree757ad1a88ce2394db734acb20e6bd63cd5cb3d24 /meta/classes
parent8a77467fe87de0e8a51e624aade2c994ee322836 (diff)
downloadpoky-38c2f66ea79f3ee3fed1757160340548e7687181.tar.gz
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>
Diffstat (limited to 'meta/classes')
-rw-r--r--meta/classes/image.bbclass37
-rw-r--r--meta/classes/rootfs_deb.bbclass37
-rw-r--r--meta/classes/rootfs_ipk.bbclass30
-rw-r--r--meta/classes/rootfs_rpm.bbclass35
4 files changed, 84 insertions, 55 deletions
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 865d430121..275b28f4ac 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -255,6 +255,43 @@ multilib_sanity_check() {
255 echo $@ | python ${MULTILIB_CHECK_FILE} 255 echo $@ | python ${MULTILIB_CHECK_FILE}
256} 256}
257 257
258get_split_linguas() {
259 for translation in ${IMAGE_LINGUAS}; do
260 translation_split=$(echo ${translation} | awk -F '-' '{print $1}')
261 echo ${translation}
262 echo ${translation_split}
263 done | sort | uniq
264}
265
266rootfs_install_all_locales() {
267 # Generate list of installed packages for which additional locale packages might be available
268 INSTALLED_PACKAGES=`list_installed_packages | egrep -v -- "(-locale-|^locale-base-|-dev$|-doc$|^kernel|^glibc|^ttf|^task|^perl|^python)"`
269
270 # Generate a list of locale packages that exist
271 SPLIT_LINGUAS=`get_split_linguas`
272 PACKAGES_TO_INSTALL=""
273 for lang in $SPLIT_LINGUAS; do
274 for pkg in $INSTALLED_PACKAGES; do
275 existing_pkg=`rootfs_check_package_exists $pkg-locale-$lang`
276 if [ "$existing_pkg" != "" ]; then
277 PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL $existing_pkg"
278 fi
279 done
280 done
281
282 # Install the packages, if any
283 if [ "$PACKAGES_TO_INSTALL" != "" ]; then
284 rootfs_install_packages $PACKAGES_TO_INSTALL
285 fi
286
287 # Workaround for broken shell function dependencies
288 if false ; then
289 get_split_linguas
290 list_installed_packages
291 rootfs_check_package_exists
292 fi
293}
294
258# set '*' as the root password so the images 295# set '*' as the root password so the images
259# can decide if they want it or not 296# can decide if they want it or not
260zap_root_password () { 297zap_root_password () {
diff --git a/meta/classes/rootfs_deb.bbclass b/meta/classes/rootfs_deb.bbclass
index bef055c6f5..b6c706c580 100644
--- a/meta/classes/rootfs_deb.bbclass
+++ b/meta/classes/rootfs_deb.bbclass
@@ -8,8 +8,18 @@ ROOTFS_PKGMANAGE_BOOTSTRAP = "run-postinsts"
8do_rootfs[depends] += "dpkg-native:do_populate_sysroot apt-native:do_populate_sysroot" 8do_rootfs[depends] += "dpkg-native:do_populate_sysroot apt-native:do_populate_sysroot"
9do_rootfs[recrdeptask] += "do_package_write_deb" 9do_rootfs[recrdeptask] += "do_package_write_deb"
10 10
11DEB_POSTPROCESS_COMMANDS = "rootfs_install_all_locales; "
12
11opkglibdir = "${localstatedir}/lib/opkg" 13opkglibdir = "${localstatedir}/lib/opkg"
12 14
15deb_package_setflag() {
16 sed -i -e "/^Package: $2\$/{n; s/Status: install ok .*/Status: install ok $1/;}" ${IMAGE_ROOTFS}/var/lib/dpkg/status
17}
18
19deb_package_getflag() {
20 cat ${IMAGE_ROOTFS}/var/lib/dpkg/status | sed -n -e "/^Package: $2\$/{n; s/Status: install ok .*/$1/; p}"
21}
22
13fakeroot rootfs_deb_do_rootfs () { 23fakeroot rootfs_deb_do_rootfs () {
14 set +e 24 set +e
15 25
@@ -28,25 +38,18 @@ fakeroot rootfs_deb_do_rootfs () {
28 export INSTALL_TASK_DEB="rootfs" 38 export INSTALL_TASK_DEB="rootfs"
29 39
30 package_install_internal_deb 40 package_install_internal_deb
31 41 ${DEB_POSTPROCESS_COMMANDS}
32 42
33 export D=${IMAGE_ROOTFS} 43 export D=${IMAGE_ROOTFS}
34 export OFFLINE_ROOT=${IMAGE_ROOTFS} 44 export OFFLINE_ROOT=${IMAGE_ROOTFS}
35 export IPKG_OFFLINE_ROOT=${IMAGE_ROOTFS} 45 export IPKG_OFFLINE_ROOT=${IMAGE_ROOTFS}
36 export OPKG_OFFLINE_ROOT=${IMAGE_ROOTFS} 46 export OPKG_OFFLINE_ROOT=${IMAGE_ROOTFS}
37 47
38 _flag () {
39 sed -i -e "/^Package: $2\$/{n; s/Status: install ok .*/Status: install ok $1/;}" ${IMAGE_ROOTFS}/var/lib/dpkg/status
40 }
41 _getflag () {
42 cat ${IMAGE_ROOTFS}/var/lib/dpkg/status | sed -n -e "/^Package: $2\$/{n; s/Status: install ok .*/$1/; p}"
43 }
44
45 # Attempt to run preinsts 48 # Attempt to run preinsts
46 # Mark packages with preinst failures as unpacked 49 # Mark packages with preinst failures as unpacked
47 for i in ${IMAGE_ROOTFS}/var/lib/dpkg/info/*.preinst; do 50 for i in ${IMAGE_ROOTFS}/var/lib/dpkg/info/*.preinst; do
48 if [ -f $i ] && ! sh $i; then 51 if [ -f $i ] && ! sh $i; then
49 _flag unpacked `basename $i .preinst` 52 deb_package_setflag unpacked `basename $i .preinst`
50 fi 53 fi
51 done 54 done
52 55
@@ -54,7 +57,7 @@ fakeroot rootfs_deb_do_rootfs () {
54 # Mark packages with postinst failures as unpacked 57 # Mark packages with postinst failures as unpacked
55 for i in ${IMAGE_ROOTFS}/var/lib/dpkg/info/*.postinst; do 58 for i in ${IMAGE_ROOTFS}/var/lib/dpkg/info/*.postinst; do
56 if [ -f $i ] && ! sh $i configure; then 59 if [ -f $i ] && ! sh $i configure; then
57 _flag unpacked `basename $i .postinst` 60 deb_package_setflag unpacked `basename $i .postinst`
58 fi 61 fi
59 done 62 done
60 63
@@ -104,3 +107,17 @@ list_package_depends() {
104list_package_recommends() { 107list_package_recommends() {
105 ${DPKG_QUERY_COMMAND} -s $1 | grep ^Recommends | sed -e 's/^Recommends: //' -e 's/,//g' -e 's:([=<>]* [0-9a-zA-Z.~\-]*)::g' 108 ${DPKG_QUERY_COMMAND} -s $1 | grep ^Recommends | sed -e 's/^Recommends: //' -e 's/,//g' -e 's:([=<>]* [0-9a-zA-Z.~\-]*)::g'
106} 109}
110
111rootfs_check_package_exists() {
112 if [ `apt-cache showpkg $1 | wc -l` -gt 2 ]; then
113 echo $1
114 fi
115}
116
117rootfs_install_packages() {
118 ${STAGING_BINDIR_NATIVE}/apt-get install $@ --force-yes --allow-unauthenticated
119
120 for pkg in $@ ; do
121 deb_package_setflag installed $pkg
122 done
123}
diff --git a/meta/classes/rootfs_ipk.bbclass b/meta/classes/rootfs_ipk.bbclass
index b5556fa254..48fb2fbd18 100644
--- a/meta/classes/rootfs_ipk.bbclass
+++ b/meta/classes/rootfs_ipk.bbclass
@@ -16,7 +16,7 @@ IPKG_ARGS = "-f ${IPKGCONF_TARGET} -o ${IMAGE_ROOTFS} --force-overwrite"
16 16
17OPKG_PREPROCESS_COMMANDS = "package_update_index_ipk; package_generate_ipkg_conf" 17OPKG_PREPROCESS_COMMANDS = "package_update_index_ipk; package_generate_ipkg_conf"
18 18
19OPKG_POSTPROCESS_COMMANDS = "ipk_insert_feed_uris" 19OPKG_POSTPROCESS_COMMANDS = "ipk_insert_feed_uris; rootfs_install_all_locales; "
20 20
21opkglibdir = "${localstatedir}/lib/opkg" 21opkglibdir = "${localstatedir}/lib/opkg"
22 22
@@ -148,26 +148,14 @@ list_package_recommends() {
148 opkg-cl ${IPKG_ARGS} info $1 | grep ^Recommends | sed -e 's/^Recommends: //' -e 's/,//g' -e 's:([=<>]* [0-9a-zA-Z.~\-]*)::g' 148 opkg-cl ${IPKG_ARGS} info $1 | grep ^Recommends | sed -e 's/^Recommends: //' -e 's/,//g' -e 's:([=<>]* [0-9a-zA-Z.~\-]*)::g'
149} 149}
150 150
151install_all_locales() { 151rootfs_check_package_exists() {
152 152 if [ `opkg-cl ${IPKG_ARGS} info $1 | wc -l` -gt 2 ]; then
153 PACKAGES_TO_INSTALL="" 153 echo $1
154 154 fi
155 INSTALLED_PACKAGES=`list_installed_packages | egrep -v -- "(-locale-|-dev$|-doc$|^kernel|^glibc|^ttf|^task|^perl|^python)"` 155}
156 156
157 for pkg in $INSTALLED_PACKAGES 157rootfs_install_packages() {
158 do 158 opkg-cl ${IPKG_ARGS} install $PACKAGES_TO_INSTALL
159 for lang in ${IMAGE_LOCALES}
160 do
161 if [ `opkg-cl ${IPKG_ARGS} info $pkg-locale-$lang | wc -l` -gt 2 ]
162 then
163 PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL $pkg-locale-$lang"
164 fi
165 done
166 done
167 if [ "$PACKAGES_TO_INSTALL" != "" ]
168 then
169 opkg-cl ${IPKG_ARGS} install $PACKAGES_TO_INSTALL
170 fi
171} 159}
172 160
173ipk_insert_feed_uris () { 161ipk_insert_feed_uris () {
diff --git a/meta/classes/rootfs_rpm.bbclass b/meta/classes/rootfs_rpm.bbclass
index 966b074181..30f3783e3c 100644
--- a/meta/classes/rootfs_rpm.bbclass
+++ b/meta/classes/rootfs_rpm.bbclass
@@ -21,12 +21,7 @@ do_rootfs[depends] += "opkg-native:do_populate_sysroot"
21do_rootfs[recrdeptask] += "do_package_write_rpm" 21do_rootfs[recrdeptask] += "do_package_write_rpm"
22 22
23RPM_PREPROCESS_COMMANDS = "package_update_index_rpm; package_generate_rpm_conf; " 23RPM_PREPROCESS_COMMANDS = "package_update_index_rpm; package_generate_rpm_conf; "
24RPM_POSTPROCESS_COMMANDS = "" 24RPM_POSTPROCESS_COMMANDS = "rootfs_install_all_locales; "
25
26# To test the install_all_locales.. enable the following...
27#RPM_POSTPROCESS_COMMANDS = "install_all_locales; "
28#
29#IMAGE_LOCALES="en-gb"
30 25
31# 26#
32# Allow distributions to alter when [postponed] package install scripts are run 27# Allow distributions to alter when [postponed] package install scripts are run
@@ -198,24 +193,16 @@ list_package_recommends() {
198 ${RPM_QUERY_CMD} -q --suggests $1 193 ${RPM_QUERY_CMD} -q --suggests $1
199} 194}
200 195
201install_all_locales() { 196rootfs_check_package_exists() {
202 PACKAGES_TO_INSTALL="" 197 resolve_package_rpm ${RPMCONF_TARGET_BASE}-base_archs.conf $1
203 198}
204 # Generate list of installed packages... 199
205 INSTALLED_PACKAGES=`list_installed_packages | egrep -v -- "(-locale-|-dev$|-doc$|^kernel|^glibc|^ttf|^task|^perl|^python)"` 200rootfs_install_packages() {
206 201 for pkg in $@; do
207 # This would likely be faster if we did it in one transaction 202 ${RPM} --root ${IMAGE_ROOTFS} -D "_dbpath ${rpmlibdir}" \
208 # but this should be good enough for the few users of this function... 203 -D "__dbi_txn create nofsync private" \
209 for pkg in $INSTALLED_PACKAGES; do 204 --noscripts --notriggers --noparentdirs --nolinktos \
210 for lang in ${IMAGE_LOCALES}; do 205 -Uhv $pkg || true
211 pkg_name=$(resolve_package_rpm $pkg-locale-$lang ${RPMCONF_TARGET_BASE}.conf)
212 if [ -n "$pkg_name" ]; then
213 ${RPM} --root ${IMAGE_ROOTFS} -D "_dbpath ${rpmlibdir}" \
214 -D "__dbi_txn create nofsync private" \
215 --noscripts --notriggers --noparentdirs --nolinktos \
216 -Uhv $pkg_name || true
217 fi
218 done
219 done 206 done
220} 207}
221 208