Commit 7e78670e authored by Michael Shigorin's avatar Michael Shigorin

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.
parent 041d5754
......@@ -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
......
# 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) \
......
Эта фича определяет формат упаковки создаваемого образа.
На данный момент поддерживаются iso (загрузочный ISO9660
для дистрибутивов) и tar/tgz (виртуальные окружения).
для дистрибутивов) и tar/cpio с возможностью сжатия gz/xz
(виртуальные окружения).
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)))))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment