image.mk 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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}-${ADK_LIBC}-${FS}
  48. ROOTFSSQUASHFS= ${ADK_TARGET}-${ADK_LIBC}-${FS}.img
  49. ROOTFSTARBALL= ${ADK_TARGET}-${ADK_LIBC}-${FS}.tar.gz
  50. INITRAMFS_PIGGYBACK= ${ADK_TARGET}-${ADK_LIBC}-${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 -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 -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}-${FS}-kernel \
  64. ${BUILD_DIR}/root.squashfs > \
  65. ${BUILD_DIR}/${ROOTFSSQUASHFS}
  66. imageclean:
  67. rm -f $(BIN_DIR)/$(ADK_TARGET)-* ${BUILD_DIR}/$(ADK_TARGET)-*