Revert "Preparing development version 2.4.2-SNAPSHOT"
[hbase.git] / hbase-common / src / saveVersion.sh
blobf42862d83c72a7adc88913aa5c0544f211411dd7
1 #!/usr/bin/env bash
3 # This file is used to generate the annotation of package info that
4 # records the user, url, revision and timestamp.
6 # Licensed to the Apache Software Foundation (ASF) under one or more
7 # contributor license agreements. See the NOTICE file distributed with
8 # this work for additional information regarding copyright ownership.
9 # The ASF licenses this file to You under the Apache License, Version 2.0
10 # (the "License"); you may not use this file except in compliance with
11 # the License. You may obtain a copy of the License at
13 # http://www.apache.org/licenses/LICENSE-2.0
15 # Unless required by applicable law or agreed to in writing, software
16 # distributed under the License is distributed on an "AS IS" BASIS,
17 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 # See the License for the specific language governing permissions and
19 # limitations under the License.
21 set -e
23 unset LANG
24 unset LC_CTYPE
26 version=$1
27 outputDirectory=$2
29 pushd .
30 cd ..
32 user=$(whoami | sed -n -e "s/\\\/\\\\\\\\/p")
33 if [ "$user" == "" ]
34 then
35 user=$(whoami)
37 date=$(date)
38 cwd=$(pwd)
39 if [ -d .svn ]; then
40 revision=$( (svn info | sed -n -e "s/Last Changed Rev: \(.*\)/\1/p") || true)
41 url=$( (svn info | sed -n -e 's/^URL: \(.*\)/\1/p') || true)
42 elif [ -d .git ]; then
43 revision=$(git log -1 --no-show-signature --pretty=format:"%H" || true)
44 hostname=$(hostname)
45 url="git://${hostname}${cwd}"
47 if [ -z "${revision}" ]; then
48 echo "[WARN] revision info is empty! either we're not in VCS or VCS commands failed." >&2
49 revision="Unknown"
50 url="file://$cwd"
52 if ! [ -x "$(command -v openssl)" ]; then
53 if ! [ -x "$(command -v gpg)" ]; then
54 srcChecksum="Unknown"
55 else
56 srcChecksum=$(find hbase-*/src/main/ | grep -e "\.java" -e "\.proto" | LC_ALL=C sort | xargs gpg --print-md sha512 | gpg --print-md sha512 | tr '\n' ' ' | sed 's/[[:space:]]*//g')
58 else
59 srcChecksum=$(find hbase-*/src/main/ | grep -e "\.java" -e "\.proto" | LC_ALL=C sort | xargs openssl dgst -sha512 | openssl dgst -sha512 | sed 's/^.* //')
61 popd
63 mkdir -p "$outputDirectory/org/apache/hadoop/hbase"
64 cat >"$outputDirectory/org/apache/hadoop/hbase/Version.java" <<EOF
66 * Generated by src/saveVersion.sh
68 package org.apache.hadoop.hbase;
70 import org.apache.yetus.audience.InterfaceAudience;
72 @InterfaceAudience.Private
73 @edu.umd.cs.findbugs.annotations.SuppressWarnings(value="DM_STRING_CTOR",
74 justification="Intentional; to be modified in test")
75 public class Version {
76 public static final String version = new String("$version");
77 public static final String revision = "$revision";
78 public static final String user = "$user";
79 public static final String date = "$date";
80 public static final String url = "$url";
81 public static final String srcChecksum = "$srcChecksum";
83 EOF