summaryrefslogtreecommitdiffstats
path: root/meta/classes/rootfs_ipk.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/rootfs_ipk.bbclass')
-rw-r--r--meta/classes/rootfs_ipk.bbclass188
1 files changed, 188 insertions, 0 deletions
diff --git a/meta/classes/rootfs_ipk.bbclass b/meta/classes/rootfs_ipk.bbclass
new file mode 100644
index 0000000000..b0805dc329
--- /dev/null
+++ b/meta/classes/rootfs_ipk.bbclass
@@ -0,0 +1,188 @@
1#
2# Creates a root filesystem out of IPKs
3#
4# This rootfs can be mounted via root-nfs or it can be put into an cramfs/jffs etc.
5# See image.bbclass for a usage of this.
6#
7
8EXTRAOPKGCONFIG ?= ""
9ROOTFS_PKGMANAGE = "opkg opkg-collateral ${EXTRAOPKGCONFIG}"
10ROOTFS_PKGMANAGE_BOOTSTRAP = "run-postinsts"
11
12do_rootfs[depends] += "opkg-native:do_populate_sysroot opkg-utils-native:do_populate_sysroot"
13do_rootfs[recrdeptask] += "do_package_write_ipk"
14rootfs_ipk_do_rootfs[vardepsexclude] += "BUILDNAME"
15
16do_rootfs[lockfiles] += "${WORKDIR}/ipk.lock"
17
18OPKG_PREPROCESS_COMMANDS = "package_update_index_ipk; package_generate_ipkg_conf"
19
20OPKG_POSTPROCESS_COMMANDS = "ipk_insert_feed_uris; "
21
22OPKGLIBDIR = "${localstatedir}/lib"
23
24MULTILIBRE_ALLOW_REP = "${OPKGLIBDIR}/opkg"
25
26fakeroot rootfs_ipk_do_rootfs () {
27 #set -x
28
29 rm -f ${IPKGCONF_TARGET}
30 touch ${IPKGCONF_TARGET}
31
32 ${OPKG_PREPROCESS_COMMANDS}
33
34 mkdir -p ${T}/
35
36 export INSTALL_CONF_IPK="${IPKGCONF_TARGET}"
37 export INSTALL_ROOTFS_IPK="${IMAGE_ROOTFS}"
38 STATUS=${IMAGE_ROOTFS}${OPKGLIBDIR}/opkg/status
39 mkdir -p ${IMAGE_ROOTFS}${OPKGLIBDIR}/opkg
40
41 opkg-cl ${OPKG_ARGS} update
42
43 # prime the status file with bits that we don't want
44 for i in ${BAD_RECOMMENDATIONS}; do
45 pkginfo="`opkg-cl ${OPKG_ARGS} info $i`"
46 if [ ! -z "$pkginfo" ]; then
47 # Take just the first package stanza as otherwise only
48 # the last one will have the right Status line.
49 echo "$pkginfo" | awk "/^Package:/ { print } \
50 /^Architecture:/ { print } \
51 /^Version:/ { print } \
52 /^$/ { exit } \
53 END { print \"Status: deinstall hold not-installed\n\" }" - >> $STATUS
54 else
55 echo "Requested ignored recommendation $i is not a package"
56 fi
57 done
58
59 #install
60 export INSTALL_PACKAGES_ATTEMPTONLY_IPK="${PACKAGE_INSTALL_ATTEMPTONLY}"
61 export INSTALL_PACKAGES_LINGUAS_IPK="${LINGUAS_INSTALL}"
62 export INSTALL_TASK_IPK="rootfs"
63
64
65 export INSTALL_PACKAGES_IPK="${PACKAGE_INSTALL}"
66
67 #post install
68 export D=${IMAGE_ROOTFS}
69 export OFFLINE_ROOT=${IMAGE_ROOTFS}
70 export IPKG_OFFLINE_ROOT=${IMAGE_ROOTFS}
71 export OPKG_OFFLINE_ROOT=${IPKG_OFFLINE_ROOT}
72 export INTERCEPT_DIR=${WORKDIR}/intercept_scripts
73 export NATIVE_ROOT=${STAGING_DIR_NATIVE}
74
75 package_install_internal_ipk
76
77 # Distro specific packages should create this
78 #mkdir -p ${IMAGE_ROOTFS}/etc/opkg/
79 #grep "^arch" ${IPKGCONF_TARGET} >${IMAGE_ROOTFS}/etc/opkg/arch.conf
80
81 rootfs_install_complementary
82
83 ${OPKG_POSTPROCESS_COMMANDS}
84 ${ROOTFS_POSTINSTALL_COMMAND}
85
86 install -d ${IMAGE_ROOTFS}/${sysconfdir}
87 echo ${BUILDNAME} > ${IMAGE_ROOTFS}/${sysconfdir}/version
88
89 ${ROOTFS_POSTPROCESS_COMMAND}
90
91 if ${@base_contains("IMAGE_FEATURES", "read-only-rootfs", "true", "false" ,d)}; then
92 if [ -n "$(delayed_postinsts)" ]; then
93 bberror "Some packages could not be configured offline and rootfs is read-only."
94 exit 1
95 fi
96 fi
97
98 rm -f ${IMAGE_ROOTFS}${OPKGLIBDIR}/opkg/lists/*
99 log_check rootfs
100}
101
102rootfs_ipk_do_rootfs[vardeps] += "delayed_postinsts"
103
104delayed_postinsts () {
105 cat ${STATUS}|grep -e "^Package:" -e "^Status:"|sed -ne 'N;s/Package: \(.*\)\nStatus:.*unpacked/\1/p'
106}
107
108save_postinsts () {
109 # Scripts need to be ordered when executed, this ensures numeric order
110 # If we ever run into needing more the 899 scripts, we'll have to
111 # change num to start with 1000.
112 num=100
113 for p in $(delayed_postinsts); do
114 install -d ${IMAGE_ROOTFS}${sysconfdir}/ipk-postinsts
115 cp ${IMAGE_ROOTFS}${OPKGLIBDIR}/opkg/info/$p.postinst ${IMAGE_ROOTFS}${sysconfdir}/ipk-postinsts/$num-$p
116 num=`echo \$((num+1))`
117 done
118}
119
120rootfs_ipk_write_manifest() {
121 manifest=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.manifest
122 cp ${IMAGE_ROOTFS}${OPKGLIBDIR}/opkg/status $manifest
123
124 sed '/Depends/d' -i $manifest
125 sed '/Status/d' -i $manifest
126 sed '/Architecture/d' -i $manifest
127 sed '/Installed-Time/d' -i $manifest
128 sed '/Auto-Installed/d' -i $manifest
129 sed '/Recommends/d' -i $manifest
130 sed '/Provides/d' -i $manifest
131 sed '/Conflicts/d' -i $manifest
132}
133
134remove_packaging_data_files() {
135 rm -rf ${IMAGE_ROOTFS}${OPKGLIBDIR}/opkg
136 # We need the directory for the package manager lock
137 mkdir ${IMAGE_ROOTFS}${OPKGLIBDIR}/opkg
138}
139
140rootfs_install_packages() {
141 opkg-cl ${OPKG_ARGS} install `cat $1`
142}
143
144rootfs_uninstall_packages() {
145 opkg-cl ${OPKG_ARGS} --force-depends remove $@
146}
147
148ipk_insert_feed_uris () {
149
150 echo "Building from feeds activated!"
151
152 for line in ${IPK_FEED_URIS}
153 do
154 # strip leading and trailing spaces/tabs, then split into name and uri
155 line_clean="`echo "$line"|sed 's/^[ \t]*//;s/[ \t]*$//'`"
156 feed_name="`echo "$line_clean" | sed -n 's/\(.*\)##\(.*\)/\1/p'`"
157 feed_uri="`echo "$line_clean" | sed -n 's/\(.*\)##\(.*\)/\2/p'`"
158
159 echo "Added $feed_name feed with URL $feed_uri"
160
161 # insert new feed-sources
162 echo "src/gz $feed_name $feed_uri" >> ${IPKGCONF_TARGET}
163 done
164
165 # Allow to use package deploy directory contents as quick devel-testing
166 # feed. This creates individual feed configs for each arch subdir of those
167 # specified as compatible for the current machine.
168 # NOTE: Development-helper feature, NOT a full-fledged feed.
169 if [ -n "${FEED_DEPLOYDIR_BASE_URI}" ]; then
170 for arch in ${PACKAGE_ARCHS}
171 do
172 echo "src/gz local-$arch ${FEED_DEPLOYDIR_BASE_URI}/$arch" >> ${IMAGE_ROOTFS}/etc/opkg/local-$arch-feed.conf
173 done
174 fi
175}
176
177python () {
178
179 if d.getVar('BUILD_IMAGES_FROM_FEEDS', True):
180 flags = d.getVarFlag('do_rootfs', 'recrdeptask')
181 flags = flags.replace("do_package_write_ipk", "")
182 flags = flags.replace("do_deploy", "")
183 flags = flags.replace("do_populate_sysroot", "")
184 d.setVarFlag('do_rootfs', 'recrdeptask', flags)
185 d.setVar('OPKG_PREPROCESS_COMMANDS', "package_generate_archlist\nipk_insert_feed_uris")
186 d.setVar('OPKG_POSTPROCESS_COMMANDS', '')
187}
188