2005-08-31 10:45:47 +00:00
|
|
|
inherit package
|
2008-08-18 08:01:41 +00:00
|
|
|
|
2006-09-19 09:04:09 +00:00
|
|
|
IMAGE_PKGTYPE ?= "rpm"
|
2005-08-31 10:45:47 +00:00
|
|
|
|
2010-09-03 17:43:41 +00:00
|
|
|
RPM="rpm"
|
|
|
|
RPMBUILD="rpmbuild"
|
2005-08-31 10:45:47 +00:00
|
|
|
|
2010-08-20 16:52:39 +00:00
|
|
|
PKGWRITEDIRRPM = "${WORKDIR}/deploy-rpms"
|
2008-08-18 08:01:41 +00:00
|
|
|
|
2010-08-20 16:52:39 +00:00
|
|
|
python package_rpm_fn () {
|
|
|
|
bb.data.setVar('PKGFN', bb.data.getVar('PKG',d), d)
|
2005-08-31 10:45:47 +00:00
|
|
|
}
|
|
|
|
|
2010-08-20 16:52:39 +00:00
|
|
|
python package_rpm_install () {
|
|
|
|
bb.fatal("package_rpm_install not implemented!")
|
2008-08-18 08:01:41 +00:00
|
|
|
}
|
|
|
|
|
2011-01-30 06:07:50 +00:00
|
|
|
RPMCONF_TARGET_BASE = "${DEPLOY_DIR_RPM}/solvedb"
|
|
|
|
RPMCONF_HOST_BASE = "${DEPLOY_DIR_RPM}/solvedb-sdk"
|
2010-08-22 05:44:21 +00:00
|
|
|
#
|
|
|
|
# Update the Packages depsolver db in ${DEPLOY_DIR_RPM}
|
|
|
|
#
|
|
|
|
package_update_index_rpm () {
|
|
|
|
if [ ! -z "${DEPLOY_KEEP_PACKAGES}" ]; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2011-08-01 16:56:37 +00:00
|
|
|
# Update target packages
|
|
|
|
base_archs="${PACKAGE_ARCHS}"
|
|
|
|
ml_archs="${MULTILIB_PACKAGE_ARCHS}"
|
|
|
|
package_update_index_rpm_common "${RPMCONF_TARGET_BASE}" base_archs ml_archs
|
|
|
|
|
|
|
|
# Update SDK packages
|
2011-08-01 17:11:22 +00:00
|
|
|
base_archs="${SDK_PACKAGE_ARCHS}"
|
2011-08-01 16:56:37 +00:00
|
|
|
package_update_index_rpm_common "${RPMCONF_HOST_BASE}" base_archs
|
|
|
|
}
|
|
|
|
|
|
|
|
package_update_index_rpm_common () {
|
|
|
|
rpmconf_base="$1"
|
|
|
|
shift
|
2011-07-18 20:55:28 +00:00
|
|
|
|
2011-08-01 16:56:37 +00:00
|
|
|
for archvar in "$@"; do
|
2011-07-18 20:55:28 +00:00
|
|
|
eval archs=\${${archvar}}
|
|
|
|
packagedirs=""
|
|
|
|
for arch in $archs; do
|
|
|
|
packagedirs="${DEPLOY_DIR_RPM}/$arch $packagedirs"
|
|
|
|
rm -rf ${DEPLOY_DIR_RPM}/$arch/solvedb
|
|
|
|
done
|
2010-08-22 05:44:21 +00:00
|
|
|
|
2011-08-01 16:56:37 +00:00
|
|
|
cat /dev/null > ${rpmconf_base}-${archvar}.conf
|
2011-07-18 20:55:28 +00:00
|
|
|
for pkgdir in $packagedirs; do
|
|
|
|
if [ -e $pkgdir/ ]; then
|
|
|
|
echo "Generating solve db for $pkgdir..."
|
2011-08-01 16:56:37 +00:00
|
|
|
echo $pkgdir/solvedb >> ${rpmconf_base}-${archvar}.conf
|
2011-07-18 20:55:28 +00:00
|
|
|
if [ -d $pkgdir/solvedb ]; then
|
|
|
|
# We've already processed this and it's a duplicate
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
mkdir -p $pkgdir/solvedb
|
|
|
|
echo "# Dynamically generated solve manifest" >> $pkgdir/solvedb/manifest
|
|
|
|
find $pkgdir -maxdepth 1 -type f >> $pkgdir/solvedb/manifest
|
|
|
|
${RPM} -i --replacepkgs --replacefiles --oldpackage \
|
|
|
|
-D "_dbpath $pkgdir/solvedb" --justdb \
|
|
|
|
--noaid --nodeps --noorder --noscripts --notriggers --noparentdirs --nolinktos --stats \
|
|
|
|
--ignoresize --nosignature --nodigest \
|
|
|
|
-D "__dbi_txn create nofsync" \
|
|
|
|
$pkgdir/solvedb/manifest
|
2011-02-16 04:56:13 +00:00
|
|
|
fi
|
2011-07-18 20:55:28 +00:00
|
|
|
done
|
2010-08-22 05:44:21 +00:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Generate an rpm configuration suitable for use against the
|
|
|
|
# generated depsolver db's...
|
|
|
|
#
|
|
|
|
package_generate_rpm_conf () {
|
2011-08-01 16:56:37 +00:00
|
|
|
# Update target packages
|
|
|
|
package_generate_rpm_conf_common "${RPMCONF_TARGET_BASE}" base_archs ml_archs
|
2011-07-18 20:55:28 +00:00
|
|
|
|
2011-08-01 16:56:37 +00:00
|
|
|
# Update SDK packages
|
|
|
|
package_generate_rpm_conf_common "${RPMCONF_HOST_BASE}" base_archs
|
|
|
|
}
|
|
|
|
|
|
|
|
package_generate_rpm_conf_common() {
|
|
|
|
rpmconf_base="$1"
|
|
|
|
shift
|
|
|
|
|
|
|
|
printf "_solve_dbpath " > ${rpmconf_base}.macro
|
|
|
|
o_colon=false
|
2011-01-30 06:07:50 +00:00
|
|
|
|
2011-08-01 16:56:37 +00:00
|
|
|
for archvar in "$@"; do
|
|
|
|
printf "_solve_dbpath " > ${rpmconf_base}-${archvar}.macro
|
2011-07-18 20:55:28 +00:00
|
|
|
colon=false
|
2011-08-01 16:56:37 +00:00
|
|
|
for each in `cat ${rpmconf_base}-${archvar}.conf` ; do
|
|
|
|
if [ "$o_colon" == true ]; then
|
|
|
|
printf ":" >> ${rpmconf_base}.macro
|
2011-07-18 20:55:28 +00:00
|
|
|
fi
|
|
|
|
if [ "$colon" == true ]; then
|
2011-08-01 16:56:37 +00:00
|
|
|
printf ":" >> ${rpmconf_base}-${archvar}.macro
|
2011-07-18 20:55:28 +00:00
|
|
|
fi
|
2011-08-01 16:56:37 +00:00
|
|
|
printf "%s" $each >> ${rpmconf_base}.macro
|
|
|
|
o_colon=true
|
|
|
|
printf "%s" $each >> ${rpmconf_base}-${archvar}.macro
|
2011-07-18 20:55:28 +00:00
|
|
|
colon=true
|
|
|
|
done
|
2011-08-01 16:56:37 +00:00
|
|
|
printf "\n" >> ${rpmconf_base}-${archvar}.macro
|
2011-01-30 06:07:50 +00:00
|
|
|
done
|
2011-08-01 16:56:37 +00:00
|
|
|
printf "\n" >> ${rpmconf_base}.macro
|
2010-08-22 05:44:21 +00:00
|
|
|
}
|
|
|
|
|
2011-01-30 04:04:46 +00:00
|
|
|
rpm_log_check() {
|
|
|
|
target="$1"
|
|
|
|
lf_path="$2"
|
|
|
|
|
|
|
|
lf_txt="`cat $lf_path`"
|
|
|
|
for keyword_die in "Cannot find package" "exit 1" ERR Fail
|
|
|
|
do
|
|
|
|
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 ""
|
|
|
|
do_exit=1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
test "$do_exit" = 1 && exit 1
|
|
|
|
true
|
|
|
|
}
|
|
|
|
|
2011-01-30 06:07:50 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Resolve package names to filepaths
|
|
|
|
# resolve_pacakge <pkgname> <solvdb conffile>
|
|
|
|
#
|
|
|
|
resolve_package_rpm () {
|
2011-07-18 20:55:28 +00:00
|
|
|
local conffile="$1"
|
|
|
|
shift
|
2011-01-30 06:07:50 +00:00
|
|
|
local pkg_name=""
|
|
|
|
for solve in `cat ${conffile}`; do
|
2011-07-18 20:55:28 +00:00
|
|
|
pkg_name=$(${RPM} -D "_dbpath $solve" -D "__dbi_txn create nofsync" -q --yaml $@ | grep -i 'Packageorigin' | cut -d : -f 2)
|
2011-01-30 06:07:50 +00:00
|
|
|
if [ -n "$pkg_name" ]; then
|
|
|
|
break;
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
echo $pkg_name
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# install a bunch of packages using rpm
|
|
|
|
# the following shell variables needs to be set before calling this func:
|
|
|
|
# INSTALL_ROOTFS_RPM - install root dir
|
2011-02-25 23:31:50 +00:00
|
|
|
# INSTALL_PLATFORM_RPM - main platform
|
|
|
|
# INSTALL_PLATFORM_EXTRA_RPM - extra platform
|
2011-01-30 06:07:50 +00:00
|
|
|
# INSTALL_CONFBASE_RPM - configuration file base name
|
2011-11-08 06:19:37 +00:00
|
|
|
# INSTALL_PACKAGES_RPM - packages to be installed
|
2011-01-30 06:07:50 +00:00
|
|
|
# INSTALL_PACKAGES_ATTEMPTONLY_RPM - packages attemped to be installed only
|
|
|
|
# INSTALL_PACKAGES_LINGUAS_RPM - additional packages for uclibc
|
|
|
|
# INSTALL_PROVIDENAME_RPM - content for provide name
|
|
|
|
# INSTALL_TASK_RPM - task name
|
|
|
|
|
|
|
|
package_install_internal_rpm () {
|
|
|
|
|
|
|
|
local target_rootfs="${INSTALL_ROOTFS_RPM}"
|
2011-02-25 23:31:50 +00:00
|
|
|
local platform="${INSTALL_PLATFORM_RPM}"
|
|
|
|
local platform_extra="${INSTALL_PLATFORM_EXTRA_RPM}"
|
2011-01-30 06:07:50 +00:00
|
|
|
local confbase="${INSTALL_CONFBASE_RPM}"
|
2011-11-08 06:19:37 +00:00
|
|
|
local package_to_install="${INSTALL_PACKAGES_RPM}"
|
2011-01-30 06:07:50 +00:00
|
|
|
local package_attemptonly="${INSTALL_PACKAGES_ATTEMPTONLY_RPM}"
|
2011-07-30 12:46:40 +00:00
|
|
|
local package_linguas="${INSTALL_PACKAGES_LINGUAS_RPM}"
|
2011-01-30 06:07:50 +00:00
|
|
|
local providename="${INSTALL_PROVIDENAME_RPM}"
|
|
|
|
local task="${INSTALL_TASK_RPM}"
|
|
|
|
|
|
|
|
# Setup base system configuration
|
|
|
|
mkdir -p ${target_rootfs}/etc/rpm/
|
2011-07-18 20:55:28 +00:00
|
|
|
echo "${platform}${TARGET_VENDOR}-${TARGET_OS}" > ${target_rootfs}/etc/rpm/platform
|
2011-02-25 23:31:50 +00:00
|
|
|
if [ ! -z "$platform_extra" ]; then
|
|
|
|
for pt in $platform_extra ; do
|
2011-08-11 15:38:30 +00:00
|
|
|
case $pt in
|
|
|
|
noarch | any | all)
|
|
|
|
os="`echo ${TARGET_OS} | sed "s,-.*,,"`.*"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
os="${TARGET_OS}"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
echo "$pt-.*-$os" >> ${target_rootfs}/etc/rpm/platform
|
2011-01-30 06:07:50 +00:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Tell RPM that the "/" directory exist and is available
|
|
|
|
mkdir -p ${target_rootfs}/etc/rpm/sysinfo
|
|
|
|
echo "/" >${target_rootfs}/etc/rpm/sysinfo/Dirnames
|
|
|
|
if [ ! -z "$providename" ]; then
|
2011-08-01 16:56:37 +00:00
|
|
|
cat /dev/null > ${target_rootfs}/etc/rpm/sysinfo/Providename
|
2011-01-30 06:07:50 +00:00
|
|
|
for provide in $providename ; do
|
|
|
|
echo $provide >> ${target_rootfs}/etc/rpm/sysinfo/Providename
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Setup manifest of packages to install...
|
|
|
|
mkdir -p ${target_rootfs}/install
|
|
|
|
echo "# Install manifest" > ${target_rootfs}/install/install.manifest
|
|
|
|
|
|
|
|
# Uclibc builds don't provide this stuff...
|
|
|
|
if [ x${TARGET_OS} = "xlinux" ] || [ x${TARGET_OS} = "xlinux-gnueabi" ] ; then
|
2011-07-30 12:46:40 +00:00
|
|
|
if [ ! -z "${package_linguas}" ]; then
|
|
|
|
for pkg in ${package_linguas}; do
|
2011-01-30 06:07:50 +00:00
|
|
|
echo "Processing $pkg..."
|
2011-07-18 20:55:28 +00:00
|
|
|
|
2011-08-01 16:56:37 +00:00
|
|
|
archvar=base_archs
|
2011-11-08 06:19:37 +00:00
|
|
|
manifest=install.manifest
|
2011-09-09 13:30:08 +00:00
|
|
|
ml_prefix=`echo ${pkg} | cut -d'-' -f1`
|
|
|
|
ml_pkg=$pkg
|
|
|
|
for i in ${MULTILIB_PREFIX_LIST} ; do
|
|
|
|
if [ ${ml_prefix} == ${i} ]; then
|
|
|
|
ml_pkg=$(echo ${pkg} | sed "s,^${ml_prefix}-\(.*\),\1,")
|
|
|
|
archvar=ml_archs
|
2011-11-08 06:19:37 +00:00
|
|
|
manifest=install_multilib.manifest
|
2011-09-09 13:30:08 +00:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
2011-07-18 20:55:28 +00:00
|
|
|
|
|
|
|
pkg_name=$(resolve_package_rpm ${confbase}-${archvar}.conf ${ml_pkg})
|
2011-01-30 06:07:50 +00:00
|
|
|
if [ -z "$pkg_name" ]; then
|
2011-07-18 20:55:28 +00:00
|
|
|
echo "Unable to find package $pkg ($ml_pkg)!"
|
2011-01-30 06:07:50 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2011-11-08 06:19:37 +00:00
|
|
|
echo $pkg_name >> ${target_rootfs}/install/${manifest}
|
2011-01-30 06:07:50 +00:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ ! -z "${package_to_install}" ]; then
|
|
|
|
for pkg in ${package_to_install} ; do
|
|
|
|
echo "Processing $pkg..."
|
2011-07-18 20:55:28 +00:00
|
|
|
|
2011-08-01 16:56:37 +00:00
|
|
|
archvar=base_archs
|
2011-11-08 06:19:37 +00:00
|
|
|
manifest=install.manifest
|
2011-09-09 13:30:08 +00:00
|
|
|
ml_prefix=`echo ${pkg} | cut -d'-' -f1`
|
|
|
|
ml_pkg=$pkg
|
|
|
|
for i in ${MULTILIB_PREFIX_LIST} ; do
|
|
|
|
if [ ${ml_prefix} == ${i} ]; then
|
|
|
|
ml_pkg=$(echo ${pkg} | sed "s,^${ml_prefix}-\(.*\),\1,")
|
|
|
|
archvar=ml_archs
|
2011-11-08 06:19:37 +00:00
|
|
|
manifest=install_multilib.manifest
|
2011-09-09 13:30:08 +00:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
2011-07-18 20:55:28 +00:00
|
|
|
|
|
|
|
pkg_name=$(resolve_package_rpm ${confbase}-${archvar}.conf ${ml_pkg})
|
2011-01-30 06:07:50 +00:00
|
|
|
if [ -z "$pkg_name" ]; then
|
2011-07-18 20:55:28 +00:00
|
|
|
echo "Unable to find package $pkg ($ml_pkg)!"
|
2011-01-30 06:07:50 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2011-11-08 06:19:37 +00:00
|
|
|
echo $pkg_name >> ${target_rootfs}/install/${manifest}
|
2011-01-30 06:07:50 +00:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2011-09-21 19:06:52 +00:00
|
|
|
# Normal package installation
|
|
|
|
|
2011-01-30 06:07:50 +00:00
|
|
|
# Generate an install solution by doing a --justdb install, then recreate it with
|
|
|
|
# an actual package install!
|
2011-02-16 04:20:49 +00:00
|
|
|
${RPM} --predefine "_rpmds_sysinfo_path ${target_rootfs}/etc/rpm/sysinfo" \
|
|
|
|
--predefine "_rpmrc_platform_path ${target_rootfs}/etc/rpm/platform" \
|
2011-09-21 19:06:52 +00:00
|
|
|
-D "_dbpath ${target_rootfs}/install" -D "`cat ${confbase}-base_archs.macro`" \
|
2011-01-30 06:07:50 +00:00
|
|
|
-D "__dbi_txn create nofsync" \
|
|
|
|
-U --justdb --noscripts --notriggers --noparentdirs --nolinktos --ignoresize \
|
|
|
|
${target_rootfs}/install/install.manifest
|
|
|
|
|
|
|
|
if [ ! -z "${package_attemptonly}" ]; then
|
|
|
|
echo "Adding attempt only packages..."
|
|
|
|
for pkg in ${package_attemptonly} ; do
|
|
|
|
echo "Processing $pkg..."
|
2011-08-12 00:23:48 +00:00
|
|
|
archvar=base_archs
|
2011-09-09 13:30:08 +00:00
|
|
|
ml_prefix=`echo ${pkg} | cut -d'-' -f1`
|
|
|
|
ml_pkg=$pkg
|
|
|
|
for i in ${MULTILIB_PREFIX_LIST} ; do
|
|
|
|
if [ ${ml_prefix} == ${i} ]; then
|
|
|
|
ml_pkg=$(echo ${pkg} | sed "s,^${ml_prefix}-\(.*\),\1,")
|
|
|
|
archvar=ml_archs
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
2011-08-12 00:23:48 +00:00
|
|
|
|
|
|
|
pkg_name=$(resolve_package_rpm ${confbase}-${archvar}.conf ${ml_pkg})
|
2011-01-30 06:07:50 +00:00
|
|
|
if [ -z "$pkg_name" ]; then
|
2011-08-12 00:23:48 +00:00
|
|
|
echo "Note: Unable to find package $pkg ($ml_pkg) -- PACKAGE_INSTALL_ATTEMPTONLY"
|
|
|
|
continue
|
2011-01-30 06:07:50 +00:00
|
|
|
fi
|
|
|
|
echo "Attempting $pkg_name..." >> "${WORKDIR}/temp/log.do_${task}_attemptonly.${PID}"
|
2011-02-16 04:20:49 +00:00
|
|
|
${RPM} --predefine "_rpmds_sysinfo_path ${target_rootfs}/etc/rpm/sysinfo" \
|
|
|
|
--predefine "_rpmrc_platform_path ${target_rootfs}/etc/rpm/platform" \
|
2011-01-30 06:07:50 +00:00
|
|
|
-D "_dbpath ${target_rootfs}/install" -D "`cat ${confbase}.macro`" \
|
|
|
|
-D "__dbi_txn create nofsync private" \
|
|
|
|
-U --justdb --noscripts --notriggers --noparentdirs --nolinktos --ignoresize \
|
|
|
|
$pkg_name >> "${WORKDIR}/temp/log.do_${task}_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 > ${target_rootfs}/install/recommend.list
|
|
|
|
while [ $loop -eq 1 ]; do
|
|
|
|
# Dump the full set of recommends...
|
2011-02-16 04:20:49 +00:00
|
|
|
${RPM} --predefine "_rpmds_sysinfo_path ${target_rootfs}/etc/rpm/sysinfo" \
|
|
|
|
--predefine "_rpmrc_platform_path ${target_rootfs}/etc/rpm/platform" \
|
2011-08-01 16:56:37 +00:00
|
|
|
-D "_dbpath ${target_rootfs}/install" -D "`cat ${confbase}.macro`" \
|
2011-01-30 06:07:50 +00:00
|
|
|
-D "__dbi_txn create nofsync private" \
|
|
|
|
-qa --qf "[%{RECOMMENDS}\n]" | sort -u > ${target_rootfs}/install/recommend
|
|
|
|
# Did we add more to the list?
|
|
|
|
grep -v -x -F -f ${target_rootfs}/install/recommend.list ${target_rootfs}/install/recommend > ${target_rootfs}/install/recommend.new || true
|
|
|
|
# We don't want to loop unless there is a change to the list!
|
|
|
|
loop=0
|
|
|
|
cat ${target_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..."
|
2011-08-12 00:23:48 +00:00
|
|
|
found=0
|
|
|
|
for archvar in base_archs ml_archs ; do
|
|
|
|
pkg_name=$(resolve_package_rpm ${confbase}-${archvar}.conf ${pkg})
|
|
|
|
if [ -n "$pkg_name" ]; then
|
|
|
|
found=1
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ $found -eq 0 ]; then
|
|
|
|
echo "Note: Unable to find package $pkg -- suggests"
|
2011-01-30 06:07:50 +00:00
|
|
|
echo "Unable to find package $pkg." >> "${WORKDIR}/temp/log.do_${task}_recommend.${PID}"
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
echo "Attempting $pkg_name..." >> "${WORKDIR}/temp/log.do_{task}_recommend.${PID}"
|
2011-02-16 04:20:49 +00:00
|
|
|
${RPM} --predefine "_rpmds_sysinfo_path ${target_rootfs}/etc/rpm/sysinfo" \
|
|
|
|
--predefine "_rpmrc_platform_path ${target_rootfs}/etc/rpm/platform" \
|
2011-01-30 06:07:50 +00:00
|
|
|
-D "_dbpath ${target_rootfs}/install" -D "`cat ${confbase}.macro`" \
|
|
|
|
-D "__dbi_txn create nofsync private" \
|
|
|
|
-U --justdb --noscripts --notriggers --noparentdirs --nolinktos --ignoresize \
|
|
|
|
$pkg_name >> "${WORKDIR}/temp/log.do_${task}_recommend.${PID}" 2>&1 || true
|
|
|
|
done
|
|
|
|
cat ${target_rootfs}/install/recommend.list ${target_rootfs}/install/recommend.new | sort -u > ${target_rootfs}/install/recommend.new.list
|
|
|
|
mv -f ${target_rootfs}/install/recommend.new.list ${target_rootfs}/install/recommend.list
|
|
|
|
rm ${target_rootfs}/install/recommend ${target_rootfs}/install/recommend.new
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Now that we have a solution, pull out a list of what to install...
|
|
|
|
echo "Manifest: ${target_rootfs}/install/install.manifest"
|
|
|
|
${RPM} -D "_dbpath ${target_rootfs}/install" -qa --yaml \
|
|
|
|
-D "__dbi_txn create nofsync private" \
|
|
|
|
| grep -i 'Packageorigin' | cut -d : -f 2 > ${target_rootfs}/install/install_solution.manifest
|
|
|
|
|
2011-09-30 21:31:52 +00:00
|
|
|
touch ${target_rootfs}/install/install_multilib_solution.manifest
|
|
|
|
|
2011-11-08 06:19:37 +00:00
|
|
|
if [ -e "${target_rootfs}/install/install_multilib.manifest" ]; then
|
2011-09-30 21:31:52 +00:00
|
|
|
# multilib package installation
|
2011-09-21 19:06:52 +00:00
|
|
|
|
2011-09-30 21:31:52 +00:00
|
|
|
# Generate an install solution by doing a --justdb install, then recreate it with
|
|
|
|
# an actual package install!
|
|
|
|
${RPM} --predefine "_rpmds_sysinfo_path ${target_rootfs}/etc/rpm/sysinfo" \
|
|
|
|
--predefine "_rpmrc_platform_path ${target_rootfs}/etc/rpm/platform" \
|
|
|
|
-D "_dbpath ${target_rootfs}/install" -D "`cat ${confbase}-ml_archs.macro`" \
|
|
|
|
-D "__dbi_txn create nofsync" \
|
|
|
|
-U --justdb --noscripts --notriggers --noparentdirs --nolinktos --ignoresize \
|
|
|
|
${target_rootfs}/install/install_multilib.manifest
|
|
|
|
|
|
|
|
# Now that we have a solution, pull out a list of what to install...
|
|
|
|
echo "Manifest: ${target_rootfs}/install/install_multilib.manifest"
|
|
|
|
${RPM} -D "_dbpath ${target_rootfs}/install" -qa --yaml \
|
|
|
|
-D "__dbi_txn create nofsync private" \
|
|
|
|
| grep -i 'Packageorigin' | cut -d : -f 2 > ${target_rootfs}/install/install_multilib_solution.manifest
|
2011-09-21 19:06:52 +00:00
|
|
|
|
2011-09-30 21:31:52 +00:00
|
|
|
fi
|
2011-09-21 19:06:52 +00:00
|
|
|
|
2011-09-28 02:24:13 +00:00
|
|
|
cat ${target_rootfs}/install/install_solution.manifest > ${target_rootfs}/install/total_solution.manifest
|
|
|
|
cat ${target_rootfs}/install/install_multilib_solution.manifest >> ${target_rootfs}/install/total_solution.manifest
|
2011-09-21 19:06:52 +00:00
|
|
|
|
2011-01-30 06:07:50 +00:00
|
|
|
# Attempt install
|
|
|
|
${RPM} --root ${target_rootfs} \
|
2011-02-16 04:20:49 +00:00
|
|
|
--predefine "_rpmds_sysinfo_path ${target_rootfs}/etc/rpm/sysinfo" \
|
|
|
|
--predefine "_rpmrc_platform_path ${target_rootfs}/etc/rpm/platform" \
|
2011-01-30 06:07:50 +00:00
|
|
|
-D "_dbpath ${rpmlibdir}" \
|
2011-09-21 19:06:52 +00:00
|
|
|
--noscripts --notriggers --noparentdirs --nolinktos --replacepkgs \
|
2011-01-30 06:07:50 +00:00
|
|
|
-D "__dbi_txn create nofsync private" \
|
2011-09-28 02:24:13 +00:00
|
|
|
-Uhv ${target_rootfs}/install/total_solution.manifest
|
2011-01-30 06:07:50 +00:00
|
|
|
}
|
|
|
|
|
2010-08-20 16:52:39 +00:00
|
|
|
python write_specfile () {
|
2010-09-29 15:11:24 +00:00
|
|
|
import textwrap
|
2010-10-10 04:24:38 +00:00
|
|
|
import oe.packagedata
|
2010-09-29 15:11:24 +00:00
|
|
|
|
2011-07-18 20:55:28 +00:00
|
|
|
# We need a simple way to remove the MLPREFIX from the package name,
|
|
|
|
# and dependency information...
|
|
|
|
def strip_multilib(name, d):
|
|
|
|
multilibs = d.getVar('MULTILIBS', True) or ""
|
|
|
|
for ext in multilibs.split():
|
|
|
|
eext = ext.split(':')
|
2011-08-03 14:52:48 +00:00
|
|
|
if len(eext) > 1 and eext[0] == 'multilib' and name and name.find(eext[1] + '-') >= 0:
|
|
|
|
name = "".join(name.split(eext[1] + '-'))
|
2011-07-18 20:55:28 +00:00
|
|
|
return name
|
|
|
|
|
|
|
|
# ml = bb.data.getVar("MLPREFIX", d, True)
|
|
|
|
# if ml and name and len(ml) != 0 and name.find(ml) == 0:
|
|
|
|
# return ml.join(name.split(ml, 1)[1:])
|
|
|
|
# return name
|
|
|
|
|
2011-06-21 00:08:19 +00:00
|
|
|
# In RPM, dependencies are of the format: pkg <>= Epoch:Version-Release
|
|
|
|
# This format is similar to OE, however there are restrictions on the
|
|
|
|
# characters that can be in a field. In the Version field, "-"
|
|
|
|
# characters are not allowed. "-" is allowed in the Release field.
|
|
|
|
#
|
|
|
|
# We translate the "-" in the version to a "+", by loading the PKGV
|
|
|
|
# from the dependent recipe, replacing the - with a +, and then using
|
|
|
|
# that value to do a replace inside of this recipe's dependencies.
|
|
|
|
# This preserves the "-" separator between the version and release, as
|
|
|
|
# well as any "-" characters inside of the release field.
|
|
|
|
#
|
|
|
|
# All of this has to happen BEFORE the mapping_rename_hook as
|
|
|
|
# after renaming we cannot look up the dependencies in the packagedata
|
|
|
|
# store.
|
2010-08-20 16:52:39 +00:00
|
|
|
def translate_vers(varname, d):
|
|
|
|
depends = bb.data.getVar(varname, d, True)
|
|
|
|
if depends:
|
|
|
|
depends_dict = bb.utils.explode_dep_versions(depends)
|
|
|
|
newdeps_dict = {}
|
|
|
|
for dep in depends_dict:
|
|
|
|
ver = depends_dict[dep]
|
|
|
|
if dep and ver:
|
|
|
|
if '-' in ver:
|
2010-10-10 04:24:38 +00:00
|
|
|
subd = oe.packagedata.read_subpkgdata_dict(dep, d)
|
2011-06-21 00:08:19 +00:00
|
|
|
if 'PKGV' in subd:
|
|
|
|
pv = subd['PKGV']
|
|
|
|
reppv = pv.replace('-', '+')
|
|
|
|
ver = ver.replace(pv, reppv)
|
2011-08-03 14:53:15 +00:00
|
|
|
newdeps_dict[dep] = ver
|
2010-08-20 16:52:39 +00:00
|
|
|
depends = bb.utils.join_deps(newdeps_dict)
|
|
|
|
bb.data.setVar(varname, depends.strip(), d)
|
|
|
|
|
|
|
|
# We need to change the style the dependency from BB to RPM
|
|
|
|
# This needs to happen AFTER the mapping_rename_hook
|
2010-09-01 01:05:10 +00:00
|
|
|
def print_deps(variable, tag, array, d):
|
|
|
|
depends = variable
|
|
|
|
if depends:
|
|
|
|
depends_dict = bb.utils.explode_dep_versions(depends)
|
|
|
|
for dep in depends_dict:
|
|
|
|
ver = depends_dict[dep]
|
|
|
|
if dep and ver:
|
|
|
|
ver = ver.replace('(', '')
|
|
|
|
ver = ver.replace(')', '')
|
|
|
|
array.append("%s: %s %s" % (tag, dep, ver))
|
|
|
|
else:
|
|
|
|
array.append("%s: %s" % (tag, dep))
|
2010-08-20 16:52:39 +00:00
|
|
|
|
|
|
|
def walk_files(walkpath, target, conffiles):
|
|
|
|
import os
|
|
|
|
for rootpath, dirs, files in os.walk(walkpath):
|
|
|
|
path = rootpath.replace(walkpath, "")
|
2010-09-01 18:37:01 +00:00
|
|
|
for dir in dirs:
|
|
|
|
# All packages own the directories their files are in...
|
|
|
|
target.append("%dir " + path + "/" + dir)
|
2010-08-20 16:52:39 +00:00
|
|
|
for file in files:
|
|
|
|
if conffiles.count(path + "/" + file):
|
|
|
|
target.append("%config " + path + "/" + file)
|
|
|
|
else:
|
|
|
|
target.append(path + "/" + file)
|
|
|
|
|
2011-11-09 11:12:08 +00:00
|
|
|
# Prevent the prerm/postrm scripts from being run during an upgrade
|
|
|
|
def wrap_uninstall(scriptvar):
|
|
|
|
scr = scriptvar.strip()
|
|
|
|
if scr.startswith("#!"):
|
|
|
|
pos = scr.find("\n") + 1
|
|
|
|
else:
|
|
|
|
pos = 0
|
|
|
|
scr = scr[:pos] + 'if [ "$1" = "0" ] ; then\n' + scr[pos:] + '\nfi'
|
|
|
|
return scr
|
|
|
|
|
2010-08-20 16:52:39 +00:00
|
|
|
packages = bb.data.getVar('PACKAGES', d, True)
|
|
|
|
if not packages or packages == '':
|
|
|
|
bb.debug(1, "No packages; nothing to do")
|
2008-08-18 08:01:41 +00:00
|
|
|
return
|
2005-08-31 10:45:47 +00:00
|
|
|
|
2010-08-20 16:52:39 +00:00
|
|
|
pkgdest = bb.data.getVar('PKGDEST', d, True)
|
|
|
|
if not pkgdest:
|
|
|
|
bb.fatal("No PKGDEST")
|
2008-08-18 08:01:41 +00:00
|
|
|
return
|
2005-08-31 10:45:47 +00:00
|
|
|
|
2010-08-20 16:52:39 +00:00
|
|
|
outspecfile = bb.data.getVar('OUTSPECFILE', d, True)
|
|
|
|
if not outspecfile:
|
|
|
|
bb.fatal("No OUTSPECFILE")
|
2008-08-18 08:01:41 +00:00
|
|
|
return
|
|
|
|
|
2010-08-20 16:52:39 +00:00
|
|
|
# Construct the SPEC file...
|
2011-07-18 20:55:28 +00:00
|
|
|
srcname = strip_multilib(bb.data.getVar('PN', d, True), d)
|
2010-09-29 15:11:24 +00:00
|
|
|
srcsummary = (bb.data.getVar('SUMMARY', d, True) or bb.data.getVar('DESCRIPTION', d, True) or ".")
|
2011-05-19 02:17:43 +00:00
|
|
|
srcversion = bb.data.getVar('PKGV', d, True).replace('-', '+')
|
|
|
|
srcrelease = bb.data.getVar('PKGR', d, True)
|
|
|
|
srcepoch = (bb.data.getVar('PKGE', d, True) or "")
|
2010-08-20 16:52:39 +00:00
|
|
|
srclicense = bb.data.getVar('LICENSE', d, True)
|
|
|
|
srcsection = bb.data.getVar('SECTION', d, True)
|
|
|
|
srcmaintainer = bb.data.getVar('MAINTAINER', d, True)
|
|
|
|
srchomepage = bb.data.getVar('HOMEPAGE', d, True)
|
2010-09-29 15:11:24 +00:00
|
|
|
srcdescription = bb.data.getVar('DESCRIPTION', d, True) or "."
|
2010-08-20 16:52:39 +00:00
|
|
|
|
2011-07-18 20:55:28 +00:00
|
|
|
srcdepends = strip_multilib(bb.data.getVar('DEPENDS', d, True), d)
|
2010-08-20 16:52:39 +00:00
|
|
|
srcrdepends = []
|
|
|
|
srcrrecommends = []
|
|
|
|
srcrsuggests = []
|
|
|
|
srcrprovides = []
|
|
|
|
srcrreplaces = []
|
|
|
|
srcrconflicts = []
|
|
|
|
srcrobsoletes = []
|
|
|
|
|
|
|
|
srcpreinst = []
|
|
|
|
srcpostinst = []
|
|
|
|
srcprerm = []
|
|
|
|
srcpostrm = []
|
|
|
|
|
|
|
|
spec_preamble_top = []
|
|
|
|
spec_preamble_bottom = []
|
|
|
|
|
|
|
|
spec_scriptlets_top = []
|
|
|
|
spec_scriptlets_bottom = []
|
|
|
|
|
|
|
|
spec_files_top = []
|
|
|
|
spec_files_bottom = []
|
2005-08-31 10:45:47 +00:00
|
|
|
|
|
|
|
for pkg in packages.split():
|
|
|
|
localdata = bb.data.createCopy(d)
|
2010-08-20 16:52:39 +00:00
|
|
|
|
2008-08-18 08:01:41 +00:00
|
|
|
root = "%s/%s" % (pkgdest, pkg)
|
|
|
|
|
|
|
|
lf = bb.utils.lockfile(root + ".lock")
|
2005-08-31 10:45:47 +00:00
|
|
|
|
|
|
|
bb.data.setVar('ROOT', '', localdata)
|
|
|
|
bb.data.setVar('ROOT_%s' % pkg, root, localdata)
|
2008-08-18 08:01:41 +00:00
|
|
|
pkgname = bb.data.getVar('PKG_%s' % pkg, localdata, 1)
|
|
|
|
if not pkgname:
|
|
|
|
pkgname = pkg
|
|
|
|
bb.data.setVar('PKG', pkgname, localdata)
|
2005-08-31 10:45:47 +00:00
|
|
|
|
2010-07-07 11:53:46 +00:00
|
|
|
bb.data.setVar('OVERRIDES', pkg, localdata)
|
2005-08-31 10:45:47 +00:00
|
|
|
|
|
|
|
bb.data.update_data(localdata)
|
2010-08-20 16:52:39 +00:00
|
|
|
|
|
|
|
conffiles = (bb.data.getVar('CONFFILES', localdata, True) or "").split()
|
|
|
|
|
2011-07-18 20:55:28 +00:00
|
|
|
splitname = strip_multilib(pkgname, d)
|
2010-08-20 16:52:39 +00:00
|
|
|
|
2011-01-28 18:01:32 +00:00
|
|
|
splitsummary = (bb.data.getVar('SUMMARY', localdata, True) or bb.data.getVar('DESCRIPTION', localdata, True) or ".")
|
2011-05-19 02:17:43 +00:00
|
|
|
splitversion = (bb.data.getVar('PKGV', localdata, True) or "").replace('-', '+')
|
|
|
|
splitrelease = (bb.data.getVar('PKGR', localdata, True) or "")
|
|
|
|
splitepoch = (bb.data.getVar('PKGE', localdata, True) or "")
|
2010-08-20 16:52:39 +00:00
|
|
|
splitlicense = (bb.data.getVar('LICENSE', localdata, True) or "")
|
|
|
|
splitsection = (bb.data.getVar('SECTION', localdata, True) or "")
|
2010-09-29 15:11:24 +00:00
|
|
|
splitdescription = (bb.data.getVar('DESCRIPTION', localdata, True) or ".")
|
2010-08-20 16:52:39 +00:00
|
|
|
|
|
|
|
translate_vers('RDEPENDS', localdata)
|
|
|
|
translate_vers('RRECOMMENDS', localdata)
|
|
|
|
translate_vers('RSUGGESTS', localdata)
|
|
|
|
translate_vers('RPROVIDES', localdata)
|
|
|
|
translate_vers('RREPLACES', localdata)
|
|
|
|
translate_vers('RCONFLICTS', localdata)
|
|
|
|
|
|
|
|
# Map the dependencies into their final form
|
|
|
|
bb.build.exec_func("mapping_rename_hook", localdata)
|
|
|
|
|
2011-08-03 14:53:15 +00:00
|
|
|
splitrdepends = strip_multilib(bb.data.getVar('RDEPENDS', localdata, True), d) or ""
|
|
|
|
splitrrecommends = strip_multilib(bb.data.getVar('RRECOMMENDS', localdata, True), d) or ""
|
|
|
|
splitrsuggests = strip_multilib(bb.data.getVar('RSUGGESTS', localdata, True), d) or ""
|
|
|
|
splitrprovides = strip_multilib(bb.data.getVar('RPROVIDES', localdata, True), d) or ""
|
|
|
|
splitrreplaces = strip_multilib(bb.data.getVar('RREPLACES', localdata, True), d) or ""
|
|
|
|
splitrconflicts = strip_multilib(bb.data.getVar('RCONFLICTS', localdata, True), d) or ""
|
2010-08-20 16:52:39 +00:00
|
|
|
splitrobsoletes = []
|
|
|
|
|
2011-08-03 15:32:03 +00:00
|
|
|
# For now we need to manually supplement RPROVIDES with any update-alternatives links
|
|
|
|
if pkg == d.getVar("PN", True):
|
|
|
|
splitrprovides = splitrprovides + " " + (d.getVar('ALTERNATIVE_LINK', True) or '') + " " + (d.getVar('ALTERNATIVE_LINKS', True) or '')
|
|
|
|
|
2010-08-20 16:52:39 +00:00
|
|
|
# Gather special src/first package data
|
|
|
|
if srcname == splitname:
|
|
|
|
srcrdepends = splitrdepends
|
|
|
|
srcrrecommends = splitrrecommends
|
|
|
|
srcrsuggests = splitrsuggests
|
|
|
|
srcrprovides = splitrprovides
|
|
|
|
srcrreplaces = splitrreplaces
|
|
|
|
srcrconflicts = splitrconflicts
|
|
|
|
|
|
|
|
srcpreinst = bb.data.getVar('pkg_preinst', localdata, True)
|
|
|
|
srcpostinst = bb.data.getVar('pkg_postinst', localdata, True)
|
|
|
|
srcprerm = bb.data.getVar('pkg_prerm', localdata, True)
|
|
|
|
srcpostrm = bb.data.getVar('pkg_postrm', localdata, True)
|
|
|
|
|
|
|
|
file_list = []
|
|
|
|
walk_files(root, file_list, conffiles)
|
|
|
|
if not file_list and bb.data.getVar('ALLOW_EMPTY', localdata) != "1":
|
|
|
|
bb.note("Not creating empty RPM package for %s" % splitname)
|
|
|
|
else:
|
|
|
|
bb.note("Creating RPM package for %s" % splitname)
|
|
|
|
spec_files_top.append('%files')
|
2011-05-20 00:26:49 +00:00
|
|
|
spec_files_top.append('%defattr(-,-,-,-)')
|
2010-08-20 16:52:39 +00:00
|
|
|
if file_list:
|
2011-06-20 15:59:58 +00:00
|
|
|
bb.note("Creating RPM package for %s" % splitname)
|
2010-08-20 16:52:39 +00:00
|
|
|
spec_files_top.extend(file_list)
|
2011-06-20 15:59:58 +00:00
|
|
|
else:
|
|
|
|
bb.note("Creating EMPTY RPM Package for %s" % splitname)
|
2010-08-20 16:52:39 +00:00
|
|
|
spec_files_top.append('')
|
|
|
|
|
|
|
|
bb.utils.unlockfile(lf)
|
|
|
|
continue
|
|
|
|
|
|
|
|
# Process subpackage data
|
|
|
|
spec_preamble_bottom.append('%%package -n %s' % splitname)
|
|
|
|
spec_preamble_bottom.append('Summary: %s' % splitsummary)
|
|
|
|
if srcversion != splitversion:
|
|
|
|
spec_preamble_bottom.append('Version: %s' % splitversion)
|
|
|
|
if srcrelease != splitrelease:
|
|
|
|
spec_preamble_bottom.append('Release: %s' % splitrelease)
|
|
|
|
if srcepoch != splitepoch:
|
|
|
|
spec_preamble_bottom.append('Epoch: %s' % splitepoch)
|
|
|
|
if srclicense != splitlicense:
|
|
|
|
spec_preamble_bottom.append('License: %s' % splitlicense)
|
|
|
|
spec_preamble_bottom.append('Group: %s' % splitsection)
|
|
|
|
|
|
|
|
# Replaces == Obsoletes && Provides
|
|
|
|
if splitrreplaces and splitrreplaces.strip() != "":
|
|
|
|
for dep in splitrreplaces.split(','):
|
|
|
|
if splitrprovides:
|
|
|
|
splitrprovides = splitrprovides + ", " + dep
|
|
|
|
else:
|
|
|
|
splitrprovides = dep
|
|
|
|
if splitrobsoletes:
|
|
|
|
splitrobsoletes = splitrobsoletes + ", " + dep
|
|
|
|
else:
|
|
|
|
splitrobsoletes = dep
|
|
|
|
|
2010-09-01 01:05:10 +00:00
|
|
|
print_deps(splitrdepends, "Requires", spec_preamble_bottom, d)
|
2010-09-01 21:04:45 +00:00
|
|
|
# Suggests in RPM are like recommends in Poky!
|
|
|
|
print_deps(splitrrecommends, "Suggests", spec_preamble_bottom, d)
|
|
|
|
# While there is no analog for suggests... (So call them recommends for now)
|
|
|
|
print_deps(splitrsuggests, "Recommends", spec_preamble_bottom, d)
|
2010-09-01 01:05:10 +00:00
|
|
|
print_deps(splitrprovides, "Provides", spec_preamble_bottom, d)
|
|
|
|
print_deps(splitrobsoletes, "Obsoletes", spec_preamble_bottom, d)
|
|
|
|
|
|
|
|
# conflicts can not be in a provide! We will need to filter it.
|
|
|
|
if splitrconflicts:
|
|
|
|
depends_dict = bb.utils.explode_dep_versions(splitrconflicts)
|
|
|
|
newdeps_dict = {}
|
|
|
|
for dep in depends_dict:
|
2010-08-20 16:52:39 +00:00
|
|
|
if dep not in splitrprovides:
|
2010-09-01 01:05:10 +00:00
|
|
|
newdeps_dict[dep] = depends_dict[dep]
|
|
|
|
if newdeps_dict:
|
|
|
|
splitrconflicts = bb.utils.join_deps(newdeps_dict)
|
|
|
|
else:
|
|
|
|
splitrconflicts = ""
|
|
|
|
|
|
|
|
print_deps(splitrconflicts, "Conflicts", spec_preamble_bottom, d)
|
2010-08-20 16:52:39 +00:00
|
|
|
|
|
|
|
spec_preamble_bottom.append('')
|
|
|
|
|
|
|
|
spec_preamble_bottom.append('%%description -n %s' % splitname)
|
2010-09-29 15:11:24 +00:00
|
|
|
dedent_text = textwrap.dedent(splitdescription).strip()
|
|
|
|
spec_preamble_bottom.append('%s' % textwrap.fill(dedent_text, width=75))
|
2010-08-20 16:52:39 +00:00
|
|
|
|
|
|
|
spec_preamble_bottom.append('')
|
|
|
|
|
|
|
|
# Now process scriptlets
|
|
|
|
for script in ["preinst", "postinst", "prerm", "postrm"]:
|
|
|
|
scriptvar = bb.data.getVar('pkg_%s' % script, localdata, True)
|
|
|
|
if not scriptvar:
|
|
|
|
continue
|
|
|
|
if script == 'preinst':
|
|
|
|
spec_scriptlets_bottom.append('%%pre -n %s' % splitname)
|
|
|
|
elif script == 'postinst':
|
|
|
|
spec_scriptlets_bottom.append('%%post -n %s' % splitname)
|
|
|
|
elif script == 'prerm':
|
|
|
|
spec_scriptlets_bottom.append('%%preun -n %s' % splitname)
|
2011-11-09 11:12:08 +00:00
|
|
|
scriptvar = wrap_uninstall(scriptvar)
|
2010-08-20 16:52:39 +00:00
|
|
|
elif script == 'postrm':
|
|
|
|
spec_scriptlets_bottom.append('%%postun -n %s' % splitname)
|
2011-11-09 11:12:08 +00:00
|
|
|
scriptvar = wrap_uninstall(scriptvar)
|
2010-08-20 16:52:39 +00:00
|
|
|
spec_scriptlets_bottom.append(scriptvar)
|
|
|
|
spec_scriptlets_bottom.append('')
|
|
|
|
|
|
|
|
# Now process files
|
|
|
|
file_list = []
|
|
|
|
walk_files(root, file_list, conffiles)
|
|
|
|
if not file_list and bb.data.getVar('ALLOW_EMPTY', localdata) != "1":
|
|
|
|
bb.note("Not creating empty RPM package for %s" % splitname)
|
|
|
|
else:
|
|
|
|
spec_files_bottom.append('%%files -n %s' % splitname)
|
2011-05-20 00:26:49 +00:00
|
|
|
spec_files_bottom.append('%defattr(-,-,-,-)')
|
2010-08-20 16:52:39 +00:00
|
|
|
if file_list:
|
2011-06-20 15:59:58 +00:00
|
|
|
bb.note("Creating RPM package for %s" % splitname)
|
2010-08-20 16:52:39 +00:00
|
|
|
spec_files_bottom.extend(file_list)
|
2011-06-20 15:59:58 +00:00
|
|
|
else:
|
|
|
|
bb.note("Creating EMPTY RPM Package for %s" % splitname)
|
2010-08-20 16:52:39 +00:00
|
|
|
spec_files_bottom.append('')
|
|
|
|
|
|
|
|
del localdata
|
2008-08-18 08:01:41 +00:00
|
|
|
bb.utils.unlockfile(lf)
|
2010-08-20 16:52:39 +00:00
|
|
|
|
|
|
|
spec_preamble_top.append('Summary: %s' % srcsummary)
|
|
|
|
spec_preamble_top.append('Name: %s' % srcname)
|
|
|
|
spec_preamble_top.append('Version: %s' % srcversion)
|
|
|
|
spec_preamble_top.append('Release: %s' % srcrelease)
|
|
|
|
if srcepoch and srcepoch.strip() != "":
|
|
|
|
spec_preamble_top.append('Epoch: %s' % srcepoch)
|
|
|
|
spec_preamble_top.append('License: %s' % srclicense)
|
|
|
|
spec_preamble_top.append('Group: %s' % srcsection)
|
|
|
|
spec_preamble_top.append('Packager: %s' % srcmaintainer)
|
|
|
|
spec_preamble_top.append('URL: %s' % srchomepage)
|
|
|
|
|
|
|
|
# Replaces == Obsoletes && Provides
|
|
|
|
if srcrreplaces and srcrreplaces.strip() != "":
|
|
|
|
for dep in srcrreplaces.split(','):
|
|
|
|
if srcrprovides:
|
|
|
|
srcrprovides = srcrprovides + ", " + dep
|
|
|
|
else:
|
|
|
|
srcrprovides = dep
|
|
|
|
if srcrobsoletes:
|
|
|
|
srcrobsoletes = srcrobsoletes + ", " + dep
|
|
|
|
else:
|
|
|
|
srcrobsoletes = dep
|
2010-09-01 01:05:10 +00:00
|
|
|
|
|
|
|
print_deps(srcdepends, "BuildRequires", spec_preamble_top, d)
|
|
|
|
print_deps(srcrdepends, "Requires", spec_preamble_top, d)
|
2010-09-01 21:04:45 +00:00
|
|
|
# Suggests in RPM are like recommends in Poky!
|
|
|
|
print_deps(srcrrecommends, "Suggests", spec_preamble_top, d)
|
|
|
|
# While there is no analog for suggests... (So call them recommends for now)
|
|
|
|
print_deps(srcrsuggests, "Recommends", spec_preamble_top, d)
|
2010-09-01 01:05:10 +00:00
|
|
|
print_deps(srcrprovides, "Provides", spec_preamble_top, d)
|
|
|
|
print_deps(srcrobsoletes, "Obsoletes", spec_preamble_top, d)
|
|
|
|
|
|
|
|
# conflicts can not be in a provide! We will need to filter it.
|
|
|
|
if srcrconflicts:
|
|
|
|
depends_dict = bb.utils.explode_dep_versions(srcrconflicts)
|
|
|
|
newdeps_dict = {}
|
|
|
|
for dep in depends_dict:
|
2010-08-20 16:52:39 +00:00
|
|
|
if dep not in srcrprovides:
|
2010-09-01 01:05:10 +00:00
|
|
|
newdeps_dict[dep] = depends_dict[dep]
|
|
|
|
if newdeps_dict:
|
|
|
|
srcrconflicts = bb.utils.join_deps(newdeps_dict)
|
|
|
|
else:
|
|
|
|
srcrconflicts = ""
|
|
|
|
|
|
|
|
print_deps(srcrconflicts, "Conflicts", spec_preamble_top, d)
|
2010-08-20 16:52:39 +00:00
|
|
|
|
|
|
|
spec_preamble_top.append('')
|
|
|
|
|
|
|
|
spec_preamble_top.append('%description')
|
2010-09-29 15:11:24 +00:00
|
|
|
dedent_text = textwrap.dedent(srcdescription).strip()
|
|
|
|
spec_preamble_top.append('%s' % textwrap.fill(dedent_text, width=75))
|
2010-08-20 16:52:39 +00:00
|
|
|
|
|
|
|
spec_preamble_top.append('')
|
|
|
|
|
|
|
|
if srcpreinst:
|
|
|
|
spec_scriptlets_top.append('%pre')
|
|
|
|
spec_scriptlets_top.append(srcpreinst)
|
|
|
|
spec_scriptlets_top.append('')
|
|
|
|
if srcpostinst:
|
|
|
|
spec_scriptlets_top.append('%post')
|
|
|
|
spec_scriptlets_top.append(srcpostinst)
|
|
|
|
spec_scriptlets_top.append('')
|
|
|
|
if srcprerm:
|
|
|
|
spec_scriptlets_top.append('%preun')
|
2011-11-09 11:12:08 +00:00
|
|
|
scriptvar = wrap_uninstall(srcprerm)
|
|
|
|
spec_scriptlets_top.append(scriptvar)
|
2010-08-20 16:52:39 +00:00
|
|
|
spec_scriptlets_top.append('')
|
|
|
|
if srcpostrm:
|
|
|
|
spec_scriptlets_top.append('%postun')
|
2011-11-09 11:12:08 +00:00
|
|
|
scriptvar = wrap_uninstall(srcpostrm)
|
|
|
|
spec_scriptlets_top.append(scriptvar)
|
2010-08-20 16:52:39 +00:00
|
|
|
spec_scriptlets_top.append('')
|
|
|
|
|
|
|
|
# Write the SPEC file
|
|
|
|
try:
|
|
|
|
from __builtin__ import file
|
|
|
|
specfile = file(outspecfile, 'w')
|
|
|
|
except OSError:
|
|
|
|
raise bb.build.FuncFailed("unable to open spec file for writing.")
|
|
|
|
|
|
|
|
for line in spec_preamble_top:
|
|
|
|
specfile.write(line + "\n")
|
|
|
|
|
|
|
|
for line in spec_preamble_bottom:
|
|
|
|
specfile.write(line + "\n")
|
|
|
|
|
|
|
|
for line in spec_scriptlets_top:
|
|
|
|
specfile.write(line + "\n")
|
|
|
|
|
|
|
|
for line in spec_scriptlets_bottom:
|
|
|
|
specfile.write(line + "\n")
|
|
|
|
|
|
|
|
for line in spec_files_top:
|
|
|
|
specfile.write(line + "\n")
|
|
|
|
|
|
|
|
for line in spec_files_bottom:
|
|
|
|
specfile.write(line + "\n")
|
|
|
|
|
|
|
|
specfile.close()
|
|
|
|
}
|
|
|
|
|
|
|
|
python do_package_rpm () {
|
|
|
|
import os
|
|
|
|
|
2011-07-18 20:55:28 +00:00
|
|
|
# We need a simple way to remove the MLPREFIX from the package name,
|
|
|
|
# and dependency information...
|
|
|
|
def strip_multilib(name, d):
|
|
|
|
ml = bb.data.getVar("MLPREFIX", d, True)
|
2011-08-03 14:52:48 +00:00
|
|
|
if ml and name and len(ml) != 0 and name.find(ml) >= 0:
|
|
|
|
return "".join(name.split(ml))
|
2011-07-18 20:55:28 +00:00
|
|
|
return name
|
|
|
|
|
2010-08-20 16:52:39 +00:00
|
|
|
workdir = bb.data.getVar('WORKDIR', d, True)
|
|
|
|
outdir = bb.data.getVar('DEPLOY_DIR_IPK', d, True)
|
|
|
|
tmpdir = bb.data.getVar('TMPDIR', d, True)
|
|
|
|
pkgd = bb.data.getVar('PKGD', d, True)
|
|
|
|
pkgdest = bb.data.getVar('PKGDEST', d, True)
|
2010-10-22 11:56:20 +00:00
|
|
|
if not workdir or not outdir or not pkgd or not tmpdir:
|
2010-08-20 16:52:39 +00:00
|
|
|
bb.error("Variables incorrectly set, unable to package")
|
|
|
|
return
|
|
|
|
|
|
|
|
packages = bb.data.getVar('PACKAGES', d, True)
|
|
|
|
if not packages or packages == '':
|
|
|
|
bb.debug(1, "No packages; nothing to do")
|
|
|
|
return
|
|
|
|
|
|
|
|
# Construct the spec file...
|
2011-07-18 20:55:28 +00:00
|
|
|
srcname = strip_multilib(bb.data.getVar('PN', d, True), d)
|
2010-08-20 16:52:39 +00:00
|
|
|
outspecfile = workdir + "/" + srcname + ".spec"
|
|
|
|
bb.data.setVar('OUTSPECFILE', outspecfile, d)
|
|
|
|
bb.build.exec_func('write_specfile', d)
|
|
|
|
|
2010-08-30 21:44:31 +00:00
|
|
|
# Construct per file dependencies file
|
|
|
|
def dump_filerdeps(varname, outfile, d):
|
|
|
|
outfile.write("#!/bin/sh\n")
|
|
|
|
outfile.write("\n# Dependency table\n")
|
|
|
|
for pkg in packages.split():
|
|
|
|
dependsflist_key = 'FILE' + varname + 'FLIST' + "_" + pkg
|
|
|
|
dependsflist = (bb.data.getVar(dependsflist_key, d, True) or "")
|
|
|
|
for dfile in dependsflist.split():
|
|
|
|
key = "FILE" + varname + "_" + dfile + "_" + pkg
|
|
|
|
depends_dict = bb.utils.explode_dep_versions(bb.data.getVar(key, d, True) or "")
|
|
|
|
file = dfile.replace("@underscore@", "_")
|
|
|
|
file = file.replace("@closebrace@", "]")
|
|
|
|
file = file.replace("@openbrace@", "[")
|
|
|
|
file = file.replace("@tab@", "\t")
|
|
|
|
file = file.replace("@space@", " ")
|
|
|
|
file = file.replace("@at@", "@")
|
|
|
|
outfile.write("#" + pkgd + file + "\t")
|
|
|
|
for dep in depends_dict:
|
|
|
|
ver = depends_dict[dep]
|
|
|
|
if dep and ver:
|
|
|
|
ver = ver.replace("(","")
|
|
|
|
ver = ver.replace(")","")
|
|
|
|
outfile.write(dep + " " + ver + " ")
|
|
|
|
else:
|
|
|
|
outfile.write(dep + " ")
|
|
|
|
outfile.write("\n")
|
|
|
|
outfile.write("\n\nwhile read file_name ; do\n")
|
|
|
|
outfile.write("\tlength=$(echo \"#${file_name}\t\" | wc -c )\n")
|
|
|
|
outfile.write("\tline=$(grep \"^#${file_name}\t\" $0 | cut -c ${length}- )\n")
|
|
|
|
outfile.write("\tprintf \"%s\\n\" ${line}\n")
|
|
|
|
outfile.write("done\n")
|
|
|
|
|
|
|
|
# Poky dependencies a.k.a. RPM requires
|
|
|
|
outdepends = workdir + "/" + srcname + ".requires"
|
|
|
|
|
|
|
|
try:
|
|
|
|
from __builtin__ import file
|
|
|
|
dependsfile = file(outdepends, 'w')
|
|
|
|
except OSError:
|
|
|
|
raise bb.build.FuncFailed("unable to open spec file for writing.")
|
|
|
|
|
|
|
|
dump_filerdeps('RDEPENDS', dependsfile, d)
|
|
|
|
|
|
|
|
dependsfile.close()
|
|
|
|
os.chmod(outdepends, 0755)
|
|
|
|
|
|
|
|
# Poky / RPM Provides
|
2011-09-19 14:37:42 +00:00
|
|
|
outprovides = workdir + "/" + srcname + ".provides"
|
2010-08-30 21:44:31 +00:00
|
|
|
|
|
|
|
try:
|
|
|
|
from __builtin__ import file
|
|
|
|
providesfile = file(outprovides, 'w')
|
|
|
|
except OSError:
|
|
|
|
raise bb.build.FuncFailed("unable to open spec file for writing.")
|
|
|
|
|
|
|
|
dump_filerdeps('RPROVIDES', providesfile, d)
|
|
|
|
|
|
|
|
providesfile.close()
|
|
|
|
os.chmod(outprovides, 0755)
|
|
|
|
|
2010-08-20 16:52:39 +00:00
|
|
|
# Setup the rpmbuild arguments...
|
|
|
|
rpmbuild = bb.data.getVar('RPMBUILD', d, True)
|
|
|
|
targetsys = bb.data.getVar('TARGET_SYS', d, True)
|
2011-05-05 18:14:31 +00:00
|
|
|
targetvendor = bb.data.getVar('TARGET_VENDOR', d, True)
|
2011-09-28 11:44:28 +00:00
|
|
|
package_arch = bb.data.getVar('PACKAGE_ARCH', d, True) or ""
|
|
|
|
if package_arch not in "all any noarch".split():
|
|
|
|
ml_prefix = (bb.data.getVar('MLPREFIX', d, True) or "").replace("-", "_")
|
|
|
|
bb.data.setVar('PACKAGE_ARCH_EXTEND', ml_prefix + package_arch, d)
|
|
|
|
else:
|
|
|
|
bb.data.setVar('PACKAGE_ARCH_EXTEND', package_arch, d)
|
|
|
|
pkgwritedir = bb.data.expand('${PKGWRITEDIRRPM}/${PACKAGE_ARCH_EXTEND}', d)
|
|
|
|
pkgarch = bb.data.expand('${PACKAGE_ARCH_EXTEND}${TARGET_VENDOR}-${TARGET_OS}', d)
|
2011-08-11 20:22:52 +00:00
|
|
|
magicfile = bb.data.expand('${STAGING_DIR_NATIVE}/usr/share/misc/magic.mgc', d)
|
2010-08-25 14:40:34 +00:00
|
|
|
bb.mkdirhier(pkgwritedir)
|
|
|
|
os.chmod(pkgwritedir, 0755)
|
2010-08-20 16:52:39 +00:00
|
|
|
|
|
|
|
cmd = rpmbuild
|
2011-08-11 15:38:30 +00:00
|
|
|
cmd = cmd + " --nodeps --short-circuit --target " + pkgarch + " --buildroot " + pkgd
|
2010-08-25 14:40:34 +00:00
|
|
|
cmd = cmd + " --define '_topdir " + workdir + "' --define '_rpmdir " + pkgwritedir + "'"
|
2010-08-20 16:52:39 +00:00
|
|
|
cmd = cmd + " --define '_build_name_fmt %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm'"
|
2010-08-30 21:44:31 +00:00
|
|
|
cmd = cmd + " --define '_use_internal_dependency_generator 0'"
|
|
|
|
cmd = cmd + " --define '__find_requires " + outdepends + "'"
|
|
|
|
cmd = cmd + " --define '__find_provides " + outprovides + "'"
|
2011-01-16 03:36:23 +00:00
|
|
|
cmd = cmd + " --define '_unpackaged_files_terminate_build 0'"
|
|
|
|
cmd = cmd + " --define 'debug_package %{nil}'"
|
2011-08-11 20:22:52 +00:00
|
|
|
cmd = cmd + " --define '_rpmfc_magic_path " + magicfile + "'"
|
2010-08-20 16:52:39 +00:00
|
|
|
cmd = cmd + " -bb " + outspecfile
|
|
|
|
|
2011-03-10 17:58:15 +00:00
|
|
|
# Build the rpm package!
|
2010-08-20 16:52:39 +00:00
|
|
|
bb.data.setVar('BUILDSPEC', cmd + "\n", d)
|
|
|
|
bb.data.setVarFlag('BUILDSPEC', 'func', '1', d)
|
|
|
|
bb.build.exec_func('BUILDSPEC', d)
|
2005-08-31 10:45:47 +00:00
|
|
|
}
|
2007-08-21 09:37:30 +00:00
|
|
|
|
|
|
|
python () {
|
|
|
|
if bb.data.getVar('PACKAGES', d, True) != '':
|
2007-11-28 20:01:41 +00:00
|
|
|
deps = (bb.data.getVarFlag('do_package_write_rpm', 'depends', d) or "").split()
|
2009-11-10 14:55:23 +00:00
|
|
|
deps.append('rpm-native:do_populate_sysroot')
|
2010-06-23 14:19:06 +00:00
|
|
|
deps.append('virtual/fakeroot-native:do_populate_sysroot')
|
2007-11-28 20:01:41 +00:00
|
|
|
bb.data.setVarFlag('do_package_write_rpm', 'depends', " ".join(deps), d)
|
2010-08-20 16:52:39 +00:00
|
|
|
bb.data.setVarFlag('do_package_write_rpm', 'fakeroot', 1, d)
|
2010-10-22 15:34:06 +00:00
|
|
|
bb.data.setVarFlag('do_package_write_rpm_setscene', 'fakeroot', 1, d)
|
2007-08-21 09:37:30 +00:00
|
|
|
}
|
|
|
|
|
2010-08-05 09:52:10 +00:00
|
|
|
SSTATETASKS += "do_package_write_rpm"
|
|
|
|
do_package_write_rpm[sstate-name] = "deploy-rpm"
|
|
|
|
do_package_write_rpm[sstate-inputdirs] = "${PKGWRITEDIRRPM}"
|
|
|
|
do_package_write_rpm[sstate-outputdirs] = "${DEPLOY_DIR_RPM}"
|
2011-03-29 10:58:01 +00:00
|
|
|
# Take a shared lock, we can write multiple packages at the same time...
|
|
|
|
# but we need to stop the rootfs/solver from running while we do...
|
|
|
|
do_package_write_rpm[sstate-lockfile-shared] += "${DEPLOY_DIR_RPM}/rpm.lock"
|
2010-08-05 09:52:10 +00:00
|
|
|
|
|
|
|
python do_package_write_rpm_setscene () {
|
2010-08-20 16:52:39 +00:00
|
|
|
sstate_setscene(d)
|
2010-08-05 09:52:10 +00:00
|
|
|
}
|
2010-09-16 05:55:21 +00:00
|
|
|
addtask do_package_write_rpm_setscene
|
2007-08-21 09:37:30 +00:00
|
|
|
|
|
|
|
python do_package_write_rpm () {
|
|
|
|
bb.build.exec_func("read_subpackage_metadata", d)
|
|
|
|
bb.build.exec_func("do_package_rpm", d)
|
|
|
|
}
|
2010-08-20 16:52:39 +00:00
|
|
|
|
2010-08-05 09:52:10 +00:00
|
|
|
do_package_write_rpm[dirs] = "${PKGWRITEDIRRPM}"
|
2008-08-18 08:01:41 +00:00
|
|
|
addtask package_write_rpm before do_package_write after do_package
|
|
|
|
|
package-index.bb: add support for deb and rpm.
[YOCTO #1024]
Currently package-index.bb only supports ipk. This commit adds the support
for rpm and deb, too.
------------------------------
How to generate and use repos:
1) run "bitbake package-index" after building some target,
e.g., core-image-sato-sdk;
2) export ${DEPLOY_DIR_RPM}, ${DEPLOY_DIR_IPK} and ${DEPLOY_DIR_DEB} by a
webserver on the host, assuming the host IP is 192.168.7.1, at
http://192.168.7.1/rpm
http://192.168.7.1/ipk
http://192.168.7.1/deb
3) inside the target, according to the packaging system (rpm, ipk or deb) used
when we generate the target image, we can use different ways to manage
packages:
3.1) RPM
run "zypper addrepo http://192.168.7.1/rpm main; zypper refresh"
to retrieve info about the repo; next, we can use "zypper install/remove"
to manage packages.
3.2) IPK
add the repo info into opkg config file, i.e., in
/etc/opkg/arch.conf, we can add something like
"src i586 http://192.168.7.1/ipk/i586", and next, we run "opkg update" to
make opkg update the list of available packages. And later, we can use
"opkg install/remove" to manage packages.
3.3) DEB
Currently in target, some important config files, like
/var/lib/dpkg/status and /etc/apt/sources.list, for deb/apt are missing. So
we can't install/remove package in target at present.
(From OE-Core rev: 01e34bdb43e0cc27c1cfffd6730c384f40c404c1)
Signed-off-by: Dexuan Cui <dexuan.cui@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-05-18 04:09:01 +00:00
|
|
|
PACKAGEINDEXES += "package_update_index_rpm; createrepo ${DEPLOY_DIR_RPM};"
|
|
|
|
PACKAGEINDEXDEPS += "rpm-native:do_populate_sysroot"
|
|
|
|
PACKAGEINDEXDEPS += "createrepo-native:do_populate_sysroot"
|