File: update_windows_version

package info (click to toggle)
mpich2 1.4.1-4.2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 79,392 kB
  • sloc: ansic: 366,528; makefile: 38,717; java: 35,094; sh: 24,970; perl: 19,489; cpp: 15,894; python: 9,651; f90: 6,381; fortran: 5,449; cs: 4,019; xml: 1,200; yacc: 275; csh: 232; lex: 78; php: 8
file content (83 lines) | stat: -rwxr-xr-x 1,689 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#! /usr/bin/env perl

$version = "";
$filename = "mpich2i.vdproj";
$verbose = false;

# Create two new UUIDs
chomp($product_uuid = `uuidgen`);
chomp($package_uuid = `uuidgen`);
#print "'" . $product_uuid . "'\n";
#print "'" . $package_uuid . "'\n";

# Parse the command line
foreach $arg (@ARGV)
{
#	print "$arg\n";
	if (substr($arg, 1, 5) eq "file:")
	{
		$filename = substr $arg, 6;
#		print "file = '" . $filename . "'\n";
	}
	elsif (substr($arg, 1, 8) eq "version:")
	{
		$version = substr $arg, 9;
#		print "version = '" . $version . "'\n";
	}
	elsif ($arg eq "-v" || $arg eq "/v")
	{
		$verbose = true;
	}
	else
	{
		$version = $arg;
#		print "version = '" . $version . "'\n";
	}
}

# Get the version if none is specified on the command line
if ($version eq "")
{
	unless (open VERSION_FILE, "<Version")
	{
		die "Error: Cannot open Version file: $!";
	}
	$_ = <VERSION_FILE>;
	s/\r//;
	chomp;
	$version = $_;
	close VERSION_FILE;
}

#print "version = '$version'\n";
#print "ProductCode = $product_uuid\n";
#print "PackageCode = $package_uuid\n";

unless (open PROJ, "<$filename")
{
	die "Error: Cannot open project file ($filename): $!";
}
unless (open PROJ_TMP, ">$filename.tmp")
{
	die "Error: Cannot open output file ($filename.tmp): $!";
}

while (<PROJ>)
{
	s/(ProductVersion" = "[\d]:).*"/\1$version"/;
	s/(ProductCode.*{).*}/\1\U$product_uuid}/;
	s/(PackageCode.*{).*}/\1\U$package_uuid}/;
	print PROJ_TMP "$_";
}
close PROJ;
close PROJ_TMP;
unless (unlink "$filename")
{
	die "Error: Unable to delete the project file ($filename): $!";
}
unless (rename "$filename.tmp", "$filename")
{
	die "Error: Unable to rename '$filename.tmp' -> '$filename': $!";
}

print "Success\n";