image.mk 2.0 KB

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