
include $(TOPDIR)/rules.mk

PKG_NAME:=aprs4r-web
PKG_VERSION:=1.0.4
PKG_RELEASE:=1
PKG_MD5SUM:=a0742220f4868a03c353a2b652558a05

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://www.aprs4r.org/download

PKG_CAT:=zcat

PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)

# hacks to deal with Ruby extensions in a dirty way without using rake or gems...
BIN_PACKAGE_DIR:=$(BIN_DIR)/packages
RUBY_VERSION:=`ls $(BIN_PACKAGE_DIR)/ruby_* | cut -f 2 -d _ | cut -f 1 -d -`

include $(INCLUDE_DIR)/package.mk


define Package/aprs4r-web
	SECTION:=utils
	CATEGORY:=Hamradio
	DEFAULT:=n
	TITLE:=aprs4r-web - web interface for APRS4R and APRS4WEB
	DEPENDS:=+aprs4r +ruby-cgi +lighttpd +lighttpd-mod-cgi +lighttpd-mod-auth
	URL:=http://www.aprs4r.org/
endef

define Package/aprs4r-web/description
	aprs4r-web - web interface for APRS4R and APRS4WEB

	http://www.aprs4r.org/
endef

define Build/Configure
	echo "configure"
endef

define Build/Compile
	echo "compile"
endef

define Package/aprs4r-web/install
	echo "install"
	$(MAKE) -C $(PKG_BUILD_DIR) install DESTDIR=$(1) TARGET=openwrt
endef


define Package/aprs4r-web/preinst
#!/bin/sh
#
# APRS4R-Web pre install script
#

# stop aprs4r-web in case of update
if [ -z "${IPKG_INSTROOT}" ]; then 
	[ -x /etc/init.d/aprs4r-web ] && /etc/init.d/aprs4r-web stop
fi

exit 0
endef


define Package/aprs4r-web/postinst
#!/bin/sh
#
# APRS4R-Web post install script. 
#

# enable automatic startup script
if [ -z "${IPKG_INSTROOT}" ]; then
	[ -x /etc/init.d/aprs4r-web ] && /etc/init.d/aprs4r-web enable
	[ -x /etc/init.d/aprs4r-web ] && /etc/init.d/aprs4r-web start
fi

exit 0
endef


define Package/aprs4r-web/prerm
#!/bin/sh
#
# APRS4R-Web pre remove script. 
#

# enable automatic startup script
if [ -z "${IPKG_INSTROOT}" ]; then
	[ -x /etc/init.d/aprs4r-web ] && /etc/init.d/aprs4r-web stop
	[ -x /etc/init.d/aprs4r-web ] && /etc/init.d/aprs4r-web disable
fi

exit 0
endef


$(eval $(call BuildPackage,aprs4r-web))
