summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurentiu Palcu <laurentiu.palcu@intel.com>2014-01-13 10:16:43 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-02-11 11:53:39 +0000
commitf52391a919ec4969d3a0254513d4e0c971dd611f (patch)
treed6ab2af1f45a39cd5056934a15f86feed612df2d
parent31906d8e916f72da8493655672bd6731e46b20f5 (diff)
downloadpoky-f52391a919ec4969d3a0254513d4e0c971dd611f.tar.gz
Cleanup image,rootfs_ipk,package_ipk bbclass files
This commit cleans up the functions that were ported to python. (From OE-Core rev: d950ef40a3eae4b54cc62828e66d84a62d78c447) Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/image.bbclass38
-rw-r--r--meta/classes/package_ipk.bbclass197
-rw-r--r--meta/classes/rootfs_ipk.bbclass109
3 files changed, 4 insertions, 340 deletions
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 0b35c719fd..ffe05c9040 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -287,44 +287,6 @@ MULTILIBRE_ALLOW_REP =. "${base_bindir}|${base_sbindir}|${bindir}|${sbindir}|${l
287MULTILIB_CHECK_FILE = "${WORKDIR}/multilib_check.py" 287MULTILIB_CHECK_FILE = "${WORKDIR}/multilib_check.py"
288MULTILIB_TEMP_ROOTFS = "${WORKDIR}/multilib" 288MULTILIB_TEMP_ROOTFS = "${WORKDIR}/multilib"
289 289
290multilib_generate_python_file() {
291 cat >${MULTILIB_CHECK_FILE} <<EOF
292import sys, os, os.path
293import re,filecmp
294
295allow_rep=re.compile(re.sub("\|$","","${MULTILIBRE_ALLOW_REP}"))
296error_prompt="Multilib check error:"
297
298files={}
299dirs=raw_input()
300for dir in dirs.split():
301 for root, subfolders, subfiles in os.walk(dir):
302 for file in subfiles:
303 item=os.path.join(root,file)
304 key=str(os.path.join("/",os.path.relpath(item,dir)))
305
306 valid=True;
307 if key in files:
308 #check whether the file is allow to replace
309 if allow_rep.match(key):
310 valid=True
311 else:
312 if not filecmp.cmp(files[key],item):
313 valid=False
314 print("%s duplicate files %s %s is not the same\n" % (error_prompt, item, files[key]))
315 sys.exit(1)
316
317 #pass the check, add to list
318 if valid:
319 files[key]=item
320EOF
321}
322
323multilib_sanity_check() {
324 multilib_generate_python_file
325 echo $@ | python ${MULTILIB_CHECK_FILE}
326}
327
328# This function is intended to disallow empty root password if 'debug-tweaks' is not in IMAGE_FEATURES. 290# This function is intended to disallow empty root password if 'debug-tweaks' is not in IMAGE_FEATURES.
329zap_empty_root_password () { 291zap_empty_root_password () {
330 if [ -e ${IMAGE_ROOTFS}/etc/shadow ]; then 292 if [ -e ${IMAGE_ROOTFS}/etc/shadow ]; then
diff --git a/meta/classes/package_ipk.bbclass b/meta/classes/package_ipk.bbclass
index 73446d6c59..68c8580761 100644
--- a/meta/classes/package_ipk.bbclass
+++ b/meta/classes/package_ipk.bbclass
@@ -10,207 +10,12 @@ PKGWRITEDIRIPK = "${WORKDIR}/deploy-ipks"
10# Program to be used to build opkg packages 10# Program to be used to build opkg packages
11OPKGBUILDCMD ??= "opkg-build" 11OPKGBUILDCMD ??= "opkg-build"
12 12
13OPKG_ARGS = "-f $INSTALL_CONF_IPK -o $INSTALL_ROOTFS_IPK --force_postinstall --prefer-arch-to-version" 13OPKG_ARGS = "--force_postinstall --prefer-arch-to-version"
14OPKG_ARGS += "${@['', '--no-install-recommends'][d.getVar("NO_RECOMMENDATIONS", True) == "1"]}" 14OPKG_ARGS += "${@['', '--no-install-recommends'][d.getVar("NO_RECOMMENDATIONS", True) == "1"]}"
15OPKG_ARGS += "${@['', '--add-exclude ' + ' --add-exclude '.join((d.getVar('PACKAGE_EXCLUDE', True) or "").split())][(d.getVar("PACKAGE_EXCLUDE", True) or "") != ""]}" 15OPKG_ARGS += "${@['', '--add-exclude ' + ' --add-exclude '.join((d.getVar('PACKAGE_EXCLUDE', True) or "").split())][(d.getVar("PACKAGE_EXCLUDE", True) or "") != ""]}"
16 16
17OPKGLIBDIR = "${localstatedir}/lib" 17OPKGLIBDIR = "${localstatedir}/lib"
18 18
19package_tryout_install_multilib_ipk() {
20 #try install multilib
21 multilib_tryout_dirs=""
22 for item in ${MULTILIB_VARIANTS}; do
23 local target_rootfs="${MULTILIB_TEMP_ROOTFS}/${item}"
24 local ipkg_args="${OPKG_ARGS}"
25 local selected_pkg=""
26 local pkgname_prefix="${item}-"
27 local pkgname_len=${#pkgname_prefix}
28 for pkg in ${INSTALL_PACKAGES_MULTILIB_IPK}; do
29 local pkgname=$(echo $pkg | awk -v var=$pkgname_len '{ pkgname=substr($1, 1, var); print pkgname; }' )
30 if [ ${pkgname} = ${pkgname_prefix} ]; then
31 selected_pkg="${selected_pkg} ${pkg}"
32 fi
33 done
34 if [ ! -z "${selected_pkg}" ]; then
35 rm -f ${target_rootfs}
36 mkdir -p ${target_rootfs}/${opkglibdir}
37 opkg-cl ${ipkg_args} update
38 opkg-cl ${ipkg_args} install ${selected_pkg}
39 multilib_tryout_dirs="${multilib_tryout_dirs} ${target_rootfs}"
40 fi
41 done
42}
43
44split_multilib_packages() {
45 INSTALL_PACKAGES_NORMAL_IPK=""
46 INSTALL_PACKAGES_MULTILIB_IPK=""
47 for pkg in ${INSTALL_PACKAGES_IPK}; do
48 is_multilib=0
49 for item in ${MULTILIB_VARIANTS}; do
50 local pkgname_prefix="${item}-"
51 local pkgname_len=${#pkgname_prefix}
52 local pkgname=$(echo $pkg | awk -v var=$pkgname_len '{ pkgname=substr($1, 1, var); print pkgname; }' )
53 if [ ${pkgname} = ${pkgname_prefix} ]; then
54 is_multilib=1
55 break
56 fi
57 done
58
59 if [ ${is_multilib} = 0 ]; then
60 INSTALL_PACKAGES_NORMAL_IPK="${INSTALL_PACKAGES_NORMAL_IPK} ${pkg}"
61 else
62 INSTALL_PACKAGES_MULTILIB_IPK="${INSTALL_PACKAGES_MULTILIB_IPK} ${pkg}"
63 fi
64 done
65}
66
67#
68# install a bunch of packages using opkg
69# the following shell variables needs to be set before calling this func:
70# INSTALL_ROOTFS_IPK - install root dir
71# INSTALL_CONF_IPK - configuration file
72# INSTALL_PACKAGES_IPK - packages to be installed
73# INSTALL_PACKAGES_ATTEMPTONLY_IPK - packages attemped to be installed only
74# INSTALL_PACKAGES_LINGUAS_IPK - additional packages for uclibc
75# INSTALL_TASK_IPK - task name
76
77package_install_internal_ipk() {
78
79 local target_rootfs="${INSTALL_ROOTFS_IPK}"
80 local package_attemptonly="${INSTALL_PACKAGES_ATTEMPTONLY_IPK}"
81 local package_linguas="${INSTALL_PACKAGES_LINGUAS_IPK}"
82 local task="${INSTALL_TASK_IPK}"
83
84 split_multilib_packages
85
86 local package_to_install="${INSTALL_PACKAGES_NORMAL_IPK}"
87 local package_multilib="${INSTALL_PACKAGES_MULTILIB_IPK}"
88
89 mkdir -p ${target_rootfs}${OPKGLIBDIR}/opkg
90 touch ${target_rootfs}${OPKGLIBDIR}/opkg/status
91
92 local ipkg_args="${OPKG_ARGS}"
93
94 opkg-cl ${ipkg_args} update
95
96 for i in ${package_linguas}; do
97 opkg-cl ${ipkg_args} install $i
98 done
99
100 if [ ! -z "${package_to_install}" ]; then
101 opkg-cl ${ipkg_args} install ${package_to_install}
102 fi
103
104 if [ ! -z "${package_attemptonly}" ]; then
105 opkg-cl ${ipkg_args} install ${package_attemptonly} > "`dirname ${BB_LOGFILE}`/log.do_${task}_attemptonly.${PID}" || true
106 fi
107
108 package_tryout_install_multilib_ipk
109 if [ ! -z "${MULTILIB_CHECK_FILE}" ]; then
110 #sanity check
111 multilib_sanity_check ${target_rootfs} ${multilib_tryout_dirs} || exit 1
112 fi
113
114 if [ ! -z "${package_multilib}" ]; then
115 opkg-cl ${ipkg_args} install ${package_multilib}
116 fi
117}
118
119ipk_log_check() {
120 target="$1"
121 lf_path="$2"
122
123 lf_txt="`cat $lf_path`"
124 for keyword_die in "exit 1" "Collected errors" ERR Fail
125 do
126 if (echo "$lf_txt" | grep -v log_check | grep "$keyword_die") >/dev/null 2>&1
127 then
128 echo "log_check: There were error messages in the logfile"
129 printf "log_check: Matched keyword: [$keyword_die]\n\n"
130 echo "$lf_txt" | grep -v log_check | grep -C 5 "$keyword_die"
131 echo ""
132 do_exit=1
133 fi
134 done
135 test "$do_exit" = 1 && exit 1
136 true
137}
138
139#
140# Update the Packages index files in ${DEPLOY_DIR_IPK}
141#
142package_update_index_ipk () {
143 #set -x
144
145 ipkgarchs="${ALL_MULTILIB_PACKAGE_ARCHS} ${SDK_PACKAGE_ARCHS}"
146
147 if [ ! -z "${DEPLOY_KEEP_PACKAGES}" ]; then
148 return
149 fi
150
151 packagedirs="${DEPLOY_DIR_IPK}"
152 for arch in $ipkgarchs; do
153 packagedirs="$packagedirs ${DEPLOY_DIR_IPK}/$arch"
154 done
155
156 multilib_archs="${MULTILIB_ARCHS}"
157 for arch in $multilib_archs; do
158 packagedirs="$packagedirs ${DEPLOY_DIR_IPK}/$arch"
159 done
160
161 found=0
162 for pkgdir in $packagedirs; do
163 if [ -e $pkgdir/ ]; then
164 found=1
165 touch $pkgdir/Packages
166 flock $pkgdir/Packages.flock -c "opkg-make-index -r $pkgdir/Packages -p $pkgdir/Packages -m $pkgdir/"
167 fi
168 done
169 if [ "$found" != "1" ]; then
170 bbfatal "There are no packages in ${DEPLOY_DIR_IPK}!"
171 fi
172}
173
174#
175# Generate an ipkg conf file ${IPKGCONF_TARGET} suitable for use against
176# the target system and an ipkg conf file ${IPKGCONF_SDK} suitable for
177# use against the host system in sdk builds
178#
179package_generate_ipkg_conf () {
180 package_generate_archlist
181 echo "src oe file:${DEPLOY_DIR_IPK}" >> ${IPKGCONF_SDK}
182 ipkgarchs="${SDK_PACKAGE_ARCHS}"
183 for arch in $ipkgarchs; do
184 if [ -e ${DEPLOY_DIR_IPK}/$arch/Packages ] ; then
185 echo "src oe-$arch file:${DEPLOY_DIR_IPK}/$arch" >> ${IPKGCONF_SDK}
186 fi
187 done
188
189 echo "src oe file:${DEPLOY_DIR_IPK}" >> ${IPKGCONF_TARGET}
190 ipkgarchs="${ALL_MULTILIB_PACKAGE_ARCHS}"
191 for arch in $ipkgarchs; do
192 if [ -e ${DEPLOY_DIR_IPK}/$arch/Packages ] ; then
193 echo "src oe-$arch file:${DEPLOY_DIR_IPK}/$arch" >> ${IPKGCONF_TARGET}
194 fi
195 done
196}
197
198package_generate_archlist () {
199 ipkgarchs="${SDK_PACKAGE_ARCHS}"
200 priority=1
201 for arch in $ipkgarchs; do
202 echo "arch $arch $priority" >> ${IPKGCONF_SDK}
203 priority=$(expr $priority + 5)
204 done
205
206 ipkgarchs="${ALL_MULTILIB_PACKAGE_ARCHS}"
207 priority=1
208 for arch in $ipkgarchs; do
209 echo "arch $arch $priority" >> ${IPKGCONF_TARGET}
210 priority=$(expr $priority + 5)
211 done
212}
213
214python do_package_ipk () { 19python do_package_ipk () {
215 import re, copy 20 import re, copy
216 import textwrap 21 import textwrap
diff --git a/meta/classes/rootfs_ipk.bbclass b/meta/classes/rootfs_ipk.bbclass
index f97f027804..9d63450dd1 100644
--- a/meta/classes/rootfs_ipk.bbclass
+++ b/meta/classes/rootfs_ipk.bbclass
@@ -15,117 +15,14 @@ rootfs_ipk_do_rootfs[vardepsexclude] += "BUILDNAME"
15 15
16do_rootfs[lockfiles] += "${WORKDIR}/ipk.lock" 16do_rootfs[lockfiles] += "${WORKDIR}/ipk.lock"
17 17
18OPKG_PREPROCESS_COMMANDS = "package_update_index_ipk; package_generate_ipkg_conf" 18OPKG_PREPROCESS_COMMANDS = ""
19 19
20OPKG_POSTPROCESS_COMMANDS = "ipk_insert_feed_uris; " 20OPKG_POSTPROCESS_COMMANDS = ""
21 21
22OPKGLIBDIR = "${localstatedir}/lib" 22OPKGLIBDIR = "${localstatedir}/lib"
23 23
24MULTILIBRE_ALLOW_REP = "${OPKGLIBDIR}/opkg" 24MULTILIBRE_ALLOW_REP = "${OPKGLIBDIR}/opkg"
25 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 echo "$pkginfo" | awk "/^Status:/ { print \"Status: deinstall hold not-installed\n\" }" - >> $STATUS
48 else
49 echo "Requested ignored recommendation $i is not a package"
50 fi
51 done
52
53 #install
54 export INSTALL_PACKAGES_ATTEMPTONLY_IPK="${PACKAGE_INSTALL_ATTEMPTONLY}"
55 export INSTALL_PACKAGES_LINGUAS_IPK="${LINGUAS_INSTALL}"
56 export INSTALL_TASK_IPK="rootfs"
57
58
59 export INSTALL_PACKAGES_IPK="${PACKAGE_INSTALL}"
60
61 #post install
62 export D=${IMAGE_ROOTFS}
63 export OFFLINE_ROOT=${IMAGE_ROOTFS}
64 export IPKG_OFFLINE_ROOT=${IMAGE_ROOTFS}
65 export OPKG_OFFLINE_ROOT=${IPKG_OFFLINE_ROOT}
66 export INTERCEPT_DIR=${WORKDIR}/intercept_scripts
67 export NATIVE_ROOT=${STAGING_DIR_NATIVE}
68
69 package_install_internal_ipk
70
71 # Distro specific packages should create this
72 #mkdir -p ${IMAGE_ROOTFS}/etc/opkg/
73 #grep "^arch" ${IPKGCONF_TARGET} >${IMAGE_ROOTFS}/etc/opkg/arch.conf
74
75 rootfs_install_complementary
76
77 ${OPKG_POSTPROCESS_COMMANDS}
78 ${ROOTFS_POSTINSTALL_COMMAND}
79
80 install -d ${IMAGE_ROOTFS}/${sysconfdir}
81 echo ${BUILDNAME} > ${IMAGE_ROOTFS}/${sysconfdir}/version
82
83 ${ROOTFS_POSTPROCESS_COMMAND}
84
85 if ${@base_contains("IMAGE_FEATURES", "read-only-rootfs", "true", "false" ,d)}; then
86 delayed_postinsts="$(delayed_postinsts)"
87 if [ -n "$delayed_postinsts" ]; then
88 bberror "The following packages could not be configured offline and rootfs is read-only: $delayed_postinsts"
89 exit 1
90 fi
91 fi
92
93 rm -f ${IMAGE_ROOTFS}${OPKGLIBDIR}/opkg/lists/*
94 log_check rootfs
95}
96
97rootfs_ipk_do_rootfs[vardeps] += "delayed_postinsts"
98
99delayed_postinsts () {
100 cat ${STATUS}|grep -e "^Package:" -e "^Status:"|sed -ne 'N;s/Package: \(.*\)\nStatus:.*unpacked/\1/p'
101}
102
103save_postinsts () {
104 # Scripts need to be ordered when executed, this ensures numeric order
105 # If we ever run into needing more the 899 scripts, we'll have to
106 # change num to start with 1000.
107 num=100
108 for p in $(delayed_postinsts); do
109 install -d ${IMAGE_ROOTFS}${sysconfdir}/ipk-postinsts
110 cp ${IMAGE_ROOTFS}${OPKGLIBDIR}/opkg/info/$p.postinst ${IMAGE_ROOTFS}${sysconfdir}/ipk-postinsts/$num-$p
111 num=`echo \$((num+1))`
112 done
113}
114
115remove_packaging_data_files() {
116 rm -rf ${IMAGE_ROOTFS}${OPKGLIBDIR}/opkg
117 # We need the directory for the package manager lock
118 mkdir ${IMAGE_ROOTFS}${OPKGLIBDIR}/opkg
119}
120
121rootfs_install_packages() {
122 opkg-cl ${OPKG_ARGS} install `cat $1`
123}
124
125rootfs_uninstall_packages() {
126 opkg-cl ${OPKG_ARGS} --force-depends remove $@
127}
128
129ipk_insert_feed_uris () { 26ipk_insert_feed_uris () {
130 27
131 echo "Building from feeds activated!" 28 echo "Building from feeds activated!"
@@ -163,7 +60,7 @@ python () {
163 flags = flags.replace("do_deploy", "") 60 flags = flags.replace("do_deploy", "")
164 flags = flags.replace("do_populate_sysroot", "") 61 flags = flags.replace("do_populate_sysroot", "")
165 d.setVarFlag('do_rootfs', 'recrdeptask', flags) 62 d.setVarFlag('do_rootfs', 'recrdeptask', flags)
166 d.setVar('OPKG_PREPROCESS_COMMANDS', "package_generate_archlist\nipk_insert_feed_uris") 63 d.setVar('OPKG_PREPROCESS_COMMANDS', "ipk_insert_feed_uris")
167 d.setVar('OPKG_POSTPROCESS_COMMANDS', '') 64 d.setVar('OPKG_POSTPROCESS_COMMANDS', '')
168} 65}
169 66