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