Repository: incubator-trafodion Updated Branches: refs/heads/master c58587a30 -> 2f53adfc8
[TRAFODION-1666]script to update win-odbc version [TRAFODION-1666]Need a script to update the version of windows ODBC Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/779e7043 Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/779e7043 Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/779e7043 Branch: refs/heads/master Commit: 779e7043e953e1479f94c9d8e3c37d223853e79b Parents: a4480b3 Author: Weiqing Xu <[email protected]> Authored: Wed Dec 2 16:08:33 2015 +0800 Committer: Weiqing Xu <[email protected]> Committed: Wed Dec 2 16:08:33 2015 +0800 ---------------------------------------------------------------------- win-odbc64/odbcclient/update_version.pl | 100 +++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/779e7043/win-odbc64/odbcclient/update_version.pl ---------------------------------------------------------------------- diff --git a/win-odbc64/odbcclient/update_version.pl b/win-odbc64/odbcclient/update_version.pl new file mode 100644 index 0000000..693640c --- /dev/null +++ b/win-odbc64/odbcclient/update_version.pl @@ -0,0 +1,100 @@ +# @@@ START COPYRIGHT @@@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +# @@@ END COPYRIGHT @@@ + +# For example, if you want to update the number to 2.1.0 +# Please run it as : +# perl update_version.pl 2.1.0 + +my @version = split(/\./, $ARGV[0]); + +my $major = @version[0]; +my $minor = @version[1]; +my $sp = @version[2]; + +my $revision = 0; + +unless ( $major =~ /^\d+$/ && $minor =~ /^\d+$/ && $sp =~ /^\d+$/ && $revision =~ /^\d+$/ ) { + print "Error: Invalid version on input\n"; + exit 1; + +} + + +my @resource_files = ("TranslationDll/TranslationDll.rc", + "drvr35adm/drvr35adm.rc", + "drvr35/TCPIPV4/TCPIPV4.RC", + "drvr35/TCPIPV6/TCPIPV6.RC", + "drvr35/drvr35.rc", + "Drvr35Res/Drvr35Res.rc", + "../Install/SetCertificateDirReg/SetCertificateDirReg/SetCertificateDirReg.rc", + "drvr35/cdatasource.cpp", + "drvr35adm/drvr35adm.h" + ); + +$outfile=$infile . "\.update_version_temp"; + +print "Updating Version to $major.$minor.$sp\n"; + +sub update_file { + my $infile = $_[0]; + print "Update " , $infile, "\n"; + my $outfile = $infile + '.tmp'; + open( INFILE, $infile ) or die "Error: Can't open $infile - $!"; + open( OUTFILE, ">$outfile" ) or die "Error: Can't open $outfile - $!"; + + while ( <INFILE> ) { + if ( /FILEVERSION|PRODUCTVERSION/ ) { + s/(\d+),(\d+),(\d+),(\d+)/$major,$minor,$sp,$revision/; + print OUTFILE; + } + elsif( /"ProductVersion|FileVersion"/ ) { + s/, "(\d+), (\d+), (\d+), (\d+)"/, "$major,$minor,$sp,$revision"/; + s/, "(\d+)\.(\d+)\.(\d+)\.(\d+)"/, "$major.$minor.$sp.$revision"/; + print OUTFILE; + } + elsif( /SOFTWARE\\\\ODBC\\\\ODBCINST.INI\\\\TRAF ODBC /) { + s/(\d+)\.(\d+)/$major.$minor/; + print OUTFILE; + } + elsif( /DRIVER_NAME\[\] = "TRAF ODBC / ) { + s/(\d+)\.(\d+)/$major.$minor/; + print OUTFILE; + } + else { + print OUTFILE; + } + } + + close( INFILE ) or warn "Warning: Can't close $infile - $!"; + close( OUTFILE ) or warn "Warning: Can't close $outfile - $!"; + + unless ( rename $outfile, $infile ) { + + print "Error: Updating Version for $infile failed.\n"; + exit 1; + } +} + +foreach $file (@resource_files) { + update_file $file +} + +exit 0;
