b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame] | 1 | # |
| 2 | # This is free software, licensed under the GNU General Public License v2. |
| 3 | # See /LICENSE for more information. |
| 4 | # |
| 5 | |
| 6 | include $(TOPDIR)/rules.mk |
| 7 | |
| 8 | PKG_NAME:=policycoreutils |
| 9 | PKG_VERSION:=3.5 |
| 10 | PKG_RELEASE:=1 |
| 11 | |
| 12 | PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz |
| 13 | PKG_SOURCE_URL:=https://github.com/SELinuxProject/selinux/releases/download/$(PKG_VERSION) |
| 14 | PKG_HASH:=78453e1529fbbf800e88860094d555e781ce1fba11a7ef77b5aabb43e1173276 |
| 15 | PKG_INSTALL:=1 |
| 16 | HOST_BUILD_DEPENDS:=libsemanage/host BUILD_NLS:gettext-full/host |
| 17 | PKG_BUILD_DEPENDS:=BUSYBOX_CONFIG_PAM:libpam BUILD_NLS:gettext-full/host |
| 18 | |
| 19 | PKG_MAINTAINER:=Thomas Petazzoni <thomas.petazzoni@bootlin.com> |
| 20 | PKG_CPE_ID:=cpe:/a:selinuxproject:policycoreutils |
| 21 | PKG_LICENSE:=GPL-2.0-or-later |
| 22 | PKG_LICENSE_FILES:=COPYING |
| 23 | |
| 24 | include $(INCLUDE_DIR)/package.mk |
| 25 | include $(INCLUDE_DIR)/nls.mk |
| 26 | include $(INCLUDE_DIR)/host-build.mk |
| 27 | |
| 28 | DIR_USR_BIN:= \ |
| 29 | newrole \ |
| 30 | secon \ |
| 31 | sestatus |
| 32 | |
| 33 | DIR_USR_SBIN:= \ |
| 34 | load_policy \ |
| 35 | setsebool |
| 36 | |
| 37 | LIBEXEC_UTILS := \ |
| 38 | pp |
| 39 | |
| 40 | SBIN_UTILS:= \ |
| 41 | restorecon_xattr \ |
| 42 | setfiles |
| 43 | |
| 44 | USR_BIN_UTILS:= \ |
| 45 | newrole \ |
| 46 | secon \ |
| 47 | sestatus |
| 48 | |
| 49 | USR_SBIN_UTILS:= \ |
| 50 | fixfiles \ |
| 51 | genhomedircon \ |
| 52 | open_init_pty \ |
| 53 | run_init \ |
| 54 | semodule \ |
| 55 | load_policy \ |
| 56 | setsebool |
| 57 | |
| 58 | TARGET_LDFLAGS += $(INTL_LDFLAGS) $(if $(INTL_FULL),-lintl) |
| 59 | |
| 60 | MAKE_FLAGS += \ |
| 61 | PAMH=$(CONFIG_BUSYBOX_CONFIG_PAM) |
| 62 | |
| 63 | HOST_MAKE_FLAGS += \ |
| 64 | PAMH=$(CONFIG_BUSYBOX_CONFIG_PAM) \ |
| 65 | DESTDIR=$(STAGING_DIR_HOST) \ |
| 66 | PREFIX= \ |
| 67 | SBINDIR=/bin |
| 68 | |
| 69 | HOST_LDFLAGS += -Wl,-rpath=$(STAGING_DIR_HOSTPKG)/lib |
| 70 | |
| 71 | $(eval $(foreach a,$(DIR_SBIN),ALTS_$(a):=300:/sbin/$(a):/sbin/policycoreutils-$(a)$(newline))) |
| 72 | $(eval $(foreach a,$(DIR_USR_BIN),ALTS_$(a):=300:/usr/bin/$(a):/usr/bin/policycoreutils-$(a)$(newline))) |
| 73 | $(eval $(foreach a,$(DIR_USR_SBIN),ALTS_$(a):=300:/usr/sbin/$(a):/usr/sbin/policycoreutils-$(a)$(newline))) |
| 74 | ALTS_setfiles:=300:/sbin/restorecon:/sbin/policycoreutils-setfiles 300:/sbin/setfiles:/sbin/policycoreutils-setfiles |
| 75 | |
| 76 | DEPENDS_genhomedircon:=+libsemanage $(INTL_DEPENDS) |
| 77 | DEPENDS_load_policy:=+libselinux $(INTL_DEPENDS) |
| 78 | DEPENDS_newrole:=+libselinux +libaudit +BUSYBOX_CONFIG_PAM:libpam $(INTL_DEPENDS) |
| 79 | DEPENDS_open_init_pty:=$(INTL_DEPENDS) |
| 80 | DEPENDS_pp:=+libsepol $(INTL_DEPENDS) |
| 81 | DEPENDS_restorecon_xattr:=+libselinux +libsepol +libaudit $(INTL_DEPENDS) |
| 82 | DEPENDS_run_init:=+libselinux +libaudit +BUSYBOX_CONFIG_PAM:libpam $(INTL_DEPENDS) |
| 83 | DEPENDS_secon:=+libselinux $(INTL_DEPENDS) |
| 84 | DEPENDS_semanage:=+libsemanage |
| 85 | DEPENDS_semodule:=+libsemanage $(INTL_DEPENDS) |
| 86 | DEPENDS_sestatus:=+libselinux $(INTL_DEPENDS) |
| 87 | DEPENDS_setfiles:=+libselinux +libsepol +libaudit $(INTL_DEPENDS) |
| 88 | DEPENDS_setsebool:=+libsemanage $(INTL_DEPENDS) |
| 89 | |
| 90 | define Package/policycoreutils/Default |
| 91 | SECTION:=utils |
| 92 | CATEGORY:=Utilities |
| 93 | TITLE:=SELinux policy utility |
| 94 | URL:=http://selinuxproject.org/page/Main_Page |
| 95 | endef |
| 96 | |
| 97 | define Package/policycoreutils |
| 98 | $(call Package/policycoreutils/Default) |
| 99 | MENU:=1 |
| 100 | TITLE+= common files |
| 101 | endef |
| 102 | |
| 103 | define GenUtilPkg |
| 104 | define Package/$(1) |
| 105 | $(call Package/policycoreutils/Default) |
| 106 | DEPENDS+= policycoreutils $(DEPENDS_$(2)) |
| 107 | TITLE+= $(2) |
| 108 | ALTERNATIVES:=$(ALTS_$(2)) |
| 109 | endef |
| 110 | |
| 111 | define Package/$(1)/description |
| 112 | Policycoreutils is a collection of policy utilities |
| 113 | (originally the "core" set of utilities needed to use |
| 114 | SELinux, although it has grown a bit over time). |
| 115 | |
| 116 | This package provides the $(2) utility. |
| 117 | endef |
| 118 | endef |
| 119 | |
| 120 | $(foreach a,$(LIBEXEC_UTILS) $(SBIN_UTILS) $(USR_BIN_UTILS) $(USR_SBIN_UTILS),$(eval $(call GenUtilPkg,policycoreutils-$(a),$(a)))) |
| 121 | |
| 122 | define Package/policycoreutils/install |
| 123 | $(INSTALL_DIR) $(1)/etc |
| 124 | $(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/sestatus.conf $(1)/etc |
| 125 | ifdef CONFIG_BUSYBOX_CONFIG_PAM |
| 126 | $(INSTALL_DIR) $(1)/etc/pam.d |
| 127 | $(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/pam.d/run_init $(1)/etc/pam.d |
| 128 | $(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/pam.d/newrole $(1)/etc/pam.d |
| 129 | endif |
| 130 | endef |
| 131 | |
| 132 | define BuildUtil |
| 133 | define Package/$(1)/install |
| 134 | $(INSTALL_DIR) $$(1)$(2) |
| 135 | $(INSTALL_BIN) $$(PKG_INSTALL_DIR)$(2)/$(3) $$(1)$(2)/$(if $(ALTS_$(3)),policycoreutils-$(3),$(3)) |
| 136 | endef |
| 137 | |
| 138 | $$(eval $$(call BuildPackage,$(1))) |
| 139 | endef |
| 140 | |
| 141 | $(eval $(call BuildPackage,policycoreutils)) |
| 142 | $(foreach a,$(SBIN_UTILS),$(eval $(call BuildUtil,policycoreutils-$(a),/sbin,$(a)))) |
| 143 | $(foreach a,$(USR_BIN_UTILS),$(eval $(call BuildUtil,policycoreutils-$(a),/usr/bin,$(a)))) |
| 144 | $(foreach a,$(USR_SBIN_UTILS),$(eval $(call BuildUtil,policycoreutils-$(a),/usr/sbin,$(a)))) |
| 145 | $(foreach a,$(LIBEXEC_UTILS),$(eval $(call BuildUtil,policycoreutils-$(a),/usr/libexec/selinux/hll,$(a)))) |
| 146 | $(eval $(call HostBuild)) |