From 290956cc3a790e4d8167073f5531b1de2b989e9b Mon Sep 17 00:00:00 2001 From: Abdoulaye Walsimou Gaye Date: Sun, 16 Aug 2009 19:38:04 +0200 Subject: Rootfs: Add support of squashfs root filesystem build Signed-off-by: Abdoulaye Walsimou Gaye --- kconfig/fs.kconfig | 30 +++++++++++++--------- mk/fs.mk | 6 +++++ mk/initialpath.mk | 3 ++- mk/rootfs.mk | 7 ++++++ mk/squashfs.mk | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 107 insertions(+), 13 deletions(-) create mode 100644 mk/squashfs.mk diff --git a/kconfig/fs.kconfig b/kconfig/fs.kconfig index 9add022..8f63bf1 100644 --- a/kconfig/fs.kconfig +++ b/kconfig/fs.kconfig @@ -26,18 +26,6 @@ menu "Type of root filesystem to build" -#JFFS2 root filesystem image build -config EMBTK_ROOTFS_HAVE_JFFS2 - bool "Build a JFFS2 root filesystem image" - help - Build a JFFS2 root filesystem image for your target -config EMBTK_ROOTFS_HAVE_JFFS2_BLOCKSIZE - depends on EMBTK_ROOTFS_HAVE_JFFS2 - help - Erase block size to use in KB - int "Erase block size to use in KB" - default 512 - #INITRAMFS cpio archive config EMBTK_ROOTFS_HAVE_INITRAMFS_CPIO bool "Build cpio archive for initramfs" @@ -57,4 +45,22 @@ choice Use bzip2 compression algorithm. endchoice +#JFFS2 root filesystem image build +config EMBTK_ROOTFS_HAVE_JFFS2 + bool "Build a JFFS2 root filesystem image" + help + Build a JFFS2 root filesystem image for your target +config EMBTK_ROOTFS_HAVE_JFFS2_BLOCKSIZE + depends on EMBTK_ROOTFS_HAVE_JFFS2 + help + Erase block size to use in KB + int "Erase block size to use in KB" + default 512 + +#SQUASHFS root filesystem +config EMBTK_ROOTFS_HAVE_SQUASHFS + bool "Build a squashfs root filesystem image" + help + Build a squashfs root filesystem image for your target + endmenu diff --git a/mk/fs.mk b/mk/fs.mk index 998664e..6ceb778 100644 --- a/mk/fs.mk +++ b/mk/fs.mk @@ -45,6 +45,12 @@ build_jffs2_rootfs: -o $(EMBTK_ROOT)/rootfs-$(GNU_TARGET)-$(EMBTK_MCU_FLAG).jffs2 @rm -rf $(EMBTK_ROOT)/rootfs-$(GNU_TARGET)-$(EMBTK_MCU_FLAG).jffs2.temp +build_squashfs_rootfs: + $(call EMBTK_GENERIC_MESSAGE,"Generating squashfs root filesystem...") + $(FAKEROOT_BIN) -i $(EMBTK_ROOT)/.fakeroot.001 -- \ + $(HOSTTOOLS)/usr/bin/mksquashfs $(ROOTFS) \ + rootfs-$(GNU_TARGET)-$(EMBTK_MCU_FLAG).squashfs + build_initramfs_archive: $(call EMBTK_GENERIC_MESSAGE,"Generating cpio archive for initramfs...") ifeq ($(EMBTK_ROOTFS_HAVE_INITRAMFS_CPIO_GZIPED),y) diff --git a/mk/initialpath.mk b/mk/initialpath.mk index 3a799da..d2091a8 100644 --- a/mk/initialpath.mk +++ b/mk/initialpath.mk @@ -49,5 +49,6 @@ ifeq ($(CONFIG_EMBTK_HAVE_ROOTFS),y) endif rmallpath: - @rm -Rf build rootfs-* sysroot-* tools-* $(DOWNLOAD_DIR)/eglibc* + @rm -Rf build rootfs-* sysroot-* tools-* $(DOWNLOAD_DIR)/eglibc* \ + initramfs-* diff --git a/mk/rootfs.mk b/mk/rootfs.mk index 4d55505..fd03370 100644 --- a/mk/rootfs.mk +++ b/mk/rootfs.mk @@ -47,6 +47,13 @@ ROOTFS_HOSTTOOLS_CLEAN += mtd-utils_host_clean FILESYSTEMS += build_jffs2_rootfs endif +#Does squashfs filesystem selected? +ifeq ($(CONFIG_EMBTK_ROOTFS_HAVE_SQUASHFS),y) +include $(EMBTK_ROOT)/mk/squashfs.mk +ROOTFS_HOSTTOOLS += squashfs_host_install +FILESYSTEMS += build_squashfs_rootfs +endif + rootfs_build: $(call EMBTK_GENERIC_MESSAGE,"Building selected root filesystems...") @$(MAKE) rootfs_clean mkinitialpath $(ROOTFS_HOSTTOOLS) \ diff --git a/mk/squashfs.mk b/mk/squashfs.mk new file mode 100644 index 0000000..b9d979e --- /dev/null +++ b/mk/squashfs.mk @@ -0,0 +1,74 @@ +################################################################################ +# GAYE Abdoulaye Walsimou, +# Copyright(C) 2009 GAYE Abdoulaye Walsimou. All rights reserved. +# +# This program is free software; you can distribute it and/or modify it +# under the terms of the GNU General Public License +# (Version 2 or later) published by the Free Software Foundation. +# +# This program is distributed in the hope it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. +################################################################################ +# +# \file squashfs.mk +# \brief squashfs.mk of Embtoolkit. +# \author GAYE Abdoulaye Walsimou, +# \date August 2009 +################################################################################ + +SQUASHFS_VERSION := 4.0 +SQUASHFS_SITE := http://downloads.sourceforge.net/project/squashfs/squashfs +SQUASHFS_PACKAGE := squashfs$(SQUASHFS_VERSION).tar.gz +SQUASHFS_HOST_BUILD_DIR := $(TOOLS_BUILD)/squashfs-build +SQUASHFS_TARGET_BUILD_DIR := $(PACKAGES_BUILD)/squashfs-build + +squashfs_host_install: $(SQUASHFS_HOST_BUILD_DIR)/.installed +squashfs_target_install: $(SQUASHFS_TARGET_BUILD_DIR)/.installed + +#squashfs for host +$(SQUASHFS_HOST_BUILD_DIR)/.installed: download_squashfs \ + $(SQUASHFS_HOST_BUILD_DIR)/.decompressed + @CC=$(HOSTCC_CACHED) \ + $(MAKE) -C $(TOOLS_BUILD)/squashfs$(SQUASHFS_VERSION)/squashfs-tools + @cp $(TOOLS_BUILD)/squashfs$(SQUASHFS_VERSION)/squashfs-tools/\ + mksquashfs $(HOSTTOOLS)/usr/bin/ + @cp $(TOOLS_BUILD)/squashfs$(SQUASHFS_VERSION)/squashfs-tools/\ + unsquashfs $(HOSTTOOLS)/usr/bin/ + @touch $@ + +$(SQUASHFS_HOST_BUILD_DIR)/.decompressed: + $(call EMBTK_GENERIC_MESSAGE,"Decompressing $(SQUASHFS_PACKAGE)...") + @tar -C $(TOOLS_BUILD) -xzvf $(DOWNLOAD_DIR)/$(SQUASHFS_PACKAGE) + @mkdir -p $(SQUASHFS_HOST_BUILD_DIR) + @touch $@ + +squashfs_host_clean: + $(call EMBTK_GENERIC_MESSAGE,"Cleaning squashfs in host ...") + +#squashfs for target +$(SQUASHFS_TARGET_BUILD_DIR)/.installed: download_squashfs \ + $(SQUASHFS_TARGET_BUILD_DIR)/.decompressed + @touch $@ + +$(SQUASHFS_TARGET_BUILD_DIR)/.decompressed: + $(call EMBTK_GENERIC_MESSAGE,"Decompressing $(SQUASHFS_PACKAGE)...") + @tar -C $(PACKAGES_BUILD) -xzvf $(DOWNLOAD_DIR)/$(SQUASHFS_PACKAGE) + @mkdir -p $(SQUASHFS_TARGET_BUILD_DIR) + @touch $@ + +squashfs_target_clean: + $(call EMBTK_GENERIC_MESSAGE,"Cleaning squashfs in target ...") + +download_squashfs: + $(call EMBTK_GENERIC_MESSAGE,"Downloading $(SQUASHFS_PACKAGE) \ + if necessary...") + @test -e $(DOWNLOAD_DIR)/$(SQUASHFS_PACKAGE) || \ + wget -O $(DOWNLOAD_DIR)/$(SQUASHFS_PACKAGE) \ + $(SQUASHFS_SITE)/squashfs$(SQUASHFS_VERSION)/$(SQUASHFS_PACKAGE) + -- cgit v1.2.3