summaryrefslogtreecommitdiff
path: root/tools/hiby_patcher.pl
diff options
context:
space:
mode:
Diffstat (limited to 'tools/hiby_patcher.pl')
-rwxr-xr-xtools/hiby_patcher.pl77
1 files changed, 70 insertions, 7 deletions
diff --git a/tools/hiby_patcher.pl b/tools/hiby_patcher.pl
index 9c45ce6dd3..86b8ad3d3f 100755
--- a/tools/hiby_patcher.pl
+++ b/tools/hiby_patcher.pl
@@ -38,6 +38,10 @@ if ($model eq 'rocker') {
38 @ubiopts = ("-e", "124KiB", "-c", "1024", "-m", "2048", "-j", "8192KiB", "-U"); 38 @ubiopts = ("-e", "124KiB", "-c", "1024", "-m", "2048", "-j", "8192KiB", "-U");
39} elsif ($model eq 'x20') { 39} elsif ($model eq 'x20') {
40 @ubiopts = ("-e", "124KiB", "-c", "1024", "-m", "2048", "-j", "8192KiB", "-U"); 40 @ubiopts = ("-e", "124KiB", "-c", "1024", "-m", "2048", "-j", "8192KiB", "-U");
41} elsif ($model eq 'eros_q') {
42 @ubiopts = ("-e", "124KiB", "-c", "1024", "-m", "2048", "-j", "8192KiB", "-U");
43} elsif ($model eq 'm3k') {
44 @ubiopts = ("-e", "124KiB", "-c", "2048", "-m", "2048", "-j", "8192KiB", "-U");
41} else { 45} else {
42 die ("Unknown hiby model: $model\n"); 46 die ("Unknown hiby model: $model\n");
43} 47}
@@ -81,7 +85,6 @@ while (<UPDATE>) {
81 if ($rootfs_found) { 85 if ($rootfs_found) {
82 if (/file_path=(.*)/) { 86 if (/file_path=(.*)/) {
83 $ubiname = basename($1); 87 $ubiname = basename($1);
84 $ubiname =~ tr/[a-z]/[A-Z]/;
85 last; 88 last;
86 } 89 }
87 } else { 90 } else {
@@ -92,7 +95,11 @@ while (<UPDATE>) {
92} 95}
93close UPDATE; 96close UPDATE;
94 97
95die("can't locate rootfs image") if (! -e "$isowork/$ubiname"); 98if (! -e "$isowork/$ubiname") {
99 $ubiname =~ tr/[a-z]/[A-Z]/;
100 die("can't locate rootfs image ($ubiname)") if (! -e "$isowork/$ubiname");
101}
102
96$ubiname = "$isowork/$ubiname"; 103$ubiname = "$isowork/$ubiname";
97 104
98### Extract RootFS 105### Extract RootFS
@@ -102,6 +109,7 @@ mkdir($rootfsdir) || die ("Can't create '$rootfsdir'");
102@sysargs = ("ubireader_extract_files", "-k", "-o", $rootfsdir, $ubiname); 109@sysargs = ("ubireader_extract_files", "-k", "-o", $rootfsdir, $ubiname);
103system(@sysargs); 110system(@sysargs);
104 111
112# exit(0);
105### Mangle RootFS 113### Mangle RootFS
106 114
107# Generate rb_bootloader.sh 115# Generate rb_bootloader.sh
@@ -109,19 +117,74 @@ my $rbbasename = basename($rbbname);
109my $bootloader_sh = 117my $bootloader_sh =
110 "#!/bin/sh 118 "#!/bin/sh
111 119
112mount /dev/mmcblk0 /mnt/sd_0 &>/dev/null || \ 120#mkdir -p /mnt/sd_0
113mount /dev/mmcblk0p1 /mnt/sd_0 &>/dev/null 121#
122#mount /dev/mmcblk0 /mnt/sd_0 &>/dev/null || \
123#mount /dev/mmcblk0p1 /mnt/sd_0 &>/dev/null
124
125killall hiby_player &>/dev/null
126killall -9 hiby_player &>/dev/null
127
128killall $rbbasename &>/dev/null
129killall -9 $rbbasename &>/dev/null
114 130
115killall $rbbasename 131# /etc/init.d/K90adb start
116killall -9 $rbbasename
117 132
133# Rockbox launcher!
118/usr/bin/$rbbasename 134/usr/bin/$rbbasename
119sleep 1 135sleep 1
120reboot 136reboot
121 "; 137";
122open FILE, ">$rootfsdir/usr/bin/hiby_player.sh" || die ("can't write bootloader script!"); 138open FILE, ">$rootfsdir/usr/bin/hiby_player.sh" || die ("can't write bootloader script!");
123print FILE $bootloader_sh; 139print FILE $bootloader_sh;
124close FILE; 140close FILE;
141chmod 0755, "$rootfsdir/usr/bin/hiby_player.sh";
142
143# Auto mount/unmount external USB drives
144open FILE, ">>$rootfsdir/etc/mdev.conf" || die ("can't access mdev conf!");
145print FILE "sd[a-z][0-9]+ 0:0 664 @ /etc/rb_inserting.sh\n";
146print FILE "mmcblk[0-9]p[0-9] 0:0 664 @ /etc/rb_inserting.sh\n";
147print FILE "mmcblk[0-9] 0:0 664 @ /etc/rb_inserting.sh\n";
148print FILE "sd[a-z] 0:0 664 \$ /etc/rb_removing.sh";
149print FILE "mmcblk[0-9] 0:0 664 \$ /etc/rb_removing.sh\n";
150close FILE;
151
152my $insert_sh = '
153#!/bin/sh
154# $MDEV is the device
155
156case $MDEV in
157 mmc*)
158 MNT_POINT=/mnt/sd_0
159 ;;
160 sd*)
161 MNT_POINT=/mnt/sd_0/USB
162 ;;
163esac
164
165if [ ! -d $MNT_POINT ];then
166 mkdir $MNT_POINT
167fi
168
169mount $MDEV $MNT_POINT
170';
171
172open FILE, ">$rootfsdir/etc/rb_inserting.sh" || die("can't write hotplug helpers!");
173print FILE $insert_sh;
174close FILE;
175chmod 0755, "$rootfsdir/etc/rb_inserting.sh";
176
177my $remove_sh = '
178#!/bin/sh
179# $MDEV is the device
180sync;
181unmount -f $MDEV;
182';
183
184open FILE, ">$rootfsdir/etc/rb_removing.sh" || die("can't write hotplug helpers!");
185print FILE $remove_sh;
186close FILE;
187chmod 0755, "$rootfsdir/etc/rb_removing.sh";
125 188
126# Copy bootloader over 189# Copy bootloader over
127@sysargs=("cp", "$rbbname", "$rootfsdir/usr/bin/$rbbasename"); 190@sysargs=("cp", "$rbbname", "$rootfsdir/usr/bin/$rbbasename");