root/contributed_modules/modules/publish.pl

Revision 7056, 2.1 kB (checked in by Nick_Lewis, 3 months ago)

another go to correct my publish perl floundering

  • Property svn:mime-type set to text/plain
  • Property svn_eol-style set to native
  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1 #!/usr/bin/perl
2
3 $debug = 0;
4
5 my $reldir = "release";
6
7 while ($moddir = shift @ARGV) {
8         if (($moddir eq "-h") || ($moddir eq "-help") || ($moddir eq "--h") || ($moddir eq "--help")) {
9                 die "Usage: publish <moduledirectory> [moduledirectory]\n";
10         }
11         next if (!-d $moddir);
12         open FH, "$moddir/module.xml";
13         $newxml = "";
14         $vers = "unset";
15         $rawname = "unset";
16         while (<FH>) {
17                 if ($vers == 'unset' && /<version>(.+)<\/version>/) { $vers = $1; }
18                 if (/<rawname>(.+)<\/rawname>/) { $rawname = $1; }
19                 $newxml .= $_;
20         }
21         close FH;
22         die "Don't know version of $moddir" if ($vers eq "unset");
23         die "Don't know rawname of $moddir" if ($rawname eq "unset");
24         # Automatically check in any files that were modified but weren't checked into SVN
25         chdir($moddir);
26         @arr = <*>;
27         $files = "";
28         while ($x = shift @arr) {
29                 # Excluding module.xml which gets checked in later..
30                 next if ($x =~ /module.xml/);
31                 $files .= "$x ";
32         }
33         if ($debug) {
34                 print "svn ci -m \"Auto Check-in of any outstanding patches\" $files\n";
35         } else {
36                 system("svn ci -m \"Auto Check-in of any outstanding patches\" $files");
37         }
38         chdir("..");
39         # Now we know the version. Create the tar.gz
40         $filename = "$rawname-$vers.tgz";
41         system("tar zcf $filename --exclude .svn $rawname");
42         # Update the md5 info
43         open MD5, "md5sum $filename|";
44         $md5 = <MD5>;
45         close MD5;
46         ($md5sum, $null) = split(/ /, $md5);
47         $newxml =~ s/<md5sum>.+<\/md5sum>/<md5sum>$md5sum<\/md5sum>/;
48         $newxml =~ s/<location>.+<\/location>/<location>$reldir\/$filename<\/location>/;
49         open FH, ">$moddir/module.xml";
50         print FH $newxml;
51         close FH;
52         if ($debug) {
53                 print "mv $filename ../release/\n";
54                 print "svn add ../release/$filename\n";
55                 print "svn ps svn:mime-type application/tgz ../release/$filename\n";
56                 print "svn ci ../release/$filename $rawname/module.xml -m \"Module Publish Script: $rawname $vers\"\n";
57         } else {
58                 system("mv $filename ../release/");
59                 system("svn add ../release/$filename");
60                 system("svn ps svn:mime-type application/tgz ../release/$filename");
61                 system("svn ci ../release/$filename $rawname/module.xml -m \"Module Publish Script: $rawname $vers\"");
62         }
63 }
Note: See TracBrowser for help on using the browser.