Skip to content

Commit a570a99

Browse files
committed
complete lz4 support and some bugfixes
1 parent 6784453 commit a570a99

2 files changed

Lines changed: 98 additions & 62 deletions

File tree

menu

Lines changed: 73 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
############################################################################
1212

13-
version=0.002
13+
version=0.003
1414

1515

1616
if [ ! -e menu ]
@@ -73,11 +73,12 @@ do
7373
echo
7474
echo
7575
echo "Lopicl's Kernel Kitchen"
76+
echo "Based on Dsixda's Android Kitchen!"
7677
echo "Version $version"
7778
echo
7879
echo "----------------"
7980
echo
80-
echo "Put a boot.img in the WORKING folder for unlock hidden functions!"
81+
echo "Put a boot.img in the WORKING folder to unlock hidden functions!"
8182
echo "Enter a choice:"
8283
echo
8384

@@ -119,25 +120,22 @@ do
119120
echo " b = Build boot.img from BOOT-EXTRACTED folder (for working folder)"
120121
echo " n = Build NAND's boot folder from BOOT-EXTRACTED (for working folder)"
121122
echo " r = Remove BOOT-EXTRACTED folder (don't build anything)"
122-
else
123-
124-
if [ "$boot_img" == "true" ]
125-
then
126-
echo " w = Extract kernel+ramdisk from boot.img"
127-
echo " c = Convert boot.img into NAND boot folder"
128-
echo " p = Change 'command line' parameter in boot.img"
129-
130-
elif [ "$boot_folder" == "true" ]
131-
then
132-
echo " y = Convert NAND boot folder into boot.img"
133-
echo " z = Extract kernel+ramdisk from NAND boot folder"
134-
fi
123+
elif [ "$boot_img" == "true" ]
124+
then
125+
echo " w = Extract kernel+ramdisk from boot.img"
126+
echo " c = Convert boot.img into NAND boot folder"
127+
echo " p = Change 'command line' parameter in boot.img"
128+
129+
elif [ "$boot_folder" == "true" ]
130+
then
131+
echo " y = Convert NAND boot folder into boot.img"
132+
echo " z = Extract kernel+ramdisk from NAND boot folder"
135133
fi
136134
fi
137135

136+
138137
echo " a = Extract kernel+ramdisk from boot.img/recovery.img in any folder"
139138
echo " k = Restart Kitchen to refresh functions "
140-
echo " x = Exit"
141139
echo
142140
echo " NOTE: Other options may not be shown in this menu *until* a specific"
143141
echo " action above is selected or a specific working folder is created."
@@ -147,62 +145,79 @@ do
147145

148146
read enterLetter
149147

150-
if [ "$enterLetter" == "s" ]
151-
then
152-
scripts/show_boot_img_info
153-
154-
elif [ "$enterLetter" == "w" ]
155-
then
156-
scripts/ensure_boot_extracted
157-
158-
elif [ "$enterLetter" == "r" ]
159-
then
160-
rm -rf BOOT-EXTRACTED; echo; echo "Deleted"
148+
key=$enterLetter
161149

162-
elif [ "$enterLetter" == "b" ]
150+
if [ "$boot_img" == "true" ]
163151
then
164-
scripts/prompt_build_bootimg
165-
166-
elif [ "$enterLetter" == "a" ]
167-
then
168-
scripts/extract_boot_img
152+
if [ "$key" == "s" ]
153+
then
154+
scripts/show_boot_img_info
155+
else :
156+
fi
157+
else :
158+
fi
169159

170-
elif [ "$enterLetter" == "n" ]
160+
if [ "$extracted" == "true" ]
171161
then
172-
scripts/prompt_build_boot
173-
scripts/build_nand_boot
162+
if [ "$key" == "b" ]
163+
then
164+
scripts/prompt_build_bootimg
165+
elif [ "$key" == "n" ]
166+
then
167+
scripts/prompt_build_boot
168+
scripts/build_nand_boot
169+
elif [ "$key" == "r" ]
170+
then
171+
rm -rf BOOT-EXTRACTED; echo; echo "Deleted"
172+
else :
173+
fi
174+
else :
175+
fi
174176

