Merge bk://openembedded@openembedded.bkbits.net/packages
[vuplus_openembedded] / classes / image_ipk.oeclass
1 inherit rootfs_ipk
2
3 USE_DEVFS ?= "0"
4
5 DEPENDS += "makedevs-native"
6
7 def get_image_deps(d):
8         import oe
9         str = ""
10         for type in (oe.data.getVar('IMAGE_FSTYPES', d, 1) or "").split():
11                 deps = oe.data.getVar('IMAGE_DEPENDS_%s' % type, d) or ""
12                 if deps:
13                         str += " %s" % deps
14         return str
15
16 DEPENDS += "${@get_image_deps(d)}"
17
18 IMAGE_DEVICE_TABLE = "${@oe.which(oe.data.getVar('OEPATH', d, 1), 'files/device_table-minimal.txt')}"
19 IMAGE_POSTPROCESS_COMMAND ?= ""
20
21 # Must call real_do_rootfs() from inside here, rather than as a separate
22 # task, so that we have a single fakeroot context for the whole process.
23 fakeroot do_rootfs () {
24         set -x
25         rm -rf ${IMAGE_ROOTFS}
26
27         if [ "${USE_DEVFS}" != "1" ]; then
28                 mkdir -p ${IMAGE_ROOTFS}/dev
29                 makedevs -r ${IMAGE_ROOTFS} -D ${IMAGE_DEVICE_TABLE}
30         fi
31
32         real_do_rootfs
33
34         insert_feed_uris
35                 
36         export TOPDIR=${TOPDIR}
37
38         for type in ${IMAGE_FSTYPES}; do
39                 if test -z "$FAKEROOTKEY"; then
40                         fakeroot -i ${TMPDIR}/fakedb.image oeimage -t $type -e ${FILE}
41                 else
42                         oeimage -n "${IMAGE_NAME}" -t "$type" -e "${FILE}"
43                 fi
44         done
45
46         ${IMAGE_POSTPROCESS_COMMAND}
47 }
48
49 insert_feed_uris () {
50
51         test -z "$FEED_URIS" && return 0
52         
53         # comment out existing feed-sources inserted by ipkg-collateral
54         cat ${IMAGE_ROOTFS}/etc/ipkg.conf | sed "s/^src\ /#src\ /" > ${IMAGE_ROOTFS}/etc/ipkg.conf_
55         rm ${IMAGE_ROOTFS}/etc/ipkg.conf && mv ${IMAGE_ROOTFS}/etc/ipkg.conf_ ${IMAGE_ROOTFS}/etc/ipkg.conf
56
57         # extract, then delete destinations
58         cat ${IMAGE_ROOTFS}/etc/ipkg.conf | egrep "^dest\ " > ${IMAGE_ROOTFS}/etc/ipkg.conf.dest
59         cat ${IMAGE_ROOTFS}/etc/ipkg.conf | egrep -v "^dest\ " > ${IMAGE_ROOTFS}/etc/ipkg.conf_
60         rm ${IMAGE_ROOTFS}/etc/ipkg.conf && mv ${IMAGE_ROOTFS}/etc/ipkg.conf_ ${IMAGE_ROOTFS}/etc/ipkg.conf
61
62
63         for line in ${FEED_URIS}
64         do
65
66                 # strip leading and trailing spaces/tabs, then split into name and uri
67                 line_clean="`echo "$line"|sed 's/^[ \t]*//;s/[ \t]*$//'`"
68                 feed_name="`echo "$line_clean" | sed -n 's/\(.*\)##\(.*\)/\1/p'`"
69                 feed_uri="`echo "$line_clean" | sed -n 's/\(.*\)##\(.*\)/\2/p'`"                
70
71                 # insert new feed-sources
72                 echo "src $feed_name $feed_uri" >> ${IMAGE_ROOTFS}/etc/ipkg.conf
73         done
74         
75         # remove temporary files and rebuild ipkg.conf
76         echo "" >> ${IMAGE_ROOTFS}/etc/ipkg.conf
77         cat ${IMAGE_ROOTFS}/etc/ipkg.conf.dest >> ${IMAGE_ROOTFS}/etc/ipkg.conf
78         rm ${IMAGE_ROOTFS}/etc/ipkg.conf.dest
79         
80         cp ${IMAGE_ROOTFS}/etc/ipkg.conf ${WORKDIR}
81 }