Makefile: add target-finalize for common filesystem cleanup
[avatt.git] / target / tar / tarroot.mk
blob5b33c6213951869039038a5a4eb5982f55f5fc09
1 #############################################################
3 # tar to archive target filesystem
5 #############################################################
7 TAR_OPTS:=$(BR2_TARGET_ROOTFS_TAR_OPTIONS)
8 TAR_TARGET:=$(IMAGE).tar
10 TAR_COMPRESSOR:=
11 TAR_COMPRESSOR_EXT:=.none
12 ifeq ($(BR2_TARGET_ROOTFS_TAR_GZIP),y)
13 TAR_COMPRESSOR:=gzip -9 -c
14 TAR_COMPRESSOR_EXT:=gz
15 endif
16 ifeq ($(BR2_TARGET_ROOTFS_TAR_BZIP2),y)
17 TAR_COMPRESSOR:=bzip2 -9 -c
18 TAR_COMPRESSOR_EXT:=bz2
19 endif
20 ifeq ($(BR2_TARGET_ROOTFS_TAR_LZMA),y)
21 TAR_COMPRESSOR:=lzma -9 -c
22 TAR_COMPRESSOR_EXT:=lzma
23 endif
24 ROOTFS_TAR_COPYTO:=$(strip $(subst ",,$(BR2_TARGET_ROOTFS_TAR_COPYTO)))
25 # "))
27 tarroot: host-fakeroot makedevs
28 # Use fakeroot to pretend all target binaries are owned by root
29 rm -f $(PROJECT_BUILD_DIR)/_fakeroot.$(notdir $(TAR_TARGET))
30 touch $(PROJECT_BUILD_DIR)/.fakeroot.00000
31 cat $(PROJECT_BUILD_DIR)/.fakeroot* > $(PROJECT_BUILD_DIR)/_fakeroot.$(notdir $(TAR_TARGET))
32 echo "chown -R 0:0 $(TARGET_DIR)" >> $(PROJECT_BUILD_DIR)/_fakeroot.$(notdir $(TAR_TARGET))
33 ifneq ($(TARGET_DEVICE_TABLE),)
34 # Use fakeroot to pretend to create all needed device nodes
35 echo "$(HOST_DIR)/usr/bin/makedevs -d $(TARGET_DEVICE_TABLE) $(TARGET_DIR)" \
36 >> $(PROJECT_BUILD_DIR)/_fakeroot.$(notdir $(TAR_TARGET))
37 endif
38 # Use fakeroot so tar believes the previous fakery
39 echo "tar -c$(TAR_OPTS)f $(TAR_TARGET) -C $(TARGET_DIR) ." \
40 >> $(PROJECT_BUILD_DIR)/_fakeroot.$(notdir $(TAR_TARGET))
41 chmod a+x $(PROJECT_BUILD_DIR)/_fakeroot.$(notdir $(TAR_TARGET))
42 $(HOST_DIR)/usr/bin/fakeroot -- $(PROJECT_BUILD_DIR)/_fakeroot.$(notdir $(TAR_TARGET))
43 ifneq ($(TAR_COMPRESSOR),)
44 -rm -f $(TAR_TARGET).$()
45 PATH="$(STAGING_DIR)/sbin:$(STAGING_DIR)/bin:$(STAGING_DIR)/usr/sbin:$(STAGING_DIR)/usr/bin:$(PATH)" $(TAR_COMPRESSOR) $(TAR_TARGET) > $(TAR_TARGET).$(TAR_COMPRESSOR_EXT)
46 endif
47 ifneq ($(ROOTFS_TAR_COPYTO),)
48 $(Q)cp -f $(TAR_TARGET) $(ROOTFS_TAR_COPYTO)
49 endif
50 -@rm -f $(PROJECT_BUILD_DIR)/_fakeroot.$(notdir $(TAR_TARGET))
52 tarroot-source:
54 tarroot-clean:
56 tarroot-dirclean:
58 #############################################################
60 # Toplevel Makefile options
62 #############################################################
63 ifeq ($(BR2_TARGET_ROOTFS_TAR),y)
64 TARGETS+=tarroot
65 endif