+ case "${SNAP_TYPE}" in
+ squashfs)
+ echo ".${TMP_FILELIST}" > "${TMP_FILELIST}"
+ # Removing whiteheads of unionfs
+ cd "${SNAP_COW}"
+ find . -name '*.wh.*' >> "${TMP_FILELIST}"
+
+ if [ -e "${EXCLUDE_LIST}" ]
+ then
+ # Add explicitly excluded files
+ cat "${TMP_EXCLUDE_LIST}" >> "${TMP_FILELIST}"
+ fi
+
+ cd "${OLDPWD}"
+ mksquashfs "${SNAP_COW}" "${DEST}" -ef "${TMP_FILELIST}"
+ ;;
+
+ cpio|whole_partition)
+ if [ "${SNAP_TYPE}" = "cpio" ]
+ then
+ COPY_CMD="cpio --quiet -o0 -H newc | gzip -9c > ${DEST}"
+ else
+ COPY_CMD="cpio --quiet -pumd0 ${DEST}/"
+ fi
+
+ WORKING_DIR=$(Do_filelist "${TMP_FILELIST}")
+ cd "${WORKING_DIR}"
+ if [ -e "${EXCLUDE_LIST}" ]
+ then
+
+ # Convert \0 to \n and tag existing (rare but possible) \n in filenames,
+ # this to let grep -F -v do a proper work in filtering out
+ cat "${TMP_FILELIST}" | \
+ tr '\n' '\1' | \
+ tr '\0' '\n' | \
+ grep -F -v -f "${TMP_EXCLUDE_LIST}" | \
+ tr '\n' '\0' | \
+ tr '\1' '\n' | \
+ eval $COPY_CMD || exit 1
+ else
+ cat "${TMP_FILELIST}" | \
+ eval $COPY_CMD || exit 1
+ fi
+ cd "${OLDPWD}"
+ ;;
+
+ # ext2|ext3|ext4 and jffs2 does not easily support an exclude list; files
+ # should be copied to another directory in order to filter content
+ ext2|ext3|ext4)
+ DU_DIM="$(du -ks ${SNAP_COW} | cut -f1)"
+ REAL_DIM="$(expr ${DU_DIM} + ${DU_DIM} / 20)" # Just 5% more to be sure, need something more sophistcated here...
+ genext2fs --size-in-blocks=${REAL_DIM} --reserved-percentage=0 --root="${SNAP_COW}" "${DEST}"
+ ;;
+
+ jffs2)
+ mkfs.jffs2 --root="${SNAP_COW}" --output="${DEST}"
+ ;;
+ esac
+
+ # Remove temporary file lists
+ for filelist in "${TMP_FILELIST}" "${TMP_EXCLUDE_LIST}"
+ do
+ if [ -f "${filelist}" ]
+ then
+ rm -f "${filelist}"
+ fi
+ done