HBASE-14085 Update LICENSE and NOTICE files.
[hbase.git] / hbase-common / src / saveVersion.sh
blob890dc5a841560ef4301db2a069fecfe31704fac4
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 unset LANG
22 unset LC_CTYPE
24 version=$1
25 outputDirectory=$2
27 pushd .
28 cd ..
30 user=`whoami`
31 date=`date`
32 cwd=`pwd`
33 if [ -d .svn ]; then
34 revision=`svn info | sed -n -e 's/Last Changed Rev: \(.*\)/\1/p'`
35 url=`svn info | sed -n -e 's/^URL: \(.*\)/\1/p'`
36 elif [ -d .git ]; then
37 revision=`git log -1 --pretty=format:"%H"`
38 hostname=`hostname`
39 url="git://${hostname}${cwd}"
40 else
41 revision="Unknown"
42 url="file://$cwd"
44 which md5sum > /dev/null
45 if [ "$?" != "0" ] ; then
46 which md5 > /dev/null
47 if [ "$?" != "0" ] ; then
48 srcChecksum="Unknown"
49 else
50 srcChecksum=`find hbase-*/src/main/ | grep -e "\.java" -e "\.proto" | LC_ALL=C sort | xargs md5 | md5 | cut -d ' ' -f 1`
52 else
53 srcChecksum=`find hbase-*/src/main/ | grep -e "\.java" -e "\.proto" | LC_ALL=C sort | xargs md5sum | md5sum | cut -d ' ' -f 1`
55 popd
57 mkdir -p "$outputDirectory/org/apache/hadoop/hbase"
58 cat >"$outputDirectory/org/apache/hadoop/hbase/package-info.java" <<EOF
60 * Generated by src/saveVersion.sh
62 @VersionAnnotation(version="$version", revision="$revision",
63 user="$user", date="$date", url="$url",
64 srcChecksum="$srcChecksum")
65 package org.apache.hadoop.hbase;
66 EOF