blob: 101db26d4f676ff4851183046c3579d83c9bf8d1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
#!/bin/sh
#
. `dirname $0`/libptxdist.sh
usage() {
echo
[ -n "$1" ] && echo -e "error: $1\n"
echo "usage: $0 -r <rootdir>"
echo " [-i <ipkgdir>]"
echo " -p permissions"
echo " -e eraseblocksize"
echo " -o outputfile"
echo " [-j jffs2_extra_args]"
echo
echo " -r <rootdir> use this directory as a file source"
echo " -i <ipkgdir> use this directory as a ipkg packet source"
echo " -p <permissions> path to permissions file"
echo " -e <eraseblocksize> erase block size of the flash chips"
echo " -j <jffs2_extra_args> additional arguments for mkfs.jffs2"
echo " -o <outputfile> JFFS2 output file"
echo " -f <ipkgconfig> use this ipkg config file"
echo
exit 0
}
nflag=0
vlevel=0
ROOTDIR=
IPKGDIR=
PERMISSIONS=
ERASEBLOCKSIZE=
JFFS2EXTRA=
OUTFILE=
#
# Option parser
#
while [ $# -gt 0 ]; do
case "$1" in
--help) usage ;;
-r) ROOTDIR=`ptxd_abspath $2`; shift 2 ;;
-i) IPKGDIR=`ptxd_abspath $2`; shift 2 ;;
-p) PERMISSIONS=`ptxd_abspath $2`; shift 2 ;;
-e) ERASEBLOCKSIZE=$2; shift 2 ;;
-j) JFFS2EXTRA=$2; shift 2 ;;
-o) OUTFILE=`ptxd_abspath $2`; shift 2 ;;
-f) IPKGCONF=$2; shift 2 ;;
*) usage "unknown option" ;;
esac
done
#
# Sanity checks
#
[ -z "$ROOTDIR" ] && usage "error: -r for your root dir"
[ ! -f "$PERMISSIONS" ] && usage "error: specify the permissions file with -p"
[ -z "$ERASEBLOCKSIZE" ] && usage "error: erase block size not specified"
[ ! -x "`which mkfs.jffs2`" ] && usage "error: you need mkfs.jffs2 in your path"
[ ! -x "`which fakeroot`" ] && usage "error: you need fakeroot in your path"
[ -n "$IPKGDIR" ] && \
[ ! -x "`which ipkg-cl`" ] && usage "error: you need ipkg-cl in your path"
[ -z "$OUTFILE" ] && usage "error: specify an output file with -o"
echo
#
# If we use ipkg, prepare a directory for that. For using a plain root
# directory we just select this.
#
if [ -n "$IPKGDIR" ]; then
echo "-i specified, extracting ipkg packets"
WORKDIR=`mktemp -d /tmp/ptxdist.XXXXXX`
else
echo "-i not specified, using files from plain root directory"
WORKDIR=$ROOTDIR
fi
echo
echo "ROOTDIR=$ROOTDIR"
echo "IPKGDIR=$IPKGDIR"
echo "PERMISSIONS=$PERMISSIONS"
echo "ERASEBLOCKSIZE=$ERASEBLOCKSIZE"
echo "JFFS2EXTRA=$JFFS2EXTRA"
echo "OUTFILE=$OUTFILE"
echo "WORKDIR=$WORKDIR"
echo
cd $WORKDIR
if [ -n "$IPKGDIR" ]; then
for archive in $IPKGDIR/*.ipk; do
# "Cannot create node" messages are ok here (nodes are handled with the permissions file)
# do not confuse the user with these error messages
ipkg-cl -f $IPKGCONF -force-depends -o `pwd` install $archive 2>&1 1>/dev/null | grep -v "Cannot create node"
done
fi
echo `awk -F: "$DOPERMISSIONS" $PERMISSIONS && echo "mkfs.jffs2 -d $WORKDIR --eraseblock=$ERASEBLOCKSIZE $JFFS2EXTRA -o $OUTFILE" ` | fakeroot --
if [ -n "$IPKGDIR" ]; then
echo "cleaning up workdir"
rm -fr $WORKDIR
fi
echo "finished:"
ls -l $OUTFILE
|