瀏覽代碼

add zstd support for Linux kernel compression

Waldemar Brodkorb 9 月之前
父節點
當前提交
6eacd00ca0

+ 10 - 0
mk/image.mk

@@ -255,6 +255,16 @@ ifeq ($(ADK_LINUX_KERNEL_COMP_XZ),y)
 		echo "CONFIG_XZ_DEC_TEST=n" >> ${LINUX_DIR}/.config
 		echo "CONFIG_XZ_DEC_MICROLZMA=n" >> ${LINUX_DIR}/.config
 endif
+ifeq ($(ADK_LINUX_KERNEL_COMP_ZSTD),y)
+		echo "CONFIG_RD_XZ=n" >> ${LINUX_DIR}/.config
+		echo "CONFIG_RD_BZIP2=n" >> ${LINUX_DIR}/.config
+		echo "CONFIG_RD_GZIP=n" >> ${LINUX_DIR}/.config
+		echo "CONFIG_RD_LZO=n" >> ${LINUX_DIR}/.config
+		echo "CONFIG_RD_LZ4=n" >> ${LINUX_DIR}/.config
+		echo "CONFIG_RD_LZMA=n" >> ${LINUX_DIR}/.config
+		echo "CONFIG_RD_ZSTD=y" >> ${LINUX_DIR}/.config
+		echo "CONFIG_INITRAMFS_COMPRESSION_ZSTD=y" >> ${LINUX_DIR}/.config
+endif
 ifeq ($(ADK_LINUX_KERNEL_COMP_LZ4),y)
 		echo "CONFIG_RD_XZ=n" >> ${LINUX_DIR}/.config
 		echo "CONFIG_RD_BZIP2=n" >> ${LINUX_DIR}/.config

+ 38 - 0
package/zstd/Makefile

@@ -0,0 +1,38 @@
+# This file is part of the OpenADK project. OpenADK is copyrighted
+# material, please see the LICENCE file in the top-level directory.
+
+include $(ADK_TOPDIR)/rules.mk
+
+PKG_NAME:=		zstd
+PKG_VERSION:=		1.5.5
+PKG_RELEASE:=		1
+PKG_HASH:=		98e9c3d949d1b924e28e01eccb7deed865eefebf25c2f21c702e5cd5b63b85e1
+PKG_DESCR:=		zstandard compression application
+PKG_SECTION:=		app/archive
+PKG_SITES:=		https://github.com/facebook/zstd/archive/refs/tags/
+PKG_OPTS:=		dev
+
+DISTFILES:=             v$(PKG_VERSION).tar.gz
+
+include ${ADK_TOPDIR}/mk/host.mk
+include $(ADK_TOPDIR)/mk/package.mk
+
+$(eval $(call HOST_template,ZSTD,zstd,${PKG_VERSION}-${PKG_RELEASE}))
+$(eval $(call PKG_template,ZSTD,zstd,$(PKG_VERSION)-$(PKG_RELEASE),$(PKG_DEPENDS),$(PKG_DESCR),$(PKG_SECTION),$(PKG_OPTS)))
+
+HOST_CONFIG_STYLE:=	manual
+HOST_INSTALL_STYLE:=	auto
+CONFIG_STYLE:=		manual
+ALL_TARGET:=		default
+HOST_ALL_TARGET:=	default
+
+zstd-install:
+	$(INSTALL_DIR) $(IDIR_ZSTD)/usr/lib
+	$(CP) $(WRKINST)/usr/lib/libzstd*.so* \
+		$(IDIR_ZSTD)/usr/lib
+	$(INSTALL_DIR) $(IDIR_ZSTD)/usr/bin
+	$(INSTALL_BIN) $(WRKINST)/usr/bin/zstd \
+		$(IDIR_ZSTD)/usr/bin
+
+include ${ADK_TOPDIR}/mk/host-bottom.mk
+include $(ADK_TOPDIR)/mk/pkg-bottom.mk

+ 11 - 0
package/zstd/patches/patch-lib_Makefile

@@ -0,0 +1,11 @@
+--- zstd-1.5.5.orig/lib/Makefile	2023-04-04 22:13:52.000000000 +0200
++++ zstd-1.5.5/lib/Makefile	2024-01-17 18:12:48.257111944 +0100
+@@ -259,7 +259,7 @@ DESTDIR     ?=
+ # directory variables : GNU conventions prefer lowercase
+ # see https://www.gnu.org/prep/standards/html_node/Makefile-Conventions.html
+ # support both lower and uppercase (BSD), use uppercase in script
+-prefix      ?= /usr/local
++prefix      ?= /usr
+ PREFIX      ?= $(prefix)
+ exec_prefix ?= $(PREFIX)
+ EXEC_PREFIX ?= $(exec_prefix)

+ 11 - 0
package/zstd/patches/patch-programs_Makefile

