ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/free/rpms/smc-music/F-16/dochelper.pl
Revision: 1.1
Committed: Thu Jul 24 17:55:32 2008 UTC (4 years, 10 months ago) by jwrdegoede
Branch: MAIN
CVS Tags: F-13-split, F-12-split, smc-music-4_0-4_fc11, F-10-split, smc-music-4_0-1_fc10, F-11-split, smc-music-4_0-3_fc11, smc-music-4_0-2_fc10, F-15-split, F-16-split, smc-music-4_1-1_fc11, F-16-start, F-14-split, HEAD
Log Message:
initial smc-music import

Line File contents
1 #!/usr/bin/perl
2 #
3 # Helper script to cleanup the scattered mess of text files in the SMC data
4 # path - to avoid overloading the spec file making it unreadable. It preserves
5 # the contents of those text files into a single credits file which gets
6 # installed in a sane location
7 #
8 use strict;
9
10 # File name
11 my $LICFILE = "credits.txt";
12
13 # Prefix to installed location
14 my $PREFIX = "/usr/share/smc";
15
16 # Starting directory
17 my $STARTDIR = "data";
18
19 # Open credits file
20 open (LIC, ">$LICFILE");
21 print LIC "# Generated automatically by dochelper.pl in the smc RPM.\n\n";
22 print LIC "Additional licenses and credits for Secret Mayro Chronicles.\n";
23 print LIC "------------------------------------------------------------\n\n";
24 close (LIC);
25
26 &traverse($STARTDIR);
27
28 exit 0;
29
30 sub traverse
31 {
32 my $cwd = $_[0];
33 system("cd $cwd");
34 opendir(DIR, $cwd);
35 my @entries = readdir(DIR);
36 closedir(DIR);
37
38 foreach my $entry (@entries)
39 {
40 # Don't recurse current or parent
41 next if $entry eq '.';
42 next if $entry eq '..';
43
44 # If it's a dir, recurse.
45 if (-d "$cwd/$entry") {&traverse("$cwd/$entry");}
46
47 # Filter out none text files.
48 next if ($entry !~ m/^.*txt/g);
49
50 # Skip txt files in this dir because they are configs
51 if ($cwd ne 'data/levels')
52 {
53 if ($entry eq 'all.txt')
54 {
55 system("echo \"$PREFIX/$cwd/\*\" >> $LICFILE ; cat $cwd/all.txt >> $LICFILE ; echo \"\n\" >> $LICFILE; rm -f $cwd/all.txt");
56 }
57 else
58 {
59 my $ext = $entry;
60 my $match = 0;
61 $ext =~ s/\.txt/\.ogg/g;
62 if (-e "$cwd/$ext") { system("echo \"$PREFIX/$cwd/$ext\" >> $LICFILE"); $match = 1;}
63 $ext =~ s/\.ogg/\.ttf/g;
64 if (-e "$cwd/$ext") { system("echo \"$PREFIX/$cwd/$ext\" >> $LICFILE"); $match = 1;}
65 $ext =~ s/\.ttf/\.png/g;
66 if (-e "$cwd/$ext") { system("echo \"$PREFIX/$cwd/$ext\" >> $LICFILE"); $match = 1;}
67 if ($match == 0) { system("echo \"$PREFIX/$cwd/$entry\" >> $LICFILE"); }
68 system("cat $cwd/$entry >> $LICFILE ; echo \"\n\" >> $LICFILE ; rm -f $cwd/$entry");
69 }
70 }
71 }
72 }