5 use Digest::MD5 qw(md5 md5_hex);
11 glob("applications/*"),
21 $d++ while( $p =~ m{/}g );
38 # Skip stuff not in /luasrc/
39 ( $File::Find::name =~ m{/luasrc/} ) || return;
42 ( $File::Find::name !~ m{/\.svn\b} ) || return;
44 # Exclude luci-statistics and lucittpd for now
45 ( $File::Find::name !~ m{/luci-statistics/} && $File::Find::name !~ m{/lucittpd/} ) || return;
48 my $file = $File::Find::name;
49 $file =~ s{^.+/luasrc/}{luci/};
51 my $command = ( $File::Find::name =~ m{\.lua\z} && $ENV{LUAC} )
52 ? "$ENV{LUAC} -o - $_ |" : "< $_";
54 if( open F, $command )
56 warn sprintf "Member at 0x%08X: %s\n", $offset, $file;
62 $index[-1][0] = $offset;
64 while( read F, my $buffer, 4096 ) {
65 $size += length $buffer;
70 $pad = ( 4 - ( $size % 4 ) );
75 $index[-1][1] = $size;
76 $index[-1][2] = md5($file);
77 $index[-1][3] = 0x0000;
78 $index[-1][4] = $file;
80 $offset += $size + $pad;
88 # Build File List Member
91 my $filelist = join("\0", map $_->[4], @index) . "\0";
92 my $listsize = length $filelist;
93 push @index, [ $offset, $listsize, "", 0xFFFF, undef ];
95 warn sprintf "Filelist at 0x%08X, length 0x%08X\n", $offset, $listsize;
102 $offset += ( 4 - ($listsize % 4) );
103 print "\0" x ( 4 - ($listsize % 4) );
108 foreach my $file ( @index )
110 warn sprintf "Index[%4d]: 0x%08X 0x%08X 0x%04X 0x%04X %32s\n",
111 $count++, $file->[0], $file->[1], $file->[3], 0x0000,
112 $file->[4] ? md5_hex($file->[4]) : "0" x 32
115 print pack "NNnna16", $file->[0], $file->[1], $file->[3], 0x0000, $file->[2];
118 warn sprintf "Index at 0x%08X, length 0x%08X\n", $offset, @index * 28;
119 print pack "N", $offset;