Show
Ignore:
Timestamp:
09/19/07 22:25:41 (6 years ago)
Author:
p_lindheimer
Message:

add publish script for contribued modules

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • contributed_modules/modules/publish.pl

    r4841 r5048  
    11#!/usr/bin/perl 
    22 
    3 #  Developers: Use $debug to keep all svn ci activity from occuring, messages will then be printed. All files will still be created 
    4 #              and module.xml modifications made since these can be reverted. Review carefully if you care concerned that it will 
    5 #              lose work. 
    6 # 
    73$debug = 0; 
    8 $checkphp = 1; 
    9 $rver = "2.3"; 
    10 $fwbranch = "branches/2.3"; 
    11 $framework = "framework"; 
    124 
    135my $reldir = "release/"; 
     
    157while ($moddir = shift @ARGV) { 
    168  next if (!-d $moddir); 
    17   if ($moddir =~ /$framework/) { 
    18  
    19     # Framework module is special case. We export and pull in all the files of framework that we are going to want to udpate. For now this is 
    20     # all files under htdocs, agi-bin and bin. We have not included astetc since such files should be done with core modules. We have also 
    21     # temporarily chosen not to include FOP since it is likely FOP may be handled by a FOP module going forward. Othewise we will add it here. 
    22     # 
    23     # TODO: ADD FOP until we can get into a module 
    24     # 
    25     if (system("rm -rf $framework/agi-bin $framework/bin $framework/htdocs $framework/htdocs_panel $framework/upgrades $framework/libfreepbx.install.php")) { 
    26       die "FATAL: failed to remove previoulsly exported directories\n"; 
    27     } 
    28     if (system("svn export https://amportal.svn.sourceforge.net/svnroot/amportal/freepbx/$fwbranch/amp_conf/agi-bin $framework/agi-bin")) { 
    29       die "FATAL: failed to export agi-bin directory\n"; 
    30     } 
    31     if (system("svn export https://amportal.svn.sourceforge.net/svnroot/amportal/freepbx/$fwbranch/amp_conf/bin $framework/bin")) { 
    32       die "FATAL: failed to export bin directory\n"; 
    33     } 
    34     if (system("svn export https://amportal.svn.sourceforge.net/svnroot/amportal/freepbx/$fwbranch/amp_conf/htdocs $framework/htdocs")) { 
    35       die "FATAL: failed to export htdocs directory\n"; 
    36     } 
    37     if (system("svn export https://amportal.svn.sourceforge.net/svnroot/amportal/freepbx/$fwbranch/amp_conf/htdocs_panel $framework/htdocs_panel")) { 
    38       die "FATAL: failed to export htdocs_panel directory\n"; 
    39     } 
    40     if (system("svn export https://amportal.svn.sourceforge.net/svnroot/amportal/freepbx/$fwbranch/upgrades $framework/upgrades")) { 
    41       die "FATAL: failed to export upgrades directory\n"; 
    42     } 
    43     # svn doesn't seem to allow for a single file to be checked out so we need to do a kludgey workaround 
    44     # this is what we wanted: 
    45     # 
    46     # if (system("svn export https://amportal.svn.sourceforge.net/svnroot/amportal/freepbx/$fwbranch/libfreepbx.install.php $framework/libfreepbx.install.php")) 
    47     # 
    48     if (system("svn co --non-recursive https://amportal.svn.sourceforge.net/svnroot/amportal/freepbx/$fwbranch $framework/tmp")) { 
    49       die "FATAL: failed to checkout branch with libfreepbx.install.php\n"; 
    50     } 
    51     # Create the svnversion information for this framework snapshot 
    52     # 
    53     if (system("echo SVN VERSION: `svnversion $framework/tmp` > $framework/svnversion.txt")) { 
    54       die "FATAL: svnversion failed to create svnversion.txt\n"; 
    55     } 
    56  
    57     if (system("mv $framework/tmp/libfreepbx.install.php $framework/")) { 
    58       die "FATAL: failed to mv libfreepbx.install.php to $framework\n"; 
    59     } 
    60     if (system("rm -rf $framework/tmp")) { 
    61       die "FATAL: failed to remove $framework/tmp\n"; 
    62     } 
    63  
    64     # Now we must remove a few files which users may have legitimately edited. For now this is the main.conf.php file which is the current 
    65     # ARI file used for editing paramters and options. 
    66     # 
    67     if (system("rm -rf $framework/htdocs/recordings/includes/main.conf.php")) { 
    68       die "FATAL: failed to trim main.conf.php ARI file\n"; 
    69     } 
    70      
    71     # Remove from htdocs root mainstyle.css and index.html as these are owned by root (need to investigate why these are there 
    72     # and change that. Also some others 
    73     # 
    74     # TODO: check if these are stiff there and need to be special cased 
    75     # 
    76     if (system("rm -rf $framework/htdocs/mainstyle.css")) { 
    77       die "FATAL: failed to trim htdocs/mainstyle.css\n"; 
    78     } 
    79     if (system("rm -rf $framework/htdocs/index.html")) { 
    80       die "FATAL: failed to trim htdocs/index.html\n"; 
    81     } 
    82     if (system("rm -rf $framework/htdocs/admin/modules/_cache")) { 
    83       die "FATAL: failed to trim modules/_cache\n"; 
    84     } 
    85   } 
    86  
    879  open FH, "$moddir/module.xml";  
    8810  $newxml = ""; 
     
    10123  @arr = <*>; 
    10224  $files = ""; 
    103   if ($moddir =~ /$framework/) { 
    104     while ($x = shift @arr) { 
    105       # Excluding module.xml which gets checked in later.. 
    106       next if ($x =~ /module.xml/); 
    107       next if ($x =~ /agi-bin/); 
    108       next if ($x =~ /bin/); 
    109       next if ($x =~ /htdocs/); 
    110       next if ($x =~ /htdocs_panel/); 
    111       next if ($x =~ /upgrades/); 
    112       next if ($x =~ /libfreepbx.install.php/); 
    113       next if ($x =~ /svnversion.txt/); 
    114       $files .= "$x "; 
    115     } 
    116   } else { 
    117     while ($x = shift @arr) { 
    118       # Excluding module.xml which gets checked in later.. 
    119       next if ($x =~ /module.xml/); 
    120       $files .= "$x "; 
    121  
    122       # Quick and dirty check for php syntax errors at the top level of module directories. Should probably 
    123       # do this recursively in the future. Also - checks all files now but php -l seems to be ok with that. 
    124       # 
    125       if (-f $x && $checkphp) { 
    126         if (system("php -l $x")) { 
    127           die "FATAL: php syntax error detected in $x\n"; 
    128         } 
    129       } 
    130     } 
     25  while ($x = shift @arr) { 
     26    # Excluding module.xml which gets checked in later.. 
     27    next if ($x =~ /module.xml/); 
     28    $files .= "$x "; 
    13129  } 
    13230  if ($debug) { 
     
    14543  ($md5sum, $null) = split(/ /, $md5); 
    14644  $newxml =~ s/<md5sum>.+<\/md5sum>/<md5sum>$md5sum<\/md5sum>/; 
    147   $newxml =~ s/<location>.+<\/location>/<location>$reldir$rver\/$filename<\/location>/; 
     45  $newxml =~ s/<location>.+<\/location>/<location>$reldir\/$filename<\/location>/; 
    14846  open FH, ">$moddir/module.xml"; 
    14947  print FH $newxml; 
    15048  close FH; 
     49  system("mv $filename ../release/"); 
     50  system("svn add ../release/$filename"); 
     51  system("svn ps svn:mime-type application/tgz ../release/$filename"); 
     52  system("svn ci ../release/$filename $rawname/module.xml -m \"Module Publish Script: $rawname $vers\""); 
    15153  if ($debug) { 
    152     print "mv $filename ../../release/$rver\n"; 
    153     print "svn add ../../release/$rver/$filename\n"; 
    154     print "svn ps svn:mime-type application/tgz ../../release/$rver/$filename\n"; 
    155     print "svn ci ../../release/$rver/$filename $rawname/module.xml -m \"Module Publish Script: $rawname $vers\"\n"; 
     54    print "mv $filename ../release/\n"; 
     55    print "svn add ../release/$filename\n"; 
     56    print "svn ps svn:mime-type application/tgz ../release/$filename\n"; 
     57    print "svn ci ../release/$filename $rawname/module.xml -m \"Module Publish Script: $rawname $vers\"\n"; 
    15658  } else { 
    157     system("mv $filename ../../release/$rver"); 
    158     system("svn add ../../release/$rver/$filename"); 
    159     system("svn ps svn:mime-type application/tgz ../../release/$rver/$filename"); 
    160     system("svn ci ../../release/$rver/$filename $rawname/module.xml -m \"Module Publish Script: $rawname $vers\""); 
     59    system("mv $filename ../release/"); 
     60    system("svn add ../release/$filename"); 
     61    system("svn ps svn:mime-type application/tgz ../release/$filename"); 
     62    system("svn ci ../release/$filename $rawname/module.xml -m \"Module Publish Script: $rawname $vers\""); 
    16163  } 
    16264}