175-
elif [ "$enterLetter" == "k" ]
177+
if [ "$boot_img" == "true" ]
176178
then
177-
./menu
178-
179-
elif [ "$enterLetter" == "c" ]
179+
if [ "$key" == "w" ]
180+
then
181+
scripts/ensure_boot_extracted
182+
elif [ "$key" == "c" ]
183+
then
184+
scripts/ensure_boot_extracted
185+
scripts/build_nand_boot
186+
elif [ "$key" == "p" ]
187+
then
188+
scripts/change_cmdline
189+
else :
190+
fi
191+
else :
192+
fi
193+
194+
if [ "$boot_folder" == "true" ]
180195
then
181-
scripts/ensure_boot_extracted
182-
scripts/build_nand_boot
183-
184-
elif [ "$enterLetter" == "p" ]
196+
if [ "$key" == "y" ]
197+
then
198+
scripts/ensure_nand_extracted
199+
scripts/build_boot_img
200+
elif [ "$key" == "z" ]
201+
then
202+
scripts/ensure_nand_extracted
203+
else :
204+
fi
205+
else :
206+
fi
207+
208+
if [ "$key" == "a" ]
185209
then
186-
scripts/change_cmdline
210+
scripts/extract_boot_img
187211

188-
elif [ "$enterLetter" == "y" ]
189-
then
190-
scripts/ensure_nand_extracted
191-
scripts/build_boot_img
192212

193-
elif [ "$enterLetter" == "z" ]
213+
elif [ "$key" == "k" ]
194214
then
195-
scripts/ensure_nand_extracted
215+
bash ./menu
196216

197-
elif [ "$enterLetter" == "x" ]
198-
then
199-
exit 0
200217
else
201-
echo "Invalid option"
202-
continue
218+
scripts/press_enter
219+
bash ./menu
203220
fi
204221

205222
scripts/press_enter
206-
207223
done
208-

tools/extract_boot_files/extract-ramdisk.pl

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,39 @@ sub extract {
4444
}
4545

4646

47-
if (substr($ram1, 0, 2) eq "\x1F\x8B") {
47+
if (substr($ram1, 0, 2) eq "\x1F\x8B")
48+
{
4849
print "gzip\n";
4950
open (RAM1FILE, ">$ARGV[0]-ramdisk.cpio.gz");
5051
extract();
5152
system ("gzip -d -c ../$ARGV[0]-ramdisk.cpio.gz | cpio -i");
5253
system ("rm ../$ARGV[0]-ramdisk.cpio.gz");
53-
} elsif ($ram1 =~ /\x5D\x00...\xFF\xFF\xFF\xFF\xFF\xFF/) {
54+
}
55+
elsif ($ram1 =~ /\x5D\x00...\xFF\xFF\xFF\xFF\xFF\xFF/)
56+
{
5457
print "lzma\n";
5558
open (RAM1FILE, ">$ARGV[0]-ramdisk.cpio.lzma");
5659
extract();
5760
system ("lzcat ../$ARGV[0]-ramdisk.cpio.lzma | cpio -i");
5861
system ("rm ../$ARGV[0]-ramdisk.cpio.lzma");
59-
} else {
60-
die "Not a gzip or a lzma file";
62+
}
63+
elsif (substr($ram1, 0, 2) eq "\x04\x22")
64+
{
65+
print "lz4\n";
66+
open (RAM1FILE, ">$ARGV[0]-ramdisk.cpio.lz4");
67+
extract();
68+
system ("lz4c -d ../$ARGV[0]-ramdisk.cpio.lz4 | cpio -i");
69+
system ("rm ../$ARGV[0]-ramdisk.cpio.lz4");
70+
}
71+
elsif (substr($ram1, 0, 2) eq "\x02\x21")
72+
{
73+
print "lz4\n";
74+
open (RAM1FILE, ">$ARGV[0]-ramdisk.cpio.lz4");
75+
extract();
76+
system ("lz4c -d ../$ARGV[0]-ramdisk.cpio.lz4 | cpio -i");
77+
system ("rm ../$ARGV[0]-ramdisk.cpio.lz4");
78+
}
79+
else
80+
{
81+
die "Not a gzip or lz4 or lzma file";
6182
}

0 commit comments

Comments
 (0)