Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 513 lines (444 sloc) 19.789 kb
805f404 @eldy Update version
eldy authored
1 #!/usr/bin/perl
2 #----------------------------------------------------------------------------
3 # \file build/makepack-dolibarr.pl
4 # \brief Dolibarr package builder (tgz, zip, rpm, deb, exe)
5 # \version $Revision$
f58993e @eldy doxygen
eldy authored
6 # \author (c)2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
805f404 @eldy Update version
eldy authored
7 #----------------------------------------------------------------------------
8
9 use Cwd;
10
11 $PROJECT="dolibarr";
c67f858 @eldy Version
eldy authored
12 $MAJOR="3";
13 $MINOR="0";
14 $BUILD="0-dev"; # Mettre x pour release, x-dev pour dev, x-beta pour beta, x-rc pour release candidate
805f404 @eldy Update version
eldy authored
15 $RPMSUBVERSION="1"; # A incrementer au moment de la release
16
f644fea @eldy Exclude conf file from snapshot
eldy authored
17 @LISTETARGET=("TGZ","ZIP","RPM","DEB","EXE","EXEDOLIWAMP","SNAPSHOT"); # Possible packages
805f404 @eldy Update version
eldy authored
18 %REQUIREMENTTARGET=( # Tool requirement for each package
53edbfd @eldy makepack can build snapshot
eldy authored
19 "SNAPSHOT"=>"tar",
805f404 @eldy Update version
eldy authored
20 "TGZ"=>"tar",
21 "ZIP"=>"7z",
22 "RPM"=>"rpmbuild",
4f284e1 @eldy Update package scripts
eldy authored
23 "DEB"=>"dpkg",
a6f4a66 @eldy Prepare 2.7.0
eldy authored
24 "EXE"=>"makensis.exe",
25 "EXEDOLIWAMP"=>"iscc.exe"
805f404 @eldy Update version
eldy authored
26 );
27 %ALTERNATEPATH=(
28 "7z"=>"7-ZIP",
29 "makensis.exe"=>"NSIS"
30 );
31
32 $FILENAME="$PROJECT";
53edbfd @eldy makepack can build snapshot
eldy authored
33 $FILENAMESNAPSHOT="$PROJECT-snapshot";
805f404 @eldy Update version
eldy authored
34 $FILENAMETGZ="$PROJECT-$MAJOR.$MINOR.$BUILD";
35 $FILENAMEZIP="$PROJECT-$MAJOR.$MINOR.$BUILD";
36 $FILENAMERPM="$PROJECT-$MAJOR.$MINOR.$BUILD-$RPMSUBVERSION";
37 $FILENAMEDEB="$PROJECT-$MAJOR.$MINOR.$BUILD";
38 $FILENAMEEXE="$PROJECT-$MAJOR.$MINOR.$BUILD";
a6f4a66 @eldy Prepare 2.7.0
eldy authored
39 $FILENAMEEXEDOLIWAMP="$PROJECT-$MAJOR.$MINOR.$BUILD";
805f404 @eldy Update version
eldy authored
40 if (-d "/usr/src/redhat") {
41 # redhat
42 $RPMDIR="/usr/src/redhat";
43 }
44 if (-d "/usr/src/RPM") {
45 # mandrake
46 $RPMDIR="/usr/src/RPM";
47 }
48
49
50 use vars qw/ $REVISION $VERSION /;
51 $REVISION='$Revision$'; $REVISION =~ /\s(.*)\s/; $REVISION=$1;
52 $VERSION="1.0 (build $REVISION)";
53
54
55
56 #------------------------------------------------------------------------------
57 # MAIN
58 #------------------------------------------------------------------------------
59 ($DIR=$0) =~ s/([^\/\\]+)$//; ($PROG=$1) =~ s/\.([^\.]*)$//; $Extension=$1;
60 $DIR||='.'; $DIR =~ s/([^\/\\])[\\\/]+$/$1/;
61
7b8786f @eldy Prepare release
eldy authored
62 $SOURCE="$DIR/..";
805f404 @eldy Update version
eldy authored
63 $DESTI="$SOURCE/build";
64
c317691 @eldy Backport after release
eldy authored
65
805f404 @eldy Update version
eldy authored
66 # Detect OS type
67 # --------------
68 if ("$^O" =~ /linux/i || (-d "/etc" && -d "/var" && "$^O" !~ /cygwin/i)) { $OS='linux'; $CR=''; }
69 elsif (-d "/etc" && -d "/Users") { $OS='macosx'; $CR=''; }
70 elsif ("$^O" =~ /cygwin/i || "$^O" =~ /win32/i) { $OS='windows'; $CR="\r"; }
71 if (! $OS) {
c317691 @eldy Backport after release
eldy authored
72 print "$PROG.$Extension was not able to detect your OS.\n";
805f404 @eldy Update version
eldy authored
73 print "Can't continue.\n";
c317691 @eldy Backport after release
eldy authored
74 print "$PROG.$Extension aborted.\n";
805f404 @eldy Update version
eldy authored
75 sleep 2;
76 exit 1;
77 }
78
79 # Define buildroot
80 # ----------------
81 if ($OS =~ /linux/) {
82 $TEMP=$ENV{"TEMP"}||$ENV{"TMP"}||"/tmp";
83 }
84 if ($OS =~ /macos/) {
85 $TEMP=$ENV{"TEMP"}||$ENV{"TMP"}||"/tmp";
86 }
87 if ($OS =~ /windows/) {
88 $TEMP=$ENV{"TEMP"}||$ENV{"TMP"}||"c:/temp";
89 $PROGPATH=$ENV{"ProgramFiles"};
90 }
91 if (! $TEMP || ! -d $TEMP) {
92 print "Error: A temporary directory can not be find.\n";
93 print "Check that TEMP or TMP environment variable is set correctly.\n";
c317691 @eldy Backport after release
eldy authored
94 print "$PROG.$Extension aborted.\n";
805f404 @eldy Update version
eldy authored
95 sleep 2;
96 exit 2;
97 }
98 $BUILDROOT="$TEMP/buildroot";
99
100
101 my $copyalreadydone=0;
016805f @eldy Fxi: Translate country in region list.
eldy authored
102 my $batch=0;
805f404 @eldy Update version
eldy authored
103
b43c5d2 @eldy makepack can build snapshot
eldy authored
104 for (0..@ARGV-1) {
016805f @eldy Fxi: Translate country in region list.
eldy authored
105 if ($ARGV[$_] =~ /^-*target=(\w+)/i) { $target=$1; $batch=1; }
b43c5d2 @eldy makepack can build snapshot
eldy authored
106 if ($ARGV[$_] =~ /^-*desti=(.+)/i) { $DESTI=$1; }
712898f @eldy Can build a snapshot on 3.0 version
eldy authored
107 if ($ARGV[$_] =~ /^-*prefix=(.+)/i) {
108 $PREFIX=$1;
109 $FILENAMESNAPSHOT.="-".$PREFIX;
110 }
b43c5d2 @eldy makepack can build snapshot
eldy authored
111 }
112
805f404 @eldy Update version
eldy authored
113 print "Makepack version $VERSION\n";
114 print "Building package name: $PROJECT\n";
115 print "Building package version: $MAJOR.$MINOR.$BUILD\n";
b43c5d2 @eldy makepack can build snapshot
eldy authored
116 print "Source directory: $SOURCE\n";
117 print "Target directory: $DESTI\n";
805f404 @eldy Update version
eldy authored
118
119
53edbfd @eldy makepack can build snapshot
eldy authored
120
805f404 @eldy Update version
eldy authored
121 # Choose package targets
122 #-----------------------
123 if ($target) {
124 $CHOOSEDTARGET{uc($target)}=1;
125 }
126 else {
127 my $found=0;
128 my $NUM_SCRIPT;
129 while (! $found) {
130 my $cpt=0;
131 printf(" %d - %3s (%s)\n",$cpt,"All","Need ".join(",",values %REQUIREMENTTARGET));
132 foreach my $target (@LISTETARGET) {
133 $cpt++;
134 printf(" %d - %3s (%s)\n",$cpt,$target,"Need ".$REQUIREMENTTARGET{$target});
135 }
136
a6f4a66 @eldy Prepare 2.7.0
eldy authored
137 # On demande de choisir le fichier à passer
805f404 @eldy Update version
eldy authored
138 print "Choose one package number or several separated with space: ";
139 $NUM_SCRIPT=<STDIN>;
140 chomp($NUM_SCRIPT);
141 if ($NUM_SCRIPT =~ s/-//g) {
142 # Do not do copy
143 $copyalreadydone=1;
144 }
145 if ($NUM_SCRIPT !~ /^[0-$cpt\s]+$/)
146 {
147 print "This is not a valid package number list.\n";
148 $found = 0;
149 }
150 else
151 {
152 $found = 1;
153 }
154 }
155 print "\n";
156 if ($NUM_SCRIPT) {
157 foreach my $num (split(/\s+/,$NUM_SCRIPT)) {
158 $CHOOSEDTARGET{$LISTETARGET[$num-1]}=1;
159 }
160 }
161 else {
162 foreach my $key (@LISTETARGET) {
163 $CHOOSEDTARGET{$key}=1;
164 }
165 }
166 }
167
168 # Test if requirement is ok
169 #--------------------------
170 foreach my $target (keys %CHOOSEDTARGET) {
171 foreach my $req (split(/[,\s]/,$REQUIREMENTTARGET{$target})) {
172 # Test
173 print "Test requirement for target $target: Search '$req'... ";
174 $ret=`"$req" 2>&1`;
175 $coderetour=$?; $coderetour2=$coderetour>>8;
176 if ($coderetour != 0 && (($coderetour2 == 1 && $OS =~ /windows/ && $ret !~ /Usage/i) || ($coderetour2 == 127 && $OS !~ /windows/)) && $PROGPATH) {
177 # Not found error, we try in PROGPATH
178 $ret=`"$PROGPATH/$ALTERNATEPATH{$req}/$req\" 2>&1`;
179 $coderetour=$?; $coderetour2=$coderetour>>8;
180 $REQUIREMENTTARGET{$target}="$PROGPATH/$ALTERNATEPATH{$req}/$req";
181 }
182
183 if ($coderetour != 0 && (($coderetour2 == 1 && $OS =~ /windows/ && $ret !~ /Usage/i) || ($coderetour2 == 127 && $OS !~ /windows/))) {
184 # Not found error
185 print "Not found\nCan't build target $target. Requirement '$req' not found in PATH\n";
186 $CHOOSEDTARGET{$target}=-1;
187 last;
188 } else {
189 # Pas erreur ou erreur autre que programme absent
190 print " Found ".$REQUIREMENTTARGET{$target}."\n";
191 }
192 }
193 }
194
195 print "\n";
196
197 # Check if there is at least on target to build
198 #----------------------------------------------
199 $nboftargetok=0;
a6f4a66 @eldy Prepare 2.7.0
eldy authored
200 $nboftargetneedbuildroot=0;
bd018de @eldy makepack can build snapshot
eldy authored
201 $nboftargetneedcvs=0;
805f404 @eldy Update version
eldy authored
202 foreach my $target (keys %CHOOSEDTARGET) {
203 if ($CHOOSEDTARGET{$target} < 0) { next; }
a6f4a66 @eldy Prepare 2.7.0
eldy authored
204 if ($target ne 'EXE' && $target ne 'EXEDOLIWAMP')
205 {
206 $nboftargetneedbuildroot++;
207 }
bd018de @eldy makepack can build snapshot
eldy authored
208 if ($target eq 'SNAPSHOT')
209 {
210 $nboftargetneedcvs++;
211 }
a6f4a66 @eldy Prepare 2.7.0
eldy authored
212 $nboftargetok++;
805f404 @eldy Update version
eldy authored
213 }
214
215 if ($nboftargetok) {
216
bd018de @eldy makepack can build snapshot
eldy authored
217 # Update CVS if required
218 #-----------------------
219 if ($nboftargetneedcvs)
220 {
ab432c5 @eldy Enhance packager
eldy authored
221 print "Go to directory $SOURCE\n";
bd018de @eldy makepack can build snapshot
eldy authored
222 chdir("$SOURCE");
ab432c5 @eldy Enhance packager
eldy authored
223 print "Run cvs update -P -d\n";
d88567d @eldy Redirect error output
eldy authored
224 $ret=`cvs update -P -d 2>&1`;
bd018de @eldy makepack can build snapshot
eldy authored
225 }
226
53edbfd @eldy makepack can build snapshot
eldy authored
227 # Update buildroot if required
228 #-----------------------------
a6f4a66 @eldy Prepare 2.7.0
eldy authored
229 if ($nboftargetneedbuildroot)
230 {
231 if (! $copyalreadydone) {
232 print "Delete directory $BUILDROOT\n";
233 $ret=`rm -fr "$BUILDROOT"`;
234
235 mkdir "$BUILDROOT";
236 mkdir "$BUILDROOT/dolibarr";
237 print "Copy $SOURCE into $BUILDROOT/dolibarr\n";
238 $ret=`cp -pr "$SOURCE" "$BUILDROOT/dolibarr"`;
239 }
240 print "Clean $BUILDROOT\n";
32dfb93 @eldy Update package for debian
eldy authored
241 $ret=`rm -fr $BUILDROOT/$PROJECT/.cache`;
242 $ret=`rm -fr $BUILDROOT/$PROJECT/.project`;
243 $ret=`rm -fr $BUILDROOT/$PROJECT/.settings`;
a6f4a66 @eldy Prepare 2.7.0
eldy authored
244 $ret=`rm -fr $BUILDROOT/$PROJECT/index.php`;
8957f0a @eldy Prepare 3.0 branch
eldy authored
245 $ret=`rm -fr $BUILDROOT/$PROJECT/build/html`;
a6f4a66 @eldy Prepare 2.7.0
eldy authored
246 $ret=`rm -fr $BUILDROOT/$PROJECT/documents`;
247 $ret=`rm -fr $BUILDROOT/$PROJECT/document`;
e49763d @eldy Enhance debian installer
eldy authored
248 $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/conf/conf.php.mysql`;
2578562 @eldy Sec: Exclude backup files from packages
eldy authored
249 $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/conf/conf.php.old`;
e49763d @eldy Enhance debian installer
eldy authored
250 $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/conf/conf.php.postgres`;
888e45c @eldy Removed useless files into deb package
eldy authored
251 $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/conf/conf*sav*`;
8957f0a @eldy Prepare 3.0 branch
eldy authored
252 $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/custom`;
3ec093a @eldy Prepare 3.0
eldy authored
253 $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/custom2`;
254 $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/theme/bureau2crea`;
8957f0a @eldy Prepare 3.0 branch
eldy authored
255 $ret=`rm -fr $BUILDROOT/$PROJECT/test`;
a6f4a66 @eldy Prepare 2.7.0
eldy authored
256 $ret=`rm -fr $BUILDROOT/$PROJECT/Thumbs.db $BUILDROOT/$PROJECT/*/Thumbs.db $BUILDROOT/$PROJECT/*/*/Thumbs.db $BUILDROOT/$PROJECT/*/*/*/Thumbs.db $BUILDROOT/$PROJECT/*/*/*/*/Thumbs.db`;
257 $ret=`rm -fr $BUILDROOT/$PROJECT/CVS* $BUILDROOT/$PROJECT/*/CVS* $BUILDROOT/$PROJECT/*/*/CVS* $BUILDROOT/$PROJECT/*/*/*/CVS* $BUILDROOT/$PROJECT/*/*/*/*/CVS* $BUILDROOT/$PROJECT/*/*/*/*/*/CVS*`;
62d4e24 @eldy Enhance packager
eldy authored
258 }
805f404 @eldy Update version
eldy authored
259
260 # Build package for each target
261 #------------------------------
262 foreach my $target (keys %CHOOSEDTARGET) {
263 if ($CHOOSEDTARGET{$target} < 0) { next; }
264
265 print "\nBuild package for target $target\n";
53edbfd @eldy makepack can build snapshot
eldy authored
266
267 if ($target eq 'SNAPSHOT') {
4f284e1 @eldy Update package scripts
eldy authored
268 print "Rename $BUILDROOT/$PROJECT to $BUILDROOT/$FILENAMESNAPSHOT\n";
53edbfd @eldy makepack can build snapshot
eldy authored
269 rename("$BUILDROOT/$PROJECT","$BUILDROOT/$FILENAMESNAPSHOT");
40d4007 @eldy Fix: Remove Perl warnings
eldy authored
270 unlink("$FILENAMESNAPSHOT.tgz");
ab432c5 @eldy Enhance packager
eldy authored
271
4f284e1 @eldy Update package scripts
eldy authored
272 print "Compress $BUILDROOT into $FILENAMESNAPSHOT.tgz...\n";
273 #$cmd="tar --exclude \"$BUILDROOT/tgz/tar_exclude.txt\" --exclude .cache --exclude .settings --exclude conf.php --directory \"$BUILDROOT\" -czvf \"$FILENAMESNAPSHOT.tgz\" $FILENAMESNAPSHOT";
0c61e54 @eldy Fix: Set correct owner on build package
eldy authored
274 $cmd="tar --exclude .cache --exclude .settings --exclude conf.php --exclude conf.php.mysql --exclude conf.php.old --exclude conf.php.postgres --directory \"$BUILDROOT\" --mode=go-w --group=500 --owner=500 -czvf \"$FILENAMESNAPSHOT.tgz\" $FILENAMESNAPSHOT";
4f284e1 @eldy Update package scripts
eldy authored
275 print $cmd."\n";
53edbfd @eldy makepack can build snapshot
eldy authored
276 $ret=`$cmd`;
277 if ($OS =~ /windows/i)
278 {
279 print "Move $FILENAMESNAPSHOT.tgz to $DESTI/$FILENAMESNAPSHOT.tgz\n";
280 $ret=`mv "$FILENAMESNAPSHOT.tgz" "$DESTI/$FILENAMESNAPSHOT.tgz"`;
281 }
282 else
283 {
ab432c5 @eldy Enhance packager
eldy authored
284 print "Move $FILENAMESNAPSHOT.tgz to $DESTI/$FILENAMESNAPSHOT.tgz\n";
53edbfd @eldy makepack can build snapshot
eldy authored
285 $ret=`mv "$FILENAMESNAPSHOT.tgz" "$DESTI/$FILENAMESNAPSHOT.tgz"`;
286 }
287 next;
288 }
289
805f404 @eldy Update version
eldy authored
290 if ($target eq 'TGZ') {
4f284e1 @eldy Update package scripts
eldy authored
291 print "Rename $BUILDROOT/$PROJECT to $BUILDROOT/$FILENAMETGZ\n";
53edbfd @eldy makepack can build snapshot
eldy authored
292 rename("$BUILDROOT/$PROJECT","$BUILDROOT/$FILENAMETGZ");
0ffa0f0 @eldy Better packager
eldy authored
293 print "Remove target $FILENAMETGZ.tgz...\n";
40d4007 @eldy Fix: Remove Perl warnings
eldy authored
294 unlink("$FILENAMETGZ.tgz");
805f404 @eldy Update version
eldy authored
295 print "Compress $FILENAMETGZ into $FILENAMETGZ.tgz...\n";
0c61e54 @eldy Fix: Set correct owner on build package
eldy authored
296 $cmd="tar --exclude-vcs --exclude-from \"$DESTI/tgz/tar_exclude.txt\" --directory \"$BUILDROOT\" --mode=go-w --group=500 --owner=500 -czvf \"$FILENAMETGZ.tgz\" $FILENAMETGZ";
805f404 @eldy Update version
eldy authored
297 $ret=`$cmd`;
298 if ($OS =~ /windows/i)
299 {
300 print "Move $FILENAMETGZ.tgz to $DESTI/$FILENAMETGZ.tgz\n";
301 $ret=`mv "$FILENAMETGZ.tgz" "$DESTI/$FILENAMETGZ.tgz"`;
302 }
303 else
304 {
305 $ret=`mv "$FILENAMETGZ.tgz" "$DESTI/$FILENAMETGZ.tgz"`;
306 }
307 next;
308 }
309
310 if ($target eq 'ZIP') {
4f284e1 @eldy Update package scripts
eldy authored
311 print "Rename $BUILDROOT/$PROJECT to $BUILDROOT/$FILENAMETGZ\n";
53edbfd @eldy makepack can build snapshot
eldy authored
312 rename("$BUILDROOT/$PROJECT","$BUILDROOT/$FILENAMETGZ");
40d4007 @eldy Fix: Remove Perl warnings
eldy authored
313 unlink("$FILENAMEZIP.zip");
805f404 @eldy Update version
eldy authored
314 print "Compress $FILENAMETGZ into $FILENAMEZIP.zip...\n";
88a6f50 @eldy Update package scripts
eldy authored
315
4f284e1 @eldy Update package scripts
eldy authored
316 print "Go to directory $BUILDROOT\n";
805f404 @eldy Update version
eldy authored
317 chdir("$BUILDROOT");
88a6f50 @eldy Update package scripts
eldy authored
318
5ff8353 @eldy Update package tools
eldy authored
319 $cmd= "7z a -r -tzip -xr\@\"$BUILDROOT\/$FILENAMETGZ\/build\/zip\/zip_exclude.txt\" -mx $BUILDROOT/$FILENAMEZIP.zip $FILENAMETGZ\\*";
4f284e1 @eldy Update package scripts
eldy authored
320 print $cmd."\n";
805f404 @eldy Update version
eldy authored
321 $ret= `$cmd`;
322 #print $ret;
4f284e1 @eldy Update package scripts
eldy authored
323 #print "Go to directory $DESTI\n";
324 #chdir("$DESTI");
805f404 @eldy Update version
eldy authored
325 print "Move $FILENAMEZIP.zip to $DESTI\n";
326 rename("$BUILDROOT/$FILENAMEZIP.zip","$DESTI/$FILENAMEZIP.zip");
327 next;
328 }
329
330 if ($target eq 'RPM') { # Linux only
ab432c5 @eldy Enhance packager
eldy authored
331 print "RPM build is not yet available\n";
332 return;
333
4f284e1 @eldy Update package scripts
eldy authored
334 print "Rename $BUILDROOT/$PROJECT to $BUILDROOT/$FILENAMETGZ\n";
53edbfd @eldy makepack can build snapshot
eldy authored
335 rename("$BUILDROOT/$PROJECT","$BUILDROOT/$FILENAMETGZ");
40d4007 @eldy Fix: Remove Perl warnings
eldy authored
336 unlink("$FILENAMETGZ.tgz");
805f404 @eldy Update version
eldy authored
337 print "Compress $FILENAMETGZ into $FILENAMETGZ.tgz...\n";
338 $ret=`tar --exclude-from "$SOURCE/build/tgz/tar_exclude.txt" --directory "$BUILDROOT" -czvf "$BUILDROOT/$FILENAMETGZ.tgz" $FILENAMETGZ`;
339
340 print "Move $FILENAMETGZ.tgz to $RPMDIR/SOURCES/$FILENAMETGZ.tgz\n";
341 $cmd="mv \"$BUILDROOT/$FILENAMETGZ.tgz\" \"$RPMDIR/SOURCES/$FILENAMETGZ.tgz\"";
342 $ret=`$cmd`;
343
53edbfd @eldy makepack can build snapshot
eldy authored
344 $BUILDFIC="$FILENAME.spec";
62d4e24 @eldy Enhance packager
eldy authored
345 print "Generate file $BUILDROOT/$BUILDFIC\n";
4f284e1 @eldy Update package scripts
eldy authored
346 open (SPECFROM,"<$SOURCE/build/rpm/${BUILDFIC}") || die "Error";
805f404 @eldy Update version
eldy authored
347 open (SPECTO,">$BUILDROOT/$BUILDFIC") || die "Error";
348 while (<SPECFROM>) {
349 $_ =~ s/__VERSION__/$MAJOR.$MINOR.$BUILD/;
350 print SPECTO $_;
351 }
352 close SPECFROM;
353 close SPECTO;
354
355 print "Launch RPM build (rpm --clean -ba $BUILDROOT/${BUILDFIC})\n";
356 $ret=`rpm --clean -ba $BUILDROOT/${BUILDFIC}`;
357
358 print "Move $RPMDIR/RPMS/noarch/${FILENAMERPM}.noarch.rpm into $DESTI/${FILENAMERPM}.noarch.rpm\n";
359 $cmd="mv \"$RPMDIR/RPMS/noarch/${FILENAMERPM}.noarch.rpm\" \"$DESTI/${FILENAMERPM}.noarch.rpm\"";
360 $ret=`$cmd`;
361 next;
362 }
363
364 if ($target eq 'DEB') {
62d4e24 @eldy Enhance packager
eldy authored
365
366 $ret=`rm -fr $BUILDROOT/$PROJECT/.cvsignore $BUILDROOT/$PROJECT/*/.cvsignore $BUILDROOT/$PROJECT/*/*/.cvsignore $BUILDROOT/$PROJECT/*/*/*/.cvsignore $BUILDROOT/$PROJECT/*/*/*/*/.cvsignore $BUILDROOT/$PROJECT/*/*/*/*/*/.cvsignore $BUILDROOT/$PROJECT/*/*/*/*/*/*/.cvsignore`;
367
32dfb93 @eldy Update package for debian
eldy authored
368 print "Move $BUILDROOT/$PROJECT $BUILDROOT/$PROJECT.tmp\n";
369 $cmd="mv \"$BUILDROOT/$PROJECT\" \"$BUILDROOT/$PROJECT.tmp\"";
370 $ret=`$cmd`;
371
372 print "Create directory $BUILDROOT/$PROJECT/usr/share\n";
373 $ret=`mkdir -p "$BUILDROOT/$PROJECT/usr/share"`;
374
375 print "Move $BUILDROOT/$PROJECT.tmp $BUILDROOT/$PROJECT/usr/share/$PROJECT\n";
376 $cmd="mv \"$BUILDROOT/$PROJECT.tmp\" \"$BUILDROOT/$PROJECT/usr/share/$PROJECT\"";
377 $ret=`$cmd`;
378
379 print "Create directory $BUILDROOT/$PROJECT/DEBIAN\n";
4f284e1 @eldy Update package scripts
eldy authored
380 $ret=`mkdir "$BUILDROOT/$PROJECT/DEBIAN"`;
32dfb93 @eldy Update package for debian
eldy authored
381 print "Copy $SOURCE/build/deb/* to $BUILDROOT/$PROJECT/DEBIAN\n";
382 $ret=`cp -r "$SOURCE/build/deb/." "$BUILDROOT/$PROJECT/DEBIAN"`;
383 $ret=`rm -fr $BUILDROOT/$PROJECT/DEBIAN/CVS`;
4f284e1 @eldy Update package scripts
eldy authored
384
8fe1730 @eldy New: Debian package build is finished.
eldy authored
385 print "Remove config file\n";
386 $ret=`rm -f $BUILDROOT/$PROJECT/usr/share/$PROJECT/htdocs/conf/conf.php`;
49e701c @eldy Update package for debian
eldy authored
387
f4db921 @eldy Enhance deb packager
eldy authored
388 print "Remove other files\n";
389 $ret=`rm -f $BUILDROOT/$PROJECT/usr/share/$PROJECT/build/DoliWamp-*`;
390 $ret=`rm -f $BUILDROOT/$PROJECT/usr/share/$PROJECT/build/DoliMamp-*`;
391 $ret=`rm -f $BUILDROOT/$PROJECT/usr/share/$PROJECT/build/dolibarr-*.tar`;
392 $ret=`rm -f $BUILDROOT/$PROJECT/usr/share/$PROJECT/build/dolibarr-*.tgz`;
393 $ret=`rm -f $BUILDROOT/$PROJECT/usr/share/$PROJECT/build/dolibarr-*.zip`;
394 $ret=`rm -f $BUILDROOT/$PROJECT/usr/share/$PROJECT/build/dolibarr-*.deb`;
888e45c @eldy Removed useless files into deb package
eldy authored
395 $ret=`rm -f $BUILDROOT/$PROJECT/usr/share/$PROJECT/build/doxygen/doxygen_warnings.log`;
396 $ret=`rm -fr $BUILDROOT/$PROJECT/usr/share/$PROJECT/build/html`;
397 $ret=`rm -fr $BUILDROOT/$PROJECT/usr/share/$PROJECT/dev/dbmodel`;
398 $ret=`rm -fr $BUILDROOT/$PROJECT/usr/share/$PROJECT/dev/fpdf`;
399 $ret=`rm -fr $BUILDROOT/$PROJECT/usr/share/$PROJECT/dev/initdata`;
400 $ret=`rm -fr $BUILDROOT/$PROJECT/usr/share/$PROJECT/dev/iso-normes`;
401 $ret=`rm -fr $BUILDROOT/$PROJECT/usr/share/$PROJECT/dev/phpcheckstyle`;
402 $ret=`rm -fr $BUILDROOT/$PROJECT/usr/share/$PROJECT/dev/phpunit`;
403 $ret=`rm -fr $BUILDROOT/$PROJECT/usr/share/$PROJECT/dev/spec`;
404 $ret=`rm -fr $BUILDROOT/$PROJECT/usr/share/$PROJECT/dev/uml`;
405 $ret=`rm -fr $BUILDROOT/$PROJECT/usr/share/$PROJECT/dev/xdebug`;
3fe86b3 @eldy Exclude huge files from package
eldy authored
406 $ret=`rm -fr $BUILDROOT/$PROJECT/usr/share/$PROJECT/doc/flyer`;
407 $ret=`rm -fr $BUILDROOT/$PROJECT/usr/share/$PROJECT/doc/font`;
408 $ret=`rm -fr $BUILDROOT/$PROJECT/usr/share/$PROJECT/doc/tshirt`;
409 $ret=`rm -fr $BUILDROOT/$PROJECT/usr/share/$PROJECT/doc/rollup`;
e49763d @eldy Enhance debian installer
eldy authored
410 $ret=`rm -fr $BUILDROOT/$PROJECT/usr/share/$PROJECT/htdocs/conf/conf.php.mysql`;
2578562 @eldy Sec: Exclude backup files from packages
eldy authored
411 $ret=`rm -fr $BUILDROOT/$PROJECT/usr/share/$PROJECT/htdocs/conf/conf.php.old`;
e49763d @eldy Enhance debian installer
eldy authored
412 $ret=`rm -fr $BUILDROOT/$PROJECT/usr/share/$PROJECT/htdocs/conf/conf.php.postgres`;
888e45c @eldy Removed useless files into deb package
eldy authored
413 $ret=`rm -fr $BUILDROOT/$PROJECT/usr/share/$PROJECT/htdocs/conf/conf*sav*`;
cddd5e1 @eldy Add unit test
eldy authored
414 $ret=`rm -fr $BUILDROOT/$PROJECT/usr/share/$PROJECT/test`;
e5b7038 @eldy Prepare 3.0 package
eldy authored
415 # To remove once stable
416 $ret=`rm -f $BUILDROOT/$PROJECT/usr/share/$PROJECT/htdocs/incluces/modules/facture/doc/doc_generic_invoice_odt.modules.php`;
417 $ret=`rm -fr $BUILDROOT/$PROJECT/usr/share/$PROJECT/htdocs/htdocs/theme/bureau2crea`;
f4db921 @eldy Enhance deb packager
eldy authored
418
88a6f50 @eldy Update package scripts
eldy authored
419 print "Edit version in file $BUILDROOT/$PROJECT/DEBIAN/control\n";
420 open (SPECFROM,"<$SOURCE/build/deb/control") || die "Error";
4f284e1 @eldy Update package scripts
eldy authored
421 open (SPECTO,">$BUILDROOT/$PROJECT/DEBIAN/control") || die "Error";
422 while (<SPECFROM>) {
32dfb93 @eldy Update package for debian
eldy authored
423 $newbuild = $BUILD;
3735946 @eldy Update debian package
eldy authored
424 $newbuild =~ s/dev/0/gi;
32dfb93 @eldy Update package for debian
eldy authored
425 $newbuild =~ s/alpha/0/gi;
426 $newbuild =~ s/beta/1/gi;
427 if ($newbuild !~ /-/) { $newbuild.='-2'; }
428 $_ =~ s/__VERSION__/$MAJOR.$MINOR.$newbuild/;
4f284e1 @eldy Update package scripts
eldy authored
429 print SPECTO $_;
430 }
431 close SPECFROM;
432 close SPECTO;
32dfb93 @eldy Update package for debian
eldy authored
433
62d4e24 @eldy Enhance packager
eldy authored
434 print "Create directory $BUILDROOT/$PROJECT/usr/share/$PROJECT/documents\n";
435 $ret=`mkdir -p "$BUILDROOT/$PROJECT/usr/share/$PROJECT/documents"`;
436
8fb1d90 @eldy Fix: Package debian uninstall
eldy authored
437 #print "Create directory $BUILDROOT/$PROJECT/etc/$PROJECT\n";
438 #$ret=`mkdir -p "$BUILDROOT/$PROJECT/etc/$PROJECT"`;
32dfb93 @eldy Update package for debian
eldy authored
439
440 #print "Copy changelog file into $BUILDROOT/$PROJECT/DEBIAN\n";
441 #$ret=`cp "$SOURCE/ChangeLog" "$BUILDROOT/$PROJECT/DEBIAN/changelog"`;
442
443 print "Copy README file into $BUILDROOT/$PROJECT/DEBIAN\n";
444 $ret=`cp "$SOURCE/README" "$BUILDROOT/$PROJECT/DEBIAN/README"`;
445
446 print "Copy copyright file into $BUILDROOT/$PROJECT/DEBIAN\n";
447 $ret=`cp "$SOURCE/COPYRIGHT" "$BUILDROOT/$PROJECT/DEBIAN/copyright"`;
448
8fb1d90 @eldy Fix: Package debian uninstall
eldy authored
449 #print "Copy apache conf file into $BUILDROOT/$PROJECT/etc/$PROJECT\n";
450 #$ret=`cp "$SOURCE/build/deb/apache.conf" "$BUILDROOT/$PROJECT/etc/$PROJECT"`;
62d4e24 @eldy Enhance packager
eldy authored
451
452 print "Set permissions/owners on files/dir\n";
453 $ret=`chown -R root.root $BUILDROOT/$PROJECT`;
454 $ret=`chown -R www-data.www-data $BUILDROOT/$PROJECT/usr/share/$PROJECT/documents`;
455 $ret=`chmod -R 555 $BUILDROOT/$PROJECT`;
59a51f8 @eldy Fix: Packaging for ubuntu 10.10
eldy authored
456 $ret=`chmod 755 $BUILDROOT/$PROJECT`;
62d4e24 @eldy Enhance packager
eldy authored
457 $ret=`chmod -R 755 $BUILDROOT/$PROJECT/usr/share/$PROJECT/documents`;
458 $ret=`chmod -R 755 $BUILDROOT/$PROJECT/DEBIAN`;
32dfb93 @eldy Update package for debian
eldy authored
459
88a6f50 @eldy Update package scripts
eldy authored
460 print "Go to directory $BUILDROOT\n";
461 chdir("$BUILDROOT");
462
32dfb93 @eldy Update package for debian
eldy authored
463 $cmd="dpkg -b $BUILDROOT/$PROJECT $BUILDROOT/${FILENAMEDEB}.deb";
464 print "Launch DEB build ($cmd)\n";
88a6f50 @eldy Update package scripts
eldy authored
465 $ret=`$cmd`;
466 print $ret."\n";
4f284e1 @eldy Update package scripts
eldy authored
467 next;
805f404 @eldy Update version
eldy authored
468 }
469
470 if ($target eq 'EXE') {
471 unlink "$FILENAMEEXE.exe";
472 print "Compress into $FILENAMEEXE.exe by $FILENAMEEXE.nsi...\n";
473 $command="\"$REQUIREMENTTARGET{$target}\" /DMUI_VERSION_DOT=$MAJOR.$MINOR.$BUILD /X\"SetCompressor bzip2\" \"$SOURCE\\build\\exe\\$FILENAME.nsi\"";
474 print "$command\n";
475 $ret=`$command`;
476 print "Move $FILENAMEEXE.exe to $DESTI\n";
477 rename("$SOURCE\\build\\exe\\$FILENAMEEXE.exe","$DESTI/$FILENAMEEXE.exe");
478 next;
479 }
480
a6f4a66 @eldy Prepare 2.7.0
eldy authored
481 if ($target eq 'EXEDOLIWAMP')
482 {
483 unlink "$FILENAMEEXEDOLIWAMP.exe";
484 print "Compil exe $FILENAMEEXEDOLIWAMP.exe file from iss file \"$SOURCE\\build\\exe\\doliwamp\\doliwamp.iss\"\n";
485 $cmd= "iscc.exe \"$SOURCE\\build\\exe\\doliwamp\\doliwamp.iss\"";
486 print "$cmd\n";
487 $ret= `$cmd`;
488 #print "$ret\n";
489 print "Move \"$SOURCE\\build\\$FILENAMEEXEDOLIWAMP.exe\" to $DESTI/$FILENAMEEXEDOLIWAMP.exe\n";
490 rename("$SOURCE/build/$FILENAMEEXEDOLIWAMP.exe","$DESTI/$FILENAMEEXEDOLIWAMP.exe");
491 next;
492 }
493
805f404 @eldy Update version
eldy authored
494 }
495
496 }
497
498 print "\n----- Summary -----\n";
499 foreach my $target (keys %CHOOSEDTARGET) {
500 if ($CHOOSEDTARGET{$target} < 0) {
501 print "Package $target not built (bad requirement).\n";
502 } else {
7d48904 @eldy Fix typo
eldy authored
503 print "Package $target built successfully in $DESTI\n";
805f404 @eldy Update version
eldy authored
504 }
505 }
506
016805f @eldy Fxi: Translate country in region list.
eldy authored
507 if (! $batch) {
805f404 @eldy Update version
eldy authored
508 print "\nPress key to finish...";
509 my $WAITKEY=<STDIN>;
510 }
511
512 0;
Something went wrong with that request. Please try again.