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\z} ) || return;
45 ( $File::Find::name =~ m{\.lua\z} ) || return;
48 ( $File::Find::name !~ m{/i18n/} ) || return;
50 # Exclude cbi models and controllers for now
51 ( $File::Find::name !~ m{/controller/} && $File::Find::name !~ m{/model/cbi/} ) || return;
53 # Exclude luci-statistics and lucittpd for now
54 ( $File::Find::name !~ m{/luci-statistics/} && $File::Find::name !~ m{/lucittpd/} ) || return;
57 my $file = $File::Find::name;
58 $file =~ s{^.+/luasrc/}{luci/};
62 warn sprintf "Member at 0x%08X: %s\n", $offset, $file;
68 $index[-1][0] = $offset;
70 while( read F, my $buffer, 4096 ) {
71 $size += length $buffer;
76 $pad = ( 4 - ( $size % 4 ) );
81 $index[-1][1] = $size;
82 $index[-1][2] = md5($file);
83 $index[-1][3] = 0x0000;
84 $index[-1][4] = $file;
86 $offset += $size + $pad;
94 # Build File List Member
97 my $filelist = join("\0", map $_->[4], @index) . "\0";
98 my $listsize = length $filelist;
99 push @index, [ $offset, $listsize, "", 0xFFFF, undef ];
100 warn sprintf "Filelist at 0x%08X\n", $offset;
104 $listsize += ( 4 - ($listsize % 4) );
105 $filelist .= "\0" x ( 4 - ($listsize % 4) );
109 $offset += $listsize;
113 foreach my $file ( @index )
115 warn sprintf "Index[%4d]: 0x%08X 0x%08X 0x%04X 0x%04X %32s\n",
116 $count++, $file->[0], $file->[1], $file->[3], 0x0000,
117 $file->[4] ? md5_hex($file->[4]) : "0" x 32
120 print pack "NNnna16", $file->[0], $file->[1], $file->[3], 0x0000, $file->[2];
123 warn sprintf "Index at 0x%08X, length 0x%08X\n", $offset, @index * 28;
124 print pack "N", $offset;