-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathassemble-app-bin.sh
81 lines (65 loc) · 2.3 KB
/
assemble-app-bin.sh
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
#!/bin/sh
#
# This file was part of WDTV Tools (http://wdtvtools.sourceforge.net/).
# Copyright (C) 2009 Elmar Weber <[email protected]>
#
# adaptation to wdtvhack by Denis Roio <[email protected]>
#
# This program 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 3 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, see <http://www.gnu.org/licenses/>.
#
# assembly script for application images
appname=wdtvhack
echo "We need root access: this program needs to loopback mount a filesystem."
if [ -z $1 ]; then
# no argument, create fresh
imagefile=./$appname.app.bin
loopdir=./$appname.app.loop
# create and fill in appdir
appdir=$appname.app
sudo rm -rf $appdir $imagefile $loopdir
mkdir -p $appdir
mkdir -p $appdir/etc/init.d
cp -v S99wdtvhack $appdir/etc/init.d &&
chmod a+x $appdir/etc/init.d/S99wdtvhack &&
cp -v README AUTHORS $appdir &&
sudo chown -R root:root $appdir
dd if=/dev/zero of=$imagefile bs=1K count=64 &&
/sbin/mkfs.ext3 -F $imagefile &&
/sbin/tune2fs -c 0 -i 0 $imagefile &&
mkdir -p $loopdir &&
sudo mount -o loop $imagefile $loopdir &&
cp -a $appdir/* $loopdir/ &&
sudo rm -rf $loopdir/lost+found &&
sudo chown root:root -R $loopdir &&
sudo umount $loopdir &&
sudo rm -rf $loopdir $appdir &&
sudo /sbin/fsck.ext3 $imagefile
else
# has argument, update existing
appname=$1
loopdir=/tmp/`basename $appname`.loop
if ! [ -r $appname ]; then
echo "error: $appname doesn't exist"
exit 1
fi
mkdir -p $loopdir
sudo mount -o loop $appname $loopdir
cp -v S99wdtvhack $loopdir/etc/init.d &&
chmod a+x $loopdir/etc/init.d/S99wdtvhack &&
cp -v README AUTHORS $loopdir &&
sudo chown -R root:root $loopdir
sudo umount $loopdir
sudo sync
sudo rm -r $loopdir
fi