package-rootfs 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/bash
  2. set -e
  3. set -o pipefail
  4. cd $(dirname $0)/..
  5. source scripts/version
  6. BUILD=$(pwd)/build
  7. IMAGE_CACHE=${BUILD}/image-cache
  8. PREPOP_DIR=${IMAGE_CACHE}/var/lib/system-docker
  9. INITRD_DIR=${BUILD}/initrd
  10. ARTIFACTS=$(pwd)/dist/artifacts
  11. INITRD=${ARTIFACTS}/initrd
  12. mkdir -p ${ARTIFACTS} ${PREPOP_DIR}
  13. if [ "$(docker info | grep 'Storage Driver: ' | sed 's/Storage Driver: //')" != "overlay" ]; then
  14. echo Overlay storage driver is require do create rootfs.tar 1>&2
  15. exit 1
  16. fi
  17. DFS=$(docker run -d --privileged -v /lib/modules/$(uname -r):/lib/modules/$(uname -r) ${DFS_IMAGE}${SUFFIX} ${DFS_ARGS})
  18. trap "docker rm -fv ${DFS_ARCH} ${DFS}" EXIT
  19. docker exec -i ${DFS} docker load < ${INITRD_DIR}/usr/share/ros/images.tar
  20. docker stop ${DFS}
  21. docker run --rm --volumes-from=${DFS} rancher/os-base tar -c -C /var/lib/docker ./image | tar -x -C ${PREPOP_DIR}
  22. docker run --rm --volumes-from=${DFS} rancher/os-base tar -c -C /var/lib/docker ./overlay | tar -x -C ${PREPOP_DIR}
  23. tar -cf ${ARTIFACTS}/rootfs.tar --exclude lib/modules --exclude lib/firmware -C ${INITRD_DIR} .
  24. tar -rf ${ARTIFACTS}/rootfs.tar --exclude lib/modules --exclude lib/firmware -C ${INITRD_DIR} .
  25. rm -f ${ARTIFACTS}/rootfs.tar.gz
  26. gzip ${ARTIFACTS}/rootfs.tar