image.mk 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. # padding of images is required
  55. cat ${BIN_DIR}/${DEVICE}-${ARCH}-kernel ${BUILD_DIR}/root.squashfs > \
  56. ${BUILD_DIR}/${ROOTFSSQUASHFS}
  57. imageclean:
  58. rm -f $(BIN_DIR)/$(DEVICE)-*