layout 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #!/bin/bash
  2. set -e
  3. source $(dirname $0)/version
  4. cd $(dirname $0)/..
  5. BUILD=build
  6. INITRD_DIR=${BUILD}/initrd
  7. echo Create initrd layout in $INITRD_DIR
  8. rm -rf ${INITRD_DIR}
  9. mkdir -p ${INITRD_DIR}/usr/{etc,bin,share/ros,var/lib/cni/bin}
  10. ./scripts/template
  11. cp -rf assets/selinux ${INITRD_DIR}/usr/etc
  12. cp -rf assets/docker ${INITRD_DIR}/usr/etc
  13. cp build/images.tar ${INITRD_DIR}/usr/share/ros/
  14. cp bin/ros ${INITRD_DIR}/usr/bin/
  15. ln -s usr/bin/ros ${INITRD_DIR}/init
  16. ln -s bin ${INITRD_DIR}/usr/sbin
  17. ln -s usr/sbin ${INITRD_DIR}/sbin
  18. ln -s ros ${INITRD_DIR}/usr/bin/system-docker
  19. ln -s ros ${INITRD_DIR}/usr/bin/docker-runc
  20. ln -s ../../../../usr/bin/ros ${INITRD_DIR}/usr/var/lib/cni/bin/bridge
  21. ln -s ../../../../usr/bin/ros ${INITRD_DIR}/usr/var/lib/cni/bin/host-local
  22. # Support upgrades from old persistent consoles that bind mount these
  23. touch ${INITRD_DIR}/usr/bin/docker-containerd
  24. touch ${INITRD_DIR}/usr/bin/docker-containerd-shim
  25. touch ${INITRD_DIR}/usr/bin/docker
  26. if [ -e ${DOWNLOADS}/kernel.tar.gz ]; then
  27. mkdir -p ${BUILD}/kernel
  28. tar xf ${DOWNLOADS}/kernel.tar.gz -C ${BUILD}/kernel
  29. for i in vmlinuz vmlinux; do
  30. if [ -e ${BUILD}/kernel/boot/${i}-* ]; then
  31. mkdir -p dist/artifacts
  32. cp ${BUILD}/kernel/boot/${i}-* dist/artifacts/vmlinuz
  33. break
  34. fi
  35. done
  36. if [ -d ${BUILD}/kernel/lib ]; then
  37. rm -rf ${INITRD_DIR}/usr/lib
  38. cp -rf ${BUILD}/kernel/lib ${INITRD_DIR}/usr/
  39. depmod -b ${INITRD_DIR}/usr $(basename ${INITRD_DIR}/usr/lib/modules/*)
  40. fi
  41. fi
  42. if [ -e ${DOWNLOADS}/policy.29 ]; then
  43. mkdir -p ${INITRD_DIR}/usr/etc/selinux/ros/policy/
  44. cp ${DOWNLOADS}/policy.29 ${INITRD_DIR}/usr/etc/selinux/ros/policy/
  45. fi
  46. DFS_ARCH=$(docker create ${DFS_IMAGE}${SUFFIX})
  47. trap "docker rm -fv ${DFS_ARCH} >/dev/null" EXIT
  48. docker export ${DFS_ARCH} | tar xf - -C ${INITRD_DIR} --exclude=usr/bin/docker* \
  49. --exclude=usr/share/git-core \
  50. --exclude=usr/bin/git \
  51. --exclude=usr/bin/ssh \
  52. --exclude=usr/libexec/git-core \
  53. usr
  54. ./scripts/hash-initrd