blob: 3f839f1153c7d7e6cb7ef002b596dfb0e2c5dfa9 [file] [log] [blame]
Gunnar Mills6a3e4e42017-10-23 11:05:03 -05001#!/bin/bash
2set -eo pipefail
3
4help=$'Generate PNOR UBI image from a PNOR SquashFS Tarball
5
6Generates a UBI, Unsorted Block Images, PNOR image from a PNOR SquashFS Tarball.
7The PNOR SquashFS Tarball is generated from the generate-squashfs script.
8
9usage: generate-ubi [OPTION] <PNOR SquashFS Tarball>...
10
11Options:
12 -f, --file <file> Specify destination file. Defaults to
13 `pwd`/<PNOR Tarball FILE, removing .squashfs.tar>.ubi.mtd
14 (For example, "generate-ubi my.pnor.squashfs.tar"
15 would generate `pwd`/my.pnor.ubi.mtd output.)
16 -h, --help Display this help text and exit.
17'
18
19while [[ $# -gt 0 ]]; do
20 key="$1"
21 case $key in
22 -f|--file)
23 outfile="$2"
24 shift 2
25 ;;
26 -h|--help)
27 echo "$help"
28 exit
29 ;;
30 *)
31 tarball="$1"
32 shift 1
33 ;;
34 esac
35done
36
37if [ ! -f "${tarball}" ]; then
38 echo "Please enter a PNOR SquashFS Tarball."
39 echo "To generate PNOR SquashFS Tarball see generate-squashfs"
40 echo "$help"
41 exit 1
42fi
43
44if [[ -z $outfile ]]; then
45 # Remove .squashfs.tar from end if present and add .ubi.mtd
46 outfile=`pwd`/${tarball%".squashfs.tar"}.ubi.mtd
47else
48 if [[ $outfile != /* ]]; then
49 outfile=`pwd`/$outfile
50 fi
51fi
52