script not used

This commit is contained in:
Sébastien Loriot 2025-01-22 14:42:00 +01:00
parent d8106aab4b
commit 88ed74a164
2 changed files with 0 additions and 658 deletions

View File

@ -1,650 +0,0 @@
#!/usr/bin/env perl
#this script generates the internal release
use warnings;
use Cwd;
use File::Find;
use Getopt::Std;
use File::Spec;
use File::Temp;
use Archive::Tar;
use Archive::Tar::File;
use File::Copy;
use File::Copy::Recursive qw(dircopy);
use File::Path qw(mkpath);
use POSIX qw(strftime);
$Getopt::Std::STANDARD_HELP_VERSION = 1;
package main;
local $VERSION='$Id$';
sub HELP_MESSAGE() {
usage()
}
sub usage() {
print STDERR<<"EOF";
usage:
$0 (-h|-r)
[-n version number]
[-d releasedir] [-a allpackagesdir]
[-c candidatesdir]
[-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
-c candidatesdir
-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 SCM. 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,
$CANDIDATESDIR,
$RELEASEDIR,
$MAINDIR,
$SCRIPTSDIR,
$DEVELSCRIPTSDIR,
$LOCKCMD,
# 'files' is an associative array (hash table in perl language) that maps
# from files names (relative to CGAL_DIR) to the name of the package that
# provided it.
%files,
# 'LISTOFALLPACKAGES' is an associative array that maps from packages names
# to the full path of the working copy that provided it.
%LISTOFALLPACKAGES
);
%LISTOFALLPACKAGES = ();
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{QUIT} = \&termination_signal_handler;
$SIG{HUP} = \&termination_signal_handler;
$SIG{INT} = \&termination_signal_handler;
$SIG{TERM} = \&termination_signal_handler;
}
sub unlock()
{
unlink $LOCKFILE;
$SIG{QUIT} = 'DEFAULT';
$SIG{HUP} = 'DEFAULT';
$SIG{INT} = 'DEFAULT';
$SIG{TERM} = 'DEFAULT';
}
sub add_one_package($) {
my ($package) = @_;
}
sub list_packages($) {
my ($packages_directory) = @_;
opendir PACKAGESDIR, $packages_directory or die;
while (defined($package_name = readdir(PACKAGESDIR))) {
my $package_full_path = File::Spec->catdir($packages_directory, $package_name);
next if $package_name =~ /^\..*$/;
next if (! -d $package_full_path );
next if ($package_full_path =~ /Maintenance$/); # skip Maintenance package
$LISTOFALLPACKAGES{$package_name} = $packages_directory;
}
closedir(PACKAGESDIR);
}
sub install_packages() {
my ($filename, $direc, $tmp_package_name);
print "Installing packages ...\n";
chdir $RELEASEDIR or die;
if( ! open(LOG_CONFLICTS, ">>&=3") ) {
open(LOG_CONFLICTS, ">&", STDOUT) or die;
}
foreach my $package_name (keys(%LISTOFALLPACKAGES)) {
my $package_comes_from = $LISTOFALLPACKAGES{$package_name};
my $package_full_path = File::Spec->catdir($package_comes_from, $package_name);
$dont_submit="$package_full_path/dont_submit";
chdir "$package_comes_from" or die;
@command = ('tar', '-cf', "$RELEASEDIR/temppack.tar", '--exclude=.svn');
# comment for later: once the tar version installed on
# cgal.geometryfactory.com knows the option --exclude-vcs, use that
# option instead of --exclude=.svn
# -- Laurent Rineau, 2009/12/04 (idea by Sylvain Pion)
if( -f $dont_submit ) {
@command = (@command, "--exclude-from=$dont_submit");
}
@command = (@command, @global_dont_submit_tar_options);
@command = (@command, "-C", "$package_name", ".");
foreach( @command ) {
print "$_ ";
}
print "\n";
system(@command);
# generate the list of header file per package that not in an internal subdirectory. Files start with CGAL
$tempdir = File::Temp->newdir();
if ( -d "$package_full_path/include" ) {
@filelistcmd = ('tar', '-tf', "$RELEASEDIR/temppack.tar", '--wildcards', "./include/\*\*.h",
"--transform=s/.\\\/include\\\///", '--show-transformed-names',
'--exclude=**/internal', "--index-file=$tempdir/$package_name.txt");
system(@filelistcmd);
}
move("$RELEASEDIR/temppack.tar", "$RELEASEDIR/$VERSION/");
chdir "$RELEASEDIR/$VERSION" or die;
my $tar = Archive::Tar->new;
open my $TARFILL, "$RELEASEDIR/$VERSION/temppack.tar" or die;
if(! $tar->read($TARFILL)) {
unlink 'temppack.tar';
next;
}
for( $tar->get_files() )
{
my $filename = $_->name();
if( ! $_->is_dir() )
{
if(exists($files{$_->name()}))
{
print LOG_CONFLICTS "File ", $_->name(), " from package ", $package_name;
print LOG_CONFLICTS " conflicts with one from package ", $files{$_->name()}. "\n";
}
else
{
$files{$_->name()} = $package_name;
}
}
else { # is_dir() returned true
next if ($filename !~ /^\.\/?$/) and ($filename =~ /^\.\.?\/?$/);
my $package_from_from = $LISTOFALLPACKAGES{$package_name};
mkpath($filename);
# system("svn info $package_comes_from/$package_name/$filename | grep URL >> $filename/.scm-urls\n");
}
}
system('tar', '-xf', "temppack.tar");
if ( -e "$tempdir/$package_name.txt" ) {
if ( -d "$RELEASEDIR/$VERSION/doc/$package_name/" ) {
system("mv", ,"$tempdir/$package_name.txt", "$RELEASEDIR/$VERSION/doc/$package_name/filelist.txt");
} else {
system("rm", ,"$tempdir/$package_name.txt");
}
}
# $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");
}
close(LOG_CONFLICTS);
unlink 'temppack.tar';
( -d "$ALLPACKAGESDIR/.git" ) && system("git --git-dir=$ALLPACKAGESDIR/.git --work-tree=$ALLPACKAGESDIR log -n1 '--format=format:SCM branch:%n%H %d%n%nShort log from master:%n' > .scm-branch");
( -d "$ALLPACKAGESDIR/.git" ) && system("git --git-dir=$ALLPACKAGESDIR/.git --work-tree=$ALLPACKAGESDIR log --first-parent --format='%h %s%n parents: %p%n' cgal/master.. >> .scm-branch");
# foreach my $file (sort keys(%files)) {
# print "$files{$file}: $file\n";
# }
}
#-----------------------------------------------------------------------#
# 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 ($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";
move("tempfile", 'VERSION');
# Create include/CGAL/version.h file
chdir "$RELEASEDIR/$VERSION/include/CGAL" or die;
open(TEMPFILE, ">tempfile") or die;
my $RELEASE_DATE = strftime "%Y%m%d", localtime;
# TODO : add `svnversion` Revision.
print TEMPFILE << 'EOF';
// Copyright (c) 2006 Utrecht University (The Netherlands),
// ETH Zurich (Switzerland),
// INRIA Sophia-Antipolis (France),
// Max-Planck-Institute Saarbruecken (Germany),
// 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; either version 3 of the License,
// or (at your option) any later version.
//
// 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.
//
// SPDX-License-Identifier: LGPL-3.0-or-later
//
// Author(s) : -
// This file is automatically created by create_internal_release.
// Do not edit manually.
#ifndef CGAL_VERSION_H
#define CGAL_VERSION_H
#define CGAL_xstr(s) #s
#define CGAL_str(s) CGAL_xstr(s)
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";
print TEMPFILE "#define CGAL_GIT_HASH 0\n";
print TEMPFILE "#define CGAL_RELEASE_DATE $RELEASE_DATE\n";
print TEMPFILE << 'EOF';
#define CGAL_VERSION_STR CGAL_str(CGAL_VERSION)
#endif
EOF
close TEMPFILE || die "Error closing temporary file: $!\n";
move("tempfile", 'version.h');
chdir '../..' or die;
}
#---------------------------------------------------------------#
# CreateExampleTestDirs
#---------------------------------------------------------------#
sub CreateExampleTestDirs()
{
my $DIR;
chdir "$RELEASEDIR/$VERSION" or die;
chdir 'examples' or return;
print "Creating $VERSION/test/example directories ...\n";
foreach $DIR (glob("*")) {
if ( -d $DIR ) {
print "Creating test/${DIR}_Examples ...\n";
dircopy("$DIR", "../test/${DIR}_Examples");
}
}
chdir '..';
}
#---------------------------------------------------------------#
# CreateDemoTestDirs
#---------------------------------------------------------------#
sub CreateDemoTestDirs()
{
my $DIR;
chdir "$RELEASEDIR/$VERSION" or die;
chdir 'demo' or return;
print "Creating $VERSION/test/demo directories ...\n";
foreach $DIR (glob("*")) {
if ( -d $DIR) {
if( ("$DIR" ne "icons") && ("$DIR" ne "resources") ) {
print "Creating test/${DIR}_Demo ...\n";
dircopy("$DIR", "../test/${DIR}_Demo");
}
else {
print "Creating test/${DIR}...\n";
dircopy("$DIR", "../test/${DIR}");
}
}
}
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) && ("$DIR" ne "icons") && ("$DIR" ne "resources") ) {
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";
}
}
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;
}
#---------------------------------------------------------------#
# Generates a CMakeLists.txt in every subdirectory
# of the current directory if none already exists
#---------------------------------------------------------------#
sub generate_cmake_scripts
{
my $options = $_[0];
foreach $DIR (glob("*"))
{
if ( (-d $DIR) && ("$DIR" ne "icons") && ("$DIR" ne "resources") )
{
chdir $DIR;
if ( ! -f 'CMakeLists.txt' )
{
$_ = $DIR;
if ( -f 'cgal_create_cmake_script_options')
{
if (open(OPTIONS, "<cgal_create_cmake_script_options"))
{
$_ = <OPTIONS>;
chomp;
if (/^[\w\s-]+$/)
{
$options = $_;
}
else
{
print STDERR "Rejected cgal_create_cmake_script_options in $DIR\n";
}
close OPTIONS;
}
}
system("\"$SCRIPTSDIR/cgal_create_cmake_script\" $options") == 0 or die "Execution of \"$SCRIPTSDIR/cgal_create_cmake_script $options\" failed";
}
chdir '..';
}
}
}
sub generate_cgal_test_with_cmake
{
foreach $DIR (glob("*"))
{
if ( (-d $DIR) && ("$DIR" ne "icons") && ("$DIR" ne "resources") )
{
chdir $DIR;
if ( ! -f 'cgal_test_with_cmake' )
{
$_ = $DIR;
my $options = (/_Demo$/) ? '--no-run' : '' ;
system("$DEVELSCRIPTSDIR/create_cgal_test_with_cmake", $options) == 0 or die "Execution of $DEVELSCRIPTSDIR/create_cgal_test_with_cmake $options failed in directory $DIR";
}
chdir '..';
}
}
}
sub make_testscripts_for_cmake
{
my ($DIR, $BASEDIR);
chdir "$RELEASEDIR/$VERSION" or die;
$BASEDIR = cwd();
chdir 'test';
print "Creating test scripts\n";
generate_cgal_test_with_cmake();
print "Creating cmake scripts in test\n";
generate_cmake_scripts('test');
chdir $BASEDIR;
chdir 'examples';
print "Creating cmake scripts in examples\n";
generate_cmake_scripts('example');
chdir $BASEDIR;
chdir 'demo';
print "Creating cmake scripts in demo\n";
generate_cmake_scripts('demo');
chdir $BASEDIR;
}
#----------------------------------------------------#
# Main entry point #
#----------------------------------------------------#
sub main(){
$RELEASEDIR=cwd();
$ALLPACKAGESDIR="$RELEASEDIR/trunk";
$LOCKFILE="$RELEASEDIR/release_creation.lock";
$LOCKCMD='lockfile';
our ($opt_h, $opt_r, $opt_a, $opt_c, $opt_d, $opt_l, $opt_p, $opt_s, $opt_n);
if(! getopts('hr:a:c:d:l:p:s:n:') || $::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_c){
$CANDIDATESDIR = File::Spec->rel2abs( $::opt_c ) ;
}
if ($::opt_l){
$LOCKFILE = $::opt_l;
}
$SCRIPTSDIR="$ALLPACKAGESDIR/Scripts/scripts";
$DEVELSCRIPTSDIR="$ALLPACKAGESDIR/Scripts/developer_scripts";
$global_dont_submit="$ALLPACKAGESDIR/Maintenance/release_building/global_dont_submit";
@global_dont_submit_tar_options = ();
if (open(GLOBAL_DONT_SUBMIT, "<", $global_dont_submit) ) {
while(<GLOBAL_DONT_SUBMIT>) {
chomp;
@global_dont_submit_tar_options = (@global_dont_submit_tar_options, "--exclude=$_");
}
close(GLOBAL_DONT_SUBMIT);
}
print "Initializing variables ...\n";
print " Release dir: $RELEASEDIR\n";
print " All packages dir: $ALLPACKAGESDIR\n";
if($CANDIDATESDIR) {
print " Candidates packages dir: $CANDIDATESDIR\n";
}
print " Scripts dir: $SCRIPTSDIR\n";
print " Developer Scripts dir: $DEVELSCRIPTSDIR\n";
print " Lockfile: $LOCKFILE\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;
list_packages($ALLPACKAGESDIR);
if($CANDIDATESDIR) {
list_packages($CANDIDATESDIR);
}
install_packages();
CreateDemoTestDirs();
CreateExampleTestDirs();
create_version_file();
#make_testscripts();
make_testscripts_for_cmake();
unlock;
}
main();
# Set the indent level of perl-mode, in Emacs.
# For that file it is mostly 2, so let's choose 2.
### Local Variables:
### perl-indent-level: 2
### End:

View File

@ -4,14 +4,6 @@
# #
# Radu Ursu, Sylvain Pion, 2004-2006. # Radu Ursu, Sylvain Pion, 2004-2006.
# TODO :
# - Cleanup the public/internal separation:
# - have CGAL_VERSION_NR be not affected by the internal version
# - have CGAL_REVISION be the revision (replacing the internal number)
# - The public release case should pass the info to create_internal_release.
# [new] : create_internal_release should not know about internal/public mode.
# - Merge [some parts] into ./create_internal_release ?
DO_PUBLIC="" # Also build the public versions DO_PUBLIC="" # Also build the public versions
DO_IT="" # Real mode (copy to HTTP server), versus local testing DO_IT="" # Real mode (copy to HTTP server), versus local testing
DO_NOT_TAG="" # If set, do not call tag DO_NOT_TAG="" # If set, do not call tag