###############################################################################
# This file is part of the IPCop Firewall.                                    #
#                                                                             #
# IPCop is free software; you can redistribute it and/or modify               #
# it under the terms of the GNU General Public License as published by        #
# the Free Software Foundation; either version 2 of the License, or           #
# (at your option) any later version.                                         #
#                                                                             #
# IPCop is distributed in the hope that it will be useful,                    #
# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
# GNU General Public License for more details.                                #
#                                                                             #
# You should have received a copy of the GNU General Public License           #
# along with IPCop; if not, write to the Free Software                        #
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA    #
#                                                                             #
# Makefiles are based on LFSMake, which is                                    #
# Copyright (C) 2002 Rod Roard <rod@sunsetsystems.com>                        #
#                                                                             #
# Modifications by:                                                           #
# ??-12-2003 Mark Wormgoor < mark@wormgoor.com>                               #
#          - Modified Makefile for IPCop build                                #
#                                                                             #
# $Id: update 3981 2009-12-12 19:24:14Z owes $
#                                                                             #
###############################################################################

###############################################################################
# Definitions
###############################################################################

include Config

PKG_NAME   = update
HOST_ARCH  = all
OTHER_SRC  = no

THISAPP    = $(PKG_NAME)
TARGET     = $(DIR_INFO)/$(STAGE_ORDER)_$(STAGE)/$(THISAPP)

IPCOP_UPDATE_DIR  = $(DIR_SRC)/updates/$(VERSION)
IPCOP_UPDATE_FILE = $(SNAME)-$(VERSION)-update.$(MACHINE).tgz

###############################################################################
# Top-level Rules
###############################################################################

check :

download :

md5 :

###############################################################################
# Installation Details
###############################################################################

install :
	# Clean out some old stuff first
	rm -rf /$(INSTALLER_DIR)/images/$(IPCOP_UPDATE_FILE) /tmp/*

	# Build update for architecture: $(MACHINE) version: $(VERSION)

	# Collect the files that have changed since last IPCop version
	tar -cz --files-from=$(IPCOP_UPDATE_DIR)/ROOTFILES.${MACHINE}-${VERSION} \
		-f /tmp/patch.tar.gz --exclude='#*';

	# Add some additional files for the update
	cp $(IPCOP_UPDATE_DIR)/{setup,information.xml} /tmp
	echo "$(MACHINE)" >/tmp/ARCH
	for i in `ls $(IPCOP_UPDATE_DIR)/*.patch` ; do \
		cp $(IPCOP_UPDATE_DIR)/$$i /tmp; \
	done

	# Make sure setup is executable
	chmod 755 /tmp/setup

	# Build the update, make sure that the files are root owned
	cd /tmp && tar --owner root -cz -C /tmp -f /$(INSTALLER_DIR)/images/$(IPCOP_UPDATE_FILE) *

	# yes we want it rebuild at each time, so no POSTBUILD
