From d2cfda90cb27c7aac9d0956e71344142d2560228 Mon Sep 17 00:00:00 2001 From: Andres Salomon Date: Tue, 19 Aug 2008 15:38:13 -0400 Subject: [PATCH] separate out jffs2 image creation script Signed-off-by: Andres Salomon --- functions.sh | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++ mkjffs2.sh | 49 +++++++++++++++++++++++++++++++ 2 files changed, 132 insertions(+) create mode 100644 functions.sh create mode 100755 mkjffs2.sh diff --git a/functions.sh b/functions.sh new file mode 100644 index 0000000..00a23a4 --- /dev/null +++ b/functions.sh @@ -0,0 +1,83 @@ +#!/bin/sh -e +# +# Copyright © 2008 Andres Salomon +# +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +check_for_cmds() +{ + for cmd in $@; do + which $cmd >/dev/null || { + echo "Missing required command '$cmd'!" 1>&2 + return 1 + } + done + + return 0 +} + +# @mntpt - path to mounted root directory +# @fstype - the root filesystem type (in a form that 'mount' understands) +create_fstab() +{ + mntpt="$1" + fstype="$2" + + if [ "${fstype}" = "jffs2" ]; then + r=mtd0 + else + r="LABEL=OLPCRoot" + fi + + cat >${mntpt}/etc/fstab<${mntpt}/boot/olpc.fth< +# +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +. functions.sh + +usage() +{ + echo "" 1>&2 + echo "Usage: $0 " 1>&2 + echo "" 1>&2 + exit 1 +} + +if [ "$#" != "2" ]; then + usage +fi + +ROOT_DIR=$1 +IMG_NAME=$2 + +if [ ! -d "${ROOT_DIR}" ]; then + echo "" 1>&2 + echo "*** Unable to find root directory!" 1>&2 + usage +fi + +check_for_cmds mkfs.jffs2 sumtool +create_fstab ${ROOT_DIR} jffs2 +create_ofwboot ${ROOT_DIR} jffs2 + +mkfs.jffs2 -n -e128KiB -r ${ROOT_DIR} -o ${IMG_NAME}.pre +sumtool -n -p -e 128KiB -i ${IMG_NAME}.pre -o ${IMG_NAME} +rm -f ${IMG_NAME}.pre +./crcimg.pl < ${IMG_NAME} > ${IMG_NAME}.crc -- 2.39.5