summaryrefslogtreecommitdiff
path: root/classes/rootfs_ipk.bbclass
blob: 43ea5cecd0fbc68ac7a0713f5129d36fd0da2bda (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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#
# 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.
#

DEPENDS_prepend="ipkg-native ipkg-utils-native fakeroot-native "
DEPENDS_append=" ${EXTRA_IMAGEDEPENDS}"
RDEPENDS += "ipkg ipkg-collateral"

IPKG_ARGS = "-f ${T}/ipkg.conf -o ${IMAGE_ROOTFS}"

PACKAGE_INSTALL += "ipkg ipkg-collateral"

rootfs_ipk_do_indexes () {
	set -x

	ipkgarchs="${PACKAGE_ARCHS}"

        if [ -z "${DEPLOY_KEEP_PACKAGES}" ]; then
                touch ${DEPLOY_DIR_IPK}/Packages
                ipkg-make-index -r ${DEPLOY_DIR_IPK}/Packages -p ${DEPLOY_DIR_IPK}/Packages -l ${DEPLOY_DIR_IPK}/Packages.filelist -m ${DEPLOY_DIR_IPK}
        fi

	for arch in $ipkgarchs; do
		if [ -z "${DEPLOY_KEEP_PACKAGES}" ]; then
			if [ -e ${DEPLOY_DIR_IPK}/$arch/ ] ; then 
				touch ${DEPLOY_DIR_IPK}/$arch/Packages
				ipkg-make-index -r ${DEPLOY_DIR_IPK}/$arch/Packages -p ${DEPLOY_DIR_IPK}/$arch/Packages -l ${DEPLOY_DIR_IPK}/$arch/Packages.filelist -m ${DEPLOY_DIR_IPK}/$arch/
			fi
		fi
	done
	
	test "${DEPLOY_ENABLE_OEFEED}" -gt 0 && rootfs_create_combined_feed || /bin/true
}

rootfs_create_combined_feed() {

	# Create deploy/oe-feed which can be used as a feed in ipkg.conf
	# Set DEPLOY_ENABLE_OEFEED=2 to rebuild Packages with ipkg-make-index (very slow)
	# Set DEPLOY_ENABLE_OEFEED=1 to use the Packages files from ipk/ARCH/ (fast)

	OLD_PWD="$PWD"

	# To catch deleted / changed packages, we have to completly rebuild
	# the symlinks every time.		
	test -d "${DEPLOY_DIR}/oe-feed" && rm -rf "${DEPLOY_DIR}/oe-feed/"
	mkdir -p "${DEPLOY_DIR}/oe-feed"	
	cd "${DEPLOY_DIR}/oe-feed" || exit 1

	case "${DEPLOY_ENABLE_OEFEED}" in
	1)	MAKE_INDEX_TYPE="fast" ;;
	*)	MAKE_INDEX_TYPE="traditional" ;;
	esac
	
	for arch in $ipkgarchs
	do
		if test -d ${DEPLOY_DIR_IPK}/$arch/
		then			
			# Note: *.ipk won't work (too many arguments)
			for ipk in `ls -1 "${DEPLOY_DIR_IPK}/$arch/" | grep ".ipk$"`
			do
				ln -s "${DEPLOY_DIR_IPK}/$arch/$ipk" .
			done
		fi
			
		# Doesn't get faster than that =)	
		test "$MAKE_INDEX_TYPE" = "fast" && cat ${DEPLOY_DIR_IPK}/$arch/Packages >> ./Packages
	done

	if test "$MAKE_INDEX_TYPE" = "traditional"
	then	
		rm -f ${DEPLOY_DIR}/oe-feed/Packages
		touch ${DEPLOY_DIR}/oe-feed/Packages
		ipkg-make-index -r ${DEPLOY_DIR}/oe-feed/Packages -p ${DEPLOY_DIR}/oe-feed/Packages -l ${DEPLOY_DIR}/oe-feed/Packages.filelist -m ${DEPLOY_DIR}/oe-feed/
	fi
	
	# Some *-image.bb's are kinda touchy-feely about a changing $PWD 
	cd "$OLD_PWD"
}

fakeroot rootfs_ipk_do_rootfs () {
	set -x

	rootfs_ipk_do_indexes

	mkdir -p ${IMAGE_ROOTFS}/dev
	mkdir -p ${T}

	#Add deploy/ipk as well for backward compat
	echo "src oe file:${DEPLOY_DIR_IPK}" > ${T}/ipkg.conf
	ipkgarchs="${PACKAGE_ARCHS}"

	priority=1
	for arch in $ipkgarchs; do
		echo "arch $arch $priority" >> ${T}/ipkg.conf
		priority=$(expr $priority + 5)
		if [ -e ${DEPLOY_DIR_IPK}/$arch/Packages ] ; then
		        echo "src oe-$arch file:${DEPLOY_DIR_IPK}/$arch" >> ${T}/ipkg.conf
	    fi
	done
	ipkg-cl ${IPKG_ARGS} update
	if [ ! -z "${LINGUAS_INSTALL}" ]; then
		ipkg-cl ${IPKG_ARGS} install glibc-localedata-i18n
		for i in ${LINGUAS_INSTALL}; do
			ipkg-cl ${IPKG_ARGS} install $i
		done
	fi
	if [ ! -z "${PACKAGE_INSTALL}" ]; then
		ipkg-cl ${IPKG_ARGS} install ${PACKAGE_INSTALL}
	fi

	export D=${IMAGE_ROOTFS}
	export OFFLINE_ROOT=${IMAGE_ROOTFS}
	export IPKG_OFFLINE_ROOT=${IMAGE_ROOTFS}
	mkdir -p ${IMAGE_ROOTFS}/etc/ipkg/
	grep "^arch" ${T}/ipkg.conf >${IMAGE_ROOTFS}/etc/ipkg/arch.conf

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

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

	${ROOTFS_POSTPROCESS_COMMAND}
	
	log_check rootfs 	
}

rootfs_ipk_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 -i "$keyword_die" -C1
			echo ""
			do_exit=1				
		fi
	done
	test "$do_exit" = 1 && exit 1
	true
}