1#
2# Copyright (C) 2014-2015 OpenWrt.org
3#
4# This is free software, licensed under the GNU General Public License v2.
5# See /LICENSE for more information.
6#
7
8include $(TOPDIR)/rules.mk
9
10PKG_NAME:=fstools
11PKG_VERSION:=2016-07-24
12
13PKG_RELEASE=$(PKG_SOURCE_VERSION)
14
15PKG_SOURCE_PROTO:=git
16PKG_SOURCE_URL=$(OPENWRT_GIT)/project/fstools.git
17PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
18PKG_SOURCE_VERSION:=addd7dc21fe99f2701c1d4708071578052af401d
19PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
20CMAKE_INSTALL:=1
21
22PKG_LICENSE:=GPL-2.0
23PKG_LICENSE_FILES:=
24
25PKG_USE_MIPS16:=0
26
27PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
28
29include $(INCLUDE_DIR)/package.mk
30include $(INCLUDE_DIR)/cmake.mk
31
32TARGET_LDFLAGS += $(if $(CONFIG_USE_GLIBC),-lrt)
33CMAKE_OPTIONS += $(if $(CONFIG_FSTOOLS_UBIFS_EXTROOT),-DCMAKE_UBIFS_EXTROOT=y)
34
35define Package/fstools
36  SECTION:=base
37  CATEGORY:=Base system
38  DEPENDS:=+ubox +USE_GLIBC:librt +NAND_SUPPORT:ubi-utils
39  TITLE:=OpenWrt filesystem tools
40  MENU:=1
41endef
42
43define Package/fstools/config
44	config FSTOOLS_UBIFS_EXTROOT
45		depends on PACKAGE_fstools
46		depends on NAND_SUPPORT
47		bool "Support extroot functionality with UBIFS"
48		default y
49		help
50			This option makes it possible to use extroot functionality if the root filesystem resides on an UBIFS partition
51endef
52
53define Package/block-mount
54  SECTION:=base
55  CATEGORY:=Base system
56  TITLE:=Block device mounting and checking
57  DEPENDS:=+ubox +libubox +libuci
58endef
59
60define Package/fstools/install
61	$(INSTALL_DIR) $(1)/sbin $(1)/lib
62
63	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/{mount_root,jffs2reset,snapshot_tool} $(1)/sbin/
64	$(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libfstools.so $(1)/lib/
65	$(INSTALL_BIN) ./files/snapshot $(1)/sbin/
66	$(LN) jffs2reset $(1)/sbin/jffs2mark
67endef
68
69define Package/block-mount/install
70	$(INSTALL_DIR) $(1)/sbin $(1)/lib $(1)/usr/sbin $(1)/etc/hotplug.d/block $(1)/etc/init.d/ $(1)/etc/uci-defaults/
71
72	$(INSTALL_BIN) ./files/fstab.init $(1)/etc/init.d/fstab
73	$(INSTALL_DATA) ./files/fstab.default $(1)/etc/uci-defaults/10-fstab
74	$(INSTALL_DATA) ./files/mount.hotplug $(1)/etc/hotplug.d/block/10-mount
75
76	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/block $(1)/sbin/
77	$(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libblkid-tiny.so $(1)/lib/
78	$(LN) ../../sbin/block $(1)/usr/sbin/swapon
79	$(LN) ../../sbin/block $(1)/usr/sbin/swapoff
80
81endef
82
83define Build/InstallDev
84	$(INSTALL_DIR) $(1)/usr/include
85	$(CP) $(PKG_INSTALL_DIR)/usr/include/*.h $(1)/usr/include/
86	$(INSTALL_DIR) $(1)/usr/lib/
87	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libubi-utils.a $(1)/usr/lib/
88endef
89
90$(eval $(call BuildPackage,fstools))
91$(eval $(call BuildPackage,block-mount))
92