Skip to content
Snippets Groups Projects
Commit cae82104 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Clean tool to generate checksum file

parent 4e4df4fa
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/php
<?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]); 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, '<?xml version="1.0" encoding="UTF-8" ?>'."\n");
fputs($fp, '<checksum_list>'."\n"); fputs($fp, '<checksum_list>'."\n");
fputs($fp, '<dolibarr_root_dir version="'.$release.'">'."\n"); fputs($fp, '<dolibarr_root_dir version="'.$release.'">'."\n");
$dir_iterator = new RecursiveDirectoryIterator(dirname(__FILE__).'/../htdocs/'); $dir_iterator = new RecursiveDirectoryIterator(dirname(__FILE__).'/../htdocs/');
$iterator = new RecursiveIteratorIterator($dir_iterator); $iterator = new RecursiveIteratorIterator($dir_iterator);
// need to ignore document custom etc // 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=''; $dir='';
$needtoclose=0; $needtoclose=0;
foreach ($files as $file) { foreach ($files as $file) {
...@@ -27,3 +64,7 @@ fputs($fp, '</dir>'."\n"); ...@@ -27,3 +64,7 @@ fputs($fp, '</dir>'."\n");
fputs($fp, '</dolibarr_root_dir>'."\n"); fputs($fp, '</dolibarr_root_dir>'."\n");
fputs($fp, '</checksum_list>'."\n"); fputs($fp, '</checksum_list>'."\n");
fclose($fp); fclose($fp);
print "File ".$outputfile." generated\n";
exit(0);
...@@ -204,10 +204,10 @@ else { ...@@ -204,10 +204,10 @@ else {
my $NUM_SCRIPT; my $NUM_SCRIPT;
my $cpt=0; my $cpt=0;
while (! $found) { while (! $found) {
$cpt=-1;
printf(" %2d - %-14s (%s)\n",$cpt,"XML Filecheck","Done in all case");
$cpt=0; $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) { foreach my $target (@LISTETARGET) {
$cpt++; $cpt++;
printf(" %2d - %-14s (%s)\n",$cpt,$target,"Need ".$REQUIREMENTTARGET{$target}); printf(" %2d - %-14s (%s)\n",$cpt,$target,"Need ".$REQUIREMENTTARGET{$target});
...@@ -218,7 +218,7 @@ else { ...@@ -218,7 +218,7 @@ else {
printf(" %2d - %-14s (%s)\n",$cpt,"SF (publish)","Need ".join(",",values %REQUIREMENTPUBLISH)); printf(" %2d - %-14s (%s)\n",$cpt,"SF (publish)","Need ".join(",",values %REQUIREMENTPUBLISH));
# Ask which target to build # 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>; $NUM_SCRIPT=<STDIN>;
chomp($NUM_SCRIPT); chomp($NUM_SCRIPT);
if ($NUM_SCRIPT !~ /^[0-9\s]+$/) if ($NUM_SCRIPT !~ /^[0-9\s]+$/)
...@@ -235,30 +235,30 @@ else { ...@@ -235,30 +235,30 @@ else {
if ($NUM_SCRIPT eq "98") { if ($NUM_SCRIPT eq "98") {
$CHOOSEDPUBLISH{"ASSO"}=1; $CHOOSEDPUBLISH{"ASSO"}=1;
} }
else elsif ($NUM_SCRIPT eq "99") {
{ $CHOOSEDPUBLISH{"SF"}=1;
if ($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") { elsif ($NUM_SCRIPT eq "1") {
foreach my $key (@LISTETARGET) { $CHOOSEDTARGET{"-CHKSUM"}=1
if ($key ne 'SNAPSHOT' && $key ne 'ASSO' && $key ne 'SF') { $CHOOSEDTARGET{$key}=1; } }
} else {
} foreach my $num (split(/\s+/,$NUM_SCRIPT)) {
else { $CHOOSEDTARGET{$LISTETARGET[$num-2]}=1;
foreach my $num (split(/\s+/,$NUM_SCRIPT)) {
$CHOOSEDTARGET{$LISTETARGET[$num-1]}=1;
}
}
} }
} }
} }
# Test if requirement is ok # Test if requirement is ok
#-------------------------- #--------------------------
$atleastonerpm=0; $atleastonerpm=0;
foreach my $target (keys %CHOOSEDTARGET) { foreach my $target (sort keys %CHOOSEDTARGET) {
if ($target =~ /RPM/i) if ($target =~ /RPM/i)
{ {
if ($atleastonerpm && ($DESTI eq "$SOURCE/build")) if ($atleastonerpm && ($DESTI eq "$SOURCE/build"))
...@@ -300,20 +300,32 @@ foreach my $target (keys %CHOOSEDTARGET) { ...@@ -300,20 +300,32 @@ foreach my $target (keys %CHOOSEDTARGET) {
print "\n"; 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 # Check if there is at least one target to build
#---------------------------------------------- #----------------------------------------------
$nboftargetok=0; $nboftargetok=0;
$nboftargetneedbuildroot=0; $nboftargetneedbuildroot=0;
$nbofpublishneedtag=0; $nbofpublishneedtag=0;
foreach my $target (keys %CHOOSEDTARGET) { foreach my $target (sort keys %CHOOSEDTARGET) {
if ($CHOOSEDTARGET{$target} < 0) { next; } if ($CHOOSEDTARGET{$target} < 0) { next; }
if ($target ne 'EXE' && $target ne 'EXEDOLIWAMP') if ($target ne 'EXE' && $target ne 'EXEDOLIWAMP' && $target ne '-CHKSUM')
{ {
$nboftargetneedbuildroot++; $nboftargetneedbuildroot++;
} }
$nboftargetok++; $nboftargetok++;
} }
foreach my $target (keys %CHOOSEDPUBLISH) { foreach my $target (sort keys %CHOOSEDPUBLISH) {
if ($CHOOSEDPUBLISH{$target} < 0) { next; } if ($CHOOSEDPUBLISH{$target} < 0) { next; }
if ($target eq 'ASSO') { $nbofpublishneedtag++; } if ($target eq 'ASSO') { $nbofpublishneedtag++; }
if ($target eq 'SF') { $nbofpublishneedtag++; } if ($target eq 'SF') { $nbofpublishneedtag++; }
...@@ -322,12 +334,6 @@ foreach my $target (keys %CHOOSEDPUBLISH) { ...@@ -322,12 +334,6 @@ foreach my $target (keys %CHOOSEDPUBLISH) {
if ($nboftargetok) { 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 # Update CVS if required
#----------------------- #-----------------------
if ($nbofpublishneedtag) if ($nbofpublishneedtag)
...@@ -483,10 +489,11 @@ if ($nboftargetok) { ...@@ -483,10 +489,11 @@ if ($nboftargetok) {
# Build package for each target # Build package for each target
#------------------------------ #------------------------------
foreach my $target (keys %CHOOSEDTARGET) foreach my $target (sort keys %CHOOSEDTARGET)
{ {
if ($CHOOSEDTARGET{$target} < 0) { next; } if ($CHOOSEDTARGET{$target} < 0) { next; }
if ($target eq '-CHKSUM') { next; }
print "\nBuild package for target $target\n"; print "\nBuild package for target $target\n";
if ($target eq 'SNAPSHOT') if ($target eq 'SNAPSHOT')
...@@ -988,7 +995,7 @@ if ($nboftargetok) { ...@@ -988,7 +995,7 @@ if ($nboftargetok) {
# Publish package for each target # Publish package for each target
#-------------------------------- #--------------------------------
foreach my $target (keys %CHOOSEDPUBLISH) foreach my $target (sort keys %CHOOSEDPUBLISH)
{ {
if ($CHOOSEDPUBLISH{$target} < 0) { next; } if ($CHOOSEDPUBLISH{$target} < 0) { next; }
...@@ -1071,7 +1078,8 @@ if ($nboftargetok) { ...@@ -1071,7 +1078,8 @@ if ($nboftargetok) {
} }
print "\n----- Summary -----\n"; 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) { if ($CHOOSEDTARGET{$target} < 0) {
print "Package $target not built (bad requirement).\n"; print "Package $target not built (bad requirement).\n";
} else { } else {
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment