Merge bk://oe-devel.bkbits.net/openembedded
authornslu2-linux.adm@bkbits.net <nslu2-linux.adm@bkbits.net>
Sun, 2 Jan 2005 01:40:05 +0000 (01:40 +0000)
committernslu2-linux.adm@bkbits.net <nslu2-linux.adm@bkbits.net>
Sun, 2 Jan 2005 01:40:05 +0000 (01:40 +0000)
into bkbits.net:/repos/n/nslu2-linux/openembedded

2005/01/02 02:37:18+01:00 handhelds.org!CoreDump
Merge bk://oe-devel@oe-devel.bkbits.net/openembedded
into handhelds.org:/home/mhentges/OpenEmbedded/bitbake/openembedded

2005/01/02 02:37:06+01:00 handhelds.org!CoreDump
rootfs_ipk: Check the logfile for error messages and error-out if necessary

2005/01/02 02:34:54+01:00 handhelds.org!CoreDump
opie-image: Fail gracefully if ipkg.conf is missing

BKrev: 41d750f5kYn8z0gnIKOxG2q7gzJaXw

classes/rootfs_ipk.bbclass
packages/meta/opie-image.bb

index e69de29..747f3ad 100644 (file)
@@ -0,0 +1,129 @@
+#
+# 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_ipk.oeclass for a usage of this.
+#
+
+DEPENDS_prepend="ipkg-native ipkg-utils-native fakeroot-native "
+DEPENDS_append=" ${EXTRA_IMAGEDEPENDS}"
+
+PACKAGES = ""
+
+do_rootfs[nostamp] = 1
+do_rootfs[dirs] = ${TOPDIR}
+
+IPKG_ARGS = "-f ${T}/ipkg.conf -o ${IMAGE_ROOTFS}"
+
+ROOTFS_POSTPROCESS_COMMAND ?= ""
+
+PID = "${@os.getpid()}"
+
+# some default locales
+IMAGE_LINGUAS ?= "de-de fr-fr en-gb"
+
+LINGUAS_INSTALL = "${@" ".join(map(lambda s: "locale-base-%s" % s, bb.data.getVar('IMAGE_LINGUAS', d, 1).split()))}"
+
+real_do_rootfs () {
+       set -x
+               
+       mkdir -p ${IMAGE_ROOTFS}/dev
+
+       rm -f ${DEPLOY_DIR_IPK}/Packages
+       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}
+       mkdir -p ${T}
+       echo "src oe file:${DEPLOY_DIR_IPK}" > ${T}/ipkg.conf
+       ipkgarchs="all any noarch ${TARGET_ARCH} ${IPKG_ARCHS} ${MACHINE}"
+       priority=1
+       for arch in $ipkgarchs; do
+               echo "arch $arch $priority" >> ${T}/ipkg.conf
+               priority=$(expr $priority + 5)
+       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 "${IPKG_INSTALL}" ]; then
+               ipkg-cl ${IPKG_ARGS} install ${IPKG_INSTALL}
+       fi
+
+       export D=${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}/usr/lib/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}/usr/lib/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        
+}
+
+log_check() {
+       set +x
+       for target in $*
+       do
+               lf_path="${WORKDIR}/temp/log.do_$target.${PID}"
+               
+               echo "log_check: Using $lf_path as logfile"
+               
+               if test -e "$lf_path"
+               then
+                       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 -i "$keyword_die") &>/dev/null
+                               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"
+                                       echo ""
+                                       do_exit=1                               
+                               fi
+                       done
+                       test "$do_exit" = 1 && exit 1                                           
+               else
+                       echo "Cannot find logfile [$lf_path]"
+               fi
+               echo "Logfile is clean"         
+       done
+
+       set -x
+       
+}
+
+fakeroot do_rootfs () {
+       rm -rf ${IMAGE_ROOTFS}
+       real_do_rootfs
+}
+
+# set '*' as the rootpassword so the images
+# can decide if they want it or not
+
+zap_root_password () {
+       sed 's%^root:[^:]*:%root:*:%' < ${IMAGE_ROOTFS}/etc/passwd >${IMAGE_ROOTFS}/etc/passwd.new
+       mv ${IMAGE_ROOTFS}/etc/passwd.new ${IMAGE_ROOTFS}/etc/passwd    
+} 
+
+# export the zap_root_password
+EXPORT_FUNCTIONS zap_root_password
+
+addtask rootfs before do_build after do_install
index 83004f1..1a7f512 100644 (file)
@@ -31,7 +31,13 @@ merge_feeds() {
 
        if ! test -z "${FEED_URIS}"
        then
-
+               # Die gracefully if ipkg-collateral failed
+               if ! test -e "${IMAGE_ROOTFS}/etc/ipkg.conf"
+               then
+                       echo "[${IMAGE_ROOTFS}/etc/ipkg.conf] is missing!"
+                       exit 1
+               fi
+               
                # comment out existing feed-sources inserted by ipkg-collateral
                cat ${IMAGE_ROOTFS}/etc/ipkg.conf | sed "s/^src\ /#src\ /" > ${IMAGE_ROOTFS}/etc/ipkg.conf_
                rm ${IMAGE_ROOTFS}/etc/ipkg.conf && mv ${IMAGE_ROOTFS}/etc/ipkg.conf_ ${IMAGE_ROOTFS}/etc/ipkg.conf