image.mk 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. @cd ${TARGET_DIR}; ls=; ln=; li=; x=1; md5sum $$(find . -type f) | \
  14. sed -e "s/*//" | \
  15. while read sum name; do \
  16. inode=$$(ls -i "$$name"); \
  17. echo "$$sum $${inode%% *} $$name"; \
  18. done | sort | while read sum inode name; do \
  19. if [[ $$sum = $$ls ]]; then \
  20. [[ $$li = $$inode ]] && continue; \
  21. case $$x in \
  22. 1) echo 'WARNING: duplicate files found' \
  23. 'in filesystem! Please fix them.' >&2; \
  24. echo -n "> $$ln "; \
  25. ;; \
  26. 2) echo -n "> $$ln "; \
  27. ;; \
  28. 3) echo -n ' '; \
  29. ;; \
  30. esac; \
  31. echo -n "$$name"; \
  32. x=3; \
  33. else \
  34. case $$x in \
  35. 3) echo; \
  36. x=2; \
  37. ;; \
  38. esac; \
  39. fi; \
  40. ls=$$sum; \
  41. ln=$$name; \
  42. li=$$inode; \
  43. done
  44. chmod 4511 ${TARGET_DIR}/bin/busybox
  45. chmod 1777 ${TARGET_DIR}/tmp
  46. @if [ -d ${TARGET_DIR}/usr/share/fonts/X11 ];then \
  47. for i in $$(ls ${TARGET_DIR}/usr/share/fonts/X11/);do \
  48. mkfontdir ${TARGET_DIR}/usr/share/fonts/X11/$${i}; \
  49. done; \
  50. fi
  51. INITRAMFS= ${ADK_TARGET}-${ADK_LIBC}-${FS}
  52. ROOTFSSQUASHFS= ${ADK_TARGET}-${ADK_LIBC}-${FS}.img
  53. ROOTFSTARBALL= ${ADK_TARGET}-${ADK_LIBC}-${FS}+kernel.tar.gz
  54. ROOTFSUSERTARBALL= ${ADK_TARGET}-${ADK_LIBC}-${FS}.tar.gz
  55. INITRAMFS_PIGGYBACK= ${ADK_TARGET}-${ADK_LIBC}-${FS}.cpio
  56. ${BIN_DIR}/${ROOTFSTARBALL}: ${TARGET_DIR}
  57. cd ${TARGET_DIR}; tar -cf - --owner=0 --group=0 . | gzip -n9 >$@
  58. ${BIN_DIR}/${ROOTFSUSERTARBALL}: ${TARGET_DIR}
  59. cd ${TARGET_DIR}; tar --exclude ./boot -cf - --owner=0 --group=0 . \
  60. | gzip -n9 >$@
  61. ${BIN_DIR}/${INITRAMFS}: ${TARGET_DIR}
  62. cd ${TARGET_DIR}; find . | sed -n '/^\.\//s///p' | sort | \
  63. cpio -R 0:0 -oC512 -Mdist -Hnewc | ${ADK_COMPRESSION_TOOL} >$@
  64. ${BUILD_DIR}/${INITRAMFS_PIGGYBACK}: ${TARGET_DIR}
  65. cd ${TARGET_DIR}; find . | sed -n '/^\.\//s///p' | sort | \
  66. cpio -R 0:0 -oC512 -Mdist -Hnewc >$@
  67. ${BIN_DIR}/${ROOTFSSQUASHFS}: ${TARGET_DIR}
  68. PATH='${TARGET_PATH}' \
  69. mksquashfs ${TARGET_DIR} ${BUILD_DIR}/root.squashfs \
  70. -nopad -noappend -root-owned $(MAKE_TRACE)
  71. cat ${BIN_DIR}/${ADK_TARGET}-${FS}-kernel \
  72. ${BUILD_DIR}/root.squashfs > \
  73. ${BUILD_DIR}/${ROOTFSSQUASHFS}
  74. imageclean:
  75. rm -f $(BIN_DIR)/$(ADK_TARGET)-* ${BUILD_DIR}/$(ADK_TARGET)-*