image.mk 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # This file is part of the OpenADK project. OpenADK is copyrighted
  2. # material, please see the LICENCE file in the top-level directory.
  3. imageprepare: kernel-install image-prepare-post
  4. image-prepare-post:
  5. rng=/dev/arandom; test -e $$rng || rng=/dev/urandom; \
  6. dd if=$$rng bs=512 count=1 >>${TARGET_DIR}/etc/.rnd 2>/dev/null; \
  7. chmod 600 ${TARGET_DIR}/etc/.rnd
  8. # Sanity checks
  9. @cd ${TARGET_DIR}; ls=; ln=; li=; x=1; md5sum $$(find . -type f) | \
  10. sed -e "s/*//" | \
  11. while read sum name; do \
  12. inode=$$(ls -i "$$name"); \
  13. echo "$$sum $${inode%% *} $$name"; \
  14. done | sort | while read sum inode name; do \
  15. if [[ $$sum = $$ls ]]; then \
  16. [[ $$li = $$inode ]] && continue; \
  17. case $$x in \
  18. 1) echo 'WARNING: duplicate files found' \
  19. 'in filesystem! Please fix them.' >&2; \
  20. echo -n "> $$ln "; \
  21. ;; \
  22. 2) echo -n "> $$ln "; \
  23. ;; \
  24. 3) echo -n ' '; \
  25. ;; \
  26. esac; \
  27. echo -n "$$name"; \
  28. x=3; \
  29. else \
  30. case $$x in \
  31. 3) echo; \
  32. x=2; \
  33. ;; \
  34. esac; \
  35. fi; \
  36. ls=$$sum; \
  37. ln=$$name; \
  38. li=$$inode; \
  39. done
  40. chmod 4511 ${TARGET_DIR}/bin/busybox
  41. chmod 1777 ${TARGET_DIR}/tmp
  42. INITRAMFS= ${DEVICE}-${ARCH}-${FS}
  43. ROOTFSSQUASHFS= ${DEVICE}-${ARCH}-${FS}.img
  44. ROOTFSTARBALL= ${DEVICE}-${ARCH}-${FS}.tar.gz
  45. INITRAMFS_PIGGYBACK= ${DEVICE}-${ARCH}-${FS}.cpio
  46. ${BIN_DIR}/${ROOTFSTARBALL}: ${TARGET_DIR}
  47. cd ${TARGET_DIR}; tar -cf - --owner=0 --group=0 . | gzip -n9 >$@
  48. ${BIN_DIR}/${INITRAMFS}: ${TARGET_DIR}
  49. cd ${TARGET_DIR}; find . | sed -n '/^\.\//s///p' | sort | \
  50. cpio -R 0:0 --quiet -oC512 -Mdist -Hnewc | gzip -n9 >$@
  51. ${BUILD_DIR}/${INITRAMFS_PIGGYBACK}: ${TARGET_DIR}
  52. cd ${TARGET_DIR}; find . | sed -n '/^\.\//s///p' | sort | \
  53. cpio -R 0:0 --quiet -oC512 -Mdist -Hnewc >$@
  54. ${BIN_DIR}/${ROOTFSSQUASHFS}: ${TARGET_DIR}
  55. PATH='${TARGET_PATH}' \
  56. mksquashfs ${TARGET_DIR} ${BUILD_DIR}/root.squashfs \
  57. -nopad -noappend -root-owned $(MAKE_TRACE)
  58. cat ${BIN_DIR}/${DEVICE}-${ARCH}-kernel ${BUILD_DIR}/root.squashfs > \
  59. ${BUILD_DIR}/${ROOTFSSQUASHFS}
  60. # padding of images is required
  61. dd if=${BUILD_DIR}/${ROOTFSSQUASHFS} of=${BIN_DIR}/${ROOTFSSQUASHFS} \
  62. bs=4063232 conv=sync $(MAKE_TRACE)
  63. imageclean:
  64. rm -f $(BIN_DIR)/$(DEVICE)-* ${BUILD_DIR}/$(DEVICE)-*