diff options
author | Mark Hatle <mhatle@windriver.com> | 2010-07-20 12:57:19 -0700 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2010-07-24 00:46:57 +0100 |
commit | d668b80e866c8bb512a10bad22b0080d7afe3453 (patch) | |
tree | 959d6729ff8bd6ce1a1e722ad2d01666a5f62520 /meta | |
parent | 8760cde94aca80a920cb50230d61c187d3cfeee4 (diff) | |
download | poky-d668b80e866c8bb512a10bad22b0080d7afe3453.tar.gz |
meta/classes/rootfs_rpm.bbclass: re implement base on rpm5
Re implement the rootfs generation using rpm5. This also gets rid of the
need for yum, and handles all dep resolving internal to the script itself.
The new file scripts/rootfs_rpm-extract-postinst.awk comes from the original
yum integration work. It has been unchanged, but since yum is no longer used
we needed to move the script somewhere else.
Signed-off-by: Mark Hatle <mhatle@windriver.com>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/classes/rootfs_rpm.bbclass | 158 |
1 files changed, 67 insertions, 91 deletions
diff --git a/meta/classes/rootfs_rpm.bbclass b/meta/classes/rootfs_rpm.bbclass index be86f29200..388387a52c 100644 --- a/meta/classes/rootfs_rpm.bbclass +++ b/meta/classes/rootfs_rpm.bbclass | |||
@@ -2,130 +2,103 @@ | |||
2 | # Creates a root filesystem out of rpm packages | 2 | # Creates a root filesystem out of rpm packages |
3 | # | 3 | # |
4 | 4 | ||
5 | ROOTFS_PKGMANAGE = "rpm yum" | 5 | ROOTFS_PKGMANAGE = "rpm" |
6 | |||
7 | ROOTFS_PKGMANAGE_BOOTSTRAP = "run-postinsts" | 6 | ROOTFS_PKGMANAGE_BOOTSTRAP = "run-postinsts" |
8 | 7 | ||
9 | do_rootfs[depends] += "rpm-native:do_populate_sysroot python-urlgrabber-native:do_populate_sysroot yum-metadata-parser-native:do_populate_sysroot yum-native:do_populate_sysroot createrepo-native:do_populate_sysroot fakechroot-native:do_populate_sysroot" | 8 | RPMOPTS="--dbpath /var/lib/rpm --define='_openall_before_chroot 1'" |
9 | RPM="${BUILD_ARCH}-${BUILD_OS}-rpm ${RPMOPTS}" | ||
10 | |||
11 | do_rootfs[depends] += "rpm-native:do_populate_sysroot" | ||
10 | 12 | ||
11 | # Needed for update-alternatives | 13 | # Needed for update-alternatives |
12 | do_rootfs[depends] += "opkg-native:do_populate_sysroot" | 14 | do_rootfs[depends] += "opkg-native:do_populate_sysroot" |
13 | 15 | ||
14 | do_rootfs[recrdeptask] += "do_package_write_rpm" | 16 | do_rootfs[recrdeptask] += "do_package_write_rpm" |
15 | 17 | ||
16 | YUMCONF = "${IMAGE_ROOTFS}/etc/yum.conf" | 18 | AWKPOSTINSTSCRIPT = "${POKYBASE}/scripts/rootfs_rpm-extract-postinst.awk" |
17 | YUMARGS = "--disablerepo=* --enablerepo=poky-feed-* --installroot ${IMAGE_ROOTFS}" | ||
18 | export YUM_ARCH_FORCE = "${TARGET_ARCH}" | ||
19 | |||
20 | AWKPOSTINSTSCRIPT = "${STAGING_BINDIR_NATIVE}/extract-postinst.awk" | ||
21 | 19 | ||
22 | RPM_PREPROCESS_COMMANDS = "" | 20 | RPM_PREPROCESS_COMMANDS = "" |
23 | RPM_POSTPROCESS_COMMANDS = "rpm_insert_feeds_uris" | 21 | RPM_POSTPROCESS_COMMANDS = "" |
24 | |||
25 | rpm_insert_feeds_uris () { | ||
26 | |||
27 | echo "Building from feeds activated!" | ||
28 | |||
29 | mkdir -p ${IMAGE_ROOTFS}/etc/yum/repos.d/ | ||
30 | for line in ${RPM_FEED_URIS} | ||
31 | do | ||
32 | # strip leading and trailing spaces/tabs, then split into name and uri | ||
33 | line_clean="`echo "$line"|sed 's/^[ \t]*//;s/[ \t]*$//'`" | ||
34 | feed_name="`echo "$line_clean" | sed -n 's/\(.*\)##\(.*\)/\1/p'`" | ||
35 | feed_uri="`echo "$line_clean" | sed -n 's/\(.*\)##\(.*\)/\2/p'`" | ||
36 | |||
37 | echo "Added $feed_name feed with URL $feed_uri" | ||
38 | |||
39 | FEED_FILE=${IMAGE_ROOTFS}/etc/yum/repos.d/$feed_name | ||
40 | |||
41 | echo "[poky-feed-$feed_name]" >> $FEED_FILE | ||
42 | echo "name = $feed_name" >> $FEED_FILE | ||
43 | echo "baseurl = $feed_uri" >> $FEED_FILE | ||
44 | echo "gpgcheck = 0" >> $FEED_FILE | ||
45 | done | ||
46 | } | ||
47 | 22 | ||
48 | fakeroot rootfs_rpm_do_rootfs () { | 23 | fakeroot rootfs_rpm_do_rootfs () { |
49 | set -x | 24 | set -x |
50 | 25 | ||
51 | ${RPM_PREPROCESS_COMMANDS} | 26 | ${RPM_PREPROCESS_COMMANDS} |
52 | 27 | ||
28 | # Setup base system configuration | ||
53 | mkdir -p ${IMAGE_ROOTFS}/etc/rpm/ | 29 | mkdir -p ${IMAGE_ROOTFS}/etc/rpm/ |
54 | echo "${TARGET_ARCH}-linux" >${IMAGE_ROOTFS}/etc/rpm/platform | 30 | echo "${TARGET_ARCH}-linux" >${IMAGE_ROOTFS}/etc/rpm/platform |
55 | 31 | ||
56 | # Generate an apprpriate yum.conf | 32 | # Instantiate the dep solver database |
57 | rm -rf ${YUMCONF} | 33 | mkdir -p ${IMAGE_ROOTFS}/var/lib/rpm_solver |
58 | cat > ${YUMCONF} << EOF | ||
59 | [main] | ||
60 | cachedir=/var/cache2/yum | ||
61 | keepcache=1 | ||
62 | debuglevel=10 | ||
63 | logfile=/var/log2/yum.log | ||
64 | exactarch=0 | ||
65 | obsoletes=1 | ||
66 | tolerant=1 | ||
67 | |||
68 | EOF | ||
69 | |||
70 | #priority=1 | ||
71 | mkdir -p ${IMAGE_ROOTFS}${DEPLOY_DIR_RPM} | ||
72 | 34 | ||
35 | # Generate dep_solver manifest | ||
36 | cat /dev/null > ${IMAGE_ROOTFS}/var/lib/rpm_solver/dep_solver.manifest | ||
37 | echo "# Dynamically generated install manifest -- avoid small file bug" >> ${IMAGE_ROOTFS}/var/lib/rpm_solver/dep_solver.manifest | ||
73 | for arch in ${PACKAGE_ARCHS}; do | 38 | for arch in ${PACKAGE_ARCHS}; do |
74 | if [ ! -d ${DEPLOY_DIR_RPM}/$arch ]; then | 39 | [ -d ${DEPLOY_DIR_RPM}/$arch ] && find ${DEPLOY_DIR_RPM}/$arch -type f >> ${IMAGE_ROOTFS}/var/lib/rpm_solver/dep_solver.manifest |
75 | continue; | ||
76 | fi | ||
77 | createrepo ${DEPLOY_DIR_RPM}/$arch | ||
78 | |||
79 | echo "[poky-feed-$arch]" >> ${YUMCONF} | ||
80 | echo "name = Poky RPM $arch Feed" >> ${YUMCONF} | ||
81 | echo "baseurl=file://${DEPLOY_DIR_RPM}/$arch" >> ${YUMCONF} | ||
82 | echo "gpgcheck=0" >> ${YUMCONF} | ||
83 | echo "" >> ${YUMCONF} | ||
84 | #priority=$(expr $priority + 5) | ||
85 | |||
86 | # Copy the packages into the target image | ||
87 | # Ugly ugly ugly but rpm is braindead and can't see outside the chroot | ||
88 | # when installing :( | ||
89 | cp -r ${DEPLOY_DIR_RPM}/$arch ${IMAGE_ROOTFS}${DEPLOY_DIR_RPM}/ | ||
90 | done | 40 | done |
41 | |||
42 | ${RPM} --root ${IMAGE_ROOTFS} --dbpath /var/lib/rpm_solver --initdb | ||
43 | ${RPM} --root ${IMAGE_ROOTFS} --dbpath /var/lib/rpm_solver -Uhv ${IMAGE_ROOTFS}/var/lib/rpm_solver/dep_solver.manifest --justdb --nodeps --noparentdirs --nolinktos | ||
91 | 44 | ||
92 | 45 | # Resolve Dependencies and Install | |
93 | #mkdir -p ${IMAGE_ROOTFS}/var/lib/rpm | ||
94 | #rpm --root ${IMAGE_ROOTFS} --initdb | ||
95 | #rpm --root ${IMAGE_ROOTFS} --dbpath ${IMAGE_ROOTFS}/var/lib/rpm -ihv --nodeps --ignoreos | ||
96 | #rpm -ihv --root ${IMAGE_ROOTFS} ${PACKAGE_INSTALL} | ||
97 | |||
98 | #package_update_index_rpm | ||
99 | #package_generate_ipkg_conf | ||
100 | |||
101 | # Uclibc builds don't provide this stuff... | ||
102 | if [ x${TARGET_OS} = "xlinux" ] || [ x${TARGET_OS} = "xlinux-gnueabi" ] ; then | 46 | if [ x${TARGET_OS} = "xlinux" ] || [ x${TARGET_OS} = "xlinux-gnueabi" ] ; then |
103 | if [ ! -z "${LINGUAS_INSTALL}" ]; then | 47 | if [ ! -z "${LINGUAS_INSTALL}" ]; then |
104 | for i in ${LINGUAS_INSTALL}; do | 48 | for i in ${LINGUAS_INSTALL}; do |
105 | fakechroot yum ${YUMARGS} -y install $i | 49 | : # Do not support locales yet |
106 | done | 50 | done |
107 | fi | 51 | fi |
108 | fi | 52 | fi |
53 | |||
109 | if [ ! -z "${PACKAGE_INSTALL}" ]; then | 54 | if [ ! -z "${PACKAGE_INSTALL}" ]; then |
110 | fakechroot yum ${YUMARGS} -y install ${PACKAGE_INSTALL} | 55 | # Create the install manifest, starting with the PACKAGE_INSTALL packages |
56 | touch ${IMAGE_ROOTFS}/install.manifest | ||
57 | for each in ${PACKAGE_INSTALL} ; do | ||
58 | # Map package name to filename | ||
59 | pkg_name=$(${RPM} --root ${IMAGE_ROOTFS} --dbpath /var/lib/rpm_solver -q --qf "%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}" $each) | ||
60 | echo Processing "$each $pkg_name" | ||
61 | # Map filename to full path | ||
62 | [ -n "$pkg_name" ] && grep "/"$pkg_name ${IMAGE_ROOTFS}/var/lib/rpm_solver/dep_solver.manifest >> ${IMAGE_ROOTFS}/install.manifest | ||
63 | done | ||
111 | fi | 64 | fi |
112 | 65 | ||
66 | # Attempt to resolve dependencies and add missing packages to the install.manifest | ||
67 | # Loop over the resolution until there is nothing else to resolve... | ||
68 | # We log the solver.logs so we can track the dep solver process for debugging... | ||
69 | resolver=1 | ||
70 | while [ $resolver -gt 0 ]; do | ||
71 | (${RPM} --root ${IMAGE_ROOTFS} \ | ||
72 | --define '_solve_dbpath /var/lib/rpm_solver' --define '_solve_name_fmt add:%{___NVRA}.rpm' --aid \ | ||
73 | -Uhv --noparentdirs --nolinktos --test ${IMAGE_ROOTFS}/install.manifest > ${IMAGE_ROOTFS}/solver.log.$resolver 2>&1 || :) | ||
74 | |||
75 | resolve_continue=false | ||
76 | for each in `cat ${IMAGE_ROOTFS}/solver.log.$resolver | grep "add:" | cut -d : -f 2` ; do | ||
77 | pkg_name=$each | ||
78 | echo Processing "$each $pkg_name" | ||
79 | # Map filename to full path | ||
80 | [ -n "$pkg_name" ] && grep "/"$pkg_name ${IMAGE_ROOTFS}/var/lib/rpm_solver/dep_solver.manifest >> ${IMAGE_ROOTFS}/install.manifest | ||
81 | resolve_continue=true | ||
82 | done | ||
83 | if [ "$resolve_continue" == "true" ]; then | ||
84 | resolver=$(expr $resolver + 1) | ||
85 | else | ||
86 | resolver=0 | ||
87 | fi | ||
88 | done | ||
89 | |||
90 | # Attempt install | ||
91 | ${RPM} --root ${IMAGE_ROOTFS} \ | ||
92 | --define '_solve_dbpath /var/lib/rpm_solver' --define '_solve_name_fmt add:%{___NVRA}.rpm' --aid \ | ||
93 | -Uhv --noparentdirs --nolinktos --noscripts ${IMAGE_ROOTFS}/install.manifest | ||
94 | |||
113 | if [ ! -z "${PACKAGE_INSTALL_ATTEMPTONLY}" ]; then | 95 | if [ ! -z "${PACKAGE_INSTALL_ATTEMPTONLY}" ]; then |
114 | fakechroot yum ${YUMARGS} -y install ${PACKAGE_INSTALL_ATTEMPTONLY} > ${WORKDIR}/temp/log.do_rootfs-attemptonly.${PID} || true | 96 | : # fakechroot yum ${YUMARGS} -y install ${PACKAGE_INSTALL_ATTEMPTONLY} > ${WORKDIR}/temp/log.do_rootfs-attemptonly.${PID} || true |
115 | fi | 97 | fi |
116 | 98 | ||
117 | # Add any recommended packages to the image | 99 | # Add any recommended packages to the image |
118 | # (added as an extra script since yum itself doesn't support this) | 100 | # (added as an extra script since yum itself doesn't support this) |
119 | yum-install-recommends.py ${IMAGE_ROOTFS} "fakechroot yum ${YUMARGS} -y install" | 101 | : # yum-install-recommends.py ${IMAGE_ROOTFS} "fakechroot yum ${YUMARGS} -y install" |
120 | |||
121 | # Symlinks created under fakeroot are wrong, now we have to fix them... | ||
122 | cd ${IMAGE_ROOTFS} | ||
123 | for f in `find . -type l -print` | ||
124 | do | ||
125 | link=`readlink $f | sed -e 's#${IMAGE_ROOTFS}##'` | ||
126 | rm $f | ||
127 | ln -s $link $f | ||
128 | done | ||
129 | 102 | ||
130 | export D=${IMAGE_ROOTFS} | 103 | export D=${IMAGE_ROOTFS} |
131 | export OFFLINE_ROOT=${IMAGE_ROOTFS} | 104 | export OFFLINE_ROOT=${IMAGE_ROOTFS} |
@@ -138,7 +111,7 @@ EOF | |||
138 | ${ROOTFS_POSTINSTALL_COMMAND} | 111 | ${ROOTFS_POSTINSTALL_COMMAND} |
139 | 112 | ||
140 | mkdir -p ${IMAGE_ROOTFS}/etc/rpm-postinsts/ | 113 | mkdir -p ${IMAGE_ROOTFS}/etc/rpm-postinsts/ |
141 | rpm --root ${IMAGE_ROOTFS} -aq --queryformat 'Name: %{NAME}\n' --scripts > ${IMAGE_ROOTFS}/etc/rpm-postinsts/combined | 114 | ${RPM} --root ${IMAGE_ROOTFS} -qa --queryformat 'Name: %{NAME}\n' --scripts > ${IMAGE_ROOTFS}/etc/rpm-postinsts/combined |
142 | awk -f ${AWKPOSTINSTSCRIPT} < ${IMAGE_ROOTFS}/etc/rpm-postinsts/combined | 115 | awk -f ${AWKPOSTINSTSCRIPT} < ${IMAGE_ROOTFS}/etc/rpm-postinsts/combined |
143 | rm ${IMAGE_ROOTFS}/etc/rpm-postinsts/combined | 116 | rm ${IMAGE_ROOTFS}/etc/rpm-postinsts/combined |
144 | 117 | ||
@@ -176,13 +149,16 @@ EOF | |||
176 | rm -rf ${IMAGE_ROOTFS}/var/cache2/ | 149 | rm -rf ${IMAGE_ROOTFS}/var/cache2/ |
177 | rm -rf ${IMAGE_ROOTFS}/var/run2/ | 150 | rm -rf ${IMAGE_ROOTFS}/var/run2/ |
178 | rm -rf ${IMAGE_ROOTFS}/var/log2/ | 151 | rm -rf ${IMAGE_ROOTFS}/var/log2/ |
179 | rm -rf ${IMAGE_ROOTFS}${DEPLOY_DIR_RPM}/ | ||
180 | 152 | ||
181 | # remove lock files | 153 | # remove lock files |
182 | rm -f ${IMAGE_ROOTFS}/var/lib/rpm/__db.* | 154 | rm -f ${IMAGE_ROOTFS}/var/lib/rpm/__db.* |
183 | 155 | ||
184 | # remove no longer used yum.conf | 156 | # remove resolver files and manifests |
185 | rm -f ${IMAGE_ROOTFS}/etc/yum.conf | 157 | rm -f ${IMAGE_ROOTFS}/install.manifest |
158 | rm -f ${IMAGE_ROOTFS}/solver.log.* | ||
159 | |||
160 | # Remove resolver DB | ||
161 | rm -rf ${IMAGE_ROOTFS}/var/lib/rpm_solver | ||
186 | 162 | ||
187 | log_check rootfs | 163 | log_check rootfs |
188 | } | 164 | } |