You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

219 lines
10 KiB

  1. # SPDX-License-Identifier: GPL-2.0-only
  2. include $(TOPDIR)/rules.mk
  3. PKG_NAME:=apparmor
  4. PKG_VERSION:=3.0.3
  5. PKG_RELEASE:=$(AUTORELEASE)
  6. PKG_SOURCE:=$(PKG_NAME)-v$(PKG_VERSION).tar.bz2
  7. PKG_SOURCE_URL:=https://gitlab.com/apparmor/apparmor/-/archive/v$(PKG_VERSION)
  8. PKG_HASH:=66db49cc578e6a85ba2fc350507ad1741d2534cdfc7ed71a81261f84d6e2262d
  9. PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)-v$(PKG_VERSION)
  10. PKG_LICENSE:=GPL-2.0-only
  11. PKG_LICENSE_FILES:=LICENSE
  12. PKG_MAINTAINER:=Oskari Rauta <oskari.rauta@gmail.com>
  13. PKG_BUILD_DEPENDS:=swig/host
  14. HOST_PYTHON3_PACKAGE_BUILD_DEPENDS:=setuptools-scm
  15. include $(INCLUDE_DIR)/package.mk
  16. include $(INCLUDE_DIR)/nls.mk
  17. include ../../lang/python/python3-package.mk
  18. define Package/apparmor/Default
  19. SECTION:=utils
  20. CATEGORY:=Utilities
  21. SUBMENU:=AppArmor
  22. URL:=https://apparmor.net
  23. endef
  24. define Package/libapparmor
  25. TITLE:=AppArmor library
  26. SECTION:=libs
  27. CATEGORY:=Libraries
  28. URL:=https://apparmor.net
  29. endef
  30. define Package/python3-apparmor
  31. TITLE:=AppArmor Python bindings
  32. SECTION:=lang
  33. CATEGORY:=Languages
  34. SUBMENU:=Python
  35. URL:=https://apparmor.net
  36. DEPENDS:=+libapparmor +python3
  37. endef
  38. define Package/apparmor-utils
  39. $(call Package/apparmor/Default)
  40. TITLE:=AppArmor utils
  41. DEPENDS:=$(INTL_DEPENDS) +libapparmor +python3-apparmor +python3 +python3-readline +python3-psutil +ss +findutils-xargs
  42. endef
  43. define Package/apparmor-profiles
  44. $(call Package/apparmor/Default)
  45. TITLE:=AppArmor default profiles
  46. endef
  47. define Package/libapparmor/description
  48. Library to support AppArmor userspace utilities
  49. endef
  50. define Package/apparmor-utils/description
  51. AppArmor application security system init script and
  52. userspace utils to assist with AppArmor profile management
  53. endef
  54. define Package/apparmor-profiles/description
  55. A collection of profiles for the AppArmor application security system
  56. endef
  57. CONFIGURE_PATH=libraries/libapparmor
  58. TARGET_LDFLAGS += \
  59. -L$(PYTHON3_LIB_DIR)
  60. CONFIGURE_VARS += \
  61. SHELL=$(bash) \
  62. PYTHON_VERSION=$(PYTHON3_VERSION) \
  63. PYTHON_VERSIONS=$(PYTHON3) \
  64. PYTHON=$(PYTHON3) \
  65. PYTHON_CONFIG=$(STAGING_DIR_ROOT)/host/bin/python$(PYTHON3_VERSION)-config \
  66. PYTHON_LDFLAGS="-L$(STAGING_DIR)/usr/lib -L$(PYTHON3_LIB_DIR)" \
  67. PYTHON_CPPFLAGS="-I$(STAGING_DIR)/usr/include/python$(PYTHON3_VERSION)" \
  68. PYTHON_LDFLAGS="-I$(PYTHON3_INC_DIR) -L$(STAGING_DIR)/usr/lib -L$(PYTHON3_LIB_DIR)" \
  69. PYTHON_EXTRA_LDFLAGS="-L$(STAGING_DIR)/usr/lib -L$(PYTHON3_LIB_DIR)/config-$(PYTHON3_VERSION) -lpthread -ldl -lm -lz -lpython$(PYTHON3_VERSION)" \
  70. ac_cv_path_PYTHON_CONFIG="$(STAGING_DIR)/host/bin/python$(PYTHON3_VERSION)-config"
  71. CONFIGURE_ARGS += \
  72. --with-python \
  73. --without-perl \
  74. --without-ruby \
  75. --disable-man-pages
  76. ifeq ($(CONFIG_BUILD_NLS),y)
  77. MAKE_VARS += WITH_LIBINTL=1
  78. MAKE_FLAGS += WITH_LIBINTL=1
  79. endif
  80. APPARMOR_CFLAGS = -I$(PKG_BUILD_DIR)/libraries/libapparmor/include
  81. APPARMOR_LDFLAGS = -L$(PKG_BUILD_DIR)/libraries/libapparmor/src/.libs
  82. define Build/Configure
  83. $(MAKE) -C $(PKG_BUILD_DIR)/libraries/libapparmor configure
  84. $(RM) $(PKG_BUILD_DIR)/libraries/libapparmor/Makefile
  85. $(SED) 's#ac_cv_path_PYTHON_CONFIG=#ac_cv_path_X_PYTHON_CONFIG=#g' $(PKG_BUILD_DIR)/libraries/libapparmor/configure
  86. $(call Build/Configure/Default)
  87. endef
  88. define Build/Compile
  89. # Building libapparmor
  90. +$(MAKE_VARS) \
  91. CFLAGS="$(TARGET_CFLAGS)" CPPFLAGS="$(TARGET_CPPFLAGS)" LDFLAGS="$(TARGET_LDFLAGS)" $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/libraries/libapparmor \
  92. $(MAKE_FLAGS)
  93. # Building parser
  94. +$(MAKE_VARS) PYTHON=$(HOST_PYTHON) \
  95. CFLAGS="$(TARGET_CFLAGS) $(APPARMOR_CFLAGS)" CPPFLAGS="$(TARGET_CPPFLAGS) $(APPARMOR_CFLAGS)" LDFLAGS="$(TARGET_LDFLAGS) $(APPARMOR_LDFLAGS) -lgcc_s" USE_SYSTEM=0 $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/parser \
  96. $(MAKE_FLAGS) apparmor_parser
  97. # Building binutils
  98. +$(MAKE_VARS) PYTHON=$(HOST_PYTHON) \
  99. CFLAGS="$(TARGET_CFLAGS) $(APPARMOR_CFLAGS)" CPPFLAGS="$(TARGET_CPPFLAGS) $(APPARMOR_CFLAGS)" LDFLAGS="$(TARGET_LDFLAGS) $(APPARMOR_LDFLAGS)" USE_SYSTEM=0 $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/binutils \
  100. $(MAKE_FLAGS)
  101. # Building utils
  102. +$(MAKE_VARS) PYTHON=$(HOST_PYTHON) \
  103. CFLAGS="$(TARGET_CFLAGS) $(APPARMOR_CFLAGS)" CPPFLAGS="$(TARGET_CPPFLAGS) $(APPARMOR_CFLAGS)" LDFLAGS="$(TARGET_LDFLAGS) $(APPARMOR_LDFLAGS)" USE_SYSTEM=0 $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/utils \
  104. $(MAKE_FLAGS)
  105. # Building profiles
  106. +$(MAKE_VARS) PYTHON=$(HOST_PYTHON) \
  107. CFLAGS="$(TARGET_CFLAGS) $(APPARMOR_CFLAGS)" CPPFLAGS="$(TARGET_CPPFLAGS) $(APPARMOR_CFLAGS")" LDFLAGS="$(TARGET_LDFLAGS) $(APPARMOR_LDFLAGS)" USE_SYSTEM=0 $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/profiles \
  108. $(MAKE_FLAGS)
  109. endef
  110. define Build/Install
  111. # Make sure we have python's setup tools installed
  112. $(call Py3Build/InstallBuildDepends)
  113. $(INSTALL_DIR) $(PKG_INSTALL_DIR)-libapparmor $(PKG_INSTALL_DIR)-utils $(PKG_INSTALL_DIR)-profiles
  114. # Installing libapparmor
  115. +$(MAKE_VARS) PYTHON=$(HOST_PYTHON) VERSION=$(PYTHON3_VERSION) \
  116. CFLAGS="$(TARGET_CFLAGS)" CPPFLAGS="$(TARGET_CPPFLAGS)" LDFLAGS="$(TARGET_LDFLAGS)" \
  117. $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/libraries/libapparmor \
  118. $(MAKE_FLAGS) DESTDIR="$(PKG_INSTALL_DIR)-libapparmor" install
  119. # Installing parser
  120. +$(MAKE_VARS) PYTHON=$(HOST_PYTHON) VERSION=$(PYTHON3_VERSION) \
  121. CFLAGS="$(TARGET_CFLAGS)" LDFLAGS="$(TARGET_LDFLAGS)" USE_SYSTEM=1 $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/parser \
  122. $(MAKE_FLAGS) DESTDIR="$(PKG_INSTALL_DIR)-utils" install
  123. # Installing binutils
  124. +$(MAKE_VARS) PYTHON=$(HOST_PYTHON) VERSION=$(PYTHON3_VERSION) \
  125. CFLAGS="$(TARGET_CFLAGS)" LDFLAGS="$(TARGET_LDFLAGS)" USE_SYSTEM=1 $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/binutils \
  126. $(MAKE_FLAGS) DESTDIR="$(PKG_INSTALL_DIR)-utils" install
  127. # Installing utils
  128. +$(MAKE_VARS) PYTHON=$(HOST_PYTHON) VERSION=$(PYTHON3_VERSION) \
  129. CFLAGS="$(TARGET_CFLAGS)" LDFLAGS="$(TARGET_LDFLAGS)" USE_SYSTEM=1 $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/utils \
  130. $(MAKE_FLAGS) DESTDIR="$(PKG_INSTALL_DIR)-utils" install
  131. # Installing profiles
  132. +$(MAKE_VARS) PYTHON=$(HOST_PYTHON) VERSION=$(PYTHON3_VERSION) \
  133. CFLAGS="$(TARGET_CFLAGS)" LDFLAGS="$(TARGET_LDFLAGS)" USE_SYSTEM=1 $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/profiles \
  134. $(MAKE_FLAGS) DESTDIR="$(PKG_INSTALL_DIR)-profiles" install
  135. endef
  136. define Package/libapparmor/install
  137. $(INSTALL_DIR) $(1)/usr/lib
  138. $(INSTALL_BIN) $(PKG_INSTALL_DIR)-libapparmor/usr/lib/libapparmor.so.1 $(1)/usr/lib/
  139. $(LN) libapparmor.so.1 $(1)/usr/lib/libapparmor.so
  140. endef
  141. define Package/python3-apparmor/install
  142. $(INSTALL_DIR) \
  143. $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages \
  144. $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages/LibAppArmor \
  145. $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages/LibAppArmor \
  146. $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages/LibAppArmor-$(PKG_VERSION)-py$(PYTHON3_VERSION).egg-info
  147. $(INSTALL_DATA) $(PKG_INSTALL_DIR)-libapparmor/usr/lib/python$(PYTHON3_VERSION)/site-packages/LibAppArmor/*.py \
  148. $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages/LibAppArmor
  149. $(INSTALL_BIN) $(PKG_INSTALL_DIR)-libapparmor/usr/lib/python$(PYTHON3_VERSION)/site-packages/LibAppArmor/*.so \
  150. $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages/LibAppArmor/
  151. $(INSTALL_DATA) $(PKG_INSTALL_DIR)-libapparmor/usr/lib/python$(PYTHON3_VERSION)/site-packages/LibAppArmor-$(PKG_VERSION)-py$(PYTHON3_VERSION).egg-info/* \
  152. $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages/LibAppArmor-$(PKG_VERSION)-py$(PYTHON3_VERSION).egg-info/
  153. $(LN) -s _LibAppArmor.cpython-$(PYTHON3_VERSION_MAJOR)$(PYTHON3_VERSION_MINOR).so \
  154. $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages/LibAppArmor/_LibAppArmor.so
  155. endef
  156. define Package/apparmor-utils/install
  157. $(INSTALL_DIR) $(1)/etc/apparmor $(1)/usr/sbin $(1)/sbin
  158. $(INSTALL_BIN) $(PKG_INSTALL_DIR)-utils/sbin/apparmor_parser $(1)/sbin/
  159. $(INSTALL_CONF) $(PKG_INSTALL_DIR)-utils/etc/apparmor/*.conf $(1)/etc/apparmor/
  160. $(INSTALL_CONF) $(PKG_BUILD_DIR)/parser/parser.conf $(1)/etc/apparmor/
  161. $(INSTALL_DATA) $(PKG_INSTALL_DIR)-utils/etc/apparmor/severity.db $(1)/etc/apparmor/
  162. $(INSTALL_BIN) $(PKG_INSTALL_DIR)-utils/sbin/apparmor_parser $(1)/sbin/
  163. $(INSTALL_BIN) $(PKG_INSTALL_DIR)-utils/usr/bin/{aa-exec,aa-easyprof,aa-enabled,aa-features-abi} $(1)/usr/sbin/
  164. $(INSTALL_BIN) $(PKG_INSTALL_DIR)-utils/usr/sbin/{aa-audit,aa-autodep,aa-cleanprof,aa-complain,aa-decode,aa-disable,aa-enforce,aa-genprof,aa-logprof,aa-mergeprof,aa-remove-unknown,aa-status,aa-unconfined} $(1)/usr/sbin/
  165. $(LN) aa-status $(1)/usr/sbin/apparmor_status
  166. $(INSTALL_DIR) $(1)/usr/share/apparmor/easyprof/templates $(1)/usr/share/apparmor/easyprof/policygroups
  167. $(INSTALL_DATA) $(PKG_INSTALL_DIR)-utils/usr/share/apparmor/easyprof/templates/* $(1)/usr/share/apparmor/easyprof/templates/
  168. $(INSTALL_DATA) $(PKG_INSTALL_DIR)-utils/usr/share/apparmor/easyprof/policygroups/* $(1)/usr/share/apparmor/easyprof/policygroups/
  169. $(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages \
  170. $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages/apparmor \
  171. $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages/apparmor/rule \
  172. $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages/apparmor-$(PKG_VERSION)-py$(PYTHON3_VERSION).egg-info
  173. $(INSTALL_DATA) $(PKG_INSTALL_DIR)-utils/usr/lib/python$(PYTHON3_VERSION)/site-packages/apparmor/*.py \
  174. $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages/apparmor/
  175. $(INSTALL_DATA) $(PKG_INSTALL_DIR)-utils/usr/lib/python$(PYTHON3_VERSION)/site-packages/apparmor/rule/*.py \
  176. $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages/apparmor/rule
  177. $(INSTALL_DATA) $(PKG_INSTALL_DIR)-utils/usr/lib/python$(PYTHON3_VERSION)/site-packages/apparmor-$(PKG_VERSION)-py$(PYTHON3_VERSION).egg-info/* \
  178. $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages/apparmor-$(PKG_VERSION)-py$(PYTHON3_VERSION).egg-info/
  179. $(INSTALL_DIR) $(1)/etc/init.d $(1)/lib/functions
  180. $(INSTALL_BIN) ./files/apparmor.sh $(1)/lib/functions/
  181. $(INSTALL_BIN) ./files/apparmor.init $(1)/etc/init.d/apparmor
  182. endef
  183. define Package/apparmor-profiles/install
  184. $(INSTALL_DIR) $(1)/etc/apparmor.d $(1)/usr/share/apparmor/extra-profiles
  185. $(CP) -aR $(PKG_INSTALL_DIR)-profiles/etc/apparmor.d/** $(1)/etc/apparmor.d/
  186. $(INSTALL_CONF) $(PKG_INSTALL_DIR)-profiles/usr/share/apparmor/extra-profiles/** $(1)/usr/share/apparmor/extra-profiles/
  187. endef
  188. $(eval $(call BuildPackage,libapparmor))
  189. $(eval $(call BuildPackage,python3-apparmor))
  190. $(eval $(call BuildPackage,apparmor-utils))
  191. $(eval $(call BuildPackage,apparmor-profiles))