[rdc] simplify sitecom image generation with a script, patch from rtz
[openwrt/svn-archive/archive.git] / target / linux / rdc / image / mkimg_sitecom.pl
1 #!/usr/bin/perl
2
3 $bzimgsize = -s @ARGV[0];
4 $padding = 4 - ($bzimgsize + 2) % 4;
5 if ($padding == 4) {
6 $padding = 0; }
7 open (bzimg, @ARGV[0]);
8 while (<bzimg>) { $i .= $_; }
9 $i .= "\0"x$padding;
10 $i .= pack "v", -(unpack "%v*", $i);
11 print "CSYS";
12 print pack("V", length($i));
13 print pack("V", 0);
14 #-s @ARGV[1]
15 print "WRRM";
16 print pack("V", length($i));
17 print $i;