e1447bae70aa480fd4179658b8906d5f13009623
[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.28
12 PKG_RELEASE:=2
13
14 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
15 PKG_SOURCE_URL:=@KERNEL/linux/utils/kernel/kexec
16 PKG_HASH:=d2f0ef872f39e2fe4b1b01feb62b0001383207239b9f8041f98a95564161d053
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
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||i386||x86_64||powerpc64||mipsel||mips) \
51 +KEXEC_ZLIB:zlib +KEXEC_LZMA:liblzma @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) @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 TARGET_LD="$(TARGET_CROSS)ld"
90
91 CONFIGURE_VARS += \
92 BUILD_CC="$(HOSTCC)" \
93 TARGET_CC="$(TARGET_CC)"
94
95 define Build/Compile
96 $(MAKE) -C $(PKG_BUILD_DIR) DESTDIR="$(PKG_INSTALL_DIR)" all install
97 endef
98
99 define Package/kexec-tools/install
100 :
101 endef
102
103 define Package/kexec/install
104 $(INSTALL_DIR) $(1)/usr/sbin
105 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/kexec $(1)/usr/sbin
106
107 # make a link for compatability with other distros
108 $(INSTALL_DIR) $(1)/sbin
109 $(LN) ../usr/sbin/kexec $(1)/sbin/kexec
110 endef
111
112 define Package/kdump/install
113 $(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/init.d $(1)/etc/config $(1)/etc/uci-defaults
114 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/vmcore-dmesg $(1)/usr/sbin
115 $(INSTALL_BIN) ./files/kdump.init $(1)/etc/init.d/kdump
116 $(INSTALL_BIN) ./files/kdump.defaults $(1)/etc/uci-defaults/kdump
117 $(INSTALL_CONF) ./files/kdump.config $(1)/etc/config/kdump
118 endef
119
120 define Package/kdump/prerm
121 #!/bin/sh
122
123 case $$(uname -m) in
124 i?86|x86_64)
125 if grep -q " crashkernel=" /boot/grub/grub.cfg; then
126 mount /boot -o remount,rw
127 sed -i 's/ crashkernel=[^ ]*//' /boot/grub/grub.cfg
128 mount /boot -o remount,ro
129 fi
130 ;;
131 esac
132 endef
133
134 $(eval $(call BuildPackage,kexec-tools))
135 $(eval $(call BuildPackage,kexec))
136 $(eval $(call BuildPackage,kdump))