summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorMark Hatle <mark.hatle@windriver.com>2012-11-30 16:11:37 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-12-17 17:24:51 +0000
commita6aa74817cce38799b447cd47ef6f77aee9fcc85 (patch)
treee02a6b60d8fb05386b67dd89848c48acec4709d7 /meta
parentba08a8ccbf11542867b7dd0474599fccb0585b97 (diff)
downloadpoky-a6aa74817cce38799b447cd47ef6f77aee9fcc85.tar.gz
package_rpm: Update the way the multilib package names are translated
The variable MULTILIB_PACKAGE_ARCHS has been removed in favor of a repurposed MULTILIB_PREFIX_LIST. The format of this item is now <libid>:<arch>:<arch1>:...:<archN>. This ensures that we can correctly translate the libid to one of the supported archs in a tri-lib system. All of the users of MULTILIB_PREFIX_LIST and MULTILIB_PACKAGE_ARCHS have been modified accordingly. Also change the way attempted packages are installed, verify the package exists in the translate functions, then perform the install in one single operation. This results in a significantly faster install time. (From OE-Core rev: ffe6cf3a1c57defdbe8531bdeb588e199177bb6c) Signed-off-by: Mark Hatle <mark.hatle@windriver.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/classes/package_rpm.bbclass188
-rw-r--r--meta/classes/populate_sdk_rpm.bbclass28
-rw-r--r--meta/classes/rootfs_rpm.bbclass47
3 files changed, 216 insertions, 47 deletions
diff --git a/meta/classes/package_rpm.bbclass b/meta/classes/package_rpm.bbclass
index 4b81b68bf7..4f60daffb4 100644
--- a/meta/classes/package_rpm.bbclass
+++ b/meta/classes/package_rpm.bbclass
@@ -24,11 +24,24 @@ package_update_index_rpm () {
24 return 24 return
25 fi 25 fi
26 26
27 base_archs="`echo ${PACKAGE_ARCHS} | sed 's/-/_/g'`" 27 sdk_archs=`echo "${SDK_PACKAGE_ARCHS}" | tr - _`
28 ml_archs="`echo ${MULTILIB_PACKAGE_ARCHS} | sed 's/-/_/g'`" 28
29 sdk_archs="`echo ${SDK_PACKAGE_ARCHS} | sed 's/-/_/g'`" 29 target_archs=""
30 for i in ${MULTILIB_PREFIX_LIST} ; do
31 old_IFS="$IFS"
32 IFS=":"
33 set $i
34 IFS="$old_IFS"
35 shift # remove mlib
36 while [ -n "$1" ]; do
37 target_archs="$target_archs $1"
38 shift
39 done
40 done
30 41
31 archs=`for arch in $base_archs $ml_archs $sdk_archs ; do 42 target_archs=`echo "$target_archs" | tr - _`
43
44 archs=`for arch in $target_archs $sdk_archs ; do
32 echo $arch 45 echo $arch
33 done | sort | uniq` 46 done | sort | uniq`
34 47
@@ -59,6 +72,143 @@ rpm_log_check() {
59 true 72 true
60} 73}
61 74
75# Translate the RPM/Smart format names to the OE multilib format names
76# Input via stdin (only the first item per line is converted!)
77# Output via stdout
78translate_smart_to_oe() {
79 arg1="$1"
80
81 # Dump installed packages
82 while read pkg arch other ; do
83 if [ -z "$pkg" ]; then
84 continue
85 fi
86 new_pkg=$pkg
87 fixed_arch=`echo "$arch" | tr _ -`
88 for i in ${MULTILIB_PREFIX_LIST} ; do
89 old_IFS="$IFS"
90 IFS=":"
91 set $i
92 IFS="$old_IFS"
93 mlib="$1"
94 shift
95 while [ -n "$1" ]; do
96 cmp_arch=$1
97 shift
98 if [ "$arch" = "$cmp_arch" -o "$fixed_arch" = "$cmp_arch" ]; then
99 if [ "$mlib" = "default" ]; then
100 new_pkg="$pkg"
101 else
102 new_pkg="$mlib-$pkg"
103 fi
104 break
105 fi
106 done
107 if [ "$arch" = "$cmp_arch" -o "$fixed_arch" = "$cmp_arch" ]; then
108 break
109 fi
110 done
111
112 #echo "$pkg -> $new_pkg" >&2
113 if [ "$arg1" = "arch" ]; then
114 echo $new_pkg $cmp_arch $other
115 else
116 echo $new_pkg $other
117 fi
118 done
119}
120
121# Translate the OE multilib format names to the RPM/Smart format names
122# Input via arguments
123# Ouput via pkgs_to_install
124translate_oe_to_smart() {
125 default_archs=""
126 sdk_mode=""
127 if [ "$1" = "--sdk" ]; then
128 shift
129 sdk_mode="true"
130 # Need to reverse the order of the SDK_ARCHS highest -> lowest priority
131 archs=`echo "${SDK_PACKAGE_ARCHS}" | tr - _`
132 for arch in $archs ; do
133 default_archs="$arch $default_archs"
134 done
135 fi
136
137 attemptonly="Error"
138 if [ "$1" = "--attemptonly" ]; then
139 attemptonly="Warning"
140 shift
141 fi
142
143 # Dump a list of all available packages
144 [ ! -e ${target_rootfs}/install/tmp/fullpkglist.query ] && smart --data-dir=${target_rootfs}/var/lib/smart query --output ${target_rootfs}/install/tmp/fullpkglist.query
145
146 pkgs_to_install=""
147 for pkg in "$@" ; do
148 new_pkg="$pkg"
149 if [ -z "$sdk_mode" ]; then
150 for i in ${MULTILIB_PREFIX_LIST} ; do
151 old_IFS="$IFS"
152 IFS=":"
153 set $i
154 IFS="$old_IFS"
155 mlib="$1"
156 shift
157 if [ "$mlib" = "default" ]; then
158 if [ -z "$default_archs" ]; then
159 default_archs=$@
160 fi
161 continue
162 fi
163 subst=${pkg#${mlib}-}
164 if [ "$subst" != "$pkg" ]; then
165 feeds=$@
166 while [ -n "$1" ]; do
167 arch="$1"
168 arch=`echo "$arch" | tr - _`
169 shift
170 if grep -q '^'$subst'-[^-]*-[^-]*@'$arch'$' ${target_rootfs}/install/tmp/fullpkglist.query ; then
171 new_pkg="$subst@$arch"
172 # First found is best match
173 break
174 fi
175 done
176 if [ "$pkg" = "$new_pkg" ]; then
177 # Failed to translate, package not found!
178 echo "$attemptonly: $pkg not found in the $mlib feeds ($feeds)." >&2
179 if [ "$attemptonly" = "Error" ]; then
180 exit 1
181 fi
182 continue
183 fi
184 fi
185 done
186 fi
187 # Apparently not a multilib package...
188 if [ "$pkg" = "$new_pkg" ]; then
189 default_archs_fixed=`echo "$default_archs" | tr - _`
190 for arch in $default_archs_fixed ; do
191 if grep -q '^'$pkg'-[^-]*-[^-]*@'$arch'$' ${target_rootfs}/install/tmp/fullpkglist.query ; then
192 new_pkg="$pkg@$arch"
193 # First found is best match
194 break
195 fi
196 done
197 if [ "$pkg" = "$new_pkg" ]; then
198 # Failed to translate, package not found!
199 echo "$attemptonly: $pkg not found in the base feeds ($default_archs)." >&2
200 if [ "$attemptonly" = "Error" ]; then
201 exit 1
202 fi
203 continue
204 fi
205 fi
206 #echo "$pkg -> $new_pkg" >&2
207 pkgs_to_install="${pkgs_to_install} ${new_pkg}"
208 done
209 export pkgs_to_install
210}
211
62 212
63# 213#
64# Install a bunch of packages using rpm. 214# Install a bunch of packages using rpm.
@@ -96,18 +246,26 @@ package_install_internal_rpm () {
96 local providename="$INSTALL_PROVIDENAME_RPM" 246 local providename="$INSTALL_PROVIDENAME_RPM"
97 local task="$INSTALL_TASK_RPM" 247 local task="$INSTALL_TASK_RPM"
98 248
249 local sdk_mode=""
250 if [ "$1" = "--sdk" ]; then
251 sdk_mode="--sdk"
252 fi
253
99 # Configure internal RPM environment when using Smart 254 # Configure internal RPM environment when using Smart
100 export RPM_ETCRPM=${target_rootfs}/etc/rpm 255 export RPM_ETCRPM=${target_rootfs}/etc/rpm
101 256
102 # Setup temporary directory -- install... 257 # Setup temporary directory -- install...
103 mkdir -p ${target_rootfs}/install 258 rm -rf ${target_rootfs}/install
259 mkdir -p ${target_rootfs}/install/tmp
104 260
261 channel_priority=5
105 if [ "${INSTALL_COMPLEMENTARY_RPM}" != "1" ] ; then 262 if [ "${INSTALL_COMPLEMENTARY_RPM}" != "1" ] ; then
106 # Setup base system configuration 263 # Setup base system configuration
107 mkdir -p ${target_rootfs}/etc/rpm/ 264 mkdir -p ${target_rootfs}/etc/rpm/
108 echo "${platform}${TARGET_VENDOR}-${TARGET_OS}" > ${target_rootfs}/etc/rpm/platform 265 echo "${platform}${TARGET_VENDOR}-${TARGET_OS}" > ${target_rootfs}/etc/rpm/platform
109 if [ ! -z "$platform_extra" ]; then 266 if [ ! -z "$platform_extra" ]; then
110 for pt in $platform_extra ; do 267 for pt in $platform_extra ; do
268 channel_priority=$(expr $channel_priority + 5)
111 case $pt in 269 case $pt in
112 noarch | any | all) 270 noarch | any | all)
113 os="`echo ${TARGET_OS} | sed "s,-.*,,"`.*" 271 os="`echo ${TARGET_OS} | sed "s,-.*,,"`.*"
@@ -178,11 +336,14 @@ EOF
178 smart --data-dir=${target_rootfs}/var/lib/smart config --set rpm-extra-macros._tmppath=/install/tmp 336 smart --data-dir=${target_rootfs}/var/lib/smart config --set rpm-extra-macros._tmppath=/install/tmp
179 smart --data-dir=${target_rootfs}/var/lib/smart channel --add rpmsys type=rpm-sys -y 337 smart --data-dir=${target_rootfs}/var/lib/smart channel --add rpmsys type=rpm-sys -y
180 338
181 for arch in $platform_extra ; do 339 platform_extra_fixed=`echo "$platform_extra" | tr - _`
340 for arch in $platform_extra_fixed ; do
182 if [ -d ${DEPLOY_DIR_RPM}/$arch -a ! -e ${target_rootfs}/install/channel.$arch.stamp ] ; then 341 if [ -d ${DEPLOY_DIR_RPM}/$arch -a ! -e ${target_rootfs}/install/channel.$arch.stamp ] ; then
183 smart --data-dir=${target_rootfs}/var/lib/smart channel --add $arch type=rpm-md type=rpm-md baseurl=${DEPLOY_DIR_RPM}/$arch -y 342 smart --data-dir=${target_rootfs}/var/lib/smart channel --add $arch type=rpm-md type=rpm-md baseurl=${DEPLOY_DIR_RPM}/$arch -y
343 smart --data-dir=${target_rootfs}/var/lib/smart channel --set $arch priority=$channel_priority
184 touch ${target_rootfs}/install/channel.$arch.stamp 344 touch ${target_rootfs}/install/channel.$arch.stamp
185 fi 345 fi
346 channel_priority=$(expr $channel_priority - 5)
186 done 347 done
187 fi 348 fi
188 349
@@ -218,14 +379,15 @@ EOF
218 chmod 0755 ${WORKDIR}/scriptlet_wrapper 379 chmod 0755 ${WORKDIR}/scriptlet_wrapper
219 smart --data-dir=${target_rootfs}/var/lib/smart config --set rpm-extra-macros._cross_scriptlet_wrapper=${WORKDIR}/scriptlet_wrapper 380 smart --data-dir=${target_rootfs}/var/lib/smart config --set rpm-extra-macros._cross_scriptlet_wrapper=${WORKDIR}/scriptlet_wrapper
220 381
221 smart --data-dir=${target_rootfs}/var/lib/smart install -y ${package_to_install} ${package_linguas} 382 # Determine what to install
383 translate_oe_to_smart ${sdk_mode} ${package_to_install} ${package_linguas}
222 384
223 if [ ! -z "${package_attemptonly}" ]; then 385 [ -n "$pkgs_to_install" ] && smart --data-dir=${target_rootfs}/var/lib/smart install -y ${pkgs_to_install}
224 echo "Installing attempt only packages..." 386
225 for pkg_name in ${package_attemptonly} ; do 387 if [ -n "${package_attemptonly}" ]; then
226 echo "Attempting $pkg_name..." >> "`dirname ${BB_LOGFILE}`/log.do_${task}_attemptonly.${PID}" 388 translate_oe_to_smart ${sdk_mode} --attemptonly $package_attemptonly
227 smart --data-dir=${target_rootfs}/var/lib/smart install -y $pkg_name >> "`dirname ${BB_LOGFILE}`/log.do_${task}_attemptonly.${PID}" 2>&1 || true 389 echo "Attempting $pkgs_to_install"
228 done 390 smart --data-dir=${target_rootfs}/var/lib/smart install -y $pkgs_to_install >> "`dirname ${BB_LOGFILE}`/log.do_${task}_attemptonly.${PID}" 2>&1 || true
229 fi 391 fi
230} 392}
231 393
diff --git a/meta/classes/populate_sdk_rpm.bbclass b/meta/classes/populate_sdk_rpm.bbclass
index d26867fa9a..eb80e1dd9c 100644
--- a/meta/classes/populate_sdk_rpm.bbclass
+++ b/meta/classes/populate_sdk_rpm.bbclass
@@ -54,8 +54,16 @@ populate_sdk_rpm () {
54 54
55 # List must be prefered to least preferred order 55 # List must be prefered to least preferred order
56 INSTALL_PLATFORM_EXTRA_RPM="" 56 INSTALL_PLATFORM_EXTRA_RPM=""
57 for each_arch in ${MULTILIB_PACKAGE_ARCHS} ${PACKAGE_ARCHS} ; do 57 for i in ${MULTILIB_PREFIX_LIST} ; do
58 INSTALL_PLATFORM_EXTRA_RPM="$each_arch $INSTALL_PLATFORM_EXTRA_RPM" 58 old_IFS="$IFS"
59 IFS=":"
60 set $i
61 IFS="$old_IFS"
62 shift #remove mlib
63 while [ -n "$1" ]; do
64 INSTALL_PLATFORM_EXTRA_RPM="$INSTALL_PLATFORM_EXTRA_RPM $1"
65 shift
66 done
59 done 67 done
60 export INSTALL_PLATFORM_EXTRA_RPM 68 export INSTALL_PLATFORM_EXTRA_RPM
61 69
@@ -81,7 +89,7 @@ populate_sdk_rpm () {
81 done 89 done
82 export INSTALL_PLATFORM_EXTRA_RPM 90 export INSTALL_PLATFORM_EXTRA_RPM
83 91
84 package_install_internal_rpm 92 package_install_internal_rpm --sdk
85 populate_sdk_post_rpm ${INSTALL_ROOTFS_RPM} 93 populate_sdk_post_rpm ${INSTALL_ROOTFS_RPM}
86 94
87 # move host RPM library data 95 # move host RPM library data
@@ -98,8 +106,11 @@ populate_sdk_rpm () {
98 106
99python () { 107python () {
100 # The following code should be kept in sync w/ the rootfs_rpm version. 108 # The following code should be kept in sync w/ the rootfs_rpm version.
101 ml_package_archs = "" 109
102 ml_prefix_list = "" 110 # package_arch order is reversed. This ensures the -best- match is listed first!
111 package_archs = d.getVar("PACKAGE_ARCHS", True) or ""
112 package_archs = ":".join(package_archs.split()[::-1])
113 ml_prefix_list = "%s:%s" % ('default', package_archs)
103 multilibs = d.getVar('MULTILIBS', True) or "" 114 multilibs = d.getVar('MULTILIBS', True) or ""
104 for ext in multilibs.split(): 115 for ext in multilibs.split():
105 eext = ext.split(':') 116 eext = ext.split(':')
@@ -109,11 +120,8 @@ python () {
109 if default_tune: 120 if default_tune:
110 localdata.setVar("DEFAULTTUNE", default_tune) 121 localdata.setVar("DEFAULTTUNE", default_tune)
111 package_archs = localdata.getVar("PACKAGE_ARCHS", True) or "" 122 package_archs = localdata.getVar("PACKAGE_ARCHS", True) or ""
112 package_archs = " ".join([i in "all noarch any".split() and i or eext[1]+"_"+i for i in package_archs.split()]) 123 package_archs = ":".join([i in "all noarch any".split() and i or eext[1]+"_"+i for i in package_archs.split()][::-1])
113 ml_package_archs += " " + package_archs 124 ml_prefix_list += " %s:%s" % (eext[1], package_archs)
114 ml_prefix_list += " " + eext[1]
115 #bb.note("ML_PACKAGE_ARCHS %s %s %s" % (eext[1], localdata.getVar("PACKAGE_ARCHS", True) or "(none)", overrides))
116 d.setVar('MULTILIB_PACKAGE_ARCHS', ml_package_archs)
117 d.setVar('MULTILIB_PREFIX_LIST', ml_prefix_list) 125 d.setVar('MULTILIB_PREFIX_LIST', ml_prefix_list)
118} 126}
119 127
diff --git a/meta/classes/rootfs_rpm.bbclass b/meta/classes/rootfs_rpm.bbclass
index a507ad62e8..5000956d14 100644
--- a/meta/classes/rootfs_rpm.bbclass
+++ b/meta/classes/rootfs_rpm.bbclass
@@ -62,8 +62,16 @@ fakeroot rootfs_rpm_do_rootfs () {
62 62
63 # List must be prefered to least preferred order 63 # List must be prefered to least preferred order
64 INSTALL_PLATFORM_EXTRA_RPM="" 64 INSTALL_PLATFORM_EXTRA_RPM=""
65 for each_arch in ${MULTILIB_PACKAGE_ARCHS} ${PACKAGE_ARCHS}; do 65 for i in ${MULTILIB_PREFIX_LIST} ; do
66 INSTALL_PLATFORM_EXTRA_RPM="$each_arch $INSTALL_PLATFORM_EXTRA_RPM" 66 old_IFS="$IFS"
67 IFS=":"
68 set $i
69 IFS="$old_IFS"
70 shift #remove mlib
71 while [ -n "$1" ]; do
72 INSTALL_PLATFORM_EXTRA_RPM="$INSTALL_PLATFORM_EXTRA_RPM $1"
73 shift
74 done
67 done 75 done
68 export INSTALL_PLATFORM_RPM 76 export INSTALL_PLATFORM_RPM
69 77
@@ -143,21 +151,12 @@ rpm_setup_smart_target_config() {
143RPM_QUERY_CMD = '${RPM} --root $INSTALL_ROOTFS_RPM -D "_dbpath ${rpmlibdir}"' 151RPM_QUERY_CMD = '${RPM} --root $INSTALL_ROOTFS_RPM -D "_dbpath ${rpmlibdir}"'
144 152
145list_installed_packages() { 153list_installed_packages() {
146 GET_LIST=$(${RPM_QUERY_CMD} -qa --qf "[%{NAME} %{ARCH} %{PACKAGEORIGIN} %{Platform}\n]") 154 if [ "$1" = "arch" ]; then
147 155 ${RPM_QUERY_CMD} -qa --qf "[%{NAME} %{ARCH}\n]" | translate_smart_to_oe arch | tee /tmp/arch_list
148 # Use awk to find the multilib prefix and compare it 156 elif [ "$1" = "file" ]; then
149 # with the platform RPM thinks it is part of 157 ${RPM_QUERY_CMD} -qa --qf "[%{NAME} %{ARCH} %{PACKAGEORIGIN}\n]" | translate_smart_to_oe | tee /tmp/file_list
150 for prefix in `echo ${MULTILIB_PREFIX_LIST}`; do 158 else
151 GET_LIST=$(echo "$GET_LIST" | awk -v prefix="$prefix" '$0 ~ prefix {printf("%s-%s\n", prefix, $0); } $0 !~ prefix {print $0}') 159 ${RPM_QUERY_CMD} -qa --qf "[%{NAME} %{ARCH}\n]" | translate_smart_to_oe | tee /tmp/default_list
152 done
153
154 # print the info, need to different return counts
155 if [ "$1" = "arch" ] ; then
156 echo "$GET_LIST" | awk -v archs="${PACKAGE_ARCHS}" '{if(!index(archs, $2)) {gsub("_", "-", $2)} print $1, $2}'
157 elif [ "$1" = "file" ] ; then
158 echo "$GET_LIST" | awk '{print $1, $3}'
159 else
160 echo "$GET_LIST" | awk '{print $1}'
161 fi 160 fi
162} 161}
163 162
@@ -187,8 +186,11 @@ python () {
187 d.setVar('RPM_POSTPROCESS_COMMANDS', '') 186 d.setVar('RPM_POSTPROCESS_COMMANDS', '')
188 187
189 # The following code should be kept in sync w/ the populate_sdk_rpm version. 188 # The following code should be kept in sync w/ the populate_sdk_rpm version.
190 ml_package_archs = "" 189
191 ml_prefix_list = "" 190 # package_arch order is reversed. This ensures the -best- match is listed first!
191 package_archs = d.getVar("PACKAGE_ARCHS", True) or ""
192 package_archs = ":".join(package_archs.split()[::-1])
193 ml_prefix_list = "%s:%s" % ('default', package_archs)
192 multilibs = d.getVar('MULTILIBS', True) or "" 194 multilibs = d.getVar('MULTILIBS', True) or ""
193 for ext in multilibs.split(): 195 for ext in multilibs.split():
194 eext = ext.split(':') 196 eext = ext.split(':')
@@ -198,10 +200,7 @@ python () {
198 if default_tune: 200 if default_tune:
199 localdata.setVar("DEFAULTTUNE", default_tune) 201 localdata.setVar("DEFAULTTUNE", default_tune)
200 package_archs = localdata.getVar("PACKAGE_ARCHS", True) or "" 202 package_archs = localdata.getVar("PACKAGE_ARCHS", True) or ""
201 package_archs = " ".join([i in "all noarch any".split() and i or eext[1]+"_"+i for i in package_archs.split()]) 203 package_archs = ":".join([i in "all noarch any".split() and i or eext[1]+"_"+i for i in package_archs.split()][::-1])
202 ml_package_archs += " " + package_archs 204 ml_prefix_list += " %s:%s" % (eext[1], package_archs)
203 ml_prefix_list += " " + eext[1]
204 #bb.note("ML_PACKAGE_ARCHS %s %s %s" % (eext[1], localdata.getVar("PACKAGE_ARCHS", True) or "(none)", overrides))
205 d.setVar('MULTILIB_PACKAGE_ARCHS', ml_package_archs)
206 d.setVar('MULTILIB_PREFIX_LIST', ml_prefix_list) 205 d.setVar('MULTILIB_PREFIX_LIST', ml_prefix_list)
207} 206}