#
# Copyright (C) 2007-2016 OpenWrt.org
# Copyright (C) 2010 Vertical Communications
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
include $(INCLUDE_DIR)/version.mk

PKG_NAME:=cameo-base-files
PKG_RELEASE:=172
PKG_FLAGS:=nonshared

PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
PKG_BUILD_DEPENDS:= base-files
PKG_LICENSE:=GPL-2.0

PKG_CONFIG_DEPENDS :=

include $(INCLUDE_DIR)/package.mk

define Package/cameo-base-files
  CATEGORY:=CAMEO Proprietary Software
  DEPENDS:= base-files
  TITLE:=Base filesystem for Lede
  URL:=http://openwrt.org/
  VERSION:=$(PKG_RELEASE)-$(REVISION)
endef

define Package/cameo-base-files/conffiles
/etc/config/cameo
$(call $(TARGET)/conffiles)
endef

define Package/cameo-base-files/description
 This package contains a base filesystem and system scripts for Cameo platform.
endef

define ImageConfigOptions
	mkdir -p $(1)/lib/preinit
endef

define Build/Prepare
	mkdir -p $(PKG_BUILD_DIR)
endef

define Build/Compile/Default

endef
Build/Compile = $(Build/Compile/Default)


define Package/cameo-base-files/install
	$(CP) ./files/* $(1)/
	
	$(VERSION_SED) \
		$(1)/usr/lib/cameo-release \
		$(1)/etc/config/cameo
	$(VERSION_SED_SCRIPT) \
		$(1)/usr/lib/cameo-release \
		$(1)/etc/config/cameo
	
	mkdir -p $(1)/CONTROL
	
	for conffile in $(1)/etc/config/*; do \
		if [ -f "$$$$conffile" ]; then \
			grep "$$$${conffile##$(1)}" $(1)/CONTROL/conffiles || \
				echo "$$$${conffile##$(1)}" >> $(1)/CONTROL/conffiles; \
		fi \
	done
endef

$(eval $(call BuildPackage,cameo-base-files))
