Remove some debug code. Remove some unnecessary checks.
[kugel-rb.git] / tools / release
blob3c5d5037fec7d16f184fbb45eef8a511b43f9191
1 #!/usr/bin/env perl
3 $version = $ARGV[0];
5 if($version eq "") {
6 print "Enter version number!\n";
7 exit;
10 if(!-f "apps/version.h") {
11 print "run this script in the root dir\n";
12 exit;
14 # save the complete version string for VERSION file,
15 # strip everything after space / hyphen for filename
16 $longversion = $ARGV[0];
17 $version =~ s/[ -].+//;
19 # -L allows find to follow symbolic links
20 @files=`find -L . -name FILES`;
22 my @entries;
24 sub dirpart {
25 my ($file)=@_;
26 my @p=split("/", $file);
27 $p[$#p]=""; # blank the last one
28 my $dir=join("/", @p);
30 $dir =~ s/^\.\///; # cut off ./ beginnings
32 $dir =~ s/\/$//; # off / trailers
34 return $dir;
37 sub add {
38 my ($file)=@_;
40 my $dir=dirpart($file);
42 open(FILE, "<$file");
43 while(<FILE>) {
44 if($_ =~ /^ *\#/) {
45 next;
47 chomp;
48 push @entries, "$dir/$_";
50 close(FILE);
53 for(@files) {
54 chomp;
55 add($_);
58 sub mkalldir {
59 my ($dir) = @_;
61 my @parts = split("/", $dir);
63 #print "IN: $dir\n";
65 my $sub="";
66 for(@parts) {
67 #print "PART: $_\n";
69 $sub .= "$_";
70 if($_ eq "") {
71 next;
73 mkdir($sub, 0777);
74 #print "make $sub\n";
75 $sub .= "/";
80 #mkalldir("rockbox-1.0/firmware/malloc");
81 #exit;
83 for(@entries) {
84 my $dir = dirpart("rockbox-$version/$_");
85 #print "Create $dir\n";
86 mkalldir($dir);
87 #print "Copy $_ to $dir\n";
88 `cp -p $_ $dir 2>/dev/null`;
91 if(!open(VERSION, "<apps/version.h")) {
92 print "Can't read version.h\n";
93 exit;
96 if(!open(THIS, ">rockbox-$version/apps/version.h")) {
97 print "Can't create a new version.h for this version\n";
98 exit;
100 while(<VERSION>) {
101 $_ =~ s/^\#define APPSVERSION .*/\#define APPSVERSION \"$version\"/;
102 print THIS $_;
104 close(VERSION);
105 close(THIS);
107 if(!open(VER, ">rockbox-$version/docs/VERSION")) {
108 print "Can't create new docs/VERSION file\n";
109 exit;
111 print VER $version;
112 close(VER);
114 `tar -cjf rockbox-$version.tar.bz2 rockbox-$version`;
115 `rm -rf rockbox-$version`;