mirror of https://github.com/CGAL/cgal
470 lines
14 KiB
Perl
Executable File
470 lines
14 KiB
Perl
Executable File
#!/usr/bin/env perl
|
|
#this script generates the internal release
|
|
|
|
use Cwd;
|
|
use File::Find;
|
|
use Getopt::Std;
|
|
use File::Spec;
|
|
|
|
sub usage() {
|
|
print STDERR<<"EOF";
|
|
usage:
|
|
$0 (-h|-r)
|
|
[-n version number]
|
|
[-d releasedir] [-a allpackagesdir]
|
|
[-l lockfile]
|
|
|
|
Exactly one of the options -h or -r must be present.
|
|
-h show this message and quit
|
|
-r release version to be created
|
|
|
|
-n version number (CGAL_VERSION_NR)
|
|
-d releasedir, default releasedir is the current dir
|
|
-a allpackagesdir, default is releasedir/trunk
|
|
-l lockfile, default is releasedir/release_creation.lock
|
|
|
|
The version number is stored in VERSION and include/CGAL/version.h.
|
|
The RELEASEDIR is the place where the new release will be created.
|
|
The ALLPACKAGESDIR is the directory that contains the checked out packages
|
|
from the SVN. Could be trunk or some branch.
|
|
The LOCKFILE is some file used by lockfile command as a mutex.
|
|
|
|
Example of how to use the script:
|
|
>svn co svn+ssh://scm.gforge.inria.fr/svn/cgal/trunk
|
|
>./create_internal_release -r CGAL-3.3-I-1
|
|
or
|
|
>./create_internal_release -r CGAL-3.3-I-7 -d \$HOME -a \$HOME/CGALSVN/trunk -l release_creation.lock
|
|
|
|
|
|
EOF
|
|
}
|
|
|
|
|
|
my $TEMPFILE="TEMPFILE.$$";
|
|
|
|
#----------------------------------------------------#
|
|
# Initialisation #
|
|
#----------------------------------------------------#
|
|
|
|
my (
|
|
$VERSION,
|
|
$VERSION_NR,
|
|
$LOCKFILE,
|
|
$ALLPACKAGESDIR,
|
|
$RELEASEDIR,
|
|
$MAINDIR,
|
|
$SCRIPTSDIR,
|
|
$DEVELSCRIPTSDIR,
|
|
$LOCKCMD,
|
|
$packages_file
|
|
);
|
|
|
|
|
|
|
|
|
|
sub termination_signal_handler {
|
|
unlink $LOCKFILE;
|
|
exit 1;
|
|
}
|
|
|
|
sub lock()
|
|
{
|
|
if (system("$LOCKCMD", "-r", '10', "$LOCKFILE") != 0) {
|
|
print STDERR <<"TOTHIER";
|
|
The script could not proceed because
|
|
it could not acquire the needed lock on file $LOCKFILE.
|
|
TOTHIER
|
|
exit 1;
|
|
}
|
|
$SIG{INT} = \&termination_signal_handler;
|
|
$SIG{TERM} = \&termination_signal_handler;
|
|
}
|
|
|
|
sub unlock()
|
|
{
|
|
unlink $LOCKFILE;
|
|
$SIG{INT} = 'DEFAULT';
|
|
$SIG{TERM} = 'DEFAULT';
|
|
}
|
|
|
|
sub install_packages() {
|
|
my ($filename, $direc, %is_permited_package, $package_name, $tmp_package_name);
|
|
print "Installing packages ...\n";
|
|
chdir $RELEASEDIR or die;
|
|
if (! -f $packages_file){
|
|
print STDERR "$packages_file file does not exist\n";
|
|
unlock;
|
|
die "\n";
|
|
}
|
|
|
|
open PACKAGES_TO_INCLUDE, "$packages_file" or die;
|
|
while (<PACKAGES_TO_INCLUDE>){
|
|
chomp;
|
|
s/\s*//g;
|
|
next if /^$/;
|
|
$is_permitted_package{$_}=1;
|
|
}
|
|
close PACKAGES_TO_INCLUDE;
|
|
|
|
opendir ALLPACKAGESDIR, $ALLPACKAGESDIR or die;
|
|
while (defined($package_name = readdir(ALLPACKAGESDIR))) {
|
|
next unless $is_permitted_package{$package_name};
|
|
$dont_submit="$ALLPACKAGESDIR/$package_name/dont_submit";
|
|
$exclude_command="--exclude-from=$dont_submit";
|
|
chdir "$ALLPACKAGESDIR" or die;
|
|
if(-f $dont_submit){
|
|
system('tar', '-cf', "$RELEASEDIR/temppack.tar", '--exclude=.svn', "$exclude_command", '--exclude=TODO', '--exclude=todo', '--exclude=todo.txt', '--exclude=TODO.txt', '--exclude=TO_DO', '--exclude=dont_submit', '--exclude=*.dxy', '--exclude=Doxyfile', "$package_name");
|
|
} else {
|
|
system('tar', '-cf', "$RELEASEDIR/temppack.tar", '--exclude=.svn', '--exclude=dont_submit', '--exclude=TODO', '--exclude=todo', '--exclude=todo.txt', '--exclude=TODO.txt', '--exclude=TO_DO', '--exclude=*.dxy', '--exclude=Doxyfile', "$package_name");
|
|
}
|
|
system('mv', "$RELEASEDIR/temppack.tar", "$RELEASEDIR/$VERSION/");
|
|
|
|
|
|
chdir "$RELEASEDIR/$VERSION" or die;
|
|
system('tar', '-xf', "temppack.tar");
|
|
$tmp_package_name = "temp_${package_name}";
|
|
system("mv", "$package_name", "$tmp_package_name");
|
|
opendir packagename, "$tmp_package_name";
|
|
@fichiers = readdir packagename;
|
|
closedir packagename;
|
|
#shift @fichiers; shift @fichiers;
|
|
foreach $fichier (@fichiers){
|
|
if ($fichier ne '.' && $fichier ne '..'){
|
|
system('cp', '-r', "$tmp_package_name/$fichier", "$RELEASEDIR/$VERSION");
|
|
}
|
|
}
|
|
system('rm', '-rf', "$tmp_package_name");
|
|
}
|
|
closedir ALLPACKAGESDIR;
|
|
unlink 'temppack.tar';
|
|
}
|
|
|
|
|
|
#-----------------------------------------------------------------------#
|
|
# set the version information in VERSION and include/CGAL/version.h #
|
|
#-----------------------------------------------------------------------#
|
|
|
|
sub create_version_file()
|
|
{
|
|
#if VERSION starts with CGAL-, we remove "CGAL-" from version
|
|
#the $newver variable will store the right version
|
|
if ($result = $VERSION =~ /CGAL-(.*)/){
|
|
$newver = $1;
|
|
} else {
|
|
$newver = $VERSION;
|
|
}
|
|
|
|
# Create VERSION file
|
|
chdir "$RELEASEDIR/$VERSION" or die;
|
|
open(TEMPFILE, ">tempfile") or die;
|
|
print TEMPFILE "$newver";
|
|
close TEMPFILE || die "Error closing temporary file: $!\n";
|
|
system('mv', "tempfile", 'VERSION');
|
|
|
|
# Create include/CGAL/version.h file
|
|
chdir "$RELEASEDIR/$VERSION/include/CGAL" or die;
|
|
open(TEMPFILE, ">tempfile") or die;
|
|
|
|
# TODO : add `svnversion` Revision.
|
|
|
|
print TEMPFILE << 'EOF';
|
|
// Copyright (c) 2006 Utrecht University (The Netherlands),
|
|
// ETH Zurich (Switzerland), Freie Universitaet Berlin (Germany),
|
|
// INRIA Sophia-Antipolis (France), Martin-Luther-University Halle-Wittenberg
|
|
// (Germany), Max-Planck-Institute Saarbruecken (Germany), RISC Linz (Austria),
|
|
// and Tel-Aviv University (Israel). All rights reserved.
|
|
//
|
|
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
|
|
// modify it under the terms of the GNU Lesser General Public License as
|
|
// published by the Free Software Foundation; version 2.1 of the License.
|
|
// See the file LICENSE.LGPL distributed with CGAL.
|
|
//
|
|
// Licensees holding a valid commercial license may use this file in
|
|
// accordance with the commercial license agreement provided with the software.
|
|
//
|
|
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
|
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
//
|
|
// Author(s) : -
|
|
|
|
// This file is automatically created by create_internal_release.
|
|
// Do not edit manually.
|
|
|
|
#ifndef CGAL_VERSION_H
|
|
#define CGAL_VERSION_H
|
|
|
|
EOF
|
|
print TEMPFILE "#define CGAL_VERSION $newver\n";
|
|
print TEMPFILE "#define CGAL_VERSION_NR $VERSION_NR\n";
|
|
print TEMPFILE "#define CGAL_SVN_REVISION 0\n\n#endif\n";
|
|
|
|
close TEMPFILE || die "Error closing temporary file: $!\n";
|
|
system('mv', "tempfile", 'version.h');
|
|
chdir '../..' or die;
|
|
}
|
|
|
|
#-----------------------------------------------------------------------#
|
|
# set the version information in the doc_tex/version.tex #
|
|
#-----------------------------------------------------------------------#
|
|
|
|
sub create_version_tex_file()
|
|
{
|
|
chdir "$RELEASEDIR/$VERSION/doc_tex" or die;
|
|
open(TEMPFILE, ">tempfile") or die;
|
|
#if VERSION starts with CGAL-, we remove "CGAL-" from version
|
|
#the $newver variable will store the right version
|
|
if ($result = $VERSION =~ /CGAL-(.*)/){
|
|
$newver = $1;
|
|
} else {
|
|
$newver = $VERSION;
|
|
}
|
|
|
|
# And here we also strip the -I-... part to get the public version number
|
|
if ($result = $VERSION =~ /CGAL-(.*)-I-/){
|
|
$publicver = $1;
|
|
} else {
|
|
$publicver = $VERSION;
|
|
}
|
|
|
|
print TEMPFILE << 'EOF';
|
|
%% This file is automatically created by create_internal_release.
|
|
%% Do not edit manually.
|
|
|
|
EOF
|
|
print TEMPFILE "\\gdef\\cgalversion{$publicver}\n";
|
|
print TEMPFILE "\\gdef\\cgalinternalversion{$newver}\n";
|
|
|
|
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
|
|
|
|
my @months = ( "January", "February", "March", "April",
|
|
"May", "June", "July", "August", "September",
|
|
"October", "November", "December" );
|
|
|
|
print TEMPFILE "\\gdef\\cgalversiondate{$mday $months[$mon] ", 1900 + $year, "}\n";
|
|
|
|
close TEMPFILE || die "Error closing temporary file: $!\n";
|
|
system('mv', "tempfile", 'version.tex');
|
|
chdir '../..' or die;
|
|
}
|
|
|
|
|
|
#---------------------------------------------------------------#
|
|
# CreateExampleTestDirs
|
|
#---------------------------------------------------------------#
|
|
|
|
sub CreateExampleTestDirs()
|
|
{
|
|
my $DIR;
|
|
print "Creating $VERSION/test/example directories ...\n";
|
|
chdir "$RELEASEDIR/$VERSION" or die;
|
|
chdir 'examples' or return;
|
|
foreach $DIR (glob("*")) {
|
|
if ( -d $DIR ) {
|
|
system('cp', '-r', "$DIR", "../test/${DIR}_Examples");
|
|
}
|
|
}
|
|
chdir '..';
|
|
}
|
|
|
|
|
|
#---------------------------------------------------------------#
|
|
# CreateDemoTestDirs
|
|
#---------------------------------------------------------------#
|
|
|
|
sub CreateDemoTestDirs()
|
|
{
|
|
my $DIR;
|
|
print "Creating $VERSION/test/demo directories ...\n";
|
|
chdir "$RELEASEDIR/$VERSION" or die;
|
|
chdir 'demo' or return;
|
|
foreach $DIR (glob("*")) {
|
|
if ( -d $DIR ) {
|
|
system('cp', '-r', "$DIR", "../test/${DIR}_Demo");
|
|
}
|
|
}
|
|
chdir '..';
|
|
}
|
|
|
|
|
|
#---------------------------------------------------------------#
|
|
# make_testscripts and generate makefiles in test and examples
|
|
#---------------------------------------------------------------#
|
|
|
|
sub make_testscripts()
|
|
{
|
|
my ($DIR, $BASEDIR);
|
|
chdir "$RELEASEDIR/$VERSION" or die;
|
|
$BASEDIR = cwd();
|
|
print "Creating and checking makefiles ...\n";
|
|
|
|
chdir 'test';
|
|
foreach $DIR (glob("*")) {
|
|
if ( -d $DIR ) {
|
|
chdir $DIR;
|
|
if ( -f 'Makefile') {
|
|
rename 'Makefile', 'makefile';
|
|
}
|
|
if ( -f 'makefile' ) {
|
|
open MAKEFILE, "makefile";
|
|
open NEW_MAKEFILE, ">makefile.new";
|
|
while (<MAKEFILE>) {
|
|
s/\.o\b/\$(OBJ_EXT)/g;
|
|
s/-g\b/\$(DEBUG_OPT)/g;
|
|
print NEW_MAKEFILE $_;
|
|
}
|
|
close NEW_MAKEFILE;
|
|
close MAKEFILE;
|
|
rename("makefile.new","makefile");
|
|
} else {
|
|
my $options = '-t';
|
|
if ( -f 'cgal_create_makefile_options') {
|
|
if (open(OPTIONS, "<cgal_create_makefile_options")) {
|
|
$_ = <OPTIONS>;
|
|
chomp;
|
|
if (/^[\w\s-]+$/) { $options = $_;
|
|
} else {
|
|
print STDERR "Rejected cgal_create_makefile_options in $DIR\n";
|
|
}
|
|
close OPTIONS;
|
|
}
|
|
}
|
|
system("$SCRIPTSDIR/cgal_create_makefile", $options) == 0 or die "Execution of $SCRIPTSDIR/cgal_create_makefile failed";
|
|
}
|
|
if ( ! -f 'cgal_test' ) {
|
|
$_ = $DIR;
|
|
# chomp;
|
|
if (/_Demo$/) {
|
|
system("$DEVELSCRIPTSDIR/create_cgal_test", "--no-run") == 0 or die "Execution of $DEVELSCRIPTSDIR/create_cgal_test --no-run failed";
|
|
} else {
|
|
system("$DEVELSCRIPTSDIR/create_cgal_test") == 0 or die "Execution of $DEVELSCRIPTSDIR/create_cgal_test failed";
|
|
}
|
|
}
|
|
if ( ! -f 'cgal_test_with_cmake' ) {
|
|
$_ = $DIR;
|
|
# chomp;
|
|
if (/_Demo$/) {
|
|
system("$DEVELSCRIPTSDIR/create_cgal_test_with_cmake", "--no-run") == 0 or die "Execution of $DEVELSCRIPTSDIR/create_cgal_test_with_cmake --no-run failed";
|
|
} else {
|
|
system("$DEVELSCRIPTSDIR/create_cgal_test_with_cmake") == 0 or die "Execution of $DEVELSCRIPTSDIR/create_cgal_test_with_cmake failed";
|
|
}
|
|
}
|
|
chdir '..';
|
|
}
|
|
}
|
|
chdir $BASEDIR;
|
|
chdir 'examples';
|
|
|
|
print "Creating makefiles in examples\n";
|
|
foreach $DIR (glob("*")) {
|
|
if ( -d $DIR ) {
|
|
chdir $DIR;
|
|
if ( -f 'Makefile') {
|
|
rename 'Makefile', 'makefile';
|
|
}
|
|
if ( -f 'makefile' ) {
|
|
open MAKEFILE, "makefile";
|
|
open NEW_MAKEFILE, ">makefile.new";
|
|
while (<MAKEFILE>) {
|
|
s/\.o\b/\$(OBJ_EXT)/g;
|
|
s/-g\b/\$(DEBUG_OPT)/g;
|
|
print NEW_MAKEFILE $_;
|
|
}
|
|
close NEW_MAKEFILE;
|
|
close MAKEFILE;
|
|
rename("makefile.new","makefile");
|
|
} else {
|
|
my $options = '-d';
|
|
if ( -f 'cgal_create_makefile_options') {
|
|
if (open(OPTIONS, "<cgal_create_makefile_options")) {
|
|
$_ = <OPTIONS>;
|
|
chomp;
|
|
if (/^[\w\s-]+$/) { $options = $_;
|
|
} else {
|
|
print STDERR "Rejected cgal_create_makefile_options in $DIR\n";
|
|
}
|
|
close OPTIONS;
|
|
}
|
|
}
|
|
system("$SCRIPTSDIR/cgal_create_makefile", $options) == 0 or die "Execution of $SCRIPTSDIR/cgal_create_makefile failed";
|
|
}
|
|
chdir '..';
|
|
}
|
|
}
|
|
chdir $BASEDIR;
|
|
}
|
|
|
|
|
|
#----------------------------------------------------#
|
|
# Main entry point #
|
|
#----------------------------------------------------#
|
|
|
|
|
|
sub main(){
|
|
|
|
$RELEASEDIR=cwd();
|
|
$ALLPACKAGESDIR="$RELEASEDIR/trunk";
|
|
$LOCKFILE="$RELEASEDIR/release_creation.lock";
|
|
$LOCKCMD='lockfile';
|
|
|
|
getopts('hr:a:d:l:p:s:n:');
|
|
if ($::opt_h ) {
|
|
usage();
|
|
die "\n";
|
|
}
|
|
if ($::opt_d){
|
|
$RELEASEDIR = $::opt_d;
|
|
$ALLPACKAGESDIR = "$RELEASEDIR/trunk";
|
|
$LOCKFILE="$RELEASEDIR/release_creation.lock";
|
|
}
|
|
|
|
if ($::opt_r){
|
|
$VERSION = $::opt_r;
|
|
if ($::opt_n){
|
|
$VERSION_NR = $::opt_n;
|
|
} else {
|
|
$VERSION_NR = $VERSION;
|
|
}
|
|
} else {
|
|
usage();
|
|
die "\n";
|
|
}
|
|
if ($::opt_a){
|
|
$ALLPACKAGESDIR = File::Spec->rel2abs( $::opt_a ) ;
|
|
}
|
|
if ($::opt_l){
|
|
$LOCKFILE = $::opt_l;
|
|
}
|
|
$SCRIPTSDIR="$ALLPACKAGESDIR/Scripts/scripts";
|
|
$DEVELSCRIPTSDIR="$ALLPACKAGESDIR/Scripts/developer_scripts";
|
|
$packages_file="$ALLPACKAGESDIR/Maintenance/release_building/include_in_release";
|
|
print "Initializing variables ...\n";
|
|
print " Release dir: $RELEASEDIR\n";
|
|
print " All packages dir: $ALLPACKAGESDIR\n";
|
|
print " Scripts dir: $SCRIPTSDIR\n";
|
|
print " Developer Scripts dir: $DEVELSCRIPTSDIR\n";
|
|
print " Lockfile: $LOCKFILE\n";
|
|
print " Packages file : $packages_file\n";
|
|
umask(002);
|
|
chdir $RELEASEDIR or die;
|
|
if (! -d $VERSION){
|
|
print "Creating release directory ${VERSION} ...\n";
|
|
mkdir($VERSION, 0775);
|
|
} else {
|
|
print "$VERSION already exists in $RELEASEDIR\n";
|
|
print "Please remove it first\n";
|
|
exit 1;
|
|
}
|
|
lock;
|
|
|
|
install_packages();
|
|
CreateDemoTestDirs();
|
|
CreateExampleTestDirs();
|
|
create_version_file();
|
|
create_version_tex_file();
|
|
make_testscripts();
|
|
|
|
unlock;
|
|
}
|
|
|
|
main();
|