aef646beef0216afbadf706ffa7c82e9be169064
2 ###############################################################################
3 # Copyright (c) 2000-2016 Ericsson Telecom AB
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Eclipse Public License v1.0
6 # which accompanies this distribution, and is available at
7 # http://www.eclipse.org/legal/epl-v10.html
13 ###############################################################################
14 ###############################################################################
15 # This script is intended to archive the project hierarchy from a TPD file structure
16 ###############################################################################
23 my $ttcn3_dir = $ENV{'TTCN3_DIR'};
24 my $bindir = $ttcn3_dir . "/bin";
26 my @list = readFile
();
27 my $tpd = getTPDFileName
(\
@list);
29 if (-l
$tpd) #get the path if it is a symlink
31 $tpd = `readlink $tpd`;
34 my $root = getPathToRootDir
(\
@list); # get the workspace directory of the OS
36 chdir ($root) or die "cannot change: $!\n";
37 my $cutstring = cwd
; # this is string generated from the the absolute path to the workspace
38 my $archiveDir = getArchiveDir
(\
@list); #directory to place the archive
39 $archiveDir = $home . "/" . $archiveDir;
41 my $createDir = "mkdir -p " . $archiveDir;
42 my $res = system($createDir);
43 my $backupFileName = createBackupFileName
();
44 my $backupfile = $archiveDir . "/" . $backupFileName;
45 if ($res != 0) { die (" creating directory " . $archiveDir ." failed\n"); }
46 my $archive = $bindir . "/" . "ttcn3_makefilegen" ." -V -P " . $cutstring . " -t " . $tpd . " | xargs tar cfz ". $archiveDir . "/" . $backupFileName . " 2> /dev/null";
47 system($archive); #running it
48 if (-e
$backupfile) { print ("archiving succeeded\n"); }
49 else { print ("archiving failed\n"); }
50 chdir ($home) or die "cannot change: $!\n";
51 ############################################################
54 my $makefile = "Makefile";
55 open ( FILE
, "<", $makefile ) or die ( "failed to open file: $home\/$makefile\n" );
60 ############################################################
61 sub getPathToRootDir
#get the relative path to OS workspace
64 my $search = qr/^ROOT_DIR =/s;
67 for my $i ( 0 .. $#list )
69 if ( $list[$i] =~ $search )
73 $offset = index($list[$i], $dot);
77 if ($offset == 0) { die ( "no ROOT_DIR variable was found in the Makefile\n" ); }
78 my $path = substr $line, $offset;
81 ############################################################
82 sub getTPDFileName
# TPD filename what the Makefile is created from
85 my $search = qr/^TPD =/s;
88 for my $i ( 0 .. $#list )
90 if ( $list[$i] =~ $search )
94 $offset = index($list[$i], $assign);
98 if ($offset == 0) { die ( "no TPD variable was found in the Makefile\n" ); }
99 my $file = substr $line, $offset + 1;
100 $file =~ s/^\s+|\s+$//; # remove heading and traling whitespaces
103 ############################################################
104 sub getArchiveDir
# the name of the archive directory
107 my $search = qr/^ARCHIVE_DIR =/s;
110 for my $i ( 0 .. $#list )
112 if ( $list[$i] =~ $search )
116 $offset = index($list[$i], $assign);
120 if ($offset == 0) { die ( "no ARCHIVE_DIR variable was found in the Makefile\n" ); }
121 my $dir = substr $line, $offset + 1;
122 $dir =~ s/^\s+|\s+$//; # remove heading and trailing whitespaces
125 ############################################################
126 sub getExecutableName
# the name of the target executable
129 my $search = qr/^EXECUTABLE =/s;
132 for my $i ( 0 .. $#list )
134 if ( $list[$i] =~ $search )
138 $offset = index($list[$i], $assign);
142 if ($offset == 0) { die ( "no EXCUTABLE variable was found in the Makefile\n" ); }
143 my $exec = substr $line, $offset + 1;
144 $exec =~ s/^\s+|\s+$//; # remove heading and trailing whitespaces
147 ############################################################
148 sub createBackupFileName
150 my $backupFile = getExecutableName
(\
@list);
152 my $result = index($backupFile, $dot);
155 $backupFile = substr $backupFile, 0, $result;
158 my $date = `date '+%y%m%d-%H%M'`;
160 my $baseName = $backupFile . "-" . $date . ".tgz";
This page took 0.062625 seconds and 4 git commands to generate.