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.

216 lines
9.6 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_PROTO:=git
  7. PKG_SOURCE_URL:=https://gitlab.com/apparmor/apparmor.git
  8. PKG_SOURCE_VERSION:=0325ba06da6eeb5acf3e568063a08136fd0913e0
  9. PKG_MIRROR_HASH:=2c8f4607b9936f401a3fcb92cbc3627dc5b551fbde089162172e1801faba68bc
  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. $(if $(PYTHON3_PKG_HOST_PIP_INSTALL_ARGS), \
  113. $(call HostPython3/PipInstall,$(PYTHON3_PKG_HOST_PIP_INSTALL_ARGS)) \
  114. )
  115. $(INSTALL_DIR) $(PKG_INSTALL_DIR)-libapparmor $(PKG_INSTALL_DIR)-utils $(PKG_INSTALL_DIR)-profiles
  116. # Installing libapparmor
  117. +$(MAKE_VARS) PYTHON=$(HOST_PYTHON) VERSION=$(PYTHON3_VERSION) \
  118. CFLAGS="$(TARGET_CFLAGS)" CPPFLAGS="$(TARGET_CPPFLAGS)" LDFLAGS="$(TARGET_LDFLAGS)" \
  119. $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/libraries/libapparmor \
  120. $(MAKE_FLAGS) DESTDIR="$(PKG_INSTALL_DIR)-libapparmor" install
  121. # Installing parser
  122. +$(MAKE_VARS) PYTHON=$(HOST_PYTHON) VERSION=$(PYTHON3_VERSION) \
  123. CFLAGS="$(TARGET_CFLAGS)" LDFLAGS="$(TARGET_LDFLAGS)" USE_SYSTEM=1 $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/parser \
  124. $(MAKE_FLAGS) DESTDIR="$(PKG_INSTALL_DIR)-utils" install
  125. # Installing binutils
  126. +$(MAKE_VARS) PYTHON=$(HOST_PYTHON) VERSION=$(PYTHON3_VERSION) \
  127. CFLAGS="$(TARGET_CFLAGS)" LDFLAGS="$(TARGET_LDFLAGS)" USE_SYSTEM=1 $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/binutils \
  128. $(MAKE_FLAGS) DESTDIR="$(PKG_INSTALL_DIR)-utils" install
  129. # Installing utils
  130. +$(MAKE_VARS) PYTHON=$(HOST_PYTHON) VERSION=$(PYTHON3_VERSION) \
  131. CFLAGS="$(TARGET_CFLAGS)" LDFLAGS="$(TARGET_LDFLAGS)" USE_SYSTEM=1 $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/utils \
  132. $(MAKE_FLAGS) DESTDIR="$(PKG_INSTALL_DIR)-utils" install
  133. # Installing profiles
  134. +$(MAKE_VARS) PYTHON=$(HOST_PYTHON) VERSION=$(PYTHON3_VERSION) \
  135. CFLAGS="$(TARGET_CFLAGS)" LDFLAGS="$(TARGET_LDFLAGS)" USE_SYSTEM=1 $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/profiles \
  136. $(MAKE_FLAGS) DESTDIR="$(PKG_INSTALL_DIR)-profiles" install
  137. endef
  138. define Package/libapparmor/install
  139. $(INSTALL_DIR) $(1)/usr/lib
  140. $(INSTALL_BIN) $(PKG_INSTALL_DIR)-libapparmor/usr/lib/libapparmor.so.1 $(1)/usr/lib/
  141. $(LN) libapparmor.so.1 $(1)/usr/lib/libapparmor.so
  142. endef
  143. define Package/python3-apparmor/install
  144. $(INSTALL_DIR) \
  145. $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages \
  146. $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages/LibAppArmor
  147. $(INSTALL_DATA) $(PKG_INSTALL_DIR)-libapparmor/usr/lib/python$(PYTHON3_VERSION)/site-packages/*.egg-info \
  148. $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages/
  149. $(INSTALL_DATA) $(PKG_INSTALL_DIR)-libapparmor/usr/lib/python$(PYTHON3_VERSION)/site-packages/LibAppArmor/*.py \
  150. $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages/LibAppArmor
  151. $(INSTALL_BIN) $(PKG_INSTALL_DIR)-libapparmor/usr/lib/python$(PYTHON3_VERSION)/site-packages/LibAppArmor/*.so \
  152. $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages/LibAppArmor/
  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-notify,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/python3.9/site-packages $(1)/usr/lib/python3.9/site-packages/apparmor $(1)/usr/lib/python3.9/site-packages/apparmor/rule
  170. $(INSTALL_DATA) $(PKG_INSTALL_DIR)-utils/usr/lib/python3.9/site-packages/*.egg-info \
  171. $(1)/usr/lib/python3.9/site-packages/
  172. $(INSTALL_DATA) $(PKG_INSTALL_DIR)-utils/usr/lib/python3.9/site-packages/apparmor/*.py \
  173. $(1)/usr/lib/python3.9/site-packages/apparmor/
  174. $(INSTALL_DATA) $(PKG_INSTALL_DIR)-utils/usr/lib/python3.9/site-packages/apparmor/rule/*.py \
  175. $(1)/usr/lib/python3.9/site-packages/apparmor/rule
  176. $(INSTALL_DIR) $(1)/etc/init.d $(1)/lib/functions
  177. $(INSTALL_BIN) ./files/apparmor.sh $(1)/lib/functions/
  178. $(INSTALL_BIN) ./files/apparmor.init $(1)/etc/init.d/apparmor
  179. endef
  180. define Package/apparmor-profiles/install
  181. $(INSTALL_DIR) $(1)/etc/apparmor.d $(1)/usr/share/apparmor/extra-profiles
  182. $(CP) -aR $(PKG_INSTALL_DIR)-profiles/etc/apparmor.d/** $(1)/etc/apparmor.d/
  183. $(INSTALL_CONF) $(PKG_INSTALL_DIR)-profiles/usr/share/apparmor/extra-profiles/** $(1)/usr/share/apparmor/extra-profiles/
  184. endef
  185. $(eval $(call BuildPackage,libapparmor))
  186. $(eval $(call BuildPackage,python3-apparmor))
  187. $(eval $(call BuildPackage,apparmor-utils))
  188. $(eval $(call BuildPackage,apparmor-profiles))