Skip to content

Commit

Permalink
[aboot]: use pipe to extract docker archive to save disk space (#677)
Browse files Browse the repository at this point in the history
  • Loading branch information
lguohan authored Jun 6, 2017
1 parent fedfb82 commit b968cf7
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions files/Aboot/boot0.j2
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,8 @@ extract_image() {

mkdir -p "$image_path"

## Unzip the image
unzip -oq "$swipath" -x boot0 -d "$image_path"

## Remove installer swi as it has lots of redundunt contents
rm -f $swipath
## Unzip the image except boot0 and dockerfs archive
unzip -oq "$swipath" -x boot0 {{ FILESYSTEM_DOCKERFS }} -d "$image_path"

## detect rootfs type
rootfs_type=`grep " $target_path " /proc/mounts | cut -d' ' -f3`
Expand All @@ -75,17 +72,19 @@ extract_image() {
fi

## extract docker archive
tar xf "$image_path/{{ FILESYSTEM_DOCKERFS }}" -C "$image_path/{{ DOCKERFS_DIR }}" $TAR_EXTRA_OPTION

## clean up docker archive
rm -f "$image_path/{{ FILESYSTEM_DOCKERFS }}"
unzip -oqp "$swipath" {{ FILESYSTEM_DOCKERFS }} | tar xzf - -C "$image_path/{{ DOCKERFS_DIR }}" $TAR_EXTRA_OPTION
else
## save dockerfs archive in the image directory
unzip -oq "$swipath" {{ FILESYSTEM_DOCKERFS }} -d "$image_path"
echo "$target_path is $rootfs_type, extract {{ FILESYSTEM_DOCKERFS }} in later stage"
fi

## use new reduced-size boot swi
echo "SWI=flash:image-%%IMAGE_VERSION%%/{{ ABOOT_BOOT_IMAGE }}" > "$target_path/boot-config"

## Remove installer swi as it has lots of redundunt contents
rm -f "$swipath"

## sync disk operations
sync
}
Expand Down

0 comments on commit b968cf7

Please sign in to comment.