#!/bin/bash set -x set -e PATH=/sbin:/usr/sbin:$PATH cleanup() { [ -d "$TMP_MNT" ] && rm -rf $TMP_MNT } exitclean() { echo "Cleaning up to exit..." cleanup exit 1 } trap exitclean SIGINT SIGTERM echo "Build jffs2 image $IMG" ROOT=$1 IMG=${2:-${ROOT}.img} TMP_MNT=$(mktemp -d ./jffs2.XXXXXX) chmod a+rx $TMP_MNT/. cp -al $ROOT/* $TMP_MNT echo "(removing livesys scripts from image because they'll really foul it up if they run)" rm -f $TMP_MNT/etc/init.d/livesys* mkfs.jffs2 -n -e128KiB -r $TMP_MNT -o $IMG.tmp sumtool -n -p -e 128KiB -i $IMG.tmp -o $IMG rm $IMG.tmp crcimg $IMG echo "Done building jffs2 image $IMG" cleanup