summaryrefslogtreecommitdiff
path: root/meta/classes/populate_sdk_rpm.bbclass
blob: 00a3ab477e2e2d18133c2e2e354f3ba5ff2a5c44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# Smart is python based, so be sure python-native is available to us.
EXTRANATIVEPATH += "python-native"

do_populate_sdk[depends] += "rpm-native:do_populate_sysroot"
do_populate_sdk[depends] += "rpmresolve-native:do_populate_sysroot"
do_populate_sdk[depends] += "python-smartpm-native:do_populate_sysroot"

# Needed for update-alternatives
do_populate_sdk[depends] += "opkg-native:do_populate_sysroot"

# Creating the repo info in do_rootfs
do_populate_sdk[depends] += "createrepo-native:do_populate_sysroot"

do_populate_sdk[recrdeptask] += "do_package_write_rpm"

rpmlibdir = "/var/lib/rpm"
RPMOPTS="--dbpath ${rpmlibdir}"
RPM="rpm ${RPMOPTS}"

do_populate_sdk[lockfiles] += "${DEPLOY_DIR_RPM}/rpm.lock"

populate_sdk_post_rpm () {

	local target_rootfs=$1

	# remove lock files
	rm -f ${target_rootfs}/__db.*

	# Remove all remaining resolver files
	rm -rf ${target_rootfs}/install
	rm -rf ${target_rootfs}/var/lib/smart
}

populate_sdk_rpm () {

	package_update_index_rpm

	## install target ##
	# This needs to work in the same way as rootfs_rpm.bbclass!
	#
	export INSTALL_ROOTFS_RPM="${SDK_OUTPUT}/${SDKTARGETSYSROOT}"
	export INSTALL_PLATFORM_RPM="${TARGET_ARCH}"
	export INSTALL_PACKAGES_RPM="${TOOLCHAIN_TARGET_TASK}"
	export INSTALL_PACKAGES_ATTEMPTONLY_RPM="${TOOLCHAIN_TARGET_TASK_ATTEMPTONLY}"
	export INSTALL_PACKAGES_LINGUAS_RPM=""
	# We don't need any of these runtime items for the SDK, so
	# just make the system assume they exist.
	export INSTALL_PROVIDENAME_RPM="/bin/sh /bin/bash /usr/bin/env /usr/bin/perl pkgconfig"
	export INSTALL_TASK_RPM="populate_sdk-target"
	export INSTALL_COMPLEMENTARY_RPM=""
	export INTERCEPT_DIR=${WORKDIR}/intercept_scripts
	export NATIVE_ROOT=${STAGING_DIR_NATIVE}

	# Setup base system configuration
	mkdir -p ${INSTALL_ROOTFS_RPM}/etc/rpm/

	# List must be prefered to least preferred order
	INSTALL_PLATFORM_EXTRA_RPM=""
	for i in ${MULTILIB_PREFIX_LIST} ; do
		old_IFS="$IFS"
		IFS=":"
		set $i
		IFS="$old_IFS"
		shift #remove mlib
		while [ -n "$1" ]; do
			INSTALL_PLATFORM_EXTRA_RPM="$INSTALL_PLATFORM_EXTRA_RPM $1"
			shift
		done
	done
	export INSTALL_PLATFORM_EXTRA_RPM

	package_install_internal_rpm
	${POPULATE_SDK_POST_TARGET_COMMAND}
	populate_sdk_post_rpm ${INSTALL_ROOTFS_RPM}

	## install nativesdk ##
	echo "Installing NATIVESDK packages"
	export INSTALL_ROOTFS_RPM="${SDK_OUTPUT}"
	export INSTALL_PLATFORM_RPM="${SDK_ARCH}"
	export INSTALL_PACKAGES_RPM="${TOOLCHAIN_HOST_TASK}"
	export INSTALL_PACKAGES_ATTEMPTONLY_RPM="${TOOLCHAIN_TARGET_HOST_ATTEMPTONLY}"
	export INSTALL_PACKAGES_LINGUAS_RPM=""
	export INSTALL_PROVIDENAME_RPM="/bin/sh /bin/bash /usr/bin/env /usr/bin/perl pkgconfig libGL.so()(64bit) libGL.so"
	export INSTALL_TASK_RPM="populate_sdk_rpm-nativesdk"
	export INSTALL_COMPLEMENTARY_RPM=""

	# List must be prefered to least preferred order
	INSTALL_PLATFORM_EXTRA_RPM=""
	for each_arch in ${SDK_PACKAGE_ARCHS} ; do
		INSTALL_PLATFORM_EXTRA_RPM="$each_arch $INSTALL_PLATFORM_EXTRA_RPM"
	done
	export INSTALL_PLATFORM_EXTRA_RPM

	package_install_internal_rpm --sdk
	populate_sdk_post_rpm ${INSTALL_ROOTFS_RPM}

	# move host RPM library data
	install -d ${SDK_OUTPUT}/${SDKPATHNATIVE}${localstatedir_nativesdk}/lib/rpm
	mv ${SDK_OUTPUT}${rpmlibdir}/* ${SDK_OUTPUT}/${SDKPATHNATIVE}${localstatedir_nativesdk}/lib/rpm/
	rm -Rf ${SDK_OUTPUT}/var

	install -d ${SDK_OUTPUT}/${SDKPATHNATIVE}/${sysconfdir}
	mv ${SDK_OUTPUT}/etc/* ${SDK_OUTPUT}/${SDKPATHNATIVE}/${sysconfdir}/
	rm -rf ${SDK_OUTPUT}/etc

	populate_sdk_log_check populate_sdk
}

python () {
    # The following code should be kept in sync w/ the rootfs_rpm version.

    # package_arch order is reversed.  This ensures the -best- match is listed first!
    package_archs = d.getVar("PACKAGE_ARCHS", True) or ""
    package_archs = ":".join(package_archs.split()[::-1])
    ml_prefix_list = "%s:%s" % ('default', package_archs)
    multilibs = d.getVar('MULTILIBS', True) or ""
    for ext in multilibs.split():
        eext = ext.split(':')
        if len(eext) > 1 and eext[0] == 'multilib':
            localdata = bb.data.createCopy(d)
            default_tune = localdata.getVar("DEFAULTTUNE_virtclass-multilib-" + eext[1], False)
            if default_tune:
                localdata.setVar("DEFAULTTUNE", default_tune)
            package_archs = localdata.getVar("PACKAGE_ARCHS", True) or ""
            package_archs = ":".join([i in "all noarch any".split() and i or eext[1]+"_"+i for i in package_archs.split()][::-1])
            ml_prefix_list += " %s:%s" % (eext[1], package_archs)
    d.setVar('MULTILIB_PREFIX_LIST', ml_prefix_list)
}