include $(TOPDIR)/rules.mk

PKG_NAME:=umoci
PKG_VERSION:=0.4.7
PKG_RELEASE:=$(AUTORELEASE)

PKG_LICENSE:=Apache-2.0
PKG_LICENSE_FILES:=LICENSE

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://github.com/opencontainers/umoci/archive/v$(PKG_VERSION)
PKG_HASH:=c01b36de6fdc513eb65add57bc882d72f94fc3b4b65a8f9ef59826fb754af93e

PKG_BUILD_DEPENDS:=golang/host
PKG_BUILD_PARALLEL:=1
PKG_USE_MIPS16:=0

GO_PKG:=github.com/opencontainers/umoci/

include $(INCLUDE_DIR)/host-build.mk
include $(INCLUDE_DIR)/package.mk

GOLANG_PACKAGE_MK:=$(wildcard $(TOPDIR)/feeds/*/lang/golang/golang-package.mk)
GOLANG_HOST_PACKAGE_MK:=$(wildcard $(TOPDIR)/feeds/*/lang/golang/golang-host-build.mk)

# verify that there is only one single file returned
ifneq (1,$(words $(GOLANG_PACKAGE_MK)))
ifeq (0,$(words $(GOLANG_PACKAGE_MK)))
$(error did not find golang-package.mk in any feed)
else
$(error found multiple golang-package.mk files in the feeds)
endif
else
$(info found golang-package.mk at $(GOLANG_PACKAGE_MK))
endif

include $(GOLANG_PACKAGE_MK)
include $(GOLANG_HOST_PACKAGE_MK)

define Package/umoci
  SECTION:=utils
  CATEGORY:=Utilities
  TITLE:=umoci utility
  URL:=https://github.com/opencontainers/umoci
  DEPENDS:=$(GO_ARCH_DEPENDS)
endef

define Package/umoci/description
  OCI (Open Container Initiative) image tool modifies Open Container images.
endef

GO_PKG_BUILD_VARS += GO111MODULE=auto

define Build/Compile
	$(call GoPackage/Build/Compile)
	$(call GoPackage/Package/Install/Bin,$(PKG_INSTALL_DIR))
endef

define Package/umoci/install
	$(INSTALL_DIR) $(1)/usr/bin
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/umoci $(1)/usr/bin
endef

$(eval $(call GoBinHostBuild))
$(eval $(call HostBuild))
$(eval $(call GoBinPackage,umoci))
$(eval $(call BuildPackage,umoci))
