Skip to content

Commit

Permalink
Clean tool to generate checksum file
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Feb 24, 2015
1 parent 4e4df4f commit cae8210
Show file tree
Hide file tree
Showing 3 changed files with 12,535 additions and 35 deletions.
45 changes: 43 additions & 2 deletions build/generate_filecheck_xml.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,50 @@
#!/usr/bin/php
<?php
/* Copyright (C) 2015 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/**
* \file build/generate_filecheck_xml.php
* \ingroup dev
* \brief This script create a xml checksum file
*/

$sapi_type = php_sapi_name();
$script_file = basename(__FILE__);
$path=dirname(__FILE__).'/';

// Test if batch mode
if (substr($sapi_type, 0, 3) == 'cgi') {
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
exit;
}


// Main
parse_str($argv[1]);
$fp = fopen(dirname(__FILE__).'/../htdocs/core/filelist-'.$release.'.xml','w');
#$outputfile=dirname(__FILE__).'/../htdocs/install/filelist-'.$release.'.xml';
$outputfile=dirname(__FILE__).'/../htdocs/install/filelist.xml';
$fp = fopen($outputfile,'w');
fputs($fp, '<?xml version="1.0" encoding="UTF-8" ?>'."\n");
fputs($fp, '<checksum_list>'."\n");
fputs($fp, '<dolibarr_root_dir version="'.$release.'">'."\n");
$dir_iterator = new RecursiveDirectoryIterator(dirname(__FILE__).'/../htdocs/');
$iterator = new RecursiveIteratorIterator($dir_iterator);
// need to ignore document custom etc
$files = new RegexIterator($iterator, '#^(?:[A-Z]:)?(?:/(?!(?:custom|documents|conf|install))[^/]+)+/[^/]+\.(?:php|html|js|json|tpl|jpg|png|gif|sql|lang)$#i');
$files = new RegexIterator($iterator, '#^(?:[A-Z]:)?(?:/(?!(?:custom|documents|conf|install|nltechno))[^/]+)+/[^/]+\.(?:php|css|html|js|json|tpl|jpg|png|gif|sql|lang)$#i');
$dir='';
$needtoclose=0;
foreach ($files as $file) {
Expand All @@ -27,3 +64,7 @@
fputs($fp, '</dolibarr_root_dir>'."\n");
fputs($fp, '</checksum_list>'."\n");
fclose($fp);

print "File ".$outputfile." generated\n";

exit(0);
74 changes: 41 additions & 33 deletions build/makepack-dolibarr.pl
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,10 @@
my $NUM_SCRIPT;
my $cpt=0;
while (! $found) {
$cpt=-1;
printf(" %2d - %-14s (%s)\n",$cpt,"XML Filecheck","Done in all case");
$cpt=0;
printf(" %2d - %-14s (%s)\n",$cpt,"ALL (1..9)","Need ".join(",",values %REQUIREMENTTARGET));
printf(" %2d - %-14s (%s)\n",$cpt,"ALL (1..10)","Need ".join(",",values %REQUIREMENTTARGET));
$cpt++;
printf(" %2d - %-14s\n",$cpt,"Generate check file");
foreach my $target (@LISTETARGET) {
$cpt++;
printf(" %2d - %-14s (%s)\n",$cpt,$target,"Need ".$REQUIREMENTTARGET{$target});
Expand All @@ -218,7 +218,7 @@
printf(" %2d - %-14s (%s)\n",$cpt,"SF (publish)","Need ".join(",",values %REQUIREMENTPUBLISH));

# Ask which target to build
print "Choose one package number or several separated with space (0 - ".$cpt."): ";
print "Choose one target number or several separated with space (0 - ".$cpt."): ";
$NUM_SCRIPT=<STDIN>;
chomp($NUM_SCRIPT);
if ($NUM_SCRIPT !~ /^[0-9\s]+$/)
Expand All @@ -235,30 +235,30 @@
if ($NUM_SCRIPT eq "98") {
$CHOOSEDPUBLISH{"ASSO"}=1;
}
else
{
if ($NUM_SCRIPT eq "99") {
$CHOOSEDPUBLISH{"SF"}=1;
elsif ($NUM_SCRIPT eq "99") {
$CHOOSEDPUBLISH{"SF"}=1;
}
elsif ($NUM_SCRIPT eq "0") {
$CHOOSEDTARGET{"-CHKSUM"}=1;
foreach my $key (@LISTETARGET) {
if ($key ne 'SNAPSHOT' && $key ne 'ASSO' && $key ne 'SF') { $CHOOSEDTARGET{$key}=1; }
}
else {
if ($NUM_SCRIPT eq "0") {
foreach my $key (@LISTETARGET) {
if ($key ne 'SNAPSHOT' && $key ne 'ASSO' && $key ne 'SF') { $CHOOSEDTARGET{$key}=1; }
}
}
else {
foreach my $num (split(/\s+/,$NUM_SCRIPT)) {
$CHOOSEDTARGET{$LISTETARGET[$num-1]}=1;
}
}
}
elsif ($NUM_SCRIPT eq "1") {
$CHOOSEDTARGET{"-CHKSUM"}=1
}
else {
foreach my $num (split(/\s+/,$NUM_SCRIPT)) {
$CHOOSEDTARGET{$LISTETARGET[$num-2]}=1;
}
}
}


# Test if requirement is ok
#--------------------------
$atleastonerpm=0;
foreach my $target (keys %CHOOSEDTARGET) {
foreach my $target (sort keys %CHOOSEDTARGET) {
if ($target =~ /RPM/i)
{
if ($atleastonerpm && ($DESTI eq "$SOURCE/build"))
Expand Down Expand Up @@ -300,20 +300,32 @@

print "\n";

# Build xml check file
#-----------------------
if ($CHOOSEDTARGET{'-CHKSUM'})
{
print 'Create xml check file with md5 checksum with command php '.$SOURCE.'/build/generate_filecheck_xml.php release='.$MAJOR.'.'.$MINOR.'.'.$BUILD."\n";
$ret=`php $SOURCE/build/generate_filecheck_xml.php release=$MAJOR.$MINOR.$BUILD`;
print $ret."\n";
}


#print join(',',sort keys %CHOOSEDTARGET)."\n";

# Check if there is at least one target to build
#----------------------------------------------
$nboftargetok=0;
$nboftargetneedbuildroot=0;
$nbofpublishneedtag=0;
foreach my $target (keys %CHOOSEDTARGET) {
foreach my $target (sort keys %CHOOSEDTARGET) {
if ($CHOOSEDTARGET{$target} < 0) { next; }
if ($target ne 'EXE' && $target ne 'EXEDOLIWAMP')
if ($target ne 'EXE' && $target ne 'EXEDOLIWAMP' && $target ne '-CHKSUM')
{
$nboftargetneedbuildroot++;
}
$nboftargetok++;
}
foreach my $target (keys %CHOOSEDPUBLISH) {
foreach my $target (sort keys %CHOOSEDPUBLISH) {
if ($CHOOSEDPUBLISH{$target} < 0) { next; }
if ($target eq 'ASSO') { $nbofpublishneedtag++; }
if ($target eq 'SF') { $nbofpublishneedtag++; }
Expand All @@ -322,12 +334,6 @@

if ($nboftargetok) {

# Build xml check file
#-----------------------
print 'Create xml check file with md5 checksum'."\n";
$FULLDIRECTORY = cwd();
$ret=`php $FULLDIRECTORY/generate_filecheck_xml.php release=$MAJOR.$MINOR.$BUILD`;

# Update CVS if required
#-----------------------
if ($nbofpublishneedtag)
Expand Down Expand Up @@ -483,10 +489,11 @@

# Build package for each target
#------------------------------
foreach my $target (keys %CHOOSEDTARGET)
foreach my $target (sort keys %CHOOSEDTARGET)
{
if ($CHOOSEDTARGET{$target} < 0) { next; }

if ($target eq '-CHKSUM') { next; }

print "\nBuild package for target $target\n";

if ($target eq 'SNAPSHOT')
Expand Down Expand Up @@ -988,7 +995,7 @@

# Publish package for each target
#--------------------------------
foreach my $target (keys %CHOOSEDPUBLISH)
foreach my $target (sort keys %CHOOSEDPUBLISH)
{
if ($CHOOSEDPUBLISH{$target} < 0) { next; }

Expand Down Expand Up @@ -1071,7 +1078,8 @@
}

print "\n----- Summary -----\n";
foreach my $target (keys %CHOOSEDTARGET) {
foreach my $target (sort keys %CHOOSEDTARGET) {
if ($target eq '-CHKSUM') { print "Checksum was generated"; next; }
if ($CHOOSEDTARGET{$target} < 0) {
print "Package $target not built (bad requirement).\n";
} else {
Expand Down

0 comments on commit cae8210

Please sign in to comment.