diff --git a/lib/functions/image/rootfs-to-image.sh b/lib/functions/image/rootfs-to-image.sh index 6ad85e44c3..729a83ec72 100644 --- a/lib/functions/image/rootfs-to-image.sh +++ b/lib/functions/image/rootfs-to-image.sh @@ -35,6 +35,9 @@ function create_image_from_sdcard_rootfs() { calculate_image_version declare -r -g version="${calculated_image_version}" # global readonly from here declare rsync_ea=" -X " + declare exclude_home="--exclude=\"/home/*\"" + # Some usecase requires home directory to be included + if [[ ${INCLUDE_HOME_DIR:-no} == yes ]]; then exclude_home=""; fi # nilfs2 fs does not have extended attributes support, and have to be ignored on copy if [[ $ROOTFS_TYPE == nilfs2 ]]; then rsync_ea=""; fi if [[ $ROOTFS_TYPE != nfs ]]; then @@ -46,12 +49,12 @@ function create_image_from_sdcard_rootfs() { --exclude="/run/*" \ --exclude="/tmp/*" \ --exclude="/sys/*" \ - --exclude="/home/*" \ + $exclude_home \ --info=progress0,stats1 $SDCARD/ $MOUNT/ else display_alert "Creating rootfs archive" "rootfs.tgz" "info" tar cp --xattrs --directory=$SDCARD/ --exclude='./boot/*' --exclude='./dev/*' --exclude='./proc/*' --exclude='./run/*' --exclude='./tmp/*' \ - --exclude='./sys/*' --exclude="/home/*" . | + --exclude='./sys/*' $exclude_home . | pv -p -b -r -s "$(du -sb "$SDCARD"/ | cut -f1)" \ -N "$(logging_echo_prefix_for_pv "create_rootfs_archive") rootfs.tgz" | gzip -c > "$DEST/images/${version}-rootfs.tgz"