# SPDX-License-Identifier: GPL-2.0-only

include $(TOPDIR)/rules.mk

PKG_NAME:=fscryptctl
PKG_VERSION:=1.1.0
PKG_RELEASE:=1

PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/google/fscryptctl.git
PKG_SOURCE_VERSION:=v$(PKG_VERSION)

PKG_LICENSE:=Apache-2.0
PKG_LICENSE_FILES:=LICENSE

include $(INCLUDE_DIR)/package.mk

define Package/$(PKG_NAME)
  SECTION:=utils
  CATEGORY:=Utilities
  SUBMENU:=Encryption
  TITLE:=Fscryptctl
endef

define Package/$(PKG_NAME)/description
	fscryptctl is a low-level tool written in C that handles raw keys and manages policies for Linux filesystem encryption,
	specifically the "fscrypt" kernel interface which is supported by the ext4, f2fs, and UBIFS filesystems
endef

define Build/Compile
	$(MAKE) -C $(PKG_BUILD_DIR) \
		CC="$(TARGET_CC)" \
		LDFLAGS="$(TARGET_LDFLAGS)" \
		fscryptctl
endef

define Package/$(PKG_NAME)/install
	$(INSTALL_DIR) $(1)/usr/bin
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/fscryptctl $(1)/usr/bin/fscryptctl
endef

$(eval $(call BuildPackage,$(PKG_NAME)))
