summaryrefslogtreecommitdiffstats
path: root/meta/classes/package_rpm.bbclass
diff options
context:
space:
mode:
authorLianhao Lu <lianhao.lu@intel.com>2011-01-30 14:07:50 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-02-01 23:59:37 +0000
commit382075a9c2a5877d198a217161558da6ad2d5f89 (patch)
tree33b53b274eb1c921721f71cf87904e24851c7627 /meta/classes/package_rpm.bbclass
parentb94f9ccd05a339a5e3e8ec4c7bd8c727ca575871 (diff)
downloadpoky-382075a9c2a5877d198a217161558da6ad2d5f89.tar.gz
rootfs_rpm/package_rpm.bbclass: Move func from rootfs_rpm to package_rpm
package_deb.bbclass: 1. Modified package_update_index_rpm() and package_generate_rpm_conf() to generate sperate depsolver db and rpm configuration, for target packages and host packages respectively. 2. Added new function package_install_internal_rpm() to install a list deb packages to a specified root directory, with the specified package architecutre information. 3. Added new function resolve_package_rpm() to resolve package names to filepaths. rootfs_deb.bbclass: Used the above new functions to install the rootfs. [sgw: merged changes for createrepo] Signed-off-by: Lianhao Lu <lianhao.lu@intel.com> Signed-off-by: Saul Wold <sgw@linux.intel.com>
Diffstat (limited to 'meta/classes/package_rpm.bbclass')
-rw-r--r--meta/classes/package_rpm.bbclass230
1 files changed, 220 insertions, 10 deletions
diff --git a/meta/classes/package_rpm.bbclass b/meta/classes/package_rpm.bbclass
index 8891f06ffa..cc262dc831 100644
--- a/meta/classes/package_rpm.bbclass
+++ b/meta/classes/package_rpm.bbclass
@@ -15,6 +15,8 @@ python package_rpm_install () {
15 bb.fatal("package_rpm_install not implemented!") 15 bb.fatal("package_rpm_install not implemented!")
16} 16}
17 17
18RPMCONF_TARGET_BASE = "${DEPLOY_DIR_RPM}/solvedb"
19RPMCONF_HOST_BASE = "${DEPLOY_DIR_RPM}/solvedb-sdk"
18# 20#
19# Update the Packages depsolver db in ${DEPLOY_DIR_RPM} 21# Update the Packages depsolver db in ${DEPLOY_DIR_RPM}
20# 22#
@@ -26,15 +28,18 @@ package_update_index_rpm () {
26 fi 28 fi
27 29
28 packagedirs="" 30 packagedirs=""
31 packagedirs_sdk=""
29 for arch in $rpmarchs ; do 32 for arch in $rpmarchs ; do
30 sdkarch=`echo $arch | sed -e 's/${HOST_ARCH}/${SDK_ARCH}/'` 33 sdkarch=`echo $arch | sed -e 's/${HOST_ARCH}/${SDK_ARCH}/'`
34 extension="-nativesdk"
35 if [ "$sdkarch" = "all" -o "$sdkarch" = "any" -o "$sdkarch" = "noarch" ]; then
36 extension=""
37 fi
31 packagedirs="$packagedirs ${DEPLOY_DIR_RPM}/$arch" 38 packagedirs="$packagedirs ${DEPLOY_DIR_RPM}/$arch"
32 #packagedirs="$packagedirs ${DEPLOY_DIR_RPM}/$sdkarch-nativesdk" 39 packagedirs_sdk="$packagedirs_sdk ${DEPLOY_DIR_RPM}/$sdkarch$extension"
33 done 40 done
34 41
35 #packagedirs="$packagedirs ${DEPLOY_DIR_RPM}/${SDK_ARCH}-${TARGET_ARCH}-canadian" 42 cat /dev/null > ${RPMCONF_TARGET_BASE}.conf
36
37 cat /dev/null > ${DEPLOY_DIR_RPM}/solvedb.conf
38 for pkgdir in $packagedirs; do 43 for pkgdir in $packagedirs; do
39 if [ -e $pkgdir/ ]; then 44 if [ -e $pkgdir/ ]; then
40 echo "Generating solve db for $pkgdir..." 45 echo "Generating solve db for $pkgdir..."
@@ -48,7 +53,25 @@ package_update_index_rpm () {
48 --ignoresize --nosignature --nodigest \ 53 --ignoresize --nosignature --nodigest \
49 -D "__dbi_txn create nofsync" \ 54 -D "__dbi_txn create nofsync" \
50 $pkgdir/solvedb/manifest 55 $pkgdir/solvedb/manifest
51 echo $pkgdir/solvedb >> ${DEPLOY_DIR_RPM}/solvedb.conf 56 echo $pkgdir/solvedb >> ${RPMCONF_TARGET_BASE}.conf
57 fi
58 done
59
60 cat /dev/null > ${RPMCONF_HOST_BASE}.conf
61 for pkgdir in $packagedirs_sdk; do
62 if [ -e $pkgdir/ ]; then
63 echo "Generating solve db for $pkgdir..."
64 rm -rf $pkgdir/solvedb
65 mkdir -p $pkgdir/solvedb
66 echo "# Dynamically generated solve manifest" >> $pkgdir/solvedb/manifest
67 find $pkgdir -maxdepth 1 -type f >> $pkgdir/solvedb/manifest
68 ${RPM} -i --replacepkgs --replacefiles --oldpackage \
69 -D "_dbpath $pkgdir/solvedb" --justdb \
70 --noaid --nodeps --noorder --noscripts --notriggers --noparentdirs --nolinktos --stats \
71 --ignoresize --nosignature --nodigest \
72 -D "__dbi_txn create nofsync" \
73 $pkgdir/solvedb/manifest
74 echo $pkgdir/solvedb >> ${RPMCONF_HOST_BASE}.conf
52 fi 75 fi
53 done 76 done
54} 77}
@@ -58,16 +81,27 @@ package_update_index_rpm () {
58# generated depsolver db's... 81# generated depsolver db's...
59# 82#
60package_generate_rpm_conf () { 83package_generate_rpm_conf () {
61 printf "_solve_dbpath " > ${DEPLOY_DIR_RPM}/solvedb.macro 84 printf "_solve_dbpath " > ${RPMCONF_TARGET_BASE}.macro
85 colon=false
86 for each in `cat ${RPMCONF_TARGET_BASE}.conf` ; do
87 if [ "$colon" == true ]; then
88 printf ":" >> ${RPMCONF_TARGET_BASE}.macro
89 fi
90 printf "%s" $each >> ${RPMCONF_TARGET_BASE}.macro
91 colon=true
92 done
93 printf "\n" >> ${RPMCONF_TARGET_BASE}.macro
94
95 printf "_solve_dbpath " > ${RPMCONF_HOST_BASE}.macro
62 colon=false 96 colon=false
63 for each in `cat ${DEPLOY_DIR_RPM}/solvedb.conf` ; do 97 for each in `cat ${RPMCONF_HOST_BASE}.conf` ; do
64 if [ "$colon" == true ]; then 98 if [ "$colon" == true ]; then
65 printf ":" >> ${DEPLOY_DIR_RPM}/solvedb.macro 99 printf ":" >> ${RPMCONF_HOST_BASE}.macro
66 fi 100 fi
67 printf "%s" $each >> ${DEPLOY_DIR_RPM}/solvedb.macro 101 printf "%s" $each >> ${RPMCONF_HOST_BASE}.macro
68 colon=true 102 colon=true
69 done 103 done
70 printf "\n" >> ${DEPLOY_DIR_RPM}/solvedb.macro 104 printf "\n" >> ${RPMCONF_HOST_BASE}.macro
71} 105}
72 106
73rpm_log_check() { 107rpm_log_check() {
@@ -90,6 +124,182 @@ rpm_log_check() {
90 true 124 true
91} 125}
92 126
127
128#
129# Resolve package names to filepaths
130# resolve_pacakge <pkgname> <solvdb conffile>
131#
132resolve_package_rpm () {
133 local pkg="$1"
134 local conffile="$2"
135 local pkg_name=""
136 for solve in `cat ${conffile}`; do
137 pkg_name=$(${RPM} -D "_dbpath $solve" -D "__dbi_txn create nofsync" -q --yaml $pkg | grep -i 'Packageorigin' | cut -d : -f 2)
138 if [ -n "$pkg_name" ]; then
139 break;
140 fi
141 done
142 echo $pkg_name
143}
144
145#
146# install a bunch of packages using rpm
147# the following shell variables needs to be set before calling this func:
148# INSTALL_ROOTFS_RPM - install root dir
149# INSTALL_PLATFORM_RPM - main platform
150# INSTALL_PLATFORM_EXTRA_RPM - extra platform
151# INSTALL_CONFBASE_RPM - configuration file base name
152# INSTALL_PACKAGES_NORMAL_RPM - packages to be installed
153# INSTALL_PACKAGES_ATTEMPTONLY_RPM - packages attemped to be installed only
154# INSTALL_PACKAGES_LINGUAS_RPM - additional packages for uclibc
155# INSTALL_PROVIDENAME_RPM - content for provide name
156# INSTALL_TASK_RPM - task name
157
158package_install_internal_rpm () {
159
160 local target_rootfs="${INSTALL_ROOTFS_RPM}"
161 local platform="${INSTALL_PLATFORM_RPM}"
162 local platform_extra="${INSTALL_PLATFORM_EXTRA_RPM}"
163 local confbase="${INSTALL_CONFBASE_RPM}"
164 local package_to_install="${INSTALL_PACKAGES_NORMAL_RPM}"
165 local package_attemptonly="${INSTALL_PACKAGES_ATTEMPTONLY_RPM}"
166 local package_lingusa="${INSTALL_PACKAGES_LINGUAS_RPM}"
167 local providename="${INSTALL_PROVIDENAME_RPM}"
168 local task="${INSTALL_TASK_RPM}"
169
170 # Setup base system configuration
171 mkdir -p ${target_rootfs}/etc/rpm/
172 echo "${platform}-unknown-linux" >${target_rootfs}/etc/rpm/platform
173 if [ ! -z "$platform_extra" ]; then
174 for pt in $platform_extra ; do
175 echo "$pt-unknown-linux" >> ${target_rootfs}/etc/rpm/platform
176 done
177 fi
178
179 # Tell RPM that the "/" directory exist and is available
180 mkdir -p ${target_rootfs}/etc/rpm/sysinfo
181 echo "/" >${target_rootfs}/etc/rpm/sysinfo/Dirnames
182 if [ ! -z "$providename" ]; then
183 >>${target_rootfs}/etc/rpm/sysinfo/Providename
184 for provide in $providename ; do
185 echo $provide >> ${target_rootfs}/etc/rpm/sysinfo/Providename
186 done
187 fi
188
189 # Setup manifest of packages to install...
190 mkdir -p ${target_rootfs}/install
191 echo "# Install manifest" > ${target_rootfs}/install/install.manifest
192
193 # Uclibc builds don't provide this stuff...
194 if [ x${TARGET_OS} = "xlinux" ] || [ x${TARGET_OS} = "xlinux-gnueabi" ] ; then
195 if [ ! -z "${package_lingusa}" ]; then
196 for pkg in ${package_lingusa}; do
197 echo "Processing $pkg..."
198 pkg_name=$(resolve_package_rpm $pkg ${confbase}.conf)
199 if [ -z "$pkg_name" ]; then
200 echo "Unable to find package $pkg!"
201 exit 1
202 fi
203 echo $pkg_name >> ${IMAGE_ROOTFS}/install/install.manifest
204 done
205 fi
206 fi
207
208 if [ ! -z "${package_to_install}" ]; then
209 for pkg in ${package_to_install} ; do
210 echo "Processing $pkg..."
211 pkg_name=$(resolve_package_rpm $pkg ${confbase}.conf)
212 if [ -z "$pkg_name" ]; then
213 echo "Unable to find package $pkg!"
214 exit 1
215 fi
216 echo $pkg_name >> ${target_rootfs}/install/install.manifest
217 done
218 fi
219
220 # Generate an install solution by doing a --justdb install, then recreate it with
221 # an actual package install!
222 ${RPM} -D "_rpmds_sysinfo_path ${target_rootfs}/etc/rpm/sysinfo" \
223 -D "_dbpath ${target_rootfs}/install" -D "`cat ${confbase}.macro`" \
224 -D "__dbi_txn create nofsync" \
225 -U --justdb --noscripts --notriggers --noparentdirs --nolinktos --ignoresize \
226 ${target_rootfs}/install/install.manifest
227
228 if [ ! -z "${package_attemptonly}" ]; then
229 echo "Adding attempt only packages..."
230 for pkg in ${package_attemptonly} ; do
231 echo "Processing $pkg..."
232 pkg_name=$(resolve_package_rpm $pkg ${confbase}.conf)
233 if [ -z "$pkg_name" ]; then
234 echo "Unable to find package $pkg!"
235 exit 1
236 fi
237 echo "Attempting $pkg_name..." >> "${WORKDIR}/temp/log.do_${task}_attemptonly.${PID}"
238 ${RPM} -D "_rpmds_sysinfo_path ${target_rootfs}/etc/rpm/sysinfo" \
239 -D "_dbpath ${target_rootfs}/install" -D "`cat ${confbase}.macro`" \
240 -D "__dbi_txn create nofsync private" \
241 -U --justdb --noscripts --notriggers --noparentdirs --nolinktos --ignoresize \
242 $pkg_name >> "${WORKDIR}/temp/log.do_${task}_attemptonly.${PID}" || true
243 done
244 fi
245
246 #### Note: 'Recommends' is an arbitrary tag that means _SUGGESTS_ in Poky..
247 # Add any recommended packages to the image
248 # RPM does not solve for recommended packages because they are optional...
249 # So we query them and tree them like the ATTEMPTONLY packages above...
250 # Change the loop to "1" to run this code...
251 loop=0
252 if [ $loop -eq 1 ]; then
253 echo "Processing recommended packages..."
254 cat /dev/null > ${target_rootfs}/install/recommend.list
255 while [ $loop -eq 1 ]; do
256 # Dump the full set of recommends...
257 ${RPM} -D "_rpmds_sysinfo_path ${target_rootfs}/etc/rpm/sysinfo" \
258 -D "_dbpath ${IMAGE_ROOTFS}/install" -D "`cat ${confbase}.macro`" \
259 -D "__dbi_txn create nofsync private" \
260 -qa --qf "[%{RECOMMENDS}\n]" | sort -u > ${target_rootfs}/install/recommend
261 # Did we add more to the list?
262 grep -v -x -F -f ${target_rootfs}/install/recommend.list ${target_rootfs}/install/recommend > ${target_rootfs}/install/recommend.new || true
263 # We don't want to loop unless there is a change to the list!
264 loop=0
265 cat ${target_rootfs}/install/recommend.new | \
266 while read pkg ; do
267 # Ohh there was a new one, we'll need to loop again...
268 loop=1
269 echo "Processing $pkg..."
270 pkg_name=$(resolve_package $pkg ${confbase}.conf)
271 if [ -z "$pkg_name" ]; then
272 echo "Unable to find package $pkg." >> "${WORKDIR}/temp/log.do_${task}_recommend.${PID}"
273 continue
274 fi
275 echo "Attempting $pkg_name..." >> "${WORKDIR}/temp/log.do_{task}_recommend.${PID}"
276 ${RPM} -D "_rpmds_sysinfo_path ${target_rootfs}/etc/rpm/sysinfo" \
277 -D "_dbpath ${target_rootfs}/install" -D "`cat ${confbase}.macro`" \
278 -D "__dbi_txn create nofsync private" \
279 -U --justdb --noscripts --notriggers --noparentdirs --nolinktos --ignoresize \
280 $pkg_name >> "${WORKDIR}/temp/log.do_${task}_recommend.${PID}" 2>&1 || true
281 done
282 cat ${target_rootfs}/install/recommend.list ${target_rootfs}/install/recommend.new | sort -u > ${target_rootfs}/install/recommend.new.list
283 mv -f ${target_rootfs}/install/recommend.new.list ${target_rootfs}/install/recommend.list
284 rm ${target_rootfs}/install/recommend ${target_rootfs}/install/recommend.new
285 done
286 fi
287
288 # Now that we have a solution, pull out a list of what to install...
289 echo "Manifest: ${target_rootfs}/install/install.manifest"
290 ${RPM} -D "_dbpath ${target_rootfs}/install" -qa --yaml \
291 -D "__dbi_txn create nofsync private" \
292 | grep -i 'Packageorigin' | cut -d : -f 2 > ${target_rootfs}/install/install_solution.manifest
293
294 # Attempt install
295 ${RPM} --root ${target_rootfs} \
296 -D "_rpmds_sysinfo_path ${target_rootfs}/etc/rpm/sysinfo" \
297 -D "_dbpath ${rpmlibdir}" \
298 --noscripts --notriggers --noparentdirs --nolinktos \
299 -D "__dbi_txn create nofsync private" \
300 -Uhv ${target_rootfs}/install/install_solution.manifest
301}
302
93python write_specfile () { 303python write_specfile () {
94 import textwrap 304 import textwrap
95 305