# @package      hubzero-ellie
# @file         Makefile
# @author       Nicholas J. Kisseberth <nkissebe@purdue.edu>
# @copyright    Copyright (c) 2018 HUBzero Foundation, LLC.
# @license      http://opensource.org/licenses/MIT MIT
#
# Copyright (c) 2018 HUBzero Foundation, LLC.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# HUBzero is a registered trademark of HUBzero Foundation, LLC.
#

ETCDIR=$(DESTDIR)/etc
MAJOR_VERSION=`lsb_release -r -s | cut -d . -f 1`

all:
	@true

install:
	if [ -f /etc/debian_version -a $(MAJOR_VERSION) = '6' ]; then install --mode 0644 -D hubzero-ellie.list.squeeze $(ETCDIR)/apt/sources.list.d/hubzero-ellie.list; fi
	if [ -f /etc/debian_version -a $(MAJOR_VERSION) = '7' ]; then install --mode 0644 -D hubzero-ellie.list.wheezy $(ETCDIR)/apt/sources.list.d/hubzero-ellie.list; fi
	if [ -f /etc/debian_version -a $(MAJOR_VERSION) = '8' ]; then install --mode 0644 -D hubzero-ellie.list.jessie $(ETCDIR)/apt/sources.list.d/hubzero-ellie.list; fi
	if [ -f /etc/debian_version -a $(MAJOR_VERSION) = '9' ]; then install --mode 0644 -D hubzero-ellie.list.stretch $(ETCDIR)/apt/sources.list.d/hubzero-ellie.list; fi
	if [ -f /etc/debian_version ]; then install --mode 0644 -D hubzero-ellie.gpg $(ETCDIR)/apt/trusted.gpg.d/hubzero-ellie.gpg; fi

uninstall:
	rm $(ETCDIR)/apt/sources.list.d/hubzero-ellie.list
	rm $(ETCDIR)/apt/trustd.gpg.d/hubzero-ellie.gpg

postinst:
	sed -i -e '/packages\.hubzero\.org\/deb/d' /etc/apt/sources.list
	if [ -f /etc/debian_version ]; then apt-get update -o APT::List-Cleanup=0 -o Dir::Etc::sourcelist=/etc/apt/sources.list.d/hubzero-ellie.list -o Dir::Etc::sourceparts="/dev/null"; fi

clean:
	@true

.PHONY: all install uninstall postinst clean
