diff options
author | Sangeetha T S <sangeet2@in.ibm.com> | 2016-06-28 05:11:43 -0500 |
---|---|---|
committer | Sachin Gupta <sgupta2m@in.ibm.com> | 2016-07-01 07:29:52 -0400 |
commit | 82f9fe9c97b0a39261eef652765facdfd74e545b (patch) | |
tree | 040256c2012c1672668b4343f5f8b03f619aea11 /sbe/build/tools/hooks/gerrit-hostname | |
parent | ea84ca31e0fa859b4401a32fefc1e5cc3e33b004 (diff) | |
download | talos-sbe-82f9fe9c97b0a39261eef652765facdfd74e545b.tar.gz talos-sbe-82f9fe9c97b0a39261eef652765facdfd74e545b.zip |
Move hooks & related scripts to sbe/build/tools/hooks
Change-Id: I16dda4cefb65c64c2a0b888bf913176e166effa5
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/26331
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Reviewed-by: Sachin Gupta <sgupta2m@in.ibm.com>
Diffstat (limited to 'sbe/build/tools/hooks/gerrit-hostname')
-rwxr-xr-x | sbe/build/tools/hooks/gerrit-hostname | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/sbe/build/tools/hooks/gerrit-hostname b/sbe/build/tools/hooks/gerrit-hostname new file mode 100755 index 00000000..5299a014 --- /dev/null +++ b/sbe/build/tools/hooks/gerrit-hostname @@ -0,0 +1,79 @@ +#!/usr/bin/perl +# IBM_PROLOG_BEGIN_TAG +# This is an automatically generated prolog. +# +# $Source: sbe/build/tools/hooks/gerrit-hostname $ +# +# OpenPOWER sbe Project +# +# Contributors Listed Below - COPYRIGHT 2016 +# [+] International Business Machines Corp. +# +# +# Licensed 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. +# +# IBM_PROLOG_END_TAG + +## Usage +# It is imperative that there are no prints other than the die command or +# "export GERRIT_SRV=$host" as this script is evaluated by env.bash and not +# called directly + +use strict; + +my $homeDir = $ENV{'HOME'}; +my $sshConfigFile = $homeDir."/.ssh/config"; +# If the server changes location these will change +my $gerritHostname = "ralgit01.raleigh.ibm.com"; +my $gerritPort = "29418"; + +open(CONFIG, "< $sshConfigFile") or die " $? can't open $sshConfigFile: $!" ; + +my $host = ""; +my $hostname = ""; +my $port = ""; +while (my $line = <CONFIG>) +{ + # Whitespace after each constant is important + if ($line =~ m/^Host [^\s]/) + { + ($host) = $line =~ m/^Host (.*?)\s/ + } + elsif ($line =~ m/Hostname [^\s]/) + { + ($hostname) = $line =~ m/^*Hostname (.*)/; + } + elsif ($line =~ m/Port [^\s]/) + { + ($port) = $line =~ m/^*Port (.*)/; + } + + # Check if we found the gerrit host name + if ($host ne "" && + $hostname eq $gerritHostname && + $port eq $gerritPort) + { + last; + } +} +close(CONFIG); + +if ($host eq "") +{ + die "Error> Could not find gerrit host in $sshConfigFile"; +} +else +{ + # Set gerrit server env variable by returning command to env.bash + print "export GERRIT_SRV=$host\n"; +} |