summaryrefslogtreecommitdiff
path: root/meta/classes/package_rpm.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/package_rpm.bbclass')
-rw-r--r--meta/classes/package_rpm.bbclass1169
1 files changed, 334 insertions, 835 deletions
diff --git a/meta/classes/package_rpm.bbclass b/meta/classes/package_rpm.bbclass
index 1ff92cea5f..084546f733 100644
--- a/meta/classes/package_rpm.bbclass
+++ b/meta/classes/package_rpm.bbclass
@@ -6,623 +6,101 @@ RPM="rpm"
RPMBUILD="rpmbuild"
PKGWRITEDIRRPM = "${WORKDIR}/deploy-rpms"
-PKGWRITEDIRSRPM = "${DEPLOY_DIR}/sources/deploy-srpm"
-python package_rpm_fn () {
- d.setVar('PKGFN', d.getVar('PKG'))
-}
+# Maintaining the perfile dependencies has singificant overhead when writing the
+# packages. When set, this value merges them for efficiency.
+MERGEPERFILEDEPS = "1"
-python package_rpm_install () {
- bb.fatal("package_rpm_install not implemented!")
-}
+# Construct per file dependencies file
+def write_rpm_perfiledata(srcname, d):
+ workdir = d.getVar('WORKDIR')
+ packages = d.getVar('PACKAGES')
+ pkgd = d.getVar('PKGD')
-RPMCONF_TARGET_BASE = "${DEPLOY_DIR_RPM}/solvedb"
-RPMCONF_HOST_BASE = "${DEPLOY_DIR_RPM}/solvedb-sdk"
-#
-# Update the Packages depsolver db in ${DEPLOY_DIR_RPM}
-#
-package_update_index_rpm () {
- if [ ! -z "${DEPLOY_KEEP_PACKAGES}" -o ! -e "${DEPLOY_DIR_RPM}" ]; then
- return
- fi
-
- # Update target packages
- base_archs="`echo ${PACKAGE_ARCHS} | sed 's/-/_/g'`"
- ml_archs="`echo ${MULTILIB_PACKAGE_ARCHS} | sed 's/-/_/g'`"
- package_update_index_rpm_common "${RPMCONF_TARGET_BASE}" base_archs ml_archs
-
- # Update SDK packages
- base_archs="`echo ${SDK_PACKAGE_ARCHS} | sed 's/-/_/g'`"
- package_update_index_rpm_common "${RPMCONF_HOST_BASE}" base_archs
-}
-
-package_update_index_rpm_common () {
- rpmconf_base="$1"
- shift
-
- createdirs=""
- for archvar in "$@"; do
- eval archs=\${${archvar}}
- packagedirs=""
- for arch in $archs; do
- packagedirs="${DEPLOY_DIR_RPM}/$arch $packagedirs"
- rm -rf ${DEPLOY_DIR_RPM}/$arch/solvedb.done
- done
-
- cat /dev/null > ${rpmconf_base}-${archvar}.conf
- for pkgdir in $packagedirs; do
- if [ -e $pkgdir/ ]; then
- echo "Generating solve db for $pkgdir..."
- echo $pkgdir/solvedb >> ${rpmconf_base}-${archvar}.conf
- createdirs="$createdirs $pkgdir"
- fi
- done
- done
- rpm-createsolvedb.py "${RPM}" $createdirs
-}
-
-#
-# Generate an rpm configuration suitable for use against the
-# generated depsolver db's...
-#
-package_generate_rpm_conf () {
- # Update target packages
- package_generate_rpm_conf_common "${RPMCONF_TARGET_BASE}" base_archs ml_archs
-
- # Update SDK packages
- package_generate_rpm_conf_common "${RPMCONF_HOST_BASE}" base_archs
-}
+ def dump_filerdeps(varname, outfile, d):
+ outfile.write("#!/usr/bin/env python\n\n")
+ outfile.write("# Dependency table\n")
+ outfile.write('deps = {\n')
+ for pkg in packages.split():
+ dependsflist_key = 'FILE' + varname + 'FLIST' + "_" + pkg
+ dependsflist = (d.getVar(dependsflist_key) or "")
+ for dfile in dependsflist.split():
+ key = "FILE" + varname + "_" + dfile + "_" + pkg
+ depends_dict = bb.utils.explode_dep_versions(d.getVar(key) 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 + '" : "')
+ 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\n')
+ outfile.write("import sys\n")
+ outfile.write("while 1:\n")
+ outfile.write("\tline = sys.stdin.readline().strip()\n")
+ outfile.write("\tif not line:\n")
+ outfile.write("\t\tsys.exit(0)\n")
+ outfile.write("\tif line in deps:\n")
+ outfile.write("\t\tprint(deps[line] + '\\n')\n")
-package_generate_rpm_conf_common() {
- rpmconf_base="$1"
- shift
-
- printf "_solve_dbpath " > ${rpmconf_base}.macro
- o_colon="false"
-
- for archvar in "$@"; do
- printf "_solve_dbpath " > ${rpmconf_base}-${archvar}.macro
- colon="false"
- for each in `cat ${rpmconf_base}-${archvar}.conf` ; do
- if [ "$o_colon" = "true" ]; then
- printf ":" >> ${rpmconf_base}.macro
- fi
- if [ "$colon" = "true" ]; then
- printf ":" >> ${rpmconf_base}-${archvar}.macro
- fi
- printf "%s" $each >> ${rpmconf_base}.macro
- o_colon="true"
- printf "%s" $each >> ${rpmconf_base}-${archvar}.macro
- colon="true"
- done
- printf "\n" >> ${rpmconf_base}-${archvar}.macro
- done
- printf "\n" >> ${rpmconf_base}.macro
-}
+ # OE-core dependencies a.k.a. RPM requires
+ outdepends = workdir + "/" + srcname + ".requires"
-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"
- printf "log_check: Matched keyword: [$keyword_die]\n\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
-}
+ dependsfile = open(outdepends, 'w')
+ dump_filerdeps('RDEPENDS', dependsfile, d)
-#
-# Resolve package names to filepaths
-# resolve_pacakge <pkgname> <solvdb conffile>
-#
-resolve_package_rpm () {
- local conffile="$1"
- shift
- local pkg_name=""
- for solve in `cat ${conffile}`; do
- pkg_name=$(${RPM} -D "_dbpath $solve" -D "__dbi_txn create nofsync" -q --qf "%{packageorigin}\n" "$@" | grep -v "is not installed" || true)
- if [ -n "$pkg_name" -a "$pkg_name" != "(none)" ]; then
- echo $pkg_name
- break;
- fi
- done
-}
+ dependsfile.close()
+ os.chmod(outdepends, 0o755)
-# rpm common command and options
-rpm_common_comand () {
+ # OE-core / RPM Provides
+ outprovides = workdir + "/" + srcname + ".provides"
- local target_rootfs="${INSTALL_ROOTFS_RPM}"
+ providesfile = open(outprovides, 'w')
- ${RPM} --root ${target_rootfs} \
- --predefine "_rpmds_sysinfo_path ${target_rootfs}/etc/rpm/sysinfo" \
- --predefine "_rpmrc_platform_path ${target_rootfs}/etc/rpm/platform" \
- -D "_var ${localstatedir}" \
- -D "_dbpath ${rpmlibdir}" \
- -D "_tmppath /install/tmp" \
- --noparentdirs --nolinktos \
- -D "__dbi_txn create nofsync private" \
- -D "_cross_scriptlet_wrapper ${WORKDIR}/scriptlet_wrapper" $@
-}
+ dump_filerdeps('RPROVIDES', providesfile, d)
-# install or remove the pkg
-rpm_update_pkg () {
-
- manifest=$1
- # The manifest filename, e.g. total_solution.manifest
- m_name=${manifest##/*/}
- local target_rootfs="${INSTALL_ROOTFS_RPM}"
- installdir=$target_rootfs/install
- pre_btmanifest=$installdir/pre_bt.manifest
- cur_btmanifest=$installdir/cur_bt.manifest
-
- # Install/remove the different pkgs when total_solution.manifest is
- # comming and incremental image generation is enabled.
- if [ "${INC_RPM_IMAGE_GEN}" = "1" -a -d "${target_rootfs}${rpmlibdir}" \
- -a "$m_name" = "total_solution.manifest" \
- -a "${INSTALL_COMPLEMENTARY_RPM}" != "1" ]; then
- # Get the previous installed list
- rpm --root $target_rootfs --dbpath ${rpmlibdir} \
- -qa --qf '%{PACKAGEORIGIN} %{BUILDTIME}\n' | sort -u -o $pre_btmanifest
- # Get the current installed list (based on install/var/lib/rpm)
- rpm --root $installdir -D "_dbpath $installdir" \
- -qa --qf '%{PACKAGEORIGIN} %{BUILDTIME}\n' | sort -u -o $cur_btmanifest
- comm -1 -3 $cur_btmanifest $pre_btmanifest | sed 's#.*/\(.*\)\.rpm .*#\1#' > \
- $installdir/remove.manifest
- comm -2 -3 $cur_btmanifest $pre_btmanifest | awk '{print $1}' > \
- $installdir/incremental.manifest
-
- # Attempt to remove unwanted pkgs, the scripts(pre, post, etc.) has not
- # been run by now, so don't have to run them(preun, postun, etc.) when
- # erase the pkg
- if [ -s $installdir/remove.manifest ]; then
- rpm_common_comand --noscripts --nodeps \
- -e `cat $installdir/remove.manifest`
- fi
-
- # Attempt to install the incremental pkgs
- if [ -s $installdir/incremental.manifest ]; then
- rpm_common_comand --replacefiles --replacepkgs \
- -Uvh $installdir/incremental.manifest
- fi
- else
- # Attempt to install
- rpm_common_comand --replacepkgs -Uhv $manifest
- fi
-}
+ providesfile.close()
+ os.chmod(outprovides, 0o755)
-process_pkg_list_rpm() {
- local insttype=$1
- shift
- # $@ is special POSIX linear array can not be assigned
- # to a local variable directly in dash since its separated by
- # space and dash expands it before assignment
- # and local x=1 2 3 and not x="1 2 3"
- local pkgs
- pkgs="$@"
- local confbase=${INSTALL_CONFBASE_RPM}
-
- printf "" > ${target_rootfs}/install/base_archs.pkglist
- printf "" > ${target_rootfs}/install/ml_archs.pkglist
-
- for pkg in $pkgs; do
- echo "Processing $pkg..."
-
- archvar=base_archs
- ml_pkg=$pkg
- for i in ${MULTILIB_PREFIX_LIST} ; do
- subst=${pkg#${i}-}
- if [ $subst != $pkg ] ; then
- ml_pkg=$subst
- archvar=ml_archs
- break
- fi
- done
-
- echo $ml_pkg >> ${target_rootfs}/install/$archvar.pkglist
- done
-
- local manifestpfx="install"
- local extraopt=""
- if [ "$insttype" = "attemptonly" ] ; then
- manifestpfx="install_attemptonly"
- extraopt="-i"
- fi
-
- rpmresolve $extraopt ${confbase}-base_archs.conf ${target_rootfs}/install/base_archs.pkglist -o ${target_rootfs}/install/${manifestpfx}.manifest
- if [ -s ${target_rootfs}/install/ml_archs.pkglist ] ; then
- rpmresolve $extraopt ${confbase}-ml_archs.conf ${target_rootfs}/install/ml_archs.pkglist -o ${target_rootfs}/install/${manifestpfx}_multilib.manifest
- fi
-}
+ return (outdepends, outprovides)
-#
-# Install a bunch of packages using rpm.
-# There are 3 solutions in an image's FRESH generation:
-# 1) initial_solution
-# 2) total_solution
-# 3) COMPLEMENTARY solution
-#
-# It is different when incremental image generation is enabled in the
-# SECOND generation:
-# 1) The initial_solution is skipped.
-# 2) The incremental image generation takes action during the total_solution
-# installation, the previous installed COMPLEMENTARY pkgs usually would be
-# removed here, the new COMPLEMENTARY ones would be installed in the next
-# step.
-# 3) The COMPLEMENTARY would always be installed since it is
-# generated based on the second step's image.
-#
-# the following shell variables needs to be set before calling this func:
-# INSTALL_ROOTFS_RPM - install root dir
-# INSTALL_PLATFORM_RPM - main platform
-# INSTALL_PLATFORM_EXTRA_RPM - extra platform
-# INSTALL_CONFBASE_RPM - configuration file base name
-# INSTALL_PACKAGES_RPM - packages to be installed
-# 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
-# INSTALL_COMPLEMENTARY_RPM - 1 to enable complementary package install mode
-
-package_install_internal_rpm () {
-
- local target_rootfs="${INSTALL_ROOTFS_RPM}"
- local platform="`echo ${INSTALL_PLATFORM_RPM} | sed 's#-#_#g'`"
- local platform_extra="`echo ${INSTALL_PLATFORM_EXTRA_RPM} | sed 's#-#_#g'`"
- local confbase="${INSTALL_CONFBASE_RPM}"
- local package_to_install="${INSTALL_PACKAGES_RPM}"
- local package_attemptonly="${INSTALL_PACKAGES_ATTEMPTONLY_RPM}"
- local package_linguas="${INSTALL_PACKAGES_LINGUAS_RPM}"
- local providename="${INSTALL_PROVIDENAME_RPM}"
- local task="${INSTALL_TASK_RPM}"
-
- if [ "${INSTALL_COMPLEMENTARY_RPM}" != "1" ] ; then
- # Setup base system configuration
- mkdir -p ${target_rootfs}/etc/rpm/
- echo "${platform}${TARGET_VENDOR}-${TARGET_OS}" > ${target_rootfs}/etc/rpm/platform
- if [ ! -z "$platform_extra" ]; then
- for pt in $platform_extra ; do
- case $pt in
- noarch | any | all)
- os="`echo ${TARGET_OS} | sed "s,-.*,,"`.*"
- ;;
- *)
- os="${TARGET_OS}"
- ;;
- esac
- echo "$pt-.*-$os" >> ${target_rootfs}/etc/rpm/platform
- 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
- cat /dev/null > ${target_rootfs}/etc/rpm/sysinfo/Providename
- for provide in $providename ; do
- echo $provide >> ${target_rootfs}/etc/rpm/sysinfo/Providename
- done
- fi
- else
- # We may run through the complementary installs multiple times. For each time
- # we should add the previous solution manifest to the full "original" set to
- # avoid duplicate install steps.
- echo "Update original solution..."
- for m in ${target_rootfs}/install/initial_solution.manifest \
- ${target_rootfs}/install/total_solution.manifest; do
- if [ -s $m ]; then
- cat $m >> ${target_rootfs}/install/original_solution.manifest
- rm -f $m
- fi
- done
- sort -u ${target_rootfs}/install/original_solution.manifest -o ${target_rootfs}/install/original_solution.manifest.new
- mv ${target_rootfs}/install/original_solution.manifest.new ${target_rootfs}/install/original_solution.manifest
- fi
-
- # Setup manifest of packages to install...
- mkdir -p ${target_rootfs}/install
- rm -f ${target_rootfs}/install/install.manifest
- rm -f ${target_rootfs}/install/install_multilib.manifest
- rm -f ${target_rootfs}/install/install_attemptonly.manifest
-
- # Uclibc builds don't provide this stuff...
- if [ x${TARGET_OS} = "xlinux" ] || [ x${TARGET_OS} = "xlinux-gnueabi" ] ; then
- if [ ! -z "${package_linguas}" ]; then
- process_pkg_list_rpm linguas ${package_linguas}
- fi
- fi
-
- if [ ! -z "${package_to_install}" ]; then
- process_pkg_list_rpm default ${package_to_install}
- fi
-
- # Normal package installation
-
- # Generate an install solution by doing a --justdb install, then recreate it with
- # an actual package install!
- if [ -s ${target_rootfs}/install/install.manifest ]; then
- echo "# Install manifest padding" >> ${target_rootfs}/install/install.manifest
- ${RPM} --predefine "_rpmds_sysinfo_path ${target_rootfs}/etc/rpm/sysinfo" \
- --predefine "_rpmrc_platform_path ${target_rootfs}/etc/rpm/platform" \
- --root "${target_rootfs}/install" \
- -D "_dbpath ${target_rootfs}/install" -D "`cat ${confbase}-base_archs.macro`" \
- -D "__dbi_txn create nofsync" \
- -U --justdb --replacepkgs --noscripts --notriggers --noparentdirs --nolinktos --ignoresize \
- ${target_rootfs}/install/install.manifest
- fi
-
- if [ ! -z "${package_attemptonly}" ]; then
- echo "Adding attempt only packages..."
- process_pkg_list_rpm attemptonly ${package_attemptonly}
- cat ${target_rootfs}/install/install_attemptonly.manifest | while read pkg_name
- do
- echo "Attempting $pkg_name..." >> "`dirname ${BB_LOGFILE}`/log.do_${task}_attemptonly.${PID}"
- ${RPM} --predefine "_rpmds_sysinfo_path ${target_rootfs}/etc/rpm/sysinfo" \
- --predefine "_rpmrc_platform_path ${target_rootfs}/etc/rpm/platform" \
- --root "${target_rootfs}/install" \
- -D "_dbpath ${target_rootfs}/install" -D "`cat ${confbase}.macro`" \
- -D "__dbi_txn create nofsync private" \
- -U --justdb --replacepkgs --noscripts --notriggers --noparentdirs --nolinktos --ignoresize \
- $pkg_name >> "`dirname ${BB_LOGFILE}`/log.do_${task}_attemptonly.${PID}" 2>&1 || true
- done
- fi
-
- #### Note: 'Recommends' is an arbitrary tag that means _SUGGESTS_ in OE-core..
- # 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...
- ${RPM} --predefine "_rpmds_sysinfo_path ${target_rootfs}/etc/rpm/sysinfo" \
- --predefine "_rpmrc_platform_path ${target_rootfs}/etc/rpm/platform" \
- --root "${target_rootfs}/install" \
- -D "_dbpath ${target_rootfs}/install" -D "`cat ${confbase}.macro`" \
- -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..."
- 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"
- echo "Unable to find package $pkg." >> "`dirname ${BB_LOGFILE}`/log.do_${task}_recommend.${PID}"
- continue
- fi
- echo "Attempting $pkg_name..." >> "`dirname ${BB_LOGFILE}`/log.do_{task}_recommend.${PID}"
- ${RPM} --predefine "_rpmds_sysinfo_path ${target_rootfs}/etc/rpm/sysinfo" \
- --predefine "_rpmrc_platform_path ${target_rootfs}/etc/rpm/platform" \
- --root "${target_rootfs}/install" \
- -D "_dbpath ${target_rootfs}/install" -D "`cat ${confbase}.macro`" \
- -D "__dbi_txn create nofsync private" \
- -U --justdb --replacepkgs --noscripts --notriggers --noparentdirs --nolinktos --ignoresize \
- $pkg_name >> "`dirname ${BB_LOGFILE}`/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_solution.manifest"
- ${RPM} -D "_dbpath ${target_rootfs}/install" -qa --qf "%{packageorigin}\n" \
- --root "${target_rootfs}/install" \
- -D "__dbi_txn create nofsync private" \
- > ${target_rootfs}/install/install_solution.manifest
-
- touch ${target_rootfs}/install/install_multilib_solution.manifest
-
- if [ -s "${target_rootfs}/install/install_multilib.manifest" ]; then
- # multilib package installation
- echo "# Install multilib manifest padding" >> ${target_rootfs}/install/install_multilib.manifest
-
- # 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" \
- --root "${target_rootfs}/install" \
- -D "_dbpath ${target_rootfs}/install" -D "`cat ${confbase}-ml_archs.macro`" \
- -D "__dbi_txn create nofsync" \
- -U --justdb --replacepkgs --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 --qf "%{packageorigin}\n" \
- --root "${target_rootfs}/install" \
- -D "__dbi_txn create nofsync private" \
- > ${target_rootfs}/install/install_multilib_solution.manifest
-
- fi
-
- cat ${target_rootfs}/install/install_solution.manifest \
- ${target_rootfs}/install/install_multilib_solution.manifest | sort -u > ${target_rootfs}/install/total_solution.manifest
-
- # Construct install scriptlet wrapper
- cat << EOF > ${WORKDIR}/scriptlet_wrapper
-#!/bin/bash
-
-export PATH="${PATH}"
-export D="${target_rootfs}"
-export OFFLINE_ROOT="\$D"
-export IPKG_OFFLINE_ROOT="\$D"
-export OPKG_OFFLINE_ROOT="\$D"
-
-\$2 \$1/\$3 \$4
-if [ \$? -ne 0 ]; then
- mkdir -p \$1/etc/rpm-postinsts
- num=100
- while [ -e \$1/etc/rpm-postinsts/\${num} ]; do num=\$((num + 1)); done
- echo "#!\$2" > \$1/etc/rpm-postinsts/\${num}
- echo "# Arg: \$4" >> \$1/etc/rpm-postinsts/\${num}
- cat \$1/\$3 >> \$1/etc/rpm-postinsts/\${num}
- chmod +x \$1/etc/rpm-postinsts/\${num}
-fi
-EOF
-
- chmod 0755 ${WORKDIR}/scriptlet_wrapper
-
- # Configure RPM... we enforce these settings!
- mkdir -p ${target_rootfs}${rpmlibdir}
- mkdir -p ${target_rootfs}${rpmlibdir}/log
- # After change the __db.* cache size, log file will not be generated automatically,
- # that will raise some warnings, so touch a bare log for rpm write into it.
- touch ${target_rootfs}${rpmlibdir}/log/log.0000000001
- cat > ${target_rootfs}${rpmlibdir}/DB_CONFIG << EOF
-# ================ Environment
-set_data_dir .
-set_create_dir .
-set_lg_dir ./log
-set_tmp_dir ./tmp
-set_flags db_log_autoremove on
-
-# -- thread_count must be >= 8
-set_thread_count 64
-
-# ================ Logging
-
-# ================ Memory Pool
-set_cachesize 0 1048576 0
-set_mp_mmapsize 268435456
-
-# ================ Locking
-set_lk_max_locks 16384
-set_lk_max_lockers 16384
-set_lk_max_objects 16384
-mutex_set_max 163840
-
-# ================ Replication
-EOF
-
- if [ "${INSTALL_COMPLEMENTARY_RPM}" = "1" ] ; then
- # Only install packages not already installed (dependency calculation will
- # almost certainly have added some that have been)
- sort -u ${target_rootfs}/install/original_solution.manifest > ${target_rootfs}/install/original_solution_sorted.manifest
- sort -u ${target_rootfs}/install/total_solution.manifest > ${target_rootfs}/install/total_solution_sorted.manifest
- comm -2 -3 ${target_rootfs}/install/total_solution_sorted.manifest \
- ${target_rootfs}/install/original_solution_sorted.manifest > \
- ${target_rootfs}/install/diff.manifest
- mv ${target_rootfs}/install/diff.manifest ${target_rootfs}/install/total_solution.manifest
- elif [ "${INC_RPM_IMAGE_GEN}" = "1" -a -f "${target_rootfs}/etc/passwd" ]; then
- echo "Skipping pre install due to existing image"
- else
- # RPM is special. It can't handle dependencies and preinstall scripts correctly. Its
- # probably a feature. The only way to convince rpm to actually run the preinstall scripts
- # for base-passwd and shadow first before installing packages that depend on these packages
- # is to do two image installs, installing one set of packages, then the other.
- rm -f ${target_rootfs}/install/initial_install.manifest
- echo "Installing base dependencies first (base-passwd, base-files and shadow) since rpm is special"
- grep /base-passwd-[0-9] ${target_rootfs}/install/total_solution.manifest >> ${target_rootfs}/install/initial_install.manifest || true
- grep /base-files-[0-9] ${target_rootfs}/install/total_solution.manifest >> ${target_rootfs}/install/initial_install.manifest || true
- grep /shadow-[0-9] ${target_rootfs}/install/total_solution.manifest >> ${target_rootfs}/install/initial_install.manifest || true
-
- if [ -s ${target_rootfs}/install/initial_install.manifest ]; then
- echo "# Initial Install manifest padding..." >> ${target_rootfs}/install/initial_install.manifest
-
- # Generate an install solution by doing a --justdb install, then recreate it with
- # an actual package install!
- mkdir -p ${target_rootfs}/initial
-
- ${RPM} --predefine "_rpmds_sysinfo_path ${target_rootfs}/etc/rpm/sysinfo" \
- --predefine "_rpmrc_platform_path ${target_rootfs}/etc/rpm/platform" \
- --root "${target_rootfs}/install" \
- -D "_dbpath ${target_rootfs}/initial" -D "`cat ${confbase}.macro`" \
- -D "__dbi_txn create nofsync" \
- -U --justdb --replacepkgs --noscripts --notriggers --noparentdirs --nolinktos --ignoresize \
- ${target_rootfs}/install/initial_install.manifest
-
- ${RPM} -D "_dbpath ${target_rootfs}/initial" -qa --qf "%{packageorigin}\n" \
- -D "__dbi_txn create nofsync private" \
- --root "${target_rootfs}/install" \
- > ${target_rootfs}/install/initial_solution.manifest
-
- rpm_update_pkg ${target_rootfs}/install/initial_solution.manifest
-
- grep -Fv -f ${target_rootfs}/install/initial_solution.manifest ${target_rootfs}/install/total_solution.manifest > ${target_rootfs}/install/total_solution.manifest.new
- mv ${target_rootfs}/install/total_solution.manifest.new ${target_rootfs}/install/total_solution.manifest
-
- rm -rf ${target_rootfs}/initial
- fi
- fi
-
- echo "Installing main solution manifest (${target_rootfs}/install/total_solution.manifest)"
-
- rpm_update_pkg ${target_rootfs}/install/total_solution.manifest
-}
python write_specfile () {
- import textwrap
import oe.packagedata
# append information for logs and patches to %prep
def add_prep(d,spec_files_bottom):
- if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) == 'srpm':
- spec_files_bottom.append('%%prep -n %s' % d.getVar('PN', True) )
+ if d.getVarFlag('ARCHIVER_MODE', 'srpm') == '1' and bb.data.inherits_class('archiver', d):
+ spec_files_bottom.append('%%prep -n %s' % d.getVar('PN') )
spec_files_bottom.append('%s' % "echo \"include logs and patches, Please check them in SOURCES\"")
spec_files_bottom.append('')
# append the name of tarball to key word 'SOURCE' in xxx.spec.
def tail_source(d):
- if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) == 'srpm':
- source_list = get_package(d)
+ if d.getVarFlag('ARCHIVER_MODE', 'srpm') == '1' and bb.data.inherits_class('archiver', d):
+ ar_outdir = d.getVar('ARCHIVER_OUTDIR')
+ if not os.path.exists(ar_outdir):
+ return
+ source_list = os.listdir(ar_outdir)
source_number = 0
- workdir = d.getVar('WORKDIR', True)
for source in source_list:
# The rpmbuild doesn't need the root permission, but it needs
# to know the file's user and group name, the only user and
# group in fakeroot is "root" when working in fakeroot.
- os.chown("%s/%s" % (workdir, source), 0, 0)
- spec_preamble_top.append('Source' + str(source_number) + ': %s' % source)
+ f = os.path.join(ar_outdir, source)
+ os.chown(f, 0, 0)
+ spec_preamble_top.append('Source%s: %s' % (source_number, source))
source_number += 1
- # 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(':')
- if len(eext) > 1 and eext[0] == 'multilib' and name and name.find(eext[1] + '-') >= 0:
- name = "".join(name.split(eext[1] + '-'))
- return name
-
- def strip_multilib_deps(deps, d):
- depends = bb.utils.explode_dep_versions2(deps or "")
- newdeps = {}
- for dep in depends:
- newdeps[strip_multilib(dep, d)] = depends[dep]
- return bb.utils.join_deps(newdeps)
-
-# ml = d.getVar("MLPREFIX", True)
-# if ml and name and len(ml) != 0 and name.find(ml) == 0:
-# return ml.join(name.split(ml, 1)[1:])
-# return name
# In RPM, dependencies are of the format: pkg <>= Epoch:Version-Release
# This format is similar to OE, however there are restrictions on the
@@ -639,7 +117,7 @@ python write_specfile () {
# after renaming we cannot look up the dependencies in the packagedata
# store.
def translate_vers(varname, d):
- depends = d.getVar(varname, True)
+ depends = d.getVar(varname)
if depends:
depends_dict = bb.utils.explode_dep_versions2(depends)
newdeps_dict = {}
@@ -649,9 +127,17 @@ python write_specfile () {
if '-' in ver:
subd = oe.packagedata.read_subpkgdata_dict(dep, d)
if 'PKGV' in subd:
- pv = subd['PKGV']
- reppv = pv.replace('-', '+')
- verlist.append(ver.replace(pv, reppv))
+ pv = subd['PV']
+ pkgv = subd['PKGV']
+ reppv = pkgv.replace('-', '+')
+ ver = ver.replace(pv, reppv).replace(pkgv, reppv)
+ if 'PKGR' in subd:
+ # Make sure PKGR rather than PR in ver
+ pr = '-' + subd['PR']
+ pkgr = '-' + subd['PKGR']
+ if pkgr not in ver:
+ ver = ver.replace(pr, pkgr)
+ verlist.append(ver)
else:
verlist.append(ver)
newdeps_dict[dep] = verlist
@@ -672,13 +158,57 @@ python write_specfile () {
if not len(depends_dict[dep]):
array.append("%s: %s" % (tag, dep))
- def walk_files(walkpath, target, conffiles):
+ def walk_files(walkpath, target, conffiles, dirfiles):
+ # We can race against the ipk/deb backends which create CONTROL or DEBIAN directories
+ # when packaging. We just ignore these files which are created in
+ # packages-split/ and not package/
+ # We have the odd situation where the CONTROL/DEBIAN directory can be removed in the middle of
+ # of the walk, the isdir() test would then fail and the walk code would assume its a file
+ # hence we check for the names in files too.
for rootpath, dirs, files in os.walk(walkpath):
path = rootpath.replace(walkpath, "")
- for dir in dirs:
- # All packages own the directories their files are in...
- target.append('%dir "' + path + '/' + dir + '"')
+ if path.endswith("DEBIAN") or path.endswith("CONTROL"):
+ continue
+ path = path.replace("%", "%%%%%%%%")
+ path = path.replace("[", "?")
+ path = path.replace("]", "?")
+
+ # Treat all symlinks to directories as normal files.
+ # os.walk() lists them as directories.
+ def move_to_files(dir):
+ if os.path.islink(os.path.join(rootpath, dir)):
+ files.append(dir)
+ return True
+ else:
+ return False
+ dirs[:] = [dir for dir in dirs if not move_to_files(dir)]
+
+ # Directory handling can happen in two ways, either DIRFILES is not set at all
+ # in which case we fall back to the older behaviour of packages owning all their
+ # directories
+ if dirfiles is None:
+ for dir in dirs:
+ if dir == "CONTROL" or dir == "DEBIAN":
+ continue
+ dir = dir.replace("%", "%%%%%%%%")
+ dir = dir.replace("[", "?")
+ dir = dir.replace("]", "?")
+ # All packages own the directories their files are in...
+ target.append('%dir "' + path + '/' + dir + '"')
+ else:
+ # packages own only empty directories or explict directory.
+ # This will prevent the overlapping of security permission.
+ if path and not files and not dirs:
+ target.append('%dir "' + path + '"')
+ elif path and path in dirfiles:
+ target.append('%dir "' + path + '"')
+
for file in files:
+ if file == "CONTROL" or file == "DEBIAN":
+ continue
+ file = file.replace("%", "%%%%%%%%")
+ file = file.replace("[", "?")
+ file = file.replace("]", "?")
if conffiles.count(path + '/' + file):
target.append('%config "' + path + '/' + file + '"')
else:
@@ -694,34 +224,57 @@ python write_specfile () {
scr = scr[:pos] + 'if [ "$1" = "0" ] ; then\n' + scr[pos:] + '\nfi'
return scr
- packages = d.getVar('PACKAGES', True)
+ def get_perfile(varname, pkg, d):
+ deps = []
+ dependsflist_key = 'FILE' + varname + 'FLIST' + "_" + pkg
+ dependsflist = (d.getVar(dependsflist_key) or "")
+ for dfile in dependsflist.split():
+ key = "FILE" + varname + "_" + dfile + "_" + pkg
+ depends = d.getVar(key)
+ if depends:
+ deps.append(depends)
+ return " ".join(deps)
+
+ def append_description(spec_preamble, text):
+ """
+ Add the description to the spec file.
+ """
+ import textwrap
+ dedent_text = textwrap.dedent(text).strip()
+ # Bitbake saves "\n" as "\\n"
+ if '\\n' in dedent_text:
+ for t in dedent_text.split('\\n'):
+ spec_preamble.append(t.strip())
+ else:
+ spec_preamble.append('%s' % textwrap.fill(dedent_text, width=75))
+
+ packages = d.getVar('PACKAGES')
if not packages or packages == '':
bb.debug(1, "No packages; nothing to do")
return
- pkgdest = d.getVar('PKGDEST', True)
+ pkgdest = d.getVar('PKGDEST')
if not pkgdest:
bb.fatal("No PKGDEST")
- return
- outspecfile = d.getVar('OUTSPECFILE', True)
+ outspecfile = d.getVar('OUTSPECFILE')
if not outspecfile:
bb.fatal("No OUTSPECFILE")
- return
# Construct the SPEC file...
- srcname = strip_multilib(d.getVar('PN', True), d)
- srcsummary = (d.getVar('SUMMARY', True) or d.getVar('DESCRIPTION', True) or ".")
- srcversion = d.getVar('PKGV', True).replace('-', '+')
- srcrelease = d.getVar('PKGR', True)
- srcepoch = (d.getVar('PKGE', True) or "")
- srclicense = d.getVar('LICENSE', True)
- srcsection = d.getVar('SECTION', True)
- srcmaintainer = d.getVar('MAINTAINER', True)
- srchomepage = d.getVar('HOMEPAGE', True)
- srcdescription = d.getVar('DESCRIPTION', True) or "."
-
- srcdepends = strip_multilib_deps(d.getVar('DEPENDS', True), d)
+ srcname = d.getVar('PN')
+ srcsummary = (d.getVar('SUMMARY') or d.getVar('DESCRIPTION') or ".")
+ srcversion = d.getVar('PKGV').replace('-', '+')
+ srcrelease = d.getVar('PKGR')
+ srcepoch = (d.getVar('PKGE') or "")
+ srclicense = d.getVar('LICENSE')
+ srcsection = d.getVar('SECTION')
+ srcmaintainer = d.getVar('MAINTAINER')
+ srchomepage = d.getVar('HOMEPAGE')
+ srcdescription = d.getVar('DESCRIPTION') or "."
+ srccustomtagschunk = get_package_additional_metadata("rpm", d)
+
+ srcdepends = d.getVar('DEPENDS')
srcrdepends = []
srcrrecommends = []
srcrsuggests = []
@@ -730,10 +283,10 @@ python write_specfile () {
srcrconflicts = []
srcrobsoletes = []
- srcpreinst = []
- srcpostinst = []
- srcprerm = []
- srcpostrm = []
+ srcrpreinst = []
+ srcrpostinst = []
+ srcrprerm = []
+ srcrpostrm = []
spec_preamble_top = []
spec_preamble_bottom = []
@@ -744,35 +297,38 @@ python write_specfile () {
spec_files_top = []
spec_files_bottom = []
+ perfiledeps = (d.getVar("MERGEPERFILEDEPS") or "0") == "0"
+ extra_pkgdata = (d.getVar("RPM_EXTRA_PKGDATA") or "0") == "1"
+
for pkg in packages.split():
localdata = bb.data.createCopy(d)
root = "%s/%s" % (pkgdest, pkg)
- lf = bb.utils.lockfile(root + ".lock")
-
localdata.setVar('ROOT', '')
localdata.setVar('ROOT_%s' % pkg, root)
- pkgname = localdata.getVar('PKG_%s' % pkg, True)
+ pkgname = localdata.getVar('PKG_%s' % pkg)
if not pkgname:
pkgname = pkg
localdata.setVar('PKG', pkgname)
- localdata.setVar('OVERRIDES', pkg)
-
- bb.data.update_data(localdata)
+ localdata.setVar('OVERRIDES', d.getVar("OVERRIDES", False) + ":" + pkg)
- conffiles = (localdata.getVar('CONFFILES', True) or "").split()
+ conffiles = get_conffiles(pkg, d)
+ dirfiles = localdata.getVar('DIRFILES')
+ if dirfiles is not None:
+ dirfiles = dirfiles.split()
- splitname = strip_multilib(pkgname, d)
+ splitname = pkgname
- splitsummary = (localdata.getVar('SUMMARY', True) or localdata.getVar('DESCRIPTION', True) or ".")
- splitversion = (localdata.getVar('PKGV', True) or "").replace('-', '+')
- splitrelease = (localdata.getVar('PKGR', True) or "")
- splitepoch = (localdata.getVar('PKGE', True) or "")
- splitlicense = (localdata.getVar('LICENSE', True) or "")
- splitsection = (localdata.getVar('SECTION', True) or "")
- splitdescription = (localdata.getVar('DESCRIPTION', True) or ".")
+ splitsummary = (localdata.getVar('SUMMARY') or localdata.getVar('DESCRIPTION') or ".")
+ splitversion = (localdata.getVar('PKGV') or "").replace('-', '+')
+ splitrelease = (localdata.getVar('PKGR') or "")
+ splitepoch = (localdata.getVar('PKGE') or "")
+ splitlicense = (localdata.getVar('LICENSE') or "")
+ splitsection = (localdata.getVar('SECTION') or "")
+ splitdescription = (localdata.getVar('DESCRIPTION') or ".")
+ splitcustomtagschunk = get_package_additional_metadata("rpm", localdata)
translate_vers('RDEPENDS', localdata)
translate_vers('RRECOMMENDS', localdata)
@@ -784,14 +340,25 @@ python write_specfile () {
# Map the dependencies into their final form
mapping_rename_hook(localdata)