2 # Creates a root filesystem out of rpm packages
5 ROOTFS_PKGMANAGE = "rpm yum"
7 ROOTFS_PKGMANAGE_BOOTSTRAP = "run-postinsts"
9 do_rootfs[depends] += "rpm-native:do_populate_staging yum-native:do_populate_staging createrepo-native:do_populate_staging fakechroot-native:do_populate_staging"
10 do_rootfs[recrdeptask] += "do_package_write_rpm"
12 YUMCONF = "${IMAGE_ROOTFS}/etc/yum.conf"
13 YUMARGS = "-c ${YUMCONF} --installroot ${IMAGE_ROOTFS}"
14 export YUM_ARCH_FORCE = "${TARGET_ARCH}"
16 AWKPOSTINSTSCRIPT = "${STAGING_BINDIR_NATIVE}/extract-postinst.awk"
18 RPM_PREPROCESS_COMMANDS = ""
19 RPM_POSTPROCESS_COMMANDS = "rpm_insert_feeds_uris"
21 rpm_insert_feeds_uris () {
23 echo "Building from feeds activated!"
25 mkdir -p ${IMAGE_ROOTFS}/etc/yum/repos.d/
26 for line in ${RPM_FEED_URIS}
28 # strip leading and trailing spaces/tabs, then split into name and uri
29 line_clean="`echo "$line"|sed 's/^[ \t]*//;s/[ \t]*$//'`"
30 feed_name="`echo "$line_clean" | sed -n 's/\(.*\)##\(.*\)/\1/p'`"
31 feed_uri="`echo "$line_clean" | sed -n 's/\(.*\)##\(.*\)/\2/p'`"
33 echo "Added $feed_name feed with URL $feed_uri"
35 FEED_FILE=${IMAGE_ROOTFS}/etc/yum/repos.d/$feed_name
37 echo "[${DISTRO}-feed-$feed_name]" >> $FEED_FILE
38 echo "name = $feed_name" >> $FEED_FILE
39 echo "baseurl = $feed_uri" >> $FEED_FILE
40 echo "gpgcheck = 0" >> $FEED_FILE
44 fakeroot rootfs_rpm_do_rootfs () {
47 ${RPM_PREPROCESS_COMMANDS}
49 mkdir -p ${IMAGE_ROOTFS}/etc/rpm/
50 echo "${TARGET_ARCH}-linux" >${IMAGE_ROOTFS}/etc/rpm/platform
52 # Generate an apprpriate yum.conf
54 cat > ${YUMCONF} << EOF
56 cachedir=/var/cache2/yum
59 logfile=/var/log2/yum.log
67 mkdir -p ${IMAGE_ROOTFS}${DEPLOY_DIR_RPM}
69 for arch in ${PACKAGE_ARCHS}; do
70 if [ ! -d ${DEPLOY_DIR_RPM}/$arch ]; then
73 createrepo ${DEPLOY_DIR_RPM}/$arch
75 echo "[${DISTRO}-feed-$arch]" >> ${YUMCONF}
76 echo "name = ${DISTRO} RPM $arch Feed" >> ${YUMCONF}
77 echo "baseurl=file://${DEPLOY_DIR_RPM}/$arch" >> ${YUMCONF}
78 echo "gpgcheck=0" >> ${YUMCONF}
80 #priority=$(expr $priority + 5)
82 # Copy the packages into the target image
83 # Ugly ugly ugly but rpm is braindead and can't see outside the chroot
85 cp -r ${DEPLOY_DIR_RPM}/$arch ${IMAGE_ROOTFS}${DEPLOY_DIR_RPM}/
88 # Uclibc builds don't provide this stuff...
89 if [ x${TARGET_OS} = "xlinux" ] || [ x${TARGET_OS} = "xlinux-gnueabi" ] ; then
90 if [ ! -z "${LINGUAS_INSTALL}" ]; then
91 for i in ${LINGUAS_INSTALL}; do
92 fakechroot yum ${YUMARGS} -y install $i
96 if [ ! -z "${PACKAGE_INSTALL}" ]; then
97 fakechroot yum ${YUMARGS} -y install ${PACKAGE_INSTALL}
100 # Add any recommended packages to the image
101 # (added as an extra script since yum itself doesn't support this)
102 yum-install-recommends.py ${IMAGE_ROOTFS} "fakechroot yum ${YUMARGS} -y install"
104 # Symlinks created under fakeroot are wrong, now we have to fix them...
106 for f in `find . -type l -print`
108 link=`readlink $f | sed -e 's#${IMAGE_ROOTFS}##'`
113 export D=${IMAGE_ROOTFS}
114 export OFFLINE_ROOT=${IMAGE_ROOTFS}
115 export IPKG_OFFLINE_ROOT=${IMAGE_ROOTFS}
116 export OPKG_OFFLINE_ROOT=${IMAGE_ROOTFS}
118 ${ROOTFS_POSTINSTALL_COMMAND}
120 mkdir -p ${IMAGE_ROOTFS}/etc/rpm-postinsts/
121 rpm --root ${IMAGE_ROOTFS} -aq --queryformat 'Name: %{NAME}\n' --scripts > ${IMAGE_ROOTFS}/etc/rpm-postinsts/combined
122 awk -f ${AWKPOSTINSTSCRIPT} < ${IMAGE_ROOTFS}/etc/rpm-postinsts/combined
123 rm ${IMAGE_ROOTFS}/etc/rpm-postinsts/combined
125 for i in ${IMAGE_ROOTFS}/etc/rpm-postinsts/*.sh; do
126 if [ -f $i ] && sh $i; then
132 install -d ${IMAGE_ROOTFS}/${sysconfdir}/rcS.d
133 # Stop $i getting expanded below...
135 cat > ${IMAGE_ROOTFS}${sysconfdir}/rcS.d/S98configure << EOF
137 for i in /etc/rpm-postinsts/*.sh; do
138 echo "Running postinst $i..."
139 if [ -f $i ] && sh $i; then
143 echo "ERROR: postinst $i failed."
146 rm -f ${sysconfdir}/rcS.d/S98configure
148 chmod 0755 ${IMAGE_ROOTFS}${sysconfdir}/rcS.d/S98configure
150 install -d ${IMAGE_ROOTFS}/${sysconfdir}
151 echo ${BUILDNAME} > ${IMAGE_ROOTFS}/${sysconfdir}/version
153 ${RPM_POSTPROCESS_COMMANDS}
154 ${ROOTFS_POSTPROCESS_COMMAND}
156 rm -rf ${IMAGE_ROOTFS}/var/cache2/
157 rm -rf ${IMAGE_ROOTFS}/var/run2/
158 rm -rf ${IMAGE_ROOTFS}/var/log2/
159 rm -rf ${IMAGE_ROOTFS}${DEPLOY_DIR_RPM}/
162 rm -f ${IMAGE_ROOTFS}/var/lib/rpm/__db.*
164 # remove no longer used yum.conf
165 rm -f ${IMAGE_ROOTFS}/etc/yum.conf
170 rootfs_rpm_log_check() {
174 lf_txt="`cat $lf_path`"
175 for keyword_die in "Cannot find package" "exit 1" ERR Fail
177 if (echo "$lf_txt" | grep -v log_check | grep "$keyword_die") >/dev/null 2>&1
179 echo "log_check: There were error messages in the logfile"
180 echo -e "log_check: Matched keyword: [$keyword_die]\n"
181 echo "$lf_txt" | grep -v log_check | grep -C 5 -i "$keyword_die"
186 test "$do_exit" = 1 && exit
190 remove_packaging_data_files() {
195 install_all_locales() {
202 if bb.data.getVar('BUILD_IMAGES_FROM_FEEDS', d, True):
203 flags = bb.data.getVarFlag('do_rootfs', 'recrdeptask', d)
204 flags = flags.replace("do_package_write_rpm", "")
205 flags = flags.replace("do_deploy", "")
206 flags = flags.replace("do_populate_staging", "")
207 bb.data.setVarFlag('do_rootfs', 'recrdeptask', flags, d)
208 bb.data.setVar('RPM_PREPROCESS_COMMANDS', "rpm_insert_feed_uris", d)
209 bb.data.setVar('RPM_POSTPROCESS_COMMANDS', '', d)