Ajout script pour permettre fabrication d'un package d'un module Dolibarr seul (Pour faciliter travail diteur de module externe Dolibarr).
This commit is contained in:
parent
5d10fd8338
commit
293c37425a
15
build/README
15
build/README
@ -5,11 +5,22 @@ Building packages
|
||||
|
||||
All sub-directories of "build" directory contains files required to build
|
||||
automatically Dolibarr packages.
|
||||
There is serval tools:
|
||||
|
||||
To build Dolibarr packages, launch the script
|
||||
> perl makepack-build.pl
|
||||
- To build full Dolibarr packages, launch the script
|
||||
> perl makepack-dolibarr.pl
|
||||
|
||||
- To build a translaction packege, launch the script
|
||||
> perl makepack-dolibarrlang.pl
|
||||
|
||||
- To build a theme package, launch the script
|
||||
> perl makepack-dolibarrtheme.pl
|
||||
|
||||
- To build a package for a module, launch the script
|
||||
> perl makepack-dolibarrmodule.pl
|
||||
|
||||
|
||||
Note:
|
||||
The build directory and all its contents is absolutely not required to make
|
||||
Dolibarr working. It is here only to build Dolibarr packages, and those
|
||||
generated packages will not contains this "build" directory.
|
||||
|
||||
@ -5,32 +5,45 @@ Building packages
|
||||
|
||||
Les sous répertoires du répertoire "build" contiennent tous les fichiers
|
||||
requis pour packager Dolibarr de manière automatisé.
|
||||
On trouve plusieurs outils:
|
||||
|
||||
Pour construire les packages Dolibarr, il suffit de lancer le script
|
||||
> perl makepack-build.pl
|
||||
- Pour construire un package Dolibarr complet, il suffit de lancer le script
|
||||
> perl makepack-dolibarr.pl
|
||||
|
||||
- Pour construire un package d'une traduction, il suffit de lancer le script
|
||||
> perl makepack-dolibarrlang.pl
|
||||
|
||||
- Pour construire un package d'un theme, il suffit de lancer le script
|
||||
> perl makepack-dolibarrtheme.pl
|
||||
|
||||
- Pour construire un package d'un module, il suffit de lancer le script
|
||||
> perl makepack-dolibarrmodule.pl
|
||||
|
||||
|
||||
|
||||
Note:
|
||||
|
||||
Le répertoire build et tout ce qu'il contient n'est absolument pas requis
|
||||
pour faire fonctionner Dolibarr. Ils ne servent qu'à la génération des
|
||||
packages, lequels packages, une fois construit, n'incluent par le répertoire
|
||||
"build".
|
||||
|
||||
|
||||
On trouve dans "build", les sous-répertoires suivants:
|
||||
On trouve dans le répertoire "build", les sous-répertoires utilisés par
|
||||
l'outil makepack-dolibarr.pl:
|
||||
|
||||
* deb:
|
||||
Permet de construire un package Debian.
|
||||
Fichier de config pour construire un package Debian.
|
||||
|
||||
* rpm:
|
||||
Permet de construire un package Redhat ou Mandrake.
|
||||
Fichier de config pour construire un package Redhat ou Mandrake.
|
||||
|
||||
* tgz:
|
||||
Permet de construire un package tgz (ne contenant que les fichiers
|
||||
et instructions d'installation manuelle).
|
||||
Fichier de config pour construire un package tgz (ne contenant que les
|
||||
fichiers et instructions d'installation manuelle).
|
||||
|
||||
* exe:
|
||||
Permet de construire un package exe pour Windows.
|
||||
Fichier de config pour construire un package exe pour Windows.
|
||||
|
||||
* pad:
|
||||
Permet de construire un fichier descriptif PAD pour la promotion
|
||||
Fichier de config pour construire un fichier descriptif PAD pour la promotion
|
||||
de nouvelles versions de Dolibarr.
|
||||
|
||||
6
build/makepack-dolibarrmodule.conf
Normal file
6
build/makepack-dolibarrmodule.conf
Normal file
@ -0,0 +1,6 @@
|
||||
htdocs/includes/modules/modMyModule.class.php
|
||||
htdocs/includes/triggers/interface_mymodule.class.php
|
||||
htdocs/mymodule/page1.php
|
||||
htdocs/mymodule/page2.php
|
||||
htdocs/mysql/mymodule/script1.sql
|
||||
htdocs/mysql/mymodule/script2.sql
|
||||
297
build/makepack-dolibarrmodule.pl
Normal file
297
build/makepack-dolibarrmodule.pl
Normal file
@ -0,0 +1,297 @@
|
||||
#!/usr/bin/perl
|
||||
#----------------------------------------------------------------------------
|
||||
# \file build/makepack-dolibarrmodule.pl
|
||||
# \brief Package builder (tgz, zip, rpm, deb, exe)
|
||||
# \version $Revision$
|
||||
# \author (c)2005-2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
use Cwd;
|
||||
|
||||
$PROJECT="mymodule";
|
||||
|
||||
@LISTETARGET=("TGZ"); # Possible packages
|
||||
%REQUIREMENTTARGET=( # Tool requirement for each package
|
||||
"TGZ"=>"tar",
|
||||
);
|
||||
%ALTERNATEPATH=(
|
||||
);
|
||||
|
||||
|
||||
use vars qw/ $REVISION $VERSION /;
|
||||
$REVISION='$Revision$'; $REVISION =~ /\s(.*)\s/; $REVISION=$1;
|
||||
$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 "makepack-dolbarrmodule.pl was not able to detect your OS.\n";
|
||||
print "Can't continue.\n";
|
||||
print "makepack-dolibarrmodule.pl 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-dolibarrmodule.pl aborted.\n";
|
||||
sleep 2;
|
||||
exit 2;
|
||||
}
|
||||
$BUILDROOT="$TEMP/dolibarr-buildroot";
|
||||
|
||||
|
||||
my $copyalreadydone=0;
|
||||
my $batch=0;
|
||||
|
||||
print "Makepack module version $VERSION\n";
|
||||
print "Enter name for your module (mymodule, mywonderfulmondule, ...) : ";
|
||||
$PROJECT=<STDIN>;
|
||||
chomp($PROJECT);
|
||||
print "Enter value for major version: ";
|
||||
$MAJOR=<STDIN>;
|
||||
chomp($MAJOR);
|
||||
print "Enter value for minor version: ";
|
||||
$MINOR=<STDIN>;
|
||||
chomp($MINOR);
|
||||
|
||||
$FILENAME="$PROJECT";
|
||||
$FILENAMETGZ="module_$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/../../dolibarr";
|
||||
$DESTI="$SOURCE/build";
|
||||
|
||||
|
||||
# Choose package targets
|
||||
#-----------------------
|
||||
$target="TGZ"; # Les langs sont au format tgz
|
||||
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});
|
||||
}
|
||||
|
||||
# On demande de choisir le fichier à passer
|
||||
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";
|
||||
|
||||
# TODO Recopier fichier dans fichier conf
|
||||
$file='eee';
|
||||
|
||||
print "Copy $SOURCE into $BUILDROOT\n";
|
||||
$ret=`cp -pr "$SOURCE/".$file "$BUILDROOT/".$file`;
|
||||
}
|
||||
|
||||
|
||||
# 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;
|
||||
# unlink $BUILDROOT/$FILENAMETGZ.tgz;
|
||||
print "Compress $BUILDROOT/htdocs into $FILENAMETGZ.tgz...\n";
|
||||
$cmd="tar --exclude-from \"$DESTI/tgz/tar.exclude\" --directory \"$BUILDROOT\" -czvf \"$FILENAMETGZ.tgz\" htdocs";
|
||||
$ret=`$cmd`;
|
||||
# $cmd="tar --exclude-from \"$DESTI/tgz/tar.exclude\" --directory \"$BUILDROOT\" -czvf \"$BUILDROOT/$FILENAMETGZ.tgz\" htdocs\n";
|
||||
# $ret=`$cmd`;
|
||||
if ($OS =~ /windows/i) {
|
||||
print "Move $FILENAMETGZ.tgz to $DESTI/$FILENAMETGZ.tgz\n";
|
||||
$ret=`mv "$FILENAMETGZ.tgz" "$DESTI/$FILENAMETGZ.tgz"`;
|
||||
# $ret=`mv "$BUILDROOT/$FILENAMETGZ.tgz" "$DESTI/$FILENAMETGZ.tgz"`;
|
||||
}
|
||||
next;
|
||||
}
|
||||
|
||||
if ($target eq 'ZIP') {
|
||||
unlink $FILENAMEZIP.zip;
|
||||
print "Compress $FILENAMETGZ into $FILENAMEZIP.zip...\n";
|
||||
chdir("$BUILDROOT");
|
||||
#print "cd $BUILDROOTNT & 7z a -r -tzip -mx $BUILDROOT/$FILENAMEZIP.zip $FILENAMETGZ\\*.*\n";
|
||||
#$ret=`cd $BUILDROOTNT & 7z a -r -tzip -mx $BUILDROOT/$FILENAMEZIP.zip $FILENAMETGZ\\*.*`;
|
||||
$ret=`7z a -r -tzip -mx $BUILDROOT/$FILENAMEZIP.zip $FILENAMETGZ\\*.*`;
|
||||
print "Move $FILENAMEZIP.zip to $DESTI\n";
|
||||
rename("$BUILDROOT/$FILENAMEZIP.zip","$DESTI/$FILENAMEZIP.zip");
|
||||
next;
|
||||
}
|
||||
|
||||
if ($target eq 'RPM') { # Linux only
|
||||
$BUILDFIC="$FILENAME.spec";
|
||||
unlink $FILENAMETGZ.tgz;
|
||||
print "Compress $FILENAMETGZ into $FILENAMETGZ.tgz...\n";
|
||||
$ret=`tar --exclude-from "$SOURCE/build/tgz/tar.exclude" --directory "$BUILDROOT" -czvf "$BUILDROOT/$FILENAMETGZ.tgz" $FILENAMETGZ`;
|
||||
|
||||
print "Move $FILENAMETGZ.tgz to $RPMDIR/SOURCES/$FILENAMETGZ.tgz\n";
|
||||
$cmd="mv \"$BUILDROOT/$FILENAMETGZ.tgz\" \"$RPMDIR/SOURCES/$FILENAMETGZ.tgz\"";
|
||||
$ret=`$cmd`;
|
||||
|
||||
print "Copy $SOURCE/make/rpm/${BUILDFIC} to $BUILDROOT\n";
|
||||
# $ret=`cp -p "$SOURCE/make/rpm/${BUILDFIC}" "$BUILDROOT"`;
|
||||
open (SPECFROM,"<$SOURCE/make/rpm/${BUILDFIC}") || die "Error";
|
||||
open (SPECTO,">$BUILDROOT/$BUILDFIC") || die "Error";
|
||||
while (<SPECFROM>) {
|
||||
$_ =~ s/__VERSION__/$MAJOR.$MINOR.$BUILD/;
|
||||
print SPECTO $_;
|
||||
}
|
||||
close SPECFROM;
|
||||
close SPECTO;
|
||||
|
||||
print "Launch RPM build (rpm --clean -ba $BUILDROOT/${BUILDFIC})\n";
|
||||
$ret=`rpm --clean -ba $BUILDROOT/${BUILDFIC}`;
|
||||
|
||||
print "Move $RPMDIR/RPMS/noarch/${FILENAMERPM}.noarch.rpm into $DESTI/${FILENAMERPM}.noarch.rpm\n";
|
||||
$cmd="mv \"$RPMDIR/RPMS/noarch/${FILENAMERPM}.noarch.rpm\" \"$DESTI/${FILENAMERPM}.noarch.rpm\"";
|
||||
$ret=`$cmd`;
|
||||
next;
|
||||
}
|
||||
|
||||
if ($target eq 'DEB') {
|
||||
print "Automatic build for DEB is not yet supported.\n";
|
||||
}
|
||||
|
||||
if ($target eq 'EXE') {
|
||||
unlink "$FILENAMEEXE.exe";
|
||||
print "Compress into $FILENAMEEXE.exe by $FILENAMEEXE.nsi...\n";
|
||||
$command="\"$REQUIREMENTTARGET{$target}\" /DMUI_VERSION_DOT=$MAJOR.$MINOR.$BUILD /X\"SetCompressor bzip2\" \"$SOURCE\\build\\exe\\$FILENAME.nsi\"";
|
||||
print "$command\n";
|
||||
$ret=`$command`;
|
||||
print "Move $FILENAMEEXE.exe to $DESTI\n";
|
||||
rename("$SOURCE\\build\\exe\\$FILENAMEEXE.exe","$DESTI/$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 succeessfully in $DESTI\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (! $btach) {
|
||||
print "\nPress key to finish...";
|
||||
my $WAITKEY=<STDIN>;
|
||||
}
|
||||
|
||||
0;
|
||||
Loading…
Reference in New Issue
Block a user