summaryrefslogtreecommitdiff
path: root/classes/rootfs_ipk.bbclass
blob: 0303c54cc6c57ef2ab074446ebea9e0d87c86f66 (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
130
131
132
#
# Creates a root filesystem out of IPKs
#
# This rootfs can be mounted via root-nfs or it can be put into an cramfs/jffs etc.
# See image.bbclass for a usage of this.
#

do_rootfs[depends] += "opkg-native:do_populate_sysroot"
do_rootfs[lockfiles] = "${DEPLOY_DIR_IPK}.lock"

IPKG_TMP_DIR = "${IMAGE_ROOTFS}-tmp"
IPKG_ARGS = "-f ${IPKGCONF_TARGET} -o ${IMAGE_ROOTFS} -t ${IPKG_TMP_DIR} ${@base_conditional("PACKAGE_INSTALL_NO_DEPS", "1", "-nodeps", "", d)}"

PACKAGE_INSTALL_NO_DEPS ?= "0"

# What support to provide for online management of packages at run time?
#  full -> traditional system, opkg is installed with all metadata
#  add -> opkg is installed with basic conf files but no status database; can add new packages at runtime but not modify existing ones
#  none -> opkg not installed at all, no metadata or config files provided
ONLINE_PACKAGE_MANAGEMENT ?= "full"

# Which packages to not install on the basis of a recommendation
BAD_RECOMMENDATIONS ?= ""

IPKG_VARIANT ?= "opkg"

RDEPENDS_append = " ${@base_conditional("ONLINE_PACKAGE_MANAGEMENT", "none", "", "${IPKG_VARIANT} opkg-collateral", d)}"
PACKAGE_INSTALL_append = " ${@base_conditional("ONLINE_PACKAGE_MANAGEMENT", "none", "", "${IPKG_VARIANT} opkg-collateral", d)}"

fakeroot rootfs_ipk_do_rootfs () {
	set -x

	package_generate_ipkg_conf

	mkdir -p ${T}
	mkdir -p ${IPKG_TMP_DIR}
	mkdir -p ${IMAGE_ROOTFS}${libdir}/opkg/

	STATUS=${IMAGE_ROOTFS}${libdir}/opkg/status
	# prime the status file with bits that we don't want
	for i in ${BAD_RECOMMENDATIONS}; do
		echo "Package: $i" >> $STATUS
		echo "Architecture: ${TARGET_ARCH}" >> $STATUS
		echo "Status: deinstall ok not-installed" >> $STATUS
		echo >> $STATUS
	done

	opkg-cl ${IPKG_ARGS} update

	# Uclibc builds don't provide this stuff...
	if [ x${TARGET_OS} = "xlinux" ] || [ x${TARGET_OS} = "xlinux-gnueabi" ] ; then 
		if [ ! -z "${LINGUAS_INSTALL}" ]; then
			opkg-cl ${IPKG_ARGS} install glibc-localedata-i18n
			for i in ${LINGUAS_INSTALL}; do
				opkg-cl ${IPKG_ARGS} install $i 
			done
		fi
	fi
	if [ ! -z "${PACKAGE_INSTALL}" ]; then
		opkg-cl ${IPKG_ARGS} install ${PACKAGE_INSTALL}
	fi

	export D=${IMAGE_ROOTFS}
	export OFFLINE_ROOT=${IMAGE_ROOTFS}
	export IPKG_OFFLINE_ROOT=${IMAGE_ROOTFS}
	export OPKG_OFFLINE_ROOT=${IPKG_OFFLINE_ROOT}
	
	if [ "${ONLINE_PACKAGE_MANAGEMENT}" != "none" ]; then
        	mkdir -p ${IMAGE_ROOTFS}${sysconfdir}/opkg/
		grep "^arch" ${IPKGCONF_TARGET} >${IMAGE_ROOTFS}${sysconfdir}/opkg/arch.conf
	fi

	for i in ${IMAGE_ROOTFS}${libdir}/opkg/info/*.preinst; do
		if [ -f $i ] && ! sh -e $i; then
			opkg-cl ${IPKG_ARGS} flag unpacked `basename $i .preinst`
		fi
	done
	for i in ${IMAGE_ROOTFS}${libdir}/opkg/info/*.postinst; do
		if [ -f $i ] && ! sh -e $i configure; then
			opkg-cl ${IPKG_ARGS} flag unpacked `basename $i .postinst`
		fi
	done

	install -d ${IMAGE_ROOTFS}/${sysconfdir}
	echo ${BUILDNAME} > ${IMAGE_ROOTFS}/${sysconfdir}/version
	
	${ROOTFS_POSTPROCESS_COMMAND}

	if [ "${ONLINE_PACKAGE_MANAGEMENT}" != "none" ]; then
		if [ "${ONLINE_PACKAGE_MANAGEMENT}" == "add" ]; then
			rm -f ${IMAGE_ROOTFS}${libdir}/opkg/status
			rm -f ${IMAGE_ROOTFS}${libdir}/opkg/*/*
		else
			rm -f ${IMAGE_ROOTFS}${libdir}/opkg/lists/*
		fi
	
		# Keep these lines until package manager selection is implemented
		ln -s opkg ${IMAGE_ROOTFS}${sysconfdir}/ipkg
		ln -s opkg ${IMAGE_ROOTFS}${libdir}/ipkg
	else
		rm -rf ${IMAGE_ROOTFS}${libdir}/opkg
		rm -rf ${IMAGE_ROOTFS}/usr/lib/opkg
	fi
	
	log_check rootfs 	
	rm -rf ${IPKG_TMP_DIR}
}

rootfs_ipk_log_check() {
	target="$1"
        lf_path="$2"

	lf_txt="`cat $lf_path`"
	for keyword_die in "Cannot find package" "Cannot satisfy the following dependencies" \
	    "exit 1" ERR Fail
	do				
		if (echo "$lf_txt" | grep -v log_check | grep -w "$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"
			echo "$lf_txt" | grep -v log_check | grep -i "$keyword_die" -C1
			echo ""
			do_exit=1				
		fi
	done
	test "$do_exit" = 1 && exit 1
	true
}

remove_packaging_data_files() {
	rm -rf ${IMAGE_ROOTFS}${libdir}/opkg/
}