@@ -0,0 +1,11 @@
+--- zstd-1.5.5.orig/programs/Makefile	2023-04-04 22:13:52.000000000 +0200
++++ zstd-1.5.5/programs/Makefile	2024-01-17 18:13:11.620566871 +0100
+@@ -380,7 +380,7 @@ DESTDIR     ?=
+ # directory variables : GNU conventions prefer lowercase
+ # see https://www.gnu.org/prep/standards/html_node/Makefile-Conventions.html
+ # support both lower and uppercase (BSD), use uppercase in script
+-prefix      ?= /usr/local
++prefix      ?= /usr
+ PREFIX      ?= $(prefix)
+ exec_prefix ?= $(PREFIX)
+ bindir      ?= $(exec_prefix)/bin

+ 8 - 0
scripts/prereq.sh

@@ -651,6 +651,11 @@ if ! which lzma >/dev/null 2>&1; then
   host_build_lzma=1
 fi
 
+host_build_zstd=0
+if ! which zstd >/dev/null 2>&1; then
+  host_build_zstd=1
+fi
+
 host_build_lz4=0
 if ! which lz4c >/dev/null 2>&1; then
   host_build_lz4=1
@@ -741,6 +746,9 @@ fi
 if [ $host_build_lzma -eq 1 ]; then
   printf "\t%s\n" "select ADK_HOST_BUILD_LZMA if ADK_HOST_NEED_LZMA" >> $topdir/target/config/Config.in.prereq
 fi
+if [ $host_build_zstd -eq 1 ]; then
+  printf "\t%s\n" "select ADK_HOST_BUILD_ZSTD if ADK_HOST_NEED_ZSTD" >> $topdir/target/config/Config.in.prereq
+fi
 if [ $host_build_lz4 -eq 1 ]; then
   printf "\t%s\n" "select ADK_HOST_BUILD_LZ4 if ADK_HOST_NEED_LZ4" >> $topdir/target/config/Config.in.prereq
 fi

+ 9 - 0
target/config/Config.in.tools

@@ -191,6 +191,14 @@ config ADK_HOST_BUILD_GENEXT2FS
 	bool
 	default n
 
+config ADK_HOST_NEED_ZSTD
+	bool
+	default n
+
+config ADK_HOST_BUILD_ZSTD
+	bool
+	default n
+
 config ADK_HOST_NEED_LZ4
 	bool
 	default n
@@ -315,6 +323,7 @@ config ADK_COMPRESSION_TOOL
 	default "gzip -n9" if ADK_LINUX_KERNEL_INITRAMFS_COMPRESSION_GZIP
 	default "bzip2" if ADK_LINUX_KERNEL_INITRAMFS_COMPRESSION_BZIP2
 	default "xz -v --check=crc32 --lzma2=dict=1MiB" if ADK_LINUX_KERNEL_INITRAMFS_COMPRESSION_XZ
+	default "zstd" if ADK_LINUX_KERNEL_INITRAMFS_COMPRESSION_ZSTD
 	default "lz4c -l" if ADK_LINUX_KERNEL_INITRAMFS_COMPRESSION_LZ4
 	default "lzma -9" if ADK_LINUX_KERNEL_INITRAMFS_COMPRESSION_LZMA
 	default "lzop" if ADK_LINUX_KERNEL_INITRAMFS_COMPRESSION_LZO

+ 18 - 0
target/linux/config/Config.in.compression

@@ -8,6 +8,10 @@ config ADK_LINUX_KERNEL_INITRAMFS_COMPRESSION_XZ
 	bool
 	select ADK_HOST_NEED_XZ
 
+config ADK_LINUX_KERNEL_INITRAMFS_COMPRESSION_ZSTD
+	bool
+	select ADK_HOST_NEED_ZSTD
+
 config ADK_LINUX_KERNEL_INITRAMFS_COMPRESSION_LZ4
 	bool
 	select ADK_HOST_NEED_LZ4
@@ -57,6 +61,12 @@ config ADK_LINUX_KERNEL_RD_LZO
 config ADK_LINUX_KERNEL_KERNEL_LZO
 	bool
 
+config ADK_LINUX_KERNEL_RD_ZSTD
+	bool
+
+config ADK_LINUX_KERNEL_KERNEL_ZSTD
+	bool
+
 config ADK_LINUX_KERNEL_RD_XZ
 	bool
 
@@ -84,6 +94,14 @@ config ADK_LINUX_KERNEL_COMP_XZ
 	depends on ADK_TARGET_KERNEL_WITH_COMPRESSION \
 		|| ADK_TARGET_GENERIC
 
+config ADK_LINUX_KERNEL_COMP_ZSTD
+	bool "use Zstandard compression"
+	select ADK_LINUX_KERNEL_RD_ZSTD
+	select ADK_LINUX_KERNEL_KERNEL_ZSTD
+	select ADK_LINUX_KERNEL_INITRAMFS_COMPRESSION_ZSTD
+	depends on ADK_TARGET_KERNEL_WITH_COMPRESSION \
+		|| ADK_TARGET_GENERIC
+
 config ADK_LINUX_KERNEL_COMP_LZ4
 	bool "use LZ4 compression"
 	select ADK_LINUX_KERNEL_RD_LZ4