root/modules/branches/2.8/publish.pl

Revision 11611, 12.5 kB (checked in by p_lindheimer, 1 year ago)

Merged revisions 11610 via svnmerge from
http://www.freepbx.org/v2/svn/modules/branches/2.9

........

r11610 | p_lindheimer | 2011-02-27 15:40:01 -0800 (Sun, 27 Feb 2011) | 1 line


don't include any '.' hidden directory/file in the tarball

........

  • 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 #  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 #
7 system("which md5sum"); # typical linux format
8 if ($? == 0) {
9     $md5_command = 'md5sum';
10 } else {
11   system("which md5"); # OSX format
12   if ($? == 0) {
13     $md5_command = 'md5 -r';
14   } else {
15     die "no md5sum command\n";
16   }
17 }
18
19 $debug = 0;
20 $checkphp = 1;
21 $rver = "2.8";
22 $fwbranch = "branches/2.8";
23 $framework = "framework";
24 $fw_fop = "fw_fop";
25 $fw_ari = "fw_ari";
26 $fw_langpacks = "fw_langpacks";
27
28 my $reldir = "release/";
29
30 while ($moddir = shift @ARGV) {
31   next if (!-d $moddir);
32   # Check the XML integrity using the FreePBX XML parser
33   if (system("./check_xml.php $moddir")) {
34     die "Fatal syntax error with $moddir module.xml file, aborting\n";
35   }
36   if ($moddir =~ /$framework/) {
37
38     # 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
39     # 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
40     # 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.
41     #
42     #
43     if (system("rm -rf $framework/agi-bin $framework/bin $framework/htdocs $framework/htdocs_panel $framework/upgrades $framework/libfreepbx.install.php $framework/CHANGES")) {
44       die "FATAL: failed to remove previoulsly exported directories\n";
45     }
46     if (system("svn export http://svn.freepbx.org/freepbx/$fwbranch/amp_conf/agi-bin $framework/agi-bin")) {
47       die "FATAL: failed to export agi-bin directory\n";
48     }
49     if (system("svn export http://svn.freepbx.org/freepbx/$fwbranch/amp_conf/bin $framework/bin")) {
50       die "FATAL: failed to export bin directory\n";
51     }
52     if (system("svn export http://svn.freepbx.org/freepbx/$fwbranch/amp_conf/htdocs $framework/htdocs")) {
53       die "FATAL: failed to export htdocs directory\n";
54     }
55     if (system("svn export http://svn.freepbx.org/freepbx/$fwbranch/upgrades $framework/upgrades")) {
56       die "FATAL: failed to export upgrades directory\n";
57     }
58     # svn doesn't seem to allow for a single file to be checked out so we need to do a kludgey workaround
59     # this is what we wanted:
60     #
61     # if (system("svn export http://svn.freepbx.org/freepbx/$fwbranch/libfreepbx.install.php $framework/libfreepbx.install.php"))
62     #
63     if (system("svn co --non-recursive http://svn.freepbx.org/freepbx/$fwbranch $framework/tmp")) {
64       die "FATAL: failed to checkout branch with libfreepbx.install.php\n";
65     }
66     # Create the svnversion information for this framework snapshot
67     #
68     if (system("echo SVN VERSION: `svnversion $framework/tmp` > $framework/svnversion.txt")) {
69       die "FATAL: svnversion failed to create svnversion.txt\n";
70     }
71
72     if (system("mv $framework/tmp/libfreepbx.install.php $framework/")) {
73       die "FATAL: failed to mv libfreepbx.install.php to $framework\n";
74     }
75     if (system("mv $framework/tmp/CHANGES $framework/")) {
76       die "FATAL: failed to mv CHANGES to $framework\n";
77     }
78     if (system("rm -rf $framework/tmp")) {
79       die "FATAL: failed to remove $framework/tmp\n";
80     }
81
82     # Now we must remove a few files which users may have legitimately edited. For now, all of ARI moved to new module
83     # ARI file used for editing paramters and options.
84     #
85     if (system("rm -rf $framework/htdocs/recordings")) {
86       die "FATAL: failed to trim main.conf.php ARI file\n";
87     }
88    
89     # Remove from htdocs root mainstyle.css and index.html as these are owned by root (need to investigate why these are there
90     # and change that. Remove retrieve_op_conf_from_mysql.pl now handled by fw_fop. Also some others.
91     #
92     # TODO: check if these are stiff there and need to be special cased
93     #
94     if (system("rm -rf $framework/htdocs/mainstyle.css")) {
95       die "FATAL: failed to trim htdocs/mainstyle.css\n";
96     }
97     if (system("rm -rf $framework/htdocs/index.html")) {
98       die "FATAL: failed to trim htdocs/index.html\n";
99     }
100     if (system("rm -rf $framework/htdocs/robots.txt")) {
101       die "FATAL: failed to trim htdocs/robots.txt\n";
102     }
103     if (system("rm -rf $framework/htdocs/admin/modules/_cache")) {
104       die "FATAL: failed to trim modules/_cache\n";
105     }
106     if (system("rm -rf $framework/bin/retrieve_op_conf_from_mysql.php")) {
107       die "FATAL: failed to trim bin/retrieve_op_conf_from_mysql.php\n";
108     }
109   }
110   if ($moddir =~ /$fw_fop/) {
111     if (system("rm -rf $fw_fop/bin $fw_fop/htdocs_panel")) {
112       die "FATAL: failed to remove previoulsly exported directories\n";
113     }
114     if (system("svn export http://svn.freepbx.org/freepbx/$fwbranch/amp_conf/htdocs_panel $fw_fop/htdocs_panel")) {
115       die "FATAL: failed to export htdocs_panel directory\n";
116     }
117     if (system("svn co --non-recursive http://svn.freepbx.org/freepbx/$fwbranch/amp_conf/bin $fw_fop/tmp")) {
118       die "FATAL: failed to checkout bin\n";
119     }
120     if (system("mkdir $fw_fop/bin")) {
121       die "FATAL: failed to create $fw_fop/bin\n";
122     }
123     if (system("mv $fw_fop/tmp/retrieve_op_conf_from_mysql.php $fw_fop/bin")) {
124       die "FATAL: failed to mv retrieve_op_conf_from_mysql.php to $fw_fop/bin\n";
125     }
126     if (system("rm -rf $fw_fop/tmp")) {
127       die "FATAL: failed to remove $fw_fop/tmp\n";
128     }
129
130     # Create the svnversion information for this framework snapshot
131     #
132     if (system("echo SVN VERSION: `svn log -q -r HEAD http://svn.freepbx.org/ | cut -s -f 1 -d ' ' | cut -b '2-'` > $fw_fop/svnversion.txt")) {
133       die "FATAL: svnversion failed to create svnversion.txt\n";
134     }
135
136   }
137   if ($moddir =~ /$fw_ari/) {
138
139     if (system("rm -rf $fw_ari/htdocs_ari")) {
140       die "FATAL: failed to remove previoulsly exported directories\n";
141     }
142
143     # Create the svnversion information for this framework snapshot
144     #
145     if (system("echo SVN VERSION: `svn log -q -r HEAD http://svn.freepbx.org/ | cut -s -f 1 -d ' ' | cut -b '2-'` > $fw_ari/svnversion.txt")) {
146       die "FATAL: svnversion failed to create svnversion.txt\n";
147     }
148
149     if (system("svn export http://svn.freepbx.org/freepbx/$fwbranch/amp_conf/htdocs/recordings $fw_ari/htdocs_ari")) {
150       die "FATAL: failed to export htdocs directory\n";
151     }
152
153     # 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
154     # ARI file used for editing paramters and options.
155     #
156     if (system("rm -rf $fw_ari/htdocs_ari/includes/main.conf.php")) {
157       die "FATAL: failed to trim main.conf.php ARI file\n";
158     }
159
160   }
161   if ($moddir =~ /$fw_langpacks/) {
162
163     my $module_url="http://svn.freepbx.org/modules/branches/$rver";
164     my $base_url="http://svn.freepbx.org/freepbx/$fwbranch/amp_conf/htdocs";
165     my $framework_url="$base_url/admin";
166     my $recordings_url="$base_url/recordings";
167
168     @modules=`svn list $module_url | grep '/'`;
169
170     if (system("rm -rf $fw_langpacks/htdocs")) {
171       die "FATAL: failed to remove old htdocs dir\n";
172     }
173     if (system("mkdir -p $fw_langpacks/htdocs/admin/modules")) {
174       die "FATAL: failed to create htdocs/admin/modules\n";
175     }
176     if (system("mkdir -p $fw_langpacks/htdocs/recordings")) {
177       die "FATAL: failed to create htdocs/recordings\n";
178     }
179
180     if (system("svn export $framework_url/i18n $fw_langpacks/htdocs/admin/i18n")) {
181       die "FATAL: failed to export $framework_url/i18n\n";
182     }
183     if (system("svn export $recordings_url/locale $fw_langpacks/htdocs/recordings/locale")) {
184       die "FATAL: failed to export $recurdings_url/locale\n";
185     }
186     foreach my $module ( @modules ) {
187       chomp($module);
188       if (system("rm -rf $fw_langpacks/i18n-tmp")) {
189         die "FATAL: failed to remove temp i18n-tmp dir\n";
190       }
191       system("svn export $module_url/$module"."i18n $fw_langpacks/i18n-tmp 2> /dev/null");
192       if (($? != -1) && (-d "$fw_langpacks/i18n-tmp")) {
193         if (system("mkdir $fw_langpacks/htdocs/admin/modules/$module")) {
194           die "FATAL: failed to create htdocs/admin/modules/$module\n";
195         }
196         if (system("mv $fw_langpacks/i18n-tmp $fw_langpacks/htdocs/admin/modules/$module/i18n")) {
197           die "FATAL: failed to move i18n-tmp to htdocs/admin/modules/$module/i18n\n";
198         }
199       } else {
200         print "No i18n files for $module"."\n";
201       }
202     }
203
204
205     # Create the svnversion information for this framework snapshot
206     #
207     if (system("echo SVN VERSION: `svn log -q -r HEAD http://svn.freepbx.org/ | cut -s -f 1 -d ' ' | cut -b '2-'` > $fw_langpacks/svnversion.txt")) {
208       die "FATAL: svnversion failed to create svnversion.txt\n";
209     }
210
211   }
212
213   open FH, "$moddir/module.xml";
214   $newxml = "";
215   $vers = "unset";
216   $rawname = "unset";
217   while (<FH>) {
218     if ($vers == 'unset' && /<version>(.+)<\/version>/) { $vers = $1; }
219     if (/<rawname>(.+)<\/rawname>/) { $rawname = $1; }
220     $newxml .= $_;
221   }
222   close FH;
223   die "Don't know version of $moddir" if ($vers eq "unset");
224   die "Don't know rawname of $moddir" if ($rawname eq "unset");
225   # Automatically check in any files that were modified but weren't checked into SVN
226   chdir($moddir);
227   @arr = <*>;
228   $files = "";
229   if ($moddir =~ /$framework/) {
230     while ($x = shift @arr) {
231       # Excluding module.xml which gets checked in later..
232       next if ($x =~ /module.xml/);
233       next if ($x =~ /agi-bin/);
234       next if ($x =~ /bin/);
235       next if ($x =~ /htdocs/);
236       next if ($x =~ /htdocs_panel/);
237       next if ($x =~ /upgrades/);
238       next if ($x =~ /libfreepbx.install.php/);
239       next if ($x =~ /svnversion.txt/);
240       $files .= "$x ";
241       if (-f $x && $checkphp) {
242         if (system("php -l $x")) {
243           die "FATAL: php syntax error detected in $x\n";
244         }
245       }
246     }
247   } elsif ($moddir =~ /$fw_fop/) {
248     while ($x = shift @arr) {
249       next if ($x =~ /module.xml/);
250       next if ($x =~ /htdocs_panel/);
251       next if ($x =~ /svnversion.txt/);
252       $files .= "$x ";
253       if (-f $x && $checkphp) {
254         if (system("php -l $x")) {
255           die "FATAL: php syntax error detected in $x\n";
256         }
257       }
258     }
259   } elsif ($moddir =~ /$fw_ari/) {
260     while ($x = shift @arr) {
261       next if ($x =~ /module.xml/);
262       next if ($x =~ /htdocs_ari/);
263       next if ($x =~ /svnversion.txt/);
264       $files .= "$x ";
265       if (-f $x && $checkphp) {
266         if (system("php -l $x")) {
267           die "FATAL: php syntax error detected in $x\n";
268         }
269       }
270     }
271   } elsif ($moddir =~ /$fw_langpacks/) {
272     while ($x = shift @arr) {
273       next if ($x =~ /module.xml/);
274       next if ($x =~ /htdocs/);
275       next if ($x =~ /svnversion.txt/);
276       $files .= "$x ";
277       if (-f $x && $checkphp) {
278         if (system("php -l $x")) {
279           die "FATAL: php syntax error detected in $x\n";
280         }
281       }
282     }
283   } else {
284     while ($x = shift @arr) {
285       # Excluding module.xml which gets checked in later..
286       next if ($x =~ /module.xml/);
287       $files .= "$x ";
288
289       # Quick and dirty check for php syntax errors at the top level of module directories. Should probably
290       # do this recursively in the future. Also - checks all files now but php -l seems to be ok with that.
291       #
292       if (-f $x && $checkphp) {
293         if (!($x =~ /.*\.jar/) && system("php -l $x") ) {
294           die "FATAL: php syntax error detected in $x\n";
295         }
296       }
297     }
298   }
299   if ($debug) {
300     print "svn ci -m \"Auto Check-in of any outstanding patches\" $files\n";
301   } else {
302     system("svn ci -m \"Auto Check-in of any outstanding patches\" $files");
303   }
304   chdir("..");
305   # Now we know the version. Create the tar.gz
306   $filename = "$rawname-$vers.tgz";
307   system("tar zcf $filename --exclude '.*' $rawname");
308   # Update the md5 info
309   open MD5, "$md5_command $filename|";
310   $md5 = <MD5>;
311   close MD5;
312   ($md5sum, $null) = split(/ /, $md5);
313
314        unless ($newxml =~ s/<md5sum>.*<\/md5sum>/<md5sum>$md5sum<\/md5sum>/)
315        {
316                $newxml =~ s|</module>|<md5sum>$md5sum></md5sum>\n</module>|;
317        }
318
319        unless ($newxml =~ s/<location>.*<\/location>/<location>$reldir$rver\/$filename<\/location>/)
320        {
321                $newxml =~ s|</module>|<location>$reldir$rver></location>\n</module>|;
322        }
323
324   open FH, ">$moddir/module.xml";
325   print FH $newxml;
326   close FH;
327
328   system("svn update $rawname");
329   my $lastpublish = `svn info $rawname | grep Revision: | cut -f 2 -d ' '`;
330   chomp($lastpublish);
331
332   if ($debug) {
333     print "mv $filename ../../release/$rver\n";
334     print "svn add ../../release/$rver/$filename\n";
335     print "svn ps svn:mime-type application/tgz ../../release/$rver/$filename\n";
336     print "svn ps lastpublish '$lastpublish' $moddir\n";
337     print "svn ci ../../release/$rver/$filename $rawname/module.xml -m \"Module Publish Script: $rawname $vers\"\n";
338   } else {
339     system("mv $filename ../../release/$rver");
340     system("svn add ../../release/$rver/$filename");
341     system("svn ps svn:mime-type application/tgz ../../release/$rver/$filename");
342     system("svn ps lastpublish '$lastpublish' $rawname");
343     system("svn ci ../../release/$rver/$filename $rawname/module.xml ./$rawname -m \"Module Publish Script: $rawname $vers\"");
344   }
345 }
Note: See TracBrowser for help on using the browser.