aboutsummaryrefslogtreecommitdiffstats
path: root/package/boot/kexec-tools
diff options
context:
space:
mode:
Diffstat (limited to 'package/boot/kexec-tools')
-rw-r--r--package/boot/kexec-tools/Config.in31
-rw-r--r--package/boot/kexec-tools/Makefile87
-rw-r--r--package/boot/kexec-tools/patches/0001-Fix-zlib-lzma-decompression.patch171
-rw-r--r--package/boot/kexec-tools/patches/0002-configure.ac-apply-necessary-quotes-to-result-of-mac.patch52
-rw-r--r--package/boot/kexec-tools/patches/0003-mips-fix-compiler-warning-on-printing-64-bit-integer.patch35
-rw-r--r--package/boot/kexec-tools/patches/0004-mips-remove-unused-variable.patch30
-rw-r--r--package/boot/kexec-tools/patches/0005-mips-fix-warning-about-implicit-type-conversion.patch30
7 files changed, 436 insertions, 0 deletions
diff --git a/package/boot/kexec-tools/Config.in b/package/boot/kexec-tools/Config.in
new file mode 100644
index 0000000..6c7558f
--- /dev/null
+++ b/package/boot/kexec-tools/Config.in
@@ -0,0 +1,31 @@
+menu "Configuration"
+ depends on PACKAGE_kexec-tools
+
+config KEXEC_TOOLS_TARGET_NAME
+ string
+ prompt "Target name for kexec kernel"
+ default EXTRA_TARGET_ARCH_NAME if powerpc64
+ default ARCH
+ help
+ Defines the target type of the kernels that kexec deals
+ with. This should be the target specification of
+ the kernel you're booting.
+
+config KEXEC_TOOLS_kdump
+ bool
+ prompt "kdump support"
+ default n
+ help
+ Include the kdump utility.
+
+config KEXEC_ZLIB
+ bool
+ prompt "zlib support"
+ default y
+
+config KEXEC_LZMA
+ bool
+ prompt "lzma support"
+ default n
+
+endmenu
diff --git a/package/boot/kexec-tools/Makefile b/package/boot/kexec-tools/Makefile
new file mode 100644
index 0000000..6f04bce
--- /dev/null
+++ b/package/boot/kexec-tools/Makefile
@@ -0,0 +1,87 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=kexec-tools
+PKG_VERSION:=2.0.9
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
+PKG_SOURCE_URL:=@KERNEL/linux/utils/kernel/kexec
+PKG_MD5SUM:=6681319934e22e74c532bd392ccb1bbb
+
+PKG_FIXUP:=autoreconf
+
+PKG_CONFIG_DEPENDS := CONFIG_KEXEC_ZLIB CONFIG_KEXEC_LZMA
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/kexec-tools
+ SECTION:=utils
+ CATEGORY:=Utilities
+ DEPENDS:=@KERNEL_KEXEC @armeb||@arm||@i386||@powerpc64||@mipsel||@mips +KEXEC_ZLIB:zlib +KEXEC_LZMA:liblzma
+ TITLE:=Kernel boots kernel
+ URL:=http://kernel.org/pub/linux/kernel/people/horms/kexec-tools/
+ MAINTAINER:=Florian Fainelli <florian@openwrt.org>
+ MENU:=1
+endef
+
+define Package/kexec-tools/description
+ kexec is a set of systems call that allows you to load
+ another kernel from the currently executing Linux kernel.
+endef
+
+define Package/kexec-tools/config
+ source "$(SOURCE)/Config.in"
+endef
+
+KEXEC_TARGET_NAME:=$(call qstrip,$(CONFIG_KEXEC_TOOLS_TARGET_NAME))-linux-$(TARGET_SUFFIX)
+
+CONFIGURE_ARGS = \
+ --target=$(KEXEC_TARGET_NAME) \
+ --host=$(REAL_GNU_TARGET_NAME) \
+ --build=$(GNU_HOST_NAME) \
+ --program-prefix="" \
+ --program-suffix="" \
+ --prefix=/usr \
+ --exec-prefix=/usr \
+ --bindir=/usr/bin \
+ --sbindir=/usr/sbin \
+ --libexecdir=/usr/lib \
+ --sysconfdir=/etc \
+ $(if $(CONFIG_KEXEC_ZLIB),--with,--without)-zlib \
+ $(if $(CONFIG_KEXEC_LZMA),--with,--without)-lzma
+
+TARGET_CFLAGS += -ffunction-sections -fdata-sections
+TARGET_LDFLAGS += -Wl,--gc-sections
+
+CONFIGURE_VARS += \
+ BUILD_CC="$(HOSTCC)" \
+ TARGET_CC="$(TARGET_CC)"
+
+kexec-extra-sbin-$(CONFIG_KEXEC_TOOLS_kdump) += kdump
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR) DESTDIR="$(PKG_INSTALL_DIR)" all install
+endef
+
+define Package/kexec-tools/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) \
+ $(addprefix $(PKG_INSTALL_DIR)/usr/sbin/, \
+ $(kexec-extra-sbin-y)) \
+ $(kexec-extra-bin-y) \
+ $(PKG_INSTALL_DIR)/usr/sbin/kexec \
+ $(1)/usr/sbin
+
+# make a link for compatability with other distros
+ $(INSTALL_DIR) $(1)/sbin
+ $(LN) ../usr/sbin/kexec $(1)/sbin/kexec
+endef
+
+$(eval $(call BuildPackage,kexec-tools))
diff --git a/package/boot/kexec-tools/patches/0001-Fix-zlib-lzma-decompression.patch b/package/boot/kexec-tools/patches/0001-Fix-zlib-lzma-decompression.patch
new file mode 100644
index 0000000..06c11ec
--- /dev/null
+++ b/package/boot/kexec-tools/patches/0001-Fix-zlib-lzma-decompression.patch
@@ -0,0 +1,171 @@
+From d606837b56d46eb7f815b5d85f07fcc3f1555d00 Mon Sep 17 00:00:00 2001
+From: Yousong Zhou <yszhou4tech@gmail.com>
+Date: Sun, 1 Feb 2015 00:10:07 +0800
+Subject: [PATCH 1/5] Fix zlib/lzma decompression.
+
+Let {zlib,lzma}_decompress_file() return NULL if anything wrong happened
+to allow the other method to have a chance to run.
+
+Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
+Signed-off-by: Simon Horman <horms@verge.net.au>
+---
+ kexec/lzma.c | 33 ++++++++++++++++++++++-----------
+ kexec/zlib.c | 57 +++++++++++++++++++++++++++++++++++----------------------
+ 2 files changed, 57 insertions(+), 33 deletions(-)
+
+diff --git a/kexec/lzma.c b/kexec/lzma.c
+index 939aeb3..5bfccb7 100644
+--- a/kexec/lzma.c
++++ b/kexec/lzma.c
+@@ -162,13 +162,16 @@ char *lzma_decompress_file(const char *filename, off_t *r_size)
+ off_t size, allocated;
+ ssize_t result;
+
+- if (!filename) {
+- *r_size = 0;
+- return 0;
+- }
++ dbgprintf("Try LZMA decompression.\n");
++
++ *r_size = 0;
++ if (!filename)
++ return NULL;
++
+ fp = lzopen(filename, "rb");
+ if (fp == 0) {
+- die("Cannot open `%s'\n", filename);
++ dbgprintf("Cannot open `%s'\n", filename);
++ return NULL;
+ }
+ size = 0;
+ allocated = 65536;
+@@ -183,17 +186,25 @@ char *lzma_decompress_file(const char *filename, off_t *r_size)
+ if ((errno == EINTR) || (errno == EAGAIN))
+ continue;
+
+- die ("read on %s of %ld bytes failed\n",
+- filename, (allocated - size) + 0UL);
++ dbgprintf("%s: read on %s of %ld bytes failed\n",
++ __func__, filename, (allocated - size) + 0UL);
++ break;
+ }
+ size += result;
+- } while(result > 0);
+- result = lzclose(fp);
+- if (result != LZMA_OK) {
+- die ("Close of %s failed\n", filename);
++ } while (result > 0);
++
++ if (lzclose(fp) != LZMA_OK) {
++ dbgprintf("%s: Close of %s failed\n", __func__, filename);
++ goto fail;
+ }
++ if (result < 0)
++ goto fail;
++
+ *r_size = size;
+ return buf;
++fail:
++ free(buf);
++ return NULL;
+ }
+ #else
+ char *lzma_decompress_file(const char *UNUSED(filename), off_t *UNUSED(r_size))
+diff --git a/kexec/zlib.c b/kexec/zlib.c
+index d44df12..7170ac3 100644
+--- a/kexec/zlib.c
++++ b/kexec/zlib.c
+@@ -15,29 +15,39 @@
+ #include <ctype.h>
+ #include <zlib.h>
+
++static void _gzerror(gzFile fp, int *errnum, const char **errmsg)
++{
++ *errmsg = gzerror(fp, errnum);
++ if (*errnum == Z_ERRNO) {
++ *errmsg = strerror(*errnum);
++ }
++}
++
+ char *zlib_decompress_file(const char *filename, off_t *r_size)
+ {
+ gzFile fp;
+ int errnum;
+ const char *msg;
+ char *buf;
+- off_t size, allocated;
++ off_t size = 0, allocated;
+ ssize_t result;
+
++ dbgprintf("Try gzip decompression.\n");
++
++ *r_size = 0;
+ if (!filename) {
+- *r_size = 0;
+- return 0;
++ return NULL;
+ }
+ fp = gzopen(filename, "rb");
+ if (fp == 0) {
+- msg = gzerror(fp, &errnum);
+- if (errnum == Z_ERRNO) {
+- msg = strerror(errno);
+- }
+- fprintf(stderr, "Cannot open `%s': %s\n", filename, msg);
++ _gzerror(fp, &errnum, &msg);
++ dbgprintf("Cannot open `%s': %s\n", filename, msg);
++ return NULL;
++ }
++ if (gzdirect(fp)) {
++ /* It's not in gzip format */
+ return NULL;
+ }
+- size = 0;
+ allocated = 65536;
+ buf = xmalloc(allocated);
+ do {
+@@ -49,25 +59,28 @@ char *zlib_decompress_file(const char *filename, off_t *r_size)
+ if (result < 0) {
+ if ((errno == EINTR) || (errno == EAGAIN))
+ continue;
+-
+- msg = gzerror(fp, &errnum);
+- if (errnum == Z_ERRNO) {
+- msg = strerror(errno);
+- }
+- die ("read on %s of %ld bytes failed: %s\n",
+- filename, (allocated - size) + 0UL, msg);
++ _gzerror(fp, &errnum, &msg);
++ dbgprintf("Read on %s of %ld bytes failed: %s\n",
++ filename, (allocated - size) + 0UL, msg);
++ size = 0;
++ goto fail;
+ }
+ size += result;
+ } while(result > 0);
++
++fail:
+ result = gzclose(fp);
+ if (result != Z_OK) {
+- msg = gzerror(fp, &errnum);
+- if (errnum == Z_ERRNO) {
+- msg = strerror(errno);
+- }
+- die ("Close of %s failed: %s\n", filename, msg);
++ _gzerror(fp, &errnum, &msg);
++ dbgprintf(" Close of %s failed: %s\n", filename, msg);
++ }
++
++ if (size > 0) {
++ *r_size = size;
++ } else {
++ free(buf);
++ buf = NULL;
+ }
+- *r_size = size;
+ return buf;
+ }
+ #else
+--
+1.7.10.4
+
diff --git a/package/boot/kexec-tools/patches/0002-configure.ac-apply-necessary-quotes-to-result-of-mac.patch b/package/boot/kexec-tools/patches/0002-configure.ac-apply-necessary-quotes-to-result-of-mac.patch
new file mode 100644
index 0000000..aba8af7
--- /dev/null
+++ b/package/boot/kexec-tools/patches/0002-configure.ac-apply-necessary-quotes-to-result-of-mac.patch
@@ -0,0 +1,52 @@
+From eb20884c9bbc42bdf1ccace4444f3ce72657d7d8 Mon Sep 17 00:00:00 2001
+From: Yousong Zhou <yszhou4tech@gmail.com>
+Date: Tue, 9 Sep 2014 20:15:16 +0800
+Subject: [PATCH 2/5] configure.ac: apply necessary quotes to result of macro
+ expansion.
+
+This can fix the following error when searching for lzma support and
+while at it also apply the practice to other uses of the same pattern.
+
+ checking for lzma_code in -llzma... ./configure: line 4756: ac_fn_c_try_link: command not found
+
+Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
+---
+ configure.ac | 12 ++++++------
+ 1 file changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index db93331..c410e90 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -152,22 +152,22 @@ AC_CHECK_PROG([DIRNAME], dirname, dirname, "no", [$PATH])
+ dnl See if I have a usable copy of zlib available
+ if test "$with_zlib" = yes ; then
+ AC_CHECK_HEADER(zlib.h,
+- AC_CHECK_LIB(z, inflateInit_, ,
+- AC_MSG_NOTICE([zlib support disabled])))
++ [AC_CHECK_LIB(z, inflateInit_, ,
++ AC_MSG_NOTICE([zlib support disabled]))])
+ fi
+
+ dnl See if I have a usable copy of lzma available
+ if test "$with_lzma" = yes ; then
+ AC_CHECK_HEADER(lzma.h,
+- AC_CHECK_LIB(lzma, lzma_code, ,
+- AC_MSG_NOTICE([lzma support disabled])))
++ [AC_CHECK_LIB(lzma, lzma_code, ,
++ AC_MSG_NOTICE([lzma support disabled]))])
+ fi
+
+ dnl find Xen control stack libraries
+ if test "$with_xen" = yes ; then
+ AC_CHECK_HEADER(xenctrl.h,
+- AC_CHECK_LIB(xenctrl, xc_kexec_load, ,
+- AC_MSG_NOTICE([Xen support disabled])))
++ [AC_CHECK_LIB(xenctrl, xc_kexec_load, ,
++ AC_MSG_NOTICE([Xen support disabled]))])
+ fi
+
+ dnl ---Sanity checks
+--
+1.7.10.4
+
diff --git a/package/boot/kexec-tools/patches/0003-mips-fix-compiler-warning-on-printing-64-bit-integer.patch b/package/boot/kexec-tools/patches/0003-mips-fix-compiler-warning-on-printing-64-bit-integer.patch
new file mode 100644
index 0000000..f4762e9
--- /dev/null
+++ b/package/boot/kexec-tools/patches/0003-mips-fix-compiler-warning-on-printing-64-bit-integer.patch
@@ -0,0 +1,35 @@
+From 89d455d785190203b1d3a8766c8babb8c1688fc3 Mon Sep 17 00:00:00 2001
+From: Yousong Zhou <yszhou4tech@gmail.com>
+Date: Mon, 9 Feb 2015 19:51:25 +0800
+Subject: [PATCH 3/5] mips: fix compiler warning on printing 64-bit integer.
+
+
+Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
+---
+ kexec/arch/mips/crashdump-mips.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/kexec/arch/mips/crashdump-mips.c b/kexec/arch/mips/crashdump-mips.c
+index e7840e0..98c9f7c 100644
+--- a/kexec/arch/mips/crashdump-mips.c
++++ b/kexec/arch/mips/crashdump-mips.c
+@@ -22,6 +22,7 @@
+ #include <stdlib.h>
+ #include <errno.h>
+ #include <limits.h>
++#include <inttypes.h>
+ #include <elf.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+@@ -52,7 +53,7 @@ static int get_kernel_paddr(struct crash_elf_info *elf_info)
+
+ if (parse_iomem_single("Kernel code\n", &start, NULL) == 0) {
+ elf_info->kern_paddr_start = start;
+- dbgprintf("kernel load physical addr start = 0x%lx\n", start);
++ dbgprintf("kernel load physical addr start = 0x%" PRIu64 "\n", start);
+ return 0;
+ }
+
+--
+1.7.10.4
+
diff --git a/package/boot/kexec-tools/patches/0004-mips-remove-unused-variable.patch b/package/boot/kexec-tools/patches/0004-mips-remove-unused-variable.patch
new file mode 100644
index 0000000..8626c41
--- /dev/null
+++ b/package/boot/kexec-tools/patches/0004-mips-remove-unused-variable.patch
@@ -0,0 +1,30 @@
+From 904e9ae892b0592c916a013869e3be3d830e0155 Mon Sep 17 00:00:00 2001
+From: Yousong Zhou <yszhou4tech@gmail.com>
+Date: Mon, 9 Feb 2015 20:11:04 +0800
+Subject: [PATCH 4/5] mips: remove unused variable.
+
+Fixes the following compilation warning.
+
+ kexec/arch/mips/crashdump-mips.c:151:6: warning: unused variable 'i' [-Wunused-variable]
+
+Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
+---
+ kexec/arch/mips/crashdump-mips.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/kexec/arch/mips/crashdump-mips.c b/kexec/arch/mips/crashdump-mips.c
+index 98c9f7c..dc68cb4 100644
+--- a/kexec/arch/mips/crashdump-mips.c
++++ b/kexec/arch/mips/crashdump-mips.c
+@@ -148,7 +148,7 @@ static int exclude_crash_reserve_region(int *nr_ranges)
+ static int get_crash_memory_ranges(struct memory_range **range, int *ranges)
+ {
+ const char iomem[] = "/proc/iomem";
+- int i, memory_ranges = 0;
++ int memory_ranges = 0;
+ char line[MAX_LINE];
+ FILE *fp;
+ unsigned long long start, end;
+--
+1.7.10.4
+
diff --git a/package/boot/kexec-tools/patches/0005-mips-fix-warning-about-implicit-type-conversion.patch b/package/boot/kexec-tools/patches/0005-mips-fix-warning-about-implicit-type-conversion.patch
new file mode 100644
index 0000000..008a62d
--- /dev/null
+++ b/package/boot/kexec-tools/patches/0005-mips-fix-warning-about-implicit-type-conversion.patch
@@ -0,0 +1,30 @@
+From 00e75179b3b4b80e6e58d29a2bd948f97682fd00 Mon Sep 17 00:00:00 2001
+From: Yousong Zhou <yszhou4tech@gmail.com>
+Date: Mon, 9 Feb 2015 20:28:14 +0800
+Subject: [PATCH 5/5] mips: fix warning about implicit type conversion.
+
+Fixes the following warning.
+
+ kexec/arch/mips/kexec-elf-mips.c:161:16: warning: assignment makes integer from pointer without a cast [enabled by default]
+
+Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
+---
+ kexec/arch/mips/kexec-elf-mips.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/kexec/arch/mips/kexec-elf-mips.c b/kexec/arch/mips/kexec-elf-mips.c
+index a27d986..8a6419a 100644
+--- a/kexec/arch/mips/kexec-elf-mips.c
++++ b/kexec/arch/mips/kexec-elf-mips.c
+@@ -158,7 +158,7 @@ int elf_mips_load(int argc, char **argv, const char *buf, off_t len,
+ if (info->kexec_flags & KEXEC_ON_CRASH)
+ /* In case of crashdump segment[0] is kernel.
+ * Put cmdline just after it. */
+- cmdline_addr = info->segment[0].mem +
++ cmdline_addr = (unsigned long)info->segment[0].mem +
+ info->segment[0].memsz;
+ else
+ cmdline_addr = 0;
+--
+1.7.10.4
+