Makefile 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. #
  2. # Copyright (C) 2006-2012 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. include $(TOPDIR)/rules.mk
  8. PKG_NAME:=kexec-tools
  9. PKG_VERSION:=2.0.32
  10. PKG_RELEASE:=3
  11. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
  12. PKG_SOURCE_URL:=@KERNEL/linux/utils/kernel/kexec
  13. PKG_HASH:=8f81422a5fd2362cf6cb001b511e535565ed0f32c2f4451fb5eb68fed6710a5d
  14. PKG_LICENSE:=GPL-2.0-only
  15. PKG_LICENSE_FILES:=COPYING
  16. PKG_CPE_ID:=cpe:/a:kernel:kexec-tools
  17. PKG_CONFIG_DEPENDS := CONFIG_KEXEC_ZLIB CONFIG_KEXEC_LZMA CONFIG_KEXEC_ZSTD
  18. PKG_BUILD_FLAGS:=gc-sections
  19. include $(INCLUDE_DIR)/package.mk
  20. define Package/kexec-tools/Default
  21. SECTION:=utils
  22. CATEGORY:=Utilities
  23. URL:=https://github.com/horms/kexec-tools
  24. endef
  25. define Package/kexec-tools
  26. $(call Package/kexec-tools/Default)
  27. TITLE:=kexec-tools transition meta package
  28. DEPENDS:=+kexec
  29. endef
  30. define Package/kexec-tools/description
  31. kexec is a set of system calls that allows you to load
  32. another kernel from the currently executing Linux kernel.
  33. The kexec utility allows to load and boot another kernel.
  34. endef
  35. define Package/kexec
  36. $(call Package/kexec-tools/Default)
  37. TITLE:=Kernel boots kernel
  38. DEPENDS:=\
  39. @(armeb||arm||aarch64||i386||x86_64||powerpc64||mipsel||mips) \
  40. +KEXEC_ZLIB:zlib +KEXEC_LZMA:liblzma +KEXEC_ZSTD:libzstd @KERNEL_KEXEC
  41. endef
  42. define Package/kexec/description
  43. The kexec utility allows to load and boot another kernel.
  44. endef
  45. define Package/kdump
  46. $(call Package/kexec-tools/Default)
  47. TITLE:=Kernel crash analysis
  48. DEPENDS:=+kexec @(i386||x86_64||arm||aarch64) @KERNEL_CRASH_DUMP
  49. endef
  50. define Package/kdump/description
  51. The kdump package allows to automatically boot into a
  52. special kernel for analyzing kernel crashes using kdump.
  53. endef
  54. define Package/kexec/config
  55. source "$(SOURCE)/Config.in"
  56. endef
  57. KEXEC_TARGET_NAME:=$(ARCH)-linux-$(TARGET_SUFFIX)
  58. CONFIGURE_ARGS = \
  59. --target=$(KEXEC_TARGET_NAME) \
  60. --host=$(REAL_GNU_TARGET_NAME) \
  61. --build=$(GNU_HOST_NAME) \
  62. --program-prefix="" \
  63. --program-suffix="" \
  64. --prefix=/usr \
  65. --exec-prefix=/usr \
  66. --bindir=/usr/bin \
  67. --sbindir=/usr/sbin \
  68. --libexecdir=/usr/lib \
  69. --sysconfdir=/etc \
  70. $(if $(CONFIG_KEXEC_ZLIB),--with,--without)-zlib \
  71. $(if $(CONFIG_KEXEC_LZMA),--with,--without)-lzma \
  72. $(if $(CONFIG_KEXEC_ZSTD),--with,--without)-zstd \
  73. TARGET_LD="$(TARGET_CROSS)ld"
  74. CONFIGURE_VARS += \
  75. BUILD_CC="$(HOSTCC)" \
  76. TARGET_CC="$(TARGET_CC)"
  77. define Build/Compile
  78. $(MAKE) -C $(PKG_BUILD_DIR) DESTDIR="$(PKG_INSTALL_DIR)" all install
  79. endef
  80. define Package/kexec-tools/install
  81. :
  82. endef
  83. define Package/kexec/install
  84. $(INSTALL_DIR) $(1)/usr/sbin
  85. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/kexec $(1)/usr/sbin
  86. # make a link for compatability with other distros
  87. $(INSTALL_DIR) $(1)/sbin
  88. $(LN) ../usr/sbin/kexec $(1)/sbin/kexec
  89. endef
  90. define Package/kdump/install
  91. $(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/init.d $(1)/etc/config $(1)/etc/uci-defaults
  92. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/vmcore-dmesg $(1)/usr/sbin
  93. $(INSTALL_BIN) ./files/kdump.init $(1)/etc/init.d/kdump
  94. $(INSTALL_BIN) ./files/kdump.defaults $(1)/etc/uci-defaults/kdump
  95. $(INSTALL_CONF) ./files/kdump.config $(1)/etc/config/kdump
  96. endef
  97. define Package/kdump/prerm
  98. #!/bin/sh
  99. case $$(uname -m) in
  100. i?86|x86_64)
  101. if grep -q " crashkernel=" /boot/grub/grub.cfg; then
  102. mount /boot -o remount,rw
  103. sed -i 's/ crashkernel=[^ ]*//' /boot/grub/grub.cfg
  104. mount /boot -o remount,ro
  105. fi
  106. ;;
  107. esac
  108. endef
  109. $(eval $(call BuildPackage,kexec-tools))
  110. $(eval $(call BuildPackage,kexec))
  111. $(eval $(call BuildPackage,kdump))