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.5 KiB

  1. # SPDX-License-Identifier: GPL-2.0-only
  2. include $(TOPDIR)/rules.mk
  3. PKG_NAME:=apparmor
  4. PKG_VERSION:=3.0.1
  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:=303ceca041ad8023fa44cdda366448d60b6299790266834b4078d30b70ad27f9
  10. PKG_LICENSE:=GPL-2.0-only
  11. PKG_LICENSE_FILES:=LICENSE
  12. PKG_MAINTAINER:=Oskari Rauta <oskari.rauta@gmail.com>
  13. BUILDONLY:=1
  14. PKG_BUILD_DEPENDS:=swig/host
  15. HOST_PYTHON3_PACKAGE_BUILD_DEPENDS:=setuptools-scm
  16. include $(INCLUDE_DIR)/package.mk
  17. include $(INCLUDE_DIR)/nls.mk
  18. include ../../../packages/lang/python/python3-package.mk
  19. define Package/apparmor/Default
  20. SECTION:=utils
  21. CATEGORY:=Utilities
  22. SUBMENU:=AppArmor
  23. URL:=https://apparmor.net
  24. endef
  25. define Package/libapparmor
  26. TITLE:=AppArmor library
  27. SECTION:=libs
  28. CATEGORY:=Libraries
  29. URL:=https://apparmor.net
  30. endef
  31. define Package/python3-apparmor
  32. TITLE:=AppArmor Python bindings
  33. SECTION:=lang
  34. CATEGORY:=Languages
  35. SUBMENU:=Python
  36. URL:=https://apparmor.net
  37. DEPENDS:=+libapparmor +python3
  38. endef
  39. define Package/apparmor-utils
  40. $(call Package/apparmor/Default)
  41. TITLE:=AppArmor utils
  42. DEPENDS:=$(INTL_DEPENDS) +libapparmor +python3-apparmor +python3 +python3-readline +python3-psutil +ss +findutils-xargs
  43. endef
  44. define Package/apparmor-profiles
  45. $(call Package/apparmor/Default)
  46. TITLE:=AppArmor default profiles
  47. endef
  48. define Package/libapparmor/description
  49. Library to support AppArmor userspace utilities
  50. endef
  51. define Package/apparmor-utils/description
  52. AppArmor application security system init script and
  53. userspace utils to assist with AppArmor profile management
  54. endef
  55. define Package/apparmor-profiles/description
  56. A collection of profiles for the AppArmor application security system
  57. endef
  58. CONFIGURE_PATH=libraries/libapparmor
  59. TARGET_LDFLAGS += \
  60. -L$(PYTHON3_LIB_DIR)
  61. CONFIGURE_VARS += \
  62. SHELL=$(bash) \
  63. PYTHON_VERSION=$(PYTHON3_VERSION) \
  64. PYTHON_VERSIONS=$(PYTHON3) \
  65. PYTHON=$(PYTHON3) \
  66. PYTHON_CONFIG=$(STAGING_DIR_ROOT)/host/bin/python$(PYTHON3_VERSION)-config \
  67. PYTHON_LDFLAGS="-L$(STAGING_DIR)/usr/lib -L$(PYTHON3_LIB_DIR)" \
  68. PYTHON_CPPFLAGS="-I$(STAGING_DIR)/usr/include/python$(PYTHON3_VERSION)" \
  69. PYTHON_LDFLAGS="-I$(PYTHON3_INC_DIR) -L$(STAGING_DIR)/usr/lib -L$(PYTHON3_LIB_DIR)" \
  70. PYTHON_EXTRA_LDFLAGS="-L$(STAGING_DIR)/usr/lib -L$(PYTHON3_LIB_DIR)/config-$(PYTHON3_VERSION) -lpthread -ldl -lm -lz -lpython$(PYTHON3_VERSION)" \
  71. ac_cv_path_PYTHON_CONFIG="$(STAGING_DIR)/host/bin/python$(PYTHON3_VERSION)-config"
  72. CONFIGURE_ARGS += \
  73. --with-python \
  74. --without-perl \
  75. --without-ruby \
  76. --disable-man-pages
  77. ifeq ($(CONFIG_BUILD_NLS),y)
  78. MAKE_VARS += WITH_LIBINTL=1
  79. MAKE_FLAGS += WITH_LIBINTL=1
  80. endif
  81. APPARMOR_CFLAGS = -I$(PKG_BUILD_DIR)/libraries/libapparmor/include
  82. APPARMOR_LDFLAGS = -L$(PKG_BUILD_DIR)/libraries/libapparmor/src/.libs
  83. define Build/Configure
  84. $(MAKE) -C $(PKG_BUILD_DIR)/libraries/libapparmor configure
  85. $(RM) $(PKG_BUILD_DIR)/libraries/libapparmor/Makefile
  86. $(SED) 's#ac_cv_path_PYTHON_CONFIG=#ac_cv_path_X_PYTHON_CONFIG=#g' $(PKG_BUILD_DIR)/libraries/libapparmor/configure
  87. $(call Build/Configure/Default)
  88. endef
  89. define Build/Compile
  90. # Building libapparmor
  91. +$(MAKE_VARS) \
  92. CFLAGS="$(TARGET_CFLAGS)" CPPFLAGS="$(TARGET_CPPFLAGS)" LDFLAGS="$(TARGET_LDFLAGS)" $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/libraries/libapparmor \
  93. $(MAKE_FLAGS)
  94. # Building parser
  95. +$(MAKE_VARS) PYTHON=$(HOST_PYTHON) \
  96. 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 \
  97. $(MAKE_FLAGS) apparmor_parser
  98. # Building binutils
  99. +$(MAKE_VARS) PYTHON=$(HOST_PYTHON) \
  100. 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 \
  101. $(MAKE_FLAGS)
  102. # Building utils
  103. +$(MAKE_VARS) PYTHON=$(HOST_PYTHON) \
  104. 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 \
  105. $(MAKE_FLAGS)
  106. # Building profiles
  107. +$(MAKE_VARS) PYTHON=$(HOST_PYTHON) \
  108. 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 \
  109. $(MAKE_FLAGS)
  110. endef
  111. define Build/Install
  112. # Make sure we have python's setup tools installed
  113. $(if $(PYTHON3_PKG_HOST_PIP_INSTALL_ARGS), \
  114. $(call HostPython3/PipInstall,$(PYTHON3_PKG_HOST_PIP_INSTALL_ARGS)) \
  115. )
  116. $(INSTALL_DIR) $(PKG_INSTALL_DIR)-libapparmor $(PKG_INSTALL_DIR)-utils $(PKG_INSTALL_DIR)-profiles
  117. # Installing libapparmor
  118. +$(MAKE_VARS) PYTHON=$(HOST_PYTHON) VERSION=$(PYTHON3_VERSION) \
  119. CFLAGS="$(TARGET_CFLAGS)" CPPFLAGS="$(TARGET_CPPFLAGS)" LDFLAGS="$(TARGET_LDFLAGS)" \
  120. $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/libraries/libapparmor \
  121. $(MAKE_FLAGS) DESTDIR="$(PKG_INSTALL_DIR)-libapparmor" install
  122. # Installing parser
  123. +$(MAKE_VARS) PYTHON=$(HOST_PYTHON) VERSION=$(PYTHON3_VERSION) \
  124. CFLAGS="$(TARGET_CFLAGS)" LDFLAGS="$(TARGET_LDFLAGS)" USE_SYSTEM=1 $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/parser \
  125. $(MAKE_FLAGS) DESTDIR="$(PKG_INSTALL_DIR)-utils" install
  126. # Installing binutils
  127. +$(MAKE_VARS) PYTHON=$(HOST_PYTHON) VERSION=$(PYTHON3_VERSION) \
  128. CFLAGS="$(TARGET_CFLAGS)" LDFLAGS="$(TARGET_LDFLAGS)" USE_SYSTEM=1 $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/binutils \
  129. $(MAKE_FLAGS) DESTDIR="$(PKG_INSTALL_DIR)-utils" install
  130. # Installing utils
  131. +$(MAKE_VARS) PYTHON=$(HOST_PYTHON) VERSION=$(PYTHON3_VERSION) \
  132. CFLAGS="$(TARGET_CFLAGS)" LDFLAGS="$(TARGET_LDFLAGS)" USE_SYSTEM=1 $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/utils \
  133. $(MAKE_FLAGS) DESTDIR="$(PKG_INSTALL_DIR)-utils" install
  134. # Installing profiles
  135. +$(MAKE_VARS) PYTHON=$(HOST_PYTHON) VERSION=$(PYTHON3_VERSION) \
  136. CFLAGS="$(TARGET_CFLAGS)" LDFLAGS="$(TARGET_LDFLAGS)" USE_SYSTEM=1 $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/profiles \
  137. $(MAKE_FLAGS) DESTDIR="$(PKG_INSTALL_DIR)-profiles" install
  138. endef
  139. define Package/libapparmor/install
  140. $(INSTALL_DIR) $(1)/usr/lib
  141. $(INSTALL_BIN) $(PKG_INSTALL_DIR)-libapparmor/usr/lib/libapparmor.so.1 $(1)/usr/lib/
  142. $(LN) libapparmor.so.1 $(1)/usr/lib/libapparmor.so
  143. endef
  144. define Package/python3-apparmor/install
  145. $(INSTALL_DIR) \
  146. $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages \
  147. $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages/LibAppArmor
  148. $(INSTALL_DATA) $(PKG_INSTALL_DIR)-libapparmor/usr/lib/python$(PYTHON3_VERSION)/site-packages/*.egg-info \
  149. $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages/
  150. $(INSTALL_DATA) $(PKG_INSTALL_DIR)-libapparmor/usr/lib/python$(PYTHON3_VERSION)/site-packages/LibAppArmor/*.py \
  151. $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages/LibAppArmor
  152. $(INSTALL_BIN) $(PKG_INSTALL_DIR)-libapparmor/usr/lib/python$(PYTHON3_VERSION)/site-packages/LibAppArmor/*.so \
  153. $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages/LibAppArmor/
  154. $(LN) -s _LibAppArmor.cpython-$(PYTHON3_VERSION_MAJOR)$(PYTHON3_VERSION_MINOR).so \
  155. $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages/LibAppArmor/_LibAppArmor.so
  156. endef
  157. define Package/apparmor-utils/install
  158. $(INSTALL_DIR) $(1)/etc/apparmor $(1)/usr/sbin $(1)/sbin
  159. $(INSTALL_BIN) $(PKG_INSTALL_DIR)-utils/sbin/apparmor_parser $(1)/sbin/
  160. $(INSTALL_CONF) $(PKG_INSTALL_DIR)-utils/etc/apparmor/*.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))