image.mk 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. ${BIN_DIR}/${ROOTFSTARBALL}: ${TARGET_DIR}
  46. cd ${TARGET_DIR}; tar -cf - --owner=0 --group=0 . | gzip -n9 >$@
  47. ${BIN_DIR}/${INITRAMFS}: ${TARGET_DIR}
  48. cd ${TARGET_DIR}; find . | sed -n '/^\.\//s///p' | sort | \
  49. cpio -R 0:0 --quiet -oC512 -Mdist -Hnewc | gzip -n9 >$@
  50. ${BIN_DIR}/${ROOTFSSQUASHFS}: ${TARGET_DIR}
  51. PATH='${TARGET_PATH}' \
  52. mksquashfs ${TARGET_DIR} ${BUILD_DIR}/root.squashfs \
  53. -nopad -noappend -root-owned $(MAKE_TRACE)
  54. cat ${BIN_DIR}/${DEVICE}-${ARCH}-kernel ${BUILD_DIR}/root.squashfs > \
  55. ${BUILD_DIR}/${ROOTFSSQUASHFS}
  56. # padding of images is required
  57. dd if=${BUILD_DIR}/${ROOTFSSQUASHFS} of=${BIN_DIR}/${ROOTFSSQUASHFS} \
  58. bs=4063232 conv=sync $(MAKE_TRACE)
  59. imageclean:
  60. rm -f $(BIN_DIR)/$(DEVICE)-*