layout 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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}
  10. ./scripts/template
  11. cp -rf assets/selinux ${INITRD_DIR}/usr/etc
  12. cp build/images.tar ${INITRD_DIR}/usr/share/ros/
  13. cp bin/ros ${INITRD_DIR}/usr/bin/
  14. ln -s usr/bin/ros ${INITRD_DIR}/init
  15. ln -s bin ${INITRD_DIR}/usr/sbin
  16. ln -s usr/sbin ${INITRD_DIR}/sbin
  17. ln -s ros ${INITRD_DIR}/usr/bin/system-docker
  18. tar xvzf ${DOWNLOADS}/docker.tgz -C ${INITRD_DIR}/usr/bin --strip-components=1
  19. if [ -e ${DOWNLOADS}/kernel.tar.gz ]; then
  20. mkdir -p ${BUILD}/kernel
  21. tar xf ${DOWNLOADS}/kernel.tar.gz -C ${BUILD}/kernel
  22. for i in vmlinuz vmlinux; do
  23. if [ -e ${BUILD}/kernel/boot/${i}-* ]; then
  24. mkdir -p dist/artifacts
  25. cp ${BUILD}/kernel/boot/${i}-* dist/artifacts/vmlinuz
  26. break
  27. fi
  28. done
  29. if [ -d ${BUILD}/kernel/lib ]; then
  30. rm -rf ${INITRD_DIR}/usr/lib
  31. cp -rf ${BUILD}/kernel/lib ${INITRD_DIR}/usr/
  32. depmod -b ${INITRD_DIR}/usr $(basename ${INITRD_DIR}/usr/lib/modules/*)
  33. fi
  34. fi
  35. if [ -e ${DOWNLOADS}/policy.29 ]; then
  36. mkdir -p ${INITRD_DIR}/usr/etc/selinux/ros/policy/
  37. cp ${DOWNLOADS}/policy.29 ${INITRD_DIR}/usr/etc/selinux/ros/policy/
  38. fi
  39. DFS_ARCH=$(docker create ${DFS_IMAGE}${SUFFIX})
  40. trap "docker rm -fv ${DFS_ARCH} >/dev/null" EXIT
  41. docker export ${DFS_ARCH} | tar xf - -C ${INITRD_DIR} --exclude=usr/bin/dockerlaunch \
  42. --exclude=usr/bin/docker \
  43. --exclude=usr/share/git-core \
  44. --exclude=usr/bin/git \
  45. --exclude=usr/bin/ssh \
  46. --exclude=usr/libexec/git-core \
  47. usr
  48. ./scripts/hash-initrd