#!/usr/bin/make -f
export COMPONENT_HASH=38cee81c0692c6410c4feae4169e0c3cb2b54800
 HBASE_VERSION=2.1.0+cdh6.3.2
 HBASE_PATCHED_VERSION=2.1.0-cdh6.3.2
 HBASE_BASE_VERSION=2.1.0
 HBASE_RELEASE=1605554
 CDH_CUSTOMER_PATCH=p0
 CDH_PARCEL_CUSTOM_VERSION=2.1.0+cdh6.3.2-1605554.bionic
#
# 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.
# 
# -*- makefile -*-
SHELL=/bin/bash

# Uncomment this to turn on verbose mode.
export DH_VERBOSE=1

# This has to be exported to make some magic below work.
export DH_OPTIONS

zookeeper_home=/usr/lib/zookeeper
hbase_pkg_name=hbase

%:
	dh $@

override_dh_auto_build:
	env FULL_VERSION=${HBASE_PATCHED_VERSION} bash debian/do-component-build -Dmaven.repo.local=${HOME}/.m2/repository${M2_REPO_SUFFIX}

	
override_dh_auto_install:
	cp debian/hbase.default debian/${hbase_pkg_name}/etc/default/${hbase_pkg_name}
	bash -x debian/install_hbase.sh \
		--build-dir=build/${hbase_pkg_name}-${HBASE_PATCHED_VERSION} \
		--conf-dir=/etc/hbase/conf.dist \
		--doc-dir=usr/share/doc/${hbase_pkg_name}-doc \
		--prefix=debian/tmp \
		--extra-dir=debian/
	mkdir -p debian/tmp/etc/security/limits.d
	cp debian/hbase.nofiles.conf debian/tmp/etc/security/limits.d/${hbase_pkg_name}.conf
	# Symlink in the dependency jars from their packages. Both of these packages
	# provide an unversioned symlink foo.jar -> foo-0.1.2.jar.
	rm -f debian/tmp/usr/lib/${hbase_pkg_name}/lib/{hadoop,zookeeper,slf4j-log4j12-}*.jar
	ln -f -s ${zookeeper_home}/zookeeper.jar debian/tmp/usr/lib/${hbase_pkg_name}/lib/
	ln -f -s ${zookeeper_home}/lib/slf4j-log4j12.jar debian/tmp/usr/lib/${hbase_pkg_name}/lib/
	ln -s /var/log/${hbase_pkg_name} debian/tmp/usr/lib/${hbase_pkg_name}/logs
	ln -s /var/run/${hbase_pkg_name} debian/tmp/usr/lib/${hbase_pkg_name}/pids

	# Wage war on "executable-not-elf-or-script" warnings:
	### ruby scripts should not be executable - they require
	### hbase org.jruby.Main <script>
	find debian/tmp/usr/lib/${hbase_pkg_name}/bin debian/tmp/usr/lib/${hbase_pkg_name}/lib -name \*.rb -exec chmod 644 {} \;
	### webapps should not be executable either
	find debian/tmp/usr/lib/${hbase_pkg_name}/hbase-webapps -type f -exec chmod 644 {} \;
	bash debian/install_init_scripts.sh

override_dh_builddeb:
	dh_builddeb -- -Zgzip

override_dh_strip_nondeterminism:
	# Disable dh_strip_nondeterminism to speed up the build

override_dh_strip:
	dh_strip --no-automatic-dbgsym
