tar-images 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/bash
  2. set -ex
  3. INIT_DEP="rancher/os-bootstrap"
  4. SHARED_DEP="rancher/os-base"
  5. INIT_IMAGES_DST="build/images-init.tar"
  6. SYSTEM_IMAGES_DST="build/images-system.tar"
  7. cd $(dirname $0)/..
  8. IMAGES=$(bin/host_ros c images -i build/initrd/usr/share/ros/os-config.yml)
  9. INIT_IMAGES=""
  10. SYSTEM_IMAGES=""
  11. for i in ${APPEND_SYSTEM_IMAGES};do
  12. IMAGES="${IMAGES} ${i}"
  13. done
  14. for i in ${IMAGES}; do
  15. echo "tar-image: pull($i)"
  16. if ! docker inspect $i >/dev/null 2>&1; then
  17. docker pull ${i}
  18. fi
  19. if [ "${i%%:*}" != "$INIT_DEP" ] ; then
  20. SYSTEM_IMAGES="$SYSTEM_IMAGES $i"
  21. fi
  22. if [ "${i%%:*}" = "$INIT_DEP" ] || [ "${i%%:*}" = "$SHARED_DEP" ] ; then
  23. INIT_IMAGES="$INIT_IMAGES $i"
  24. fi
  25. done
  26. echo "tar-image: SYSTEM_IMAGES=$SYSTEM_IMAGES"
  27. echo "tar-image: INIT_IMAGES=$INIT_IMAGES"
  28. if [ "$COMPRESS" == "" ]; then
  29. ARCHIVE_CMD="gzip"
  30. else
  31. # system-docker can not load images which compressed by xz with a compression level of 9
  32. # decompression consumes more memory if using level 9
  33. # the default compression level for xz is 6
  34. ARCHIVE_CMD="xz -4 -e"
  35. fi
  36. docker save ${INIT_IMAGES} | ${ARCHIVE_CMD} > ${INIT_IMAGES_DST}
  37. docker save ${SYSTEM_IMAGES} | ${ARCHIVE_CMD} > ${SYSTEM_IMAGES_DST}
  38. echo "tar-images: DONE"