2008-08-25 20:53:13 +00:00
|
|
|
#
|
|
|
|
# Creates a root filesystem out of rpm packages
|
|
|
|
#
|
|
|
|
|
2010-10-11 11:18:02 +00:00
|
|
|
ROOTFS_PKGMANAGE = "rpm zypper"
|
2008-08-25 20:53:13 +00:00
|
|
|
ROOTFS_PKGMANAGE_BOOTSTRAP = "run-postinsts"
|
|
|
|
|
2010-07-20 19:57:19 +00:00
|
|
|
do_rootfs[depends] += "rpm-native:do_populate_sysroot"
|
2008-10-31 16:23:11 +00:00
|
|
|
|
|
|
|
# Needed for update-alternatives
|
2009-11-10 14:55:23 +00:00
|
|
|
do_rootfs[depends] += "opkg-native:do_populate_sysroot"
|
2008-10-31 16:23:11 +00:00
|
|
|
|
2008-08-25 20:53:13 +00:00
|
|
|
do_rootfs[recrdeptask] += "do_package_write_rpm"
|
|
|
|
|
2010-07-20 19:57:19 +00:00
|
|
|
AWKPOSTINSTSCRIPT = "${POKYBASE}/scripts/rootfs_rpm-extract-postinst.awk"
|
2008-09-03 23:22:06 +00:00
|
|
|
|
2010-09-02 18:28:37 +00:00
|
|
|
RPM_PREPROCESS_COMMANDS = "package_update_index_rpm; package_generate_rpm_conf; "
|
2010-07-20 19:57:19 +00:00
|
|
|
RPM_POSTPROCESS_COMMANDS = ""
|
2008-10-07 16:21:25 +00:00
|
|
|
|
2010-09-02 18:28:37 +00:00
|
|
|
# To test the install_all_locales.. enable the following...
|
|
|
|
#RPM_POSTPROCESS_COMMANDS = "install_all_locales; "
|
|
|
|
#
|
|
|
|
#IMAGE_LOCALES="en-gb"
|
|
|
|
|
2010-09-01 21:04:45 +00:00
|
|
|
rpmlibdir = "/var/lib/rpm"
|
2010-08-26 04:39:07 +00:00
|
|
|
opkglibdir = "${localstatedir}/lib/opkg"
|
|
|
|
|
2010-09-01 21:04:45 +00:00
|
|
|
RPMOPTS="--dbpath ${rpmlibdir} --define='_openall_before_chroot 1'"
|
2010-09-03 17:43:41 +00:00
|
|
|
RPM="rpm ${RPMOPTS}"
|
2010-09-01 21:04:45 +00:00
|
|
|
|
2010-10-07 14:41:17 +00:00
|
|
|
# RPM doesn't work with multiple rootfs generation at once due to collisions in the use of files
|
|
|
|
# in ${DEPLOY_DIR_RPM}. This can be removed if package_update_index_rpm can be called concurrently
|
|
|
|
do_rootfs[lockfiles] += "${DEPLOY_DIR_RPM}/rpm.lock"
|
|
|
|
|
2008-08-25 20:53:13 +00:00
|
|
|
fakeroot rootfs_rpm_do_rootfs () {
|
2010-08-22 05:44:21 +00:00
|
|
|
set +x
|
|
|
|
|
2008-10-07 16:47:22 +00:00
|
|
|
${RPM_PREPROCESS_COMMANDS}
|
2008-08-25 20:53:13 +00:00
|
|
|
|
2010-07-20 19:57:19 +00:00
|
|
|
# Setup base system configuration
|
2008-08-25 20:53:13 +00:00
|
|
|
mkdir -p ${IMAGE_ROOTFS}/etc/rpm/
|
2008-10-07 13:43:07 +00:00
|
|
|
echo "${TARGET_ARCH}-linux" >${IMAGE_ROOTFS}/etc/rpm/platform
|
2008-08-25 20:53:13 +00:00
|
|
|
|
2010-09-29 17:17:36 +00:00
|
|
|
# Tell RPM that the "/" directory exist and is available
|
|
|
|
mkdir -p ${IMAGE_ROOTFS}/etc/rpm/sysinfo
|
|
|
|
echo "/" >${IMAGE_ROOTFS}/etc/rpm/sysinfo/Dirnames
|
|
|
|
|
2010-08-22 05:44:21 +00:00
|
|
|
# Setup manifest of packages to install...
|
|
|
|
mkdir -p ${IMAGE_ROOTFS}/install
|
|
|
|
echo "# Install manifest" > ${IMAGE_ROOTFS}/install/install.manifest
|
2008-10-02 15:22:10 +00:00
|
|
|
|
2010-08-22 05:44:21 +00:00
|
|
|
# Uclibc builds don't provide this stuff...
|
2008-08-25 20:53:13 +00:00
|
|
|
if [ x${TARGET_OS} = "xlinux" ] || [ x${TARGET_OS} = "xlinux-gnueabi" ] ; then
|
|
|
|
if [ ! -z "${LINGUAS_INSTALL}" ]; then
|
2010-09-01 21:04:45 +00:00
|
|
|
for pkg in ${LINGUAS_INSTALL}; do
|
|
|
|
echo "Processing $pkg..."
|
|
|
|
pkg_name=$(resolve_package $pkg)
|
2010-09-02 18:28:37 +00:00
|
|
|
if [ -z "$pkg_name" ]; then
|
2010-09-01 21:04:45 +00:00
|
|
|
echo "Unable to find package $pkg!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
echo $pkg_name >> ${IMAGE_ROOTFS}/install/install.manifest
|
2008-08-25 20:53:13 +00:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
fi
|
2010-07-20 19:57:19 +00:00
|
|
|
|
2008-08-25 20:53:13 +00:00
|
|
|
if [ ! -z "${PACKAGE_INSTALL}" ]; then
|
2010-08-22 05:44:21 +00:00
|
|
|
for pkg in ${PACKAGE_INSTALL} ; do
|
|
|
|
echo "Processing $pkg..."
|
2010-09-01 21:04:45 +00:00
|
|
|
pkg_name=$(resolve_package $pkg)
|
2010-09-02 18:28:37 +00:00
|
|
|
if [ -z "$pkg_name" ]; then
|
2010-09-01 21:04:45 +00:00
|
|
|
echo "Unable to find package $pkg!"
|
2010-08-22 05:44:21 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
echo $pkg_name >> ${IMAGE_ROOTFS}/install/install.manifest
|
2010-07-20 19:57:19 +00:00
|
|
|
done
|
2008-08-25 20:53:13 +00:00
|
|
|
fi
|
|
|
|
|
2010-08-22 05:44:21 +00:00
|
|
|
# Generate an install solution by doing a --justdb install, then recreate it with
|
|
|
|
# an actual package install!
|
|
|
|
${RPM} -D "_dbpath ${IMAGE_ROOTFS}/install" -D "`cat ${DEPLOY_DIR_RPM}/solvedb.macro`" \
|
2010-09-01 21:04:45 +00:00
|
|
|
-D "__dbi_cdb create mp_mmapsize=128Mb mp_size=1Mb nofsync" \
|
2010-08-22 05:44:21 +00:00
|
|
|
-U --justdb --noscripts --notriggers --noparentdirs --nolinktos \
|
|
|
|
${IMAGE_ROOTFS}/install/install.manifest
|
|
|
|
|
2010-09-01 21:04:45 +00:00
|
|
|
if [ ! -z "${PACKAGE_INSTALL_ATTEMPTONLY}" ]; then
|
|
|
|
echo "Adding attempt only packages..."
|
|
|
|
for pkg in ${PACKAGE_INSTALL_ATTEMPTONLY} ; do
|
|
|
|
echo "Processing $pkg..."
|
|
|
|
pkg_name=$(resolve_package $pkg)
|
2010-09-02 18:28:37 +00:00
|
|
|
if [ -z "$pkg_name" ]; then
|
2010-09-01 21:04:45 +00:00
|
|
|
echo "Unable to find package $pkg!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
echo "Attempting $pkg_name..." >> "${WORKDIR}/temp/log.do_rootfs_attemptonly.${PID}"
|
|
|
|
${RPM} -D "_dbpath ${IMAGE_ROOTFS}/install" -D "`cat ${DEPLOY_DIR_RPM}/solvedb.macro`" \
|
|
|
|
-D "__dbi_cdb create mp_mmapsize=128Mb mp_size=1Mb nofsync private" \
|
|
|
|
-U --justdb --noscripts --notriggers --noparentdirs --nolinktos \
|
|
|
|
$pkg_name >> "${WORKDIR}/temp/log.do_rootfs_attemptonly.${PID}" || true
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
#### Note: 'Recommends' is an arbitrary tag that means _SUGGESTS_ in Poky..
|
|
|
|
# Add any recommended packages to the image
|
|
|
|
# RPM does not solve for recommended packages because they are optional...
|
|
|
|
# So we query them and tree them like the ATTEMPTONLY packages above...
|
|
|
|
# Change the loop to "1" to run this code...
|
|
|
|
loop=0
|
|
|
|
if [ $loop -eq 1 ]; then
|
|
|
|
echo "Processing recommended packages..."
|
|
|
|
cat /dev/null > ${IMAGE_ROOTFS}/install/recommend.list
|
|
|
|
while [ $loop -eq 1 ]; do
|
|
|
|
# Dump the full set of recommends...
|
|
|
|
${RPM} -D "_dbpath ${IMAGE_ROOTFS}/install" -D "`cat ${DEPLOY_DIR_RPM}/solvedb.macro`" \
|
|
|
|
-qa --qf "[%{RECOMMENDS}\n]" | sort -u > ${IMAGE_ROOTFS}/install/recommend
|
|
|
|
# Did we add more to the list?
|
|
|
|
grep -v -x -F -f ${IMAGE_ROOTFS}/install/recommend.list ${IMAGE_ROOTFS}/install/recommend > ${IMAGE_ROOTFS}/install/recommend.new || true
|
|
|
|
# We don't want to loop unless there is a change to the list!
|
|
|
|
loop=0
|
|
|
|
cat ${IMAGE_ROOTFS}/install/recommend.new | \
|
|
|
|
while read pkg ; do
|
|
|
|
# Ohh there was a new one, we'll need to loop again...
|
|
|
|
loop=1
|
|
|
|
echo "Processing $pkg..."
|
2010-09-02 18:28:37 +00:00
|
|
|
pkg_name=$(resolve_package $pkg)
|
2010-09-01 21:04:45 +00:00
|
|
|
if [ -z "$pkg_name" ]; then
|
|
|
|
echo "Unable to find package $pkg." >> "${WORKDIR}/temp/log.do_rootfs_recommend.${PID}"
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
echo "Attempting $pkg_name..." >> "${WORKDIR}/temp/log.do_rootfs_recommend.${PID}"
|
|
|
|
${RPM} -D "_dbpath ${IMAGE_ROOTFS}/install" -D "`cat ${DEPLOY_DIR_RPM}/solvedb.macro`" \
|
|
|
|
-D "__dbi_cdb create mp_mmapsize=128Mb mp_size=1Mb nofsync private" \
|
|
|
|
-U --justdb --noscripts --notriggers --noparentdirs --nolinktos \
|
|
|
|
$pkg_name >> "${WORKDIR}/temp/log.do_rootfs_recommend.${PID}" 2>&1 || true
|
|
|
|
done
|
|
|
|
cat ${IMAGE_ROOTFS}/install/recommend.list ${IMAGE_ROOTFS}/install/recommend.new | sort -u > ${IMAGE_ROOTFS}/install/recommend.new.list
|
|
|
|
mv ${IMAGE_ROOTFS}/install/recommend.new.list ${IMAGE_ROOTFS}/install/recommend.list
|
|
|
|
rm ${IMAGE_ROOTFS}/install/recommend ${IMAGE_ROOTFS}/install/recommend.new
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Now that we have a solution, pull out a list of what to install...
|
|
|
|
echo "Manifest: ${IMAGE_ROOTFS}/install/install.manifest"
|
2010-08-22 05:44:21 +00:00
|
|
|
${RPM} -D "_dbpath ${IMAGE_ROOTFS}/install" -qa --yaml \
|
|
|
|
| grep -i 'Packageorigin' | cut -d : -f 2 > ${IMAGE_ROOTFS}/install/install_solution.manifest
|
2010-07-20 19:57:19 +00:00
|
|
|
|
|
|
|
# Attempt install
|
2010-09-01 21:04:45 +00:00
|
|
|
${RPM} --root ${IMAGE_ROOTFS} -D "_dbpath ${rpmlibdir}" \
|
2010-08-22 05:44:21 +00:00
|
|
|
--noscripts --notriggers --noparentdirs --nolinktos \
|
2010-09-01 21:04:45 +00:00
|
|
|
-D "__dbi_cdb create mp_mmapsize=128Mb mp_size=1Mb nofsync private" \
|
2010-08-22 05:44:21 +00:00
|
|
|
-Uhv ${IMAGE_ROOTFS}/install/install_solution.manifest
|
2010-07-20 19:57:19 +00:00
|
|
|
|
2008-09-03 23:22:06 +00:00
|
|
|
export D=${IMAGE_ROOTFS}
|
|
|
|
export OFFLINE_ROOT=${IMAGE_ROOTFS}
|
|
|
|
export IPKG_OFFLINE_ROOT=${IMAGE_ROOTFS}
|
|
|
|
export OPKG_OFFLINE_ROOT=${IMAGE_ROOTFS}
|
2008-08-25 20:53:13 +00:00
|
|
|
|
|
|
|
${ROOTFS_POSTINSTALL_COMMAND}
|
2008-09-03 23:22:06 +00:00
|
|
|
|
|
|
|
mkdir -p ${IMAGE_ROOTFS}/etc/rpm-postinsts/
|
2010-09-01 21:04:45 +00:00
|
|
|
${RPM} --root ${IMAGE_ROOTFS} -D '_dbpath ${rpmlibdir}' -qa \
|
2010-08-22 05:44:21 +00:00
|
|
|
--qf 'Name: %{NAME}\n%|POSTIN?{postinstall scriptlet%|POSTINPROG?{ (using %{POSTINPROG})}|:\n%{POSTIN}\n}:{%|POSTINPROG?{postinstall program: %{POSTINPROG}\n}|}|' \
|
|
|
|
> ${IMAGE_ROOTFS}/etc/rpm-postinsts/combined
|
2008-09-03 23:22:06 +00:00
|
|
|
awk -f ${AWKPOSTINSTSCRIPT} < ${IMAGE_ROOTFS}/etc/rpm-postinsts/combined
|
|
|
|
rm ${IMAGE_ROOTFS}/etc/rpm-postinsts/combined
|
|
|
|
|
|
|
|
for i in ${IMAGE_ROOTFS}/etc/rpm-postinsts/*.sh; do
|
|
|
|
if [ -f $i ] && sh $i; then
|
2008-09-04 21:52:34 +00:00
|
|
|
# rm $i
|
|
|
|
mv $i $i.done
|
2008-09-03 23:22:06 +00:00
|
|
|
fi
|
|
|
|
done
|
2008-08-25 20:53:13 +00:00
|
|
|
|
2008-09-04 21:52:34 +00:00
|
|
|
install -d ${IMAGE_ROOTFS}/${sysconfdir}/rcS.d
|
|
|
|
# Stop $i getting expanded below...
|
|
|
|
i=\$i
|
|
|
|
cat > ${IMAGE_ROOTFS}${sysconfdir}/rcS.d/S98configure << EOF
|
|
|
|
#!/bin/sh
|
|
|
|
for i in /etc/rpm-postinsts/*.sh; do
|
|
|
|
echo "Running postinst $i..."
|
|
|
|
if [ -f $i ] && sh $i; then
|
|
|
|
# rm $i
|
|
|
|
mv $i $i.done
|
|
|
|
else
|
|
|
|
echo "ERROR: postinst $i failed."
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
rm -f ${sysconfdir}/rcS.d/S98configure
|
|
|
|
EOF
|
|
|
|
chmod 0755 ${IMAGE_ROOTFS}${sysconfdir}/rcS.d/S98configure
|
|
|
|
|
2008-08-25 20:53:13 +00:00
|
|
|
install -d ${IMAGE_ROOTFS}/${sysconfdir}
|
|
|
|
echo ${BUILDNAME} > ${IMAGE_ROOTFS}/${sysconfdir}/version
|
|
|
|
|
2008-10-07 16:21:25 +00:00
|
|
|
${RPM_POSTPROCESS_COMMANDS}
|
2008-08-25 20:53:13 +00:00
|
|
|
${ROOTFS_POSTPROCESS_COMMAND}
|
|
|
|
|
|
|
|
rm -rf ${IMAGE_ROOTFS}/var/cache2/
|
|
|
|
rm -rf ${IMAGE_ROOTFS}/var/run2/
|
|
|
|
rm -rf ${IMAGE_ROOTFS}/var/log2/
|
|
|
|
|
2008-10-03 15:23:05 +00:00
|
|
|
# remove lock files
|
2010-09-01 21:04:45 +00:00
|
|
|
rm -f ${IMAGE_ROOTFS}${rpmlibdir}/__db.*
|
2008-10-03 15:23:05 +00:00
|
|
|
|
2010-07-20 19:57:19 +00:00
|
|
|
# remove resolver files and manifests
|
2010-08-22 05:44:21 +00:00
|
|
|
rm -f ${IMAGE_ROOTFS}/install/install.manifest
|
2008-10-07 15:34:55 +00:00
|
|
|
|
2009-11-16 10:51:24 +00:00
|
|
|
log_check rootfs
|
2010-09-03 17:41:57 +00:00
|
|
|
|
|
|
|
# Workaround so the parser knows we need the resolve_package function!
|
2010-09-09 19:46:23 +00:00
|
|
|
if false ; then
|
|
|
|
resolve_package foo || true
|
|
|
|
fi
|
2008-08-25 20:53:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
rootfs_rpm_log_check() {
|
|
|
|
target="$1"
|
|
|
|
lf_path="$2"
|
|
|
|
|
|
|
|
lf_txt="`cat $lf_path`"
|
|
|
|
for keyword_die in "Cannot find package" "exit 1" ERR Fail
|
2009-11-16 10:51:24 +00:00
|
|
|
do
|
2008-08-25 20:53:13 +00:00
|
|
|
if (echo "$lf_txt" | grep -v log_check | grep "$keyword_die") >/dev/null 2>&1
|
|
|
|
then
|
|
|
|
echo "log_check: There were error messages in the logfile"
|
|
|
|
echo -e "log_check: Matched keyword: [$keyword_die]\n"
|
|
|
|
echo "$lf_txt" | grep -v log_check | grep -C 5 -i "$keyword_die"
|
|
|
|
echo ""
|
2009-11-16 10:51:24 +00:00
|
|
|
do_exit=1
|
2008-08-25 20:53:13 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
test "$do_exit" = 1 && exit 1
|
|
|
|
true
|
|
|
|
}
|
|
|
|
|
|
|
|
remove_packaging_data_files() {
|
2010-09-01 21:04:45 +00:00
|
|
|
rm -rf ${IMAGE_ROOTFS}${rpmlibdir}
|
2010-08-26 04:39:07 +00:00
|
|
|
rm -rf ${IMAGE_ROOTFS}${opkglibdir}
|
2008-08-25 20:53:13 +00:00
|
|
|
}
|
|
|
|
|
2010-09-01 21:04:45 +00:00
|
|
|
# Resolve package names to filepaths
|
|
|
|
resolve_package() {
|
|
|
|
pkg="$1"
|
2010-09-02 18:28:37 +00:00
|
|
|
pkg_name=""
|
2010-09-01 21:04:45 +00:00
|
|
|
for solve in `cat ${DEPLOY_DIR_RPM}/solvedb.conf`; do
|
|
|
|
pkg_name=$(${RPM} -D "_dbpath $solve" -D "_dbi_tags_3 Packages:Name:Basenames:Providename:Nvra" -D "__dbi_cdb create mp_mmapsize=128Mb mp_size=1Mb nofsync" -q --yaml $pkg | grep -i 'Packageorigin' | cut -d : -f 2)
|
|
|
|
if [ -n "$pkg_name" ]; then
|
|
|
|
break;
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
echo $pkg_name
|
|
|
|
}
|
|
|
|
|
2008-08-25 20:53:13 +00:00
|
|
|
install_all_locales() {
|
2010-09-02 18:28:37 +00:00
|
|
|
PACKAGES_TO_INSTALL=""
|
|
|
|
|
|
|
|
# Generate list of installed packages...
|
|
|
|
INSTALLED_PACKAGES=$( \
|
|
|
|
${RPM} --root ${IMAGE_ROOTFS} -D "_dbpath ${rpmlibdir}" \
|
|
|
|
-D "__dbi_cdb create mp_mmapsize=128Mb mp_size=1Mb nofsync private" \
|
|
|
|
-qa --qf "[%{NAME}\n]" | egrep -v -- "(-locale-|-dev$|-doc$|^kernel|^glibc|^ttf|^task|^perl|^python)" \
|
|
|
|
)
|
|
|
|
|
|
|
|
# This would likely be faster if we did it in one transaction
|
|
|
|
# but this should be good enough for the few users of this function...
|
|
|
|
for pkg in $INSTALLED_PACKAGES; do
|
|
|
|
for lang in ${IMAGE_LOCALES}; do
|
|
|
|
pkg_name=$(resolve_package $pkg-locale-$lang)
|
|
|
|
if [ -n "$pkg_name" ]; then
|
|
|
|
${RPM} --root ${IMAGE_ROOTFS} -D "_dbpath ${rpmlibdir}" \
|
|
|
|
--noscripts --notriggers --noparentdirs --nolinktos \
|
|
|
|
-D "__dbi_cdb create mp_mmapsize=128Mb mp_size=1Mb nofsync private" \
|
|
|
|
-Uhv $pkg_name || true
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
done
|
2008-08-25 20:53:13 +00:00
|
|
|
}
|
|
|
|
|
2008-10-07 16:47:22 +00:00
|
|
|
python () {
|
|
|
|
if bb.data.getVar('BUILD_IMAGES_FROM_FEEDS', d, True):
|
|
|
|
flags = bb.data.getVarFlag('do_rootfs', 'recrdeptask', d)
|
|
|
|
flags = flags.replace("do_package_write_rpm", "")
|
|
|
|
flags = flags.replace("do_deploy", "")
|
2009-11-10 14:55:23 +00:00
|
|
|
flags = flags.replace("do_populate_sysroot", "")
|
2008-10-07 16:47:22 +00:00
|
|
|
bb.data.setVarFlag('do_rootfs', 'recrdeptask', flags, d)
|
2010-08-22 05:44:21 +00:00
|
|
|
bb.data.setVar('RPM_PREPROCESS_COMMANDS', '', d)
|
2008-10-07 16:47:22 +00:00
|
|
|
bb.data.setVar('RPM_POSTPROCESS_COMMANDS', '', d)
|
|
|
|
}
|