From 7e78670e4b511f25416a557def3f540fddff8f80 Mon Sep 17 00:00:00 2001 From: Michael Shigorin Date: Thu, 24 Nov 2011 22:13:31 +0200 Subject: [PATCH] added support for cpio and xz Actually this is the proper rewrite that was looming ever since tgz support was introduced: there are multiple archive formats supported by mkimage, and there are multiple compression methods available as well. So the bullet got bitten yet again along with the "goal parser" which should be more straightforward by now. Thanks dkr@ and mithraen@ for the inspiration of this evening. --- Makefile | 14 ++++++-------- features.in/build-ve/lib/build-ve.mk | 6 ++++++ features.in/pack/README | 3 ++- features.in/pack/config.mk | 26 +++++++++++++++++++++----- 4 files changed, 35 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 129d2cc3..a77ffd87 100644 --- a/Makefile +++ b/Makefile @@ -16,17 +16,15 @@ help: MKIMAGE_PROFILES = $(dir $(lastword $(MAKEFILE_LIST))) # only process the first target (inter-target cleanup is tricky) -IMAGE_TARGET := $(firstword $(MAKECMDGOALS))# distro/server-base.iso +IMAGE_TARGET := $(firstword $(MAKECMDGOALS))# ve/generic.tar.gz ifeq (./,$(dir $(IMAGE_TARGET)))# convenience fallback IMAGE_TARGET := distro/$(IMAGE_TARGET)# for omitted "distro/" endif -IMAGE_CONF := $(basename $(IMAGE_TARGET))# distro/server-base -IMAGE_CLASS := $(dir $(IMAGE_TARGET))# distro/ (let's fix it) -IMAGE_CLASS := $(IMAGE_CLASS:%/=%)# distro -IMAGE_FILE := $(notdir $(IMAGE_TARGET))# server-base.iso -IMAGE_NAME := $(basename $(IMAGE_FILE))# server-base -IMAGE_TYPE := $(suffix $(IMAGE_FILE))# .iso (fix this too) -IMAGE_TYPE := $(IMAGE_TYPE:.%=%)# iso +IMAGE_CONF := $(firstword $(subst ., ,$(IMAGE_TARGET)))# ve/generic +IMAGE_CLASS := $(firstword $(subst /, ,$(IMAGE_TARGET)))# ve +IMAGE_FILE := $(lastword $(subst /, ,$(IMAGE_TARGET)))# generic.tar.gz +IMAGE_NAME := $(firstword $(subst ., ,$(IMAGE_FILE)))# generic +IMAGE_TYPE := $(subst $(IMAGE_NAME).,,$(IMAGE_FILE))# tar.gz # preferences -include $(HOME)/.mkimage/profiles.mk diff --git a/features.in/build-ve/lib/build-ve.mk b/features.in/build-ve/lib/build-ve.mk index 2e233141..a221ec5b 100644 --- a/features.in/build-ve/lib/build-ve.mk +++ b/features.in/build-ve/lib/build-ve.mk @@ -1,6 +1,12 @@ # step 4: build the virtual environment image +ifeq (tar,$(IMAGE_PACKTYPE)) MKI_TAR_COMPRESS = $(IMAGE_COMPRESS) +endif + +ifeq (cpio,$(IMAGE_PACKTYPE)) +MKI_CPIO_COMPRESS = $(IMAGE_COMPRESS) +endif IMAGE_PACKAGES = $(call list,$(BASE_LISTS)) \ $(SYSTEM_PACKAGES) \ diff --git a/features.in/pack/README b/features.in/pack/README index a7692ad4..678a1219 100644 --- a/features.in/pack/README +++ b/features.in/pack/README @@ -1,3 +1,4 @@ Эта фича определяет формат упаковки создаваемого образа. На данный момент поддерживаются iso (загрузочный ISO9660 -для дистрибутивов) и tar/tgz (виртуальные окружения). +для дистрибутивов) и tar/cpio с возможностью сжатия gz/xz +(виртуальные окружения). diff --git a/features.in/pack/config.mk b/features.in/pack/config.mk index 09047afe..74dd2ed9 100644 --- a/features.in/pack/config.mk +++ b/features.in/pack/config.mk @@ -1,5 +1,4 @@ DISTRO_EXTS := .iso -VE_EXTS := .tar .tgz use/pack: @$(call add_feature) @@ -11,8 +10,25 @@ else @$(call set,IMAGE_PACKTYPE,isodata) endif -use/pack/tar: use/pack - @$(call set,IMAGE_PACKTYPE,tar) +VE_ARCHIVES := tar cpio +VE_COMPRESSORS := gz xz# there's no sense in bzip2 by now +VE_ZIPS := $(call addsuffices, \ + $(addprefix .,$(VE_COMPRESSORS)), \ + $(VE_ARCHIVES))# tar.gz cpio.xz ... +VE_EXTS := $(sort $(addprefix .,$(VE_ARCHIVES) $(VE_ZIPS)))# .tar .tar.gz ... -use/pack/tgz: use/pack/tar - @$(call set,IMAGE_COMPRESS,gzip) +# generate rules for archive/compressor combinations +define PACK_containers +use/pack/$(1): use/pack + @$$(call set,IMAGE_PACKTYPE,$(1)) +endef + +define PACK_compressors +use/pack/$(1).$(2): use/pack/$(1) + @$$(call set,IMAGE_COMPRESS,$(2)) +endef + +$(foreach c,$(VE_ARCHIVES), \ + $(eval $(call PACK_containers,$(c))) \ + $(foreach z,$(VE_COMPRESSORS), \ + $(eval $(call PACK_compressors,$(c),$(z)))))