Prepare release
This commit is contained in:
parent
9415c5c17b
commit
7011475563
4 changed files with 0 additions and 818 deletions
|
|
@ -1,16 +0,0 @@
|
|||
# Your module name here
|
||||
#
|
||||
# Goal: Goal of module
|
||||
# Version: 1.0
|
||||
# Author: Copyright 2008 - Author name here
|
||||
# Licence: GPL
|
||||
# Install: Just unpack content of module package in Dolibarr directory.
|
||||
# Setup: Go on Dolibarr setup - modules to enable module.
|
||||
#
|
||||
# Files in module
|
||||
htdocs/mymodule/core/modules/modMyModule.class.php
|
||||
htdocs/mymodule/core/triggers/interface_mymodule.class.php
|
||||
htdocs/mymodule/page1.php
|
||||
htdocs/mymodule/page2.php
|
||||
htdocs/mymodule/sql/script1.sql
|
||||
htdocs/mymodule/sql/script2.sql
|
||||
|
|
@ -1,505 +0,0 @@
|
|||
#!/usr/bin/perl
|
||||
#----------------------------------------------------------------------------
|
||||
# \file dev/build/makepack-dolibarrmodule.pl
|
||||
# \brief Package builder (tgz, zip, rpm, deb, exe)
|
||||
# \author (c)2005-2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
# \contributor (c)2017 Nicolas ZABOURI <info@inovea-conseil.com>
|
||||
#----------------------------------------------------------------------------
|
||||
## no critic (InputOutput::ProhibitExplicitStdin,InputOutput::RequireBriefOpen)
|
||||
|
||||
#use strict;
|
||||
use warnings;
|
||||
use Cwd;
|
||||
use Term::ANSIColor;
|
||||
|
||||
my $OWNER = "ldestailleur";
|
||||
my $GROUP = "ldestailleur";
|
||||
|
||||
my @LISTETARGET = ("ZIP"); # Possible packages
|
||||
my %REQUIREMENTTARGET = ( # Tool requirement for each package
|
||||
"TGZ" => "tar",
|
||||
"ZIP" => "7z"
|
||||
);
|
||||
my %ALTERNATEPATH = ();
|
||||
|
||||
use vars qw/ $REVISION $VERSION /;
|
||||
my $REVISION = '1.0';
|
||||
my $VERSION = "3.5 (build $REVISION)";
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# MAIN
|
||||
#------------------------------------------------------------------------------
|
||||
( $DIR = $0 ) =~ s/([^\/\\]+)$//;
|
||||
( $PROG = $1 ) =~ s/\.([^\.]*)$//;
|
||||
$Extension = $1;
|
||||
$DIR ||= '.';
|
||||
$DIR =~ s/([^\/\\])[\\\/]+$/$1/;
|
||||
|
||||
# Detect OS type
|
||||
# --------------
|
||||
if ( "$^O" =~ /linux/i || ( -d "/etc" && -d "/var" && "$^O" !~ /cygwin/i ) ) {
|
||||
$OS = 'linux';
|
||||
$CR = '';
|
||||
}
|
||||
elsif ( -d "/etc" && -d "/Users" ) { $OS = 'macosx'; $CR = ''; }
|
||||
elsif ( "$^O" =~ /cygwin/i || "$^O" =~ /win32/i ) {
|
||||
$OS = 'windows';
|
||||
$CR = "\r";
|
||||
}
|
||||
if ( !$OS ) {
|
||||
print "$PROG.$Extension was not able to detect your OS.\n";
|
||||
print "Can't continue.\n";
|
||||
print "$PROG.$Extension aborted.\n";
|
||||
sleep 2;
|
||||
exit 1;
|
||||
}
|
||||
|
||||
# Define buildroot
|
||||
# ----------------
|
||||
if ( $OS =~ /linux/ ) {
|
||||
$TEMP = $ENV{"TEMP"} || $ENV{"TMP"} || "/tmp";
|
||||
}
|
||||
if ( $OS =~ /macos/ ) {
|
||||
$TEMP = $ENV{"TEMP"} || $ENV{"TMP"} || "/tmp";
|
||||
}
|
||||
if ( $OS =~ /windows/ ) {
|
||||
$TEMP = $ENV{"TEMP"} || $ENV{"TMP"} || "c:/temp";
|
||||
$PROGPATH = $ENV{"ProgramFiles"};
|
||||
}
|
||||
if ( !$TEMP || !-d $TEMP ) {
|
||||
print "Error: A temporary directory can not be find.\n";
|
||||
print "Check that TEMP or TMP environment variable is set correctly.\n";
|
||||
print "$PROG.$Extension aborted.\n";
|
||||
sleep 2;
|
||||
exit 2;
|
||||
}
|
||||
$BUILDROOT = "$TEMP/dolibarr-buildroot";
|
||||
|
||||
my $copyalreadydone = 0;
|
||||
my $batch = 0;
|
||||
|
||||
for ( 0 .. @ARGV - 1 ) {
|
||||
if ( $ARGV[$_] =~ /^-*target=(\w+)/i ) { $target = $1; $batch = 1; }
|
||||
if ( $ARGV[$_] =~ /^-*desti=(.+)/i ) { $DESTI = $1; }
|
||||
if ( $ARGV[$_] =~ /^-*prefix=(.+)/i ) {
|
||||
$PREFIX = $1;
|
||||
$FILENAMESNAPSHOT .= "-" . $PREFIX;
|
||||
}
|
||||
}
|
||||
$SOURCE = "$DIR/../..";
|
||||
$DESTI = "$SOURCE/dev/build";
|
||||
if ( $ENV{"DESTIMODULES"} ) {
|
||||
$DESTI = $ENV{"DESTIMODULES"};
|
||||
} # Force output dir if env DESTIMODULES is defined
|
||||
$NEWDESTI = $DESTI;
|
||||
|
||||
print "Makepack for modules version $VERSION\n";
|
||||
print "Source directory: $SOURCE\n";
|
||||
print "Target directory: $NEWDESTI\n";
|
||||
|
||||
# Ask module
|
||||
print
|
||||
"Enter name for your module (mymodule, mywonderfullmodule, ... or 'all') : ";
|
||||
my $PROJECTINPUT = <STDIN>;
|
||||
chomp($PROJECTINPUT);
|
||||
print "Move to " . $DIR . " directory.\n";
|
||||
chdir($DIR);
|
||||
|
||||
my @PROJECTLIST = ();
|
||||
if ( $PROJECTINPUT eq "all" ) {
|
||||
opendir( my $DIR, $DIR ) or return;
|
||||
local @rv = grep { /^makepack\-(.*)\.conf$/ } sort readdir($DIR);
|
||||
closedir($DIR);
|
||||
foreach my $xxx ( 0 .. @rv - 1 ) {
|
||||
if ( $rv[$xxx] =~ /^makepack\-(.*)\.conf$/ ) {
|
||||
@PROJECTLIST[$xxx] = $1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
@PROJECTLIST = ($PROJECTINPUT);
|
||||
}
|
||||
|
||||
# Loop on each projects
|
||||
foreach my $PROJECT (@PROJECTLIST) {
|
||||
|
||||
$PROJECTLC = lc($PROJECT);
|
||||
|
||||
if ( !-f "makepack-" . $PROJECT . ".conf" ) {
|
||||
print "Error: can't open conf file makepack-" . $PROJECT . ".conf\n";
|
||||
print "\n";
|
||||
print "For help on building a module package, see web page\n";
|
||||
print
|
||||
"http://wiki.dolibarr.org/index.php/Module_development#Create_a_package_to_distribute_and_install_your_module\n";
|
||||
print "makepack-dolibarrmodule.pl aborted.\n";
|
||||
sleep 2;
|
||||
exit 2;
|
||||
}
|
||||
|
||||
# Get version $MAJOR, $MINOR and $BUILD
|
||||
print "Version detected for module "
|
||||
. $PROJECT
|
||||
. " in file "
|
||||
. $SOURCE
|
||||
. "/htdocs/"
|
||||
. $PROJECTLC
|
||||
. "/core/modules/mod"
|
||||
. ucfirst($PROJECT)
|
||||
. ".class.php";
|
||||
my $IN;
|
||||
$result = open(
|
||||
$IN,
|
||||
"<",
|
||||
$SOURCE
|
||||
. "/htdocs/"
|
||||
. $PROJECTLC
|
||||
. "/core/modules/mod"
|
||||
. ucfirst($PROJECT)
|
||||
. ".class.php"
|
||||
);
|
||||
$custom = 1;
|
||||
if ( !$result ) {
|
||||
$result = open(
|
||||
$IN,
|
||||
"<",
|
||||
$SOURCE
|
||||
. "/htdocs/custom/"
|
||||
. $PROJECTLC
|
||||
. "/core/modules/mod"
|
||||
. ucfirst($PROJECT)
|
||||
. ".class.php"
|
||||
);
|
||||
if ( !$result ) {
|
||||
die "Error: Can't open descriptor file "
|
||||
. $SOURCE
|
||||
. "/htdocs/(or /htdocs/custom/)"
|
||||
. $PROJECTLC
|
||||
. "/core/modules/mod"
|
||||
. ucfirst($PROJECT)
|
||||
. ".class.php for reading.\n";
|
||||
}
|
||||
}
|
||||
else {
|
||||
$custom = 0;
|
||||
}
|
||||
while (<$IN>) {
|
||||
if ( $_ =~ /this->version\s*=\s*'([\d\.]+)'/ ) {
|
||||
$PROJVERSION = $1;
|
||||
last;
|
||||
}
|
||||
}
|
||||
close $IN;
|
||||
print $PROJVERSION. "\n";
|
||||
|
||||
( $MAJOR, $MINOR, $BUILD ) = split( /\./, $PROJVERSION, 3 );
|
||||
if ( $MINOR eq '' ) {
|
||||
print "Enter value for minor version for module " . $PROJECT . ": ";
|
||||
$MINOR = <STDIN>;
|
||||
chomp($MINOR);
|
||||
}
|
||||
|
||||
$FILENAME = "$PROJECTLC";
|
||||
$FILENAMETGZ =
|
||||
"module_$PROJECTLC-$MAJOR.$MINOR" . ( $BUILD ne '' ? ".$BUILD" : "" );
|
||||
$FILENAMEZIP =
|
||||
"module_$PROJECTLC-$MAJOR.$MINOR" . ( $BUILD ne '' ? ".$BUILD" : "" );
|
||||
if ( -d "/usr/src/redhat" ) {
|
||||
|
||||
# redhat
|
||||
$RPMDIR = "/usr/src/redhat";
|
||||
}
|
||||
if ( -d "/usr/src/RPM" ) {
|
||||
|
||||
# mandrake
|
||||
$RPMDIR = "/usr/src/RPM";
|
||||
}
|
||||
|
||||
# Choose package targets
|
||||
#-----------------------
|
||||
$target = "ZIP"; # Dolibarr modules are this format
|
||||
$CHOOSEDTARGET{ uc($target) } = 1;
|
||||
|
||||
# Test if requirement is ok
|
||||
#--------------------------
|
||||
foreach my $target ( keys %CHOOSEDTARGET ) {
|
||||
foreach my $req ( split( /[,\s]/, $REQUIREMENTTARGET{$target} ) ) {
|
||||
|
||||
# Test
|
||||
print "Test requirement for target $target: Search '$req'... ";
|
||||
$ret = `"$req" 2>&1`;
|
||||
$coderetour = $?;
|
||||
$coderetour2 = $coderetour >> 8;
|
||||
if (
|
||||
$coderetour != 0
|
||||
&& (
|
||||
(
|
||||
$coderetour2 == 1
|
||||
&& $OS =~ /windows/
|
||||
&& $ret !~ /Usage/i
|
||||
)
|
||||
|| ( $coderetour2 == 127 && $OS !~ /windows/ )
|
||||
)
|
||||
&& $PROGPATH
|
||||
)
|
||||
{
|
||||
# Not found error, we try in PROGPATH
|
||||
$ret = `"$PROGPATH/$ALTERNATEPATH{$req}/$req\" 2>&1`;
|
||||
$coderetour = $?;
|
||||
$coderetour2 = $coderetour >> 8;
|
||||
$REQUIREMENTTARGET{$target} =
|
||||
"$PROGPATH/$ALTERNATEPATH{$req}/$req";
|
||||
}
|
||||
|
||||
if (
|
||||
$coderetour != 0
|
||||
&& (
|
||||
(
|
||||
$coderetour2 == 1
|
||||
&& $OS =~ /windows/
|
||||
&& $ret !~ /Usage/i
|
||||
)
|
||||
|| ( $coderetour2 == 127 && $OS !~ /windows/ )
|
||||
)
|
||||
)
|
||||
{
|
||||
# Not found error
|
||||
print
|
||||
"Not found\nCan't build target $target. Requirement '$req' not found in PATH\n";
|
||||
$CHOOSEDTARGET{$target} = -1;
|
||||
last;
|
||||
}
|
||||
else {
|
||||
# Pas erreur ou erreur autre que programme absent
|
||||
print " Found " . $REQUIREMENTTARGET{$target} . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print "\n";
|
||||
|
||||
# Check if there is at least one target to build
|
||||
#----------------------------------------------
|
||||
$nboftargetok = 0;
|
||||
$nboftargetneedbuildroot = 0;
|
||||
$nboftargetneedcvs = 0;
|
||||
foreach my $target ( keys %CHOOSEDTARGET ) {
|
||||
if ( $CHOOSEDTARGET{$target} < 0 ) { next; }
|
||||
if ( $target ne 'EXE' && $target ne 'EXEDOLIWAMP' ) {
|
||||
$nboftargetneedbuildroot++;
|
||||
}
|
||||
if ( $target eq 'SNAPSHOT' ) {
|
||||
$nboftargetneedcvs++;
|
||||
}
|
||||
$nboftargetok++;
|
||||
}
|
||||
|
||||
if ($nboftargetok) {
|
||||
|
||||
# Update CVS if required
|
||||
#-----------------------
|
||||
if ($nboftargetneedcvs) {
|
||||
print "Go to directory $SOURCE\n";
|
||||
$olddir = getcwd();
|
||||
chdir("$SOURCE");
|
||||
print "Run cvs update -P -d\n";
|
||||
$ret = `cvs update -P -d 2>&1`;
|
||||
chdir("$olddir");
|
||||
}
|
||||
|
||||
# Update buildroot if required
|
||||
#-----------------------------
|
||||
if ($nboftargetneedbuildroot) {
|
||||
if ( !$copyalreadydone ) {
|
||||
print "Delete directory $BUILDROOT\n";
|
||||
$ret = `rm -fr "$BUILDROOT"`;
|
||||
|
||||
mkdir "$BUILDROOT";
|
||||
mkdir "$BUILDROOT/$PROJECTLC";
|
||||
|
||||
print "Now, we will copy all files declared in the makepack-"
|
||||
. $PROJECT
|
||||
. ".conf into the directory $BUILDROOT\n";
|
||||
my $IN2;
|
||||
open( $IN2, "<", "makepack-" . $PROJECT . ".conf" )
|
||||
or die "Error: Can't open conf file makepack-"
|
||||
. $PROJECT
|
||||
. ".conf for reading.\n";
|
||||
while (<$IN2>) {
|
||||
$entry = $_;
|
||||
|
||||
if ( $entry =~ /^#/ ) { next; } # Do not process comments
|
||||
|
||||
$entry =~ s/\n//;
|
||||
|
||||
if ( $entry =~ /^!(.*)$/ ) # Exclude so remove file/dir
|
||||
{
|
||||
print "Remove $BUILDROOT/$PROJECTLC/$1\n";
|
||||
$ret = `rm -fr "$BUILDROOT/$PROJECTLC/"$1`;
|
||||
if ( $? != 0 ) {
|
||||
die
|
||||
"Failed to delete a file to exclude declared into makepack-"
|
||||
. $PROJECT
|
||||
. ".conf file (Failed on the line "
|
||||
. $entry . ")\n";
|
||||
}
|
||||
next;
|
||||
}
|
||||
|
||||
$entry =~ /^(.*)\/[^\/]+/;
|
||||
print "Create directory $BUILDROOT/$PROJECTLC/$1\n";
|
||||
$ret = `mkdir -p "$BUILDROOT/$PROJECTLC/$1"`;
|
||||
if ( $entry !~ /version\-/ ) {
|
||||
print
|
||||
"Copy $SOURCE/$entry into $BUILDROOT/$PROJECTLC/$entry\n";
|
||||
$ret =
|
||||
`cp -pr "$SOURCE/$entry" "$BUILDROOT/$PROJECTLC/$entry"`;
|
||||
if ( $? != 0 ) {
|
||||
die
|
||||
"Failed to make copy of a file declared into makepack-"
|
||||
. $PROJECT
|
||||
. ".conf file (Failed on the line '"
|
||||
. $entry . "')\n";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
close $IN2;
|
||||
|
||||
# @timearray = localtime( time() );
|
||||
# $fulldate =
|
||||
# ( $timearray[5] + 1900 ) . '-'
|
||||
# . ( $timearray[4] + 1 ) . '-'
|
||||
# . $timearray[3] . ' '
|
||||
# . $timearray[2] . ':'
|
||||
# . $timearray[1];
|
||||
|
||||
#open(VF,">$BUILDROOT/$PROJECTLC/dev/build/version-".$PROJECTLC.".txt");
|
||||
#print "Create version file $BUILDROOT/$PROJECTLC/dev/build/version-".$PROJECTLC.".txt with date ".$fulldate."\n";
|
||||
#$ret=`mkdir -p "$BUILDROOT/$PROJECTLC/dev/build"`;
|
||||
#print VF "Version: ".$MAJOR.".".$MINOR.($BUILD ne ''?".$BUILD":"")."\n";
|
||||
#print VF "Build : ".$fulldate."\n";
|
||||
#close VF;
|
||||
}
|
||||
print "Clean $BUILDROOT\n";
|
||||
$ret = `rm -fr $BUILDROOT/$PROJECTLC/.cache`;
|
||||
$ret = `rm -fr $BUILDROOT/$PROJECTLC/.git`;
|
||||
$ret = `rm -fr $BUILDROOT/$PROJECTLC/.project`;
|
||||
$ret = `rm -fr $BUILDROOT/$PROJECTLC/.settings`;
|
||||
$ret = `rm -fr $BUILDROOT/$PROJECTLC/index.php`;
|
||||
$ret = `rm -fr $BUILDROOT/$PROJECTLC/dev/build/html`;
|
||||
$ret = `rm -fr $BUILDROOT/$PROJECTLC/documents`;
|
||||
$ret = `rm -fr $BUILDROOT/$PROJECTLC/document`;
|
||||
$ret = `rm -fr $BUILDROOT/$PROJECTLC/htdocs/conf/conf.php.mysql`;
|
||||
$ret = `rm -fr $BUILDROOT/$PROJECTLC/htdocs/conf/conf.php.old`;
|
||||
$ret = `rm -fr $BUILDROOT/$PROJECTLC/htdocs/conf/conf.php.postgres`;
|
||||
$ret = `rm -fr $BUILDROOT/$PROJECTLC/htdocs/conf/conf*sav*`;
|
||||
|
||||
if ($custom) {
|
||||
$ret =
|
||||
`cp -r $BUILDROOT/$PROJECTLC/htdocs/custom/* $BUILDROOT/$PROJECTLC/htdocs/.`;
|
||||
}
|
||||
$ret = `rm -fr $BUILDROOT/$PROJECTLC/htdocs/custom`;
|
||||
$ret = `rm -fr $BUILDROOT/$PROJECTLC/htdocs/custom2`;
|
||||
$ret = `rm -fr $BUILDROOT/$PROJECTLC/test`;
|
||||
$ret =
|
||||
`rm -fr $BUILDROOT/$PROJECTLC/Thumbs.db $BUILDROOT/$PROJECTLC/*/Thumbs.db $BUILDROOT/$PROJECTLC/*/*/Thumbs.db $BUILDROOT/$PROJECTLC/*/*/*/Thumbs.db $BUILDROOT/$PROJECTLC/*/*/*/*/Thumbs.db`;
|
||||
$ret =
|
||||
`rm -fr $BUILDROOT/$PROJECTLC/CVS* $BUILDROOT/$PROJECTLC/*/CVS* $BUILDROOT/$PROJECTLC/*/*/CVS* $BUILDROOT/$PROJECTLC/*/*/*/CVS* $BUILDROOT/$PROJECTLC/*/*/*/*/CVS* $BUILDROOT/$PROJECTLC/*/*/*/*/*/CVS*`;
|
||||
}
|
||||
|
||||
# Build package for each target
|
||||
#------------------------------
|
||||
foreach my $target ( keys %CHOOSEDTARGET ) {
|
||||
if ( $CHOOSEDTARGET{$target} < 0 ) { next; }
|
||||
|
||||
print "\nBuild package for target $target\n";
|
||||
|
||||
if ( $target eq 'TGZ' ) {
|
||||
$NEWDESTI = $DESTI;
|
||||
if ( -d $DESTI . '/../modules' ) {
|
||||
$NEWDESTI = $DESTI . '/../modules';
|
||||
}
|
||||
|
||||
print "Remove target $FILENAMETGZ.tgz...\n";
|
||||
unlink("$NEWDESTI/$FILENAMETGZ.tgz");
|
||||
print "Compress $BUILDROOT/* into $FILENAMETGZ.tgz...\n";
|
||||
$cmd =
|
||||
"tar --exclude-vcs --exclude *.tgz --directory \"$BUILDROOT\" --mode=go-w --group=500 --owner=500 -czvf \"$FILENAMETGZ.tgz\" .";
|
||||
$ret = `$cmd`;
|
||||
if ( $OS =~ /windows/i ) {
|
||||
print
|
||||
"Move $FILENAMETGZ.tgz to $NEWDESTI/$FILENAMETGZ.tgz\n";
|
||||
$ret = `mv "$FILENAMETGZ.tgz" "$NEWDESTI/$FILENAMETGZ.tgz"`;
|
||||
}
|
||||
else {
|
||||
$ret = `mv "$FILENAMETGZ.tgz" "$NEWDESTI/$FILENAMETGZ.tgz"`;
|
||||
}
|
||||
next;
|
||||
}
|
||||
|
||||
if ( $target eq 'ZIP' ) {
|
||||
$NEWDESTI = $DESTI;
|
||||
if ( -d $DESTI . '/../modules' ) {
|
||||
$NEWDESTI = $DESTI . '/../modules';
|
||||
}
|
||||
|
||||
print "Remove target $FILENAMEZIP.zip...\n";
|
||||
unlink "$NEWDESTI/$FILENAMEZIP.zip";
|
||||
print "Compress $FILENAMEZIP into $FILENAMEZIP.zip...\n";
|
||||
|
||||
print "Go to directory $BUILDROOT/$PROJECTLC\n";
|
||||
$olddir = getcwd();
|
||||
chdir("$BUILDROOT/$PROJECTLC");
|
||||
$cmd = "7z a -r -tzip -mx $BUILDROOT/$FILENAMEZIP.zip *";
|
||||
print $cmd. "\n";
|
||||
$ret = `$cmd`;
|
||||
chdir("$olddir");
|
||||
|
||||
print "Move $FILENAMEZIP.zip to $NEWDESTI/$FILENAMEZIP.zip\n";
|
||||
$ret =
|
||||
`mv "$BUILDROOT/$FILENAMEZIP.zip" "$NEWDESTI/$FILENAMEZIP.zip"`;
|
||||
$ret = `chown $OWNER:$GROUP "$NEWDESTI/$FILENAMEZIP.zip"`;
|
||||
next;
|
||||
}
|
||||
|
||||
if ( $target eq 'EXE' ) {
|
||||
$NEWDESTI = $DESTI;
|
||||
if ( -d $DESTI . '/../modules' ) {
|
||||
$NEWDESTI = $DESTI . '/../modules';
|
||||
}
|
||||
|
||||
print "Remove target $FILENAMEEXE.exe...\n";
|
||||
unlink "$NEWDESTI/$FILENAMEEXE.exe";
|
||||
print "Compress into $FILENAMEEXE.exe by $FILENAMEEXE.nsi...\n";
|
||||
$command =
|
||||
"\"$REQUIREMENTTARGET{$target}\" /DMUI_VERSION_DOT=$MAJOR.$MINOR.$BUILD /X\"SetCompressor bzip2\" \"$SOURCE\\dev\\build\\exe\\$FILENAME.nsi\"";
|
||||
print "$command\n";
|
||||
$ret = `$command`;
|
||||
print "Move $FILENAMEEXE.exe to $NEWDESTI\n";
|
||||
rename( "$SOURCE\\dev\\build\\exe\\$FILENAMEEXE.exe",
|
||||
"$NEWDESTI/$FILENAMEEXE.exe" );
|
||||
next;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
print "\n----- Summary -----\n";
|
||||
foreach my $target ( keys %CHOOSEDTARGET ) {
|
||||
if ( $CHOOSEDTARGET{$target} < 0 ) {
|
||||
print "Package $target not built (bad requirement).\n";
|
||||
}
|
||||
else {
|
||||
print "Package $target built successfully in $NEWDESTI\n";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( !$batch ) {
|
||||
print "\nPress key to finish...";
|
||||
my $WAITKEY = <STDIN>;
|
||||
}
|
||||
|
||||
0;
|
||||
|
|
@ -1,297 +0,0 @@
|
|||
#!/usr/bin/perl
|
||||
#-----------------------------------------------------------------------------
|
||||
# \file dev/build/makepack-dolibarrtheme.pl
|
||||
# \brief Script to build a theme Package for Dolibarr
|
||||
# \author (c)2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
#-----------------------------------------------------------------------------
|
||||
## no critic (InputOutput::ProhibitExplicitStdin)
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Cwd;
|
||||
use Term::ANSIColor;
|
||||
|
||||
$PROJECT = "dolibarr";
|
||||
|
||||
@LISTETARGET = ("TGZ"); # Possible packages
|
||||
%REQUIREMENTTARGET = ( # Tool requirement for each package
|
||||
"TGZ" => "tar",
|
||||
"ZIP" => "7z",
|
||||
"RPM" => "rpmbuild",
|
||||
"DEB" => "dpkg-buildpackage",
|
||||
"EXE" => "makensis.exe"
|
||||
);
|
||||
%ALTERNATEPATH = (
|
||||
"7z" => "7-ZIP",
|
||||
"makensis.exe" => "NSIS"
|
||||
);
|
||||
|
||||
use vars qw/ $REVISION $VERSION /;
|
||||
$REVISION = '1.11';
|
||||
$VERSION = "1.0 (build $REVISION)";
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# MAIN
|
||||
#------------------------------------------------------------------------------
|
||||
( $DIR = $0 ) =~ s/([^\/\\]+)$//;
|
||||
( $PROG = $1 ) =~ s/\.([^\.]*)$//;
|
||||
$Extension = $1;
|
||||
$DIR ||= '.';
|
||||
$DIR =~ s/([^\/\\])[\\\/]+$/$1/;
|
||||
|
||||
# Detect OS type
|
||||
# --------------
|
||||
if ( "$^O" =~ /linux/i || ( -d "/etc" && -d "/var" && "$^O" !~ /cygwin/i ) ) {
|
||||
$OS = 'linux';
|
||||
$CR = '';
|
||||
}
|
||||
elsif ( -d "/etc" && -d "/Users" ) { $OS = 'macosx'; $CR = ''; }
|
||||
elsif ( "$^O" =~ /cygwin/i || "$^O" =~ /win32/i ) {
|
||||
$OS = 'windows';
|
||||
$CR = "\r";
|
||||
}
|
||||
if ( !$OS ) {
|
||||
print "$PROG.$Extension was not able to detect your OS.\n";
|
||||
print "Can't continue.\n";
|
||||
print "$PROG.$Extension aborted.\n";
|
||||
sleep 2;
|
||||
exit 1;
|
||||
}
|
||||
|
||||
# Define buildroot
|
||||
# ----------------
|
||||
if ( $OS =~ /linux/ ) {
|
||||
$TEMP = $ENV{"TEMP"} || $ENV{"TMP"} || "/tmp";
|
||||
}
|
||||
if ( $OS =~ /macos/ ) {
|
||||
$TEMP = $ENV{"TEMP"} || $ENV{"TMP"} || "/tmp";
|
||||
}
|
||||
if ( $OS =~ /windows/ ) {
|
||||
$TEMP = $ENV{"TEMP"} || $ENV{"TMP"} || "c:/temp";
|
||||
$PROGPATH = $ENV{"ProgramFiles"};
|
||||
}
|
||||
if ( !$TEMP || !-d $TEMP ) {
|
||||
print "Error: A temporary directory can not be find.\n";
|
||||
print "Check that TEMP or TMP environment variable is set correctly.\n";
|
||||
print "makepack-dolibarrtheme.pl aborted.\n";
|
||||
sleep 2;
|
||||
exit 2;
|
||||
}
|
||||
$BUILDROOT = "$TEMP/dolibarr-buildroot";
|
||||
|
||||
my $copyalreadydone = 0;
|
||||
my $batch = 0;
|
||||
|
||||
print "Makepack theme version $VERSION\n";
|
||||
print "Enter name of theme(s) to package (separated with space): ";
|
||||
$PROJECT = <STDIN>;
|
||||
chomp($PROJECT);
|
||||
|
||||
@PROJECTLIST = split( / /, $PROJECT );
|
||||
$PROJECT = join( '', @PROJECTLIST );
|
||||
|
||||
# Ask and set version $MAJOR and $MINOR
|
||||
print "Enter value for version: ";
|
||||
$PROJVERSION = <STDIN>;
|
||||
chomp($PROJVERSION);
|
||||
( $MAJOR, $MINOR ) = split( /\./, $PROJVERSION, 2 );
|
||||
if ( $MINOR eq '' ) {
|
||||
print "Enter value for minor version: ";
|
||||
$MINOR = <STDIN>;
|
||||
chomp($MINOR);
|
||||
}
|
||||
|
||||
$FILENAME = "$PROJECT";
|
||||
$FILENAMETGZ = "theme_$PROJECT-$MAJOR.$MINOR";
|
||||
$FILENAMEZIP = "theme_$PROJECT-$MAJOR.$MINOR";
|
||||
|
||||
if ( -d "/usr/src/redhat" ) {
|
||||
|
||||
# redhat
|
||||
$RPMDIR = "/usr/src/redhat";
|
||||
}
|
||||
if ( -d "/usr/src/RPM" ) {
|
||||
|
||||
# mandrake
|
||||
$RPMDIR = "/usr/src/RPM";
|
||||
}
|
||||
|
||||
$SOURCE = "$DIR/../..";
|
||||
$DESTI = "$SOURCE/build";
|
||||
|
||||
# Choose package targets
|
||||
#-----------------------
|
||||
$target = "ZIP"; # Packages uses this format
|
||||
if ($target) {
|
||||
$CHOOSEDTARGET{ uc($target) } = 1;
|
||||
}
|
||||
else {
|
||||
my $found = 0;
|
||||
my $NUM_SCRIPT;
|
||||
while ( !$found ) {
|
||||
my $cpt = 0;
|
||||
printf( " %d - %3s (%s)\n",
|
||||
$cpt, "All", "Need " . join( ",", values %REQUIREMENTTARGET ) );
|
||||
foreach my $target (@LISTETARGET) {
|
||||
$cpt++;
|
||||
printf( " %d - %3s (%s)\n",
|
||||
$cpt, $target, "Need " . $REQUIREMENTTARGET{$target} );
|
||||
}
|
||||
|
||||
# Are asked to select the file to move
|
||||
print "Choose one package number or several separated with space: ";
|
||||
$NUM_SCRIPT = <STDIN>;
|
||||
chomp($NUM_SCRIPT);
|
||||
if ( $NUM_SCRIPT =~ s/-//g ) {
|
||||
|
||||
# Do not do copy
|
||||
$copyalreadydone = 1;
|
||||
}
|
||||
if ( $NUM_SCRIPT !~ /^[0-$cpt\s]+$/ ) {
|
||||
print "This is not a valid package number list.\n";
|
||||
$found = 0;
|
||||
}
|
||||
else {
|
||||
$found = 1;
|
||||
}
|
||||
}
|
||||
print "\n";
|
||||
if ($NUM_SCRIPT) {
|
||||
foreach my $num ( split( /\s+/, $NUM_SCRIPT ) ) {
|
||||
$CHOOSEDTARGET{ $LISTETARGET[ $num - 1 ] } = 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
foreach my $key (@LISTETARGET) {
|
||||
$CHOOSEDTARGET{$key} = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Test if requirement is ok
|
||||
#--------------------------
|
||||
foreach my $target ( keys %CHOOSEDTARGET ) {
|
||||
foreach my $req ( split( /[,\s]/, $REQUIREMENTTARGET{$target} ) ) {
|
||||
|
||||
# Test
|
||||
print "Test requirement for target $target: Search '$req'... ";
|
||||
$ret = `"$req" 2>&1`;
|
||||
$coderetour = $?;
|
||||
$coderetour2 = $coderetour >> 8;
|
||||
if (
|
||||
$coderetour != 0
|
||||
&& ( ( $coderetour2 == 1 && $OS =~ /windows/ && $ret !~ /Usage/i )
|
||||
|| ( $coderetour2 == 127 && $OS !~ /windows/ ) )
|
||||
&& $PROGPATH
|
||||
)
|
||||
{
|
||||
# Not found error, we try in PROGPATH
|
||||
$ret = `"$PROGPATH/$ALTERNATEPATH{$req}/$req\" 2>&1`;
|
||||
$coderetour = $?;
|
||||
$coderetour2 = $coderetour >> 8;
|
||||
$REQUIREMENTTARGET{$target} = "$PROGPATH/$ALTERNATEPATH{$req}/$req";
|
||||
}
|
||||
|
||||
if (
|
||||
$coderetour != 0
|
||||
&& ( ( $coderetour2 == 1 && $OS =~ /windows/ && $ret !~ /Usage/i )
|
||||
|| ( $coderetour2 == 127 && $OS !~ /windows/ ) )
|
||||
)
|
||||
{
|
||||
# Not found error
|
||||
print
|
||||
"Not found\nCan't build target $target. Requirement '$req' not found in PATH\n";
|
||||
$CHOOSEDTARGET{$target} = -1;
|
||||
last;
|
||||
}
|
||||
else {
|
||||
# Pas erreur ou erreur autre que programme absent
|
||||
print " Found " . $REQUIREMENTTARGET{$target} . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print "\n";
|
||||
|
||||
# Check if there is at least on target to build
|
||||
#----------------------------------------------
|
||||
$nboftargetok = 0;
|
||||
foreach my $target ( keys %CHOOSEDTARGET ) {
|
||||
if ( $CHOOSEDTARGET{$target} < 0 ) { next; }
|
||||
$nboftargetok++;
|
||||
}
|
||||
|
||||
if ($nboftargetok) {
|
||||
|
||||
# Update buildroot
|
||||
#-----------------
|
||||
if ( !$copyalreadydone ) {
|
||||
print "Delete directory $BUILDROOT\n";
|
||||
$ret = `rm -fr "$BUILDROOT"`;
|
||||
mkdir "$BUILDROOT";
|
||||
mkdir "$BUILDROOT/htdocs";
|
||||
mkdir "$BUILDROOT/htdocs/theme";
|
||||
|
||||
print "Copy $SOURCE into $BUILDROOT\n";
|
||||
mkdir "$BUILDROOT";
|
||||
foreach my $tmp (@PROJECTLIST) {
|
||||
$ret =
|
||||
`cp -pr "$SOURCE/htdocs/theme/$tmp" "$BUILDROOT/htdocs/theme"`;
|
||||
}
|
||||
}
|
||||
print "Clean $BUILDROOT\n";
|
||||
$ret =
|
||||
`rm -fr $BUILDROOT/htdocs/theme/$PROJECT/Thumbs.db $BUILDROOT/htdocs/theme/$PROJECT/*/Thumbs.db $BUILDROOT/htdocs/theme/$PROJECT/*/*/Thumbs.db $BUILDROOT/htdocs/theme/$PROJECT/*/*/*/Thumbs.db`;
|
||||
$ret =
|
||||
`rm -fr $BUILDROOT/htdocs/theme/$PROJECT/CVS* $BUILDROOT/htdocs/theme/$PROJECT/*/CVS* $BUILDROOT/htdocs/theme/$PROJECT/*/*/CVS* $BUILDROOT/htdocs/theme/$PROJECT/*/*/*/CVS* $BUILDROOT/htdocs/theme/$PROJECT/*/*/*/*/CVS* $BUILDROOT/htdocs/theme/$PROJECT/*/*/*/*/*/CVS*`;
|
||||
|
||||
# Build package for each target
|
||||
#------------------------------
|
||||
foreach my $target ( keys %CHOOSEDTARGET ) {
|
||||
if ( $CHOOSEDTARGET{$target} < 0 ) { next; }
|
||||
|
||||
print "\nBuild package for target $target\n";
|
||||
|
||||
if ( $target eq 'TGZ' ) {
|
||||
unlink $FILENAMETGZ . tgz;
|
||||
print "Compress $BUILDROOT/htdocs into $FILENAMETGZ.tgz...\n";
|
||||
$cmd =
|
||||
"tar --exclude-vcs --exclude-from \"$DESTI/tgz/tar_exclude.txt\" --directory \"$BUILDROOT\" --mode=go-w --group=500 --owner=500 -czvf \"$FILENAMETGZ.tgz\" htdocs";
|
||||
$ret = `$cmd`;
|
||||
if ( $OS =~ /windows/i ) {
|
||||
print "Move $FILENAMETGZ.tgz to $DESTI/$FILENAMETGZ.tgz\n";
|
||||
$ret = `mv "$FILENAMETGZ.tgz" "$DESTI/$FILENAMETGZ.tgz"`;
|
||||
}
|
||||
next;
|
||||
}
|
||||
|
||||
if ( $target eq 'ZIP' ) {
|
||||
unlink $FILENAMEZIP . zip;
|
||||
print "Compress $FILENAMETGZ into $FILENAMEZIP.zip...\n";
|
||||
chdir("$BUILDROOT");
|
||||
$ret = `7z a -r -tzip -mx $BUILDROOT/$FILENAMEZIP.zip htdocs`;
|
||||
print "Move $FILENAMEZIP.zip to $DESTI\n";
|
||||
$ret = `mv "$FILENAMEZIP.zip" "$DESTI/$FILENAMEZIP.zip"`;
|
||||
next;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
print "\n----- Summary -----\n";
|
||||
foreach my $target ( keys %CHOOSEDTARGET ) {
|
||||
if ( $CHOOSEDTARGET{$target} < 0 ) {
|
||||
print "Package $target not built (bad requirement).\n";
|
||||
}
|
||||
else {
|
||||
print "Package $target built successfully in $DESTI\n";
|
||||
}
|
||||
}
|
||||
|
||||
if ( !$btach ) {
|
||||
print "\nPress key to finish...";
|
||||
my $WAITKEY = <STDIN>;
|
||||
}
|
||||
|
||||
0;
|
||||
Loading…
Reference in a new issue