]> spindle.queued.net Git - xodist/blobdiff - mkext3.sh
mkchroot: add a debian-lenny-i386 image
[xodist] / mkext3.sh
index d6a46ce30bf793d0558f28e190d52878d5ff4f4f..d362715c25c376f5f8da4fa11c191410704ded40 100755 (executable)
--- a/mkext3.sh
+++ b/mkext3.sh
@@ -1,4 +1,4 @@
-#!/bin/sh -e
+#!/bin/bash -e
 #
 # Copyright © 2008  Andres Salomon <dilinger@queued.net>
 #
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-IMG_NAME="DebXO"
-ROOT_SIZE="2048"
+ROOT_SIZE="1998"
 IMG_LABEL="DebXO"
+IMG_NAME=""
 ROOT_DIR=""
 
-. functions.sh
+. ./functions.sh
 
 # @img - fs image to attach loop device to
 # @offset - if the image is partitioned, the offset to attach at
@@ -157,11 +157,10 @@ mk_ext3_fs()
 usage()
 {
        echo "" 1>&2
-       echo "Usage: $0 [<options>] <root directory>" 1>&2
+       echo "Usage: $0 [<options>] <root directory> <img>" 1>&2
        echo "" 1>&2
        echo "Options:" 1>&2
        echo "  -l <label>    Image label" 1>&2
-       echo "  -o <img>      Image (base) filename" 1>&2
        echo "  -s <size>     Root filesystem size (in MB)" 1>&2
        echo "" 1>&2
        exit 1
@@ -174,20 +173,15 @@ do
                IMG_LABEL=$2
                shift
                ;;
-       -o)
-               IMG_NAME=$2
-               shift
-               ;;
        -s)
                ROOT_SIZE=$2
                shift
                ;;
        *)
-               if [ "$#" != "1" ]; then
-                       echo "Unknown option $1" 1>&2
-                       usage
-               else
-                       ROOT_DIR="$1"
+               ROOT_DIR="$1"
+               shift
+               if [ "$#" = "1" ]; then
+                       IMG_NAME="$1"
                fi
                ;;
        esac
@@ -199,6 +193,11 @@ if [ "$ROOT_DIR" = "" ]; then
        echo "*** No root directory specified!" 1>&2
        usage
 fi
+if [ "$IMG_NAME" = "" ]; then
+       echo "" 1>&2
+       echo "*** No image name specified!" 1>&2
+       usage
+fi
 if [ ! -d "$ROOT_DIR" ]; then
        echo "" 1>&2
        echo "*** Unable to find root directory!" 1>&2