image.mk 2.5 KB

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