image.mk 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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}.tar.gz
  54. INITRAMFS_PIGGYBACK= ${ADK_TARGET}-${ADK_LIBC}-${FS}.cpio
  55. ${BIN_DIR}/${ROOTFSTARBALL}: ${TARGET_DIR}
  56. cd ${TARGET_DIR}; tar -cf - --owner=0 --group=0 . | gzip -n9 >$@
  57. ${BIN_DIR}/${INITRAMFS}: ${TARGET_DIR}
  58. cd ${TARGET_DIR}; find . | sed -n '/^\.\//s///p' | sort | \
  59. cpio -R 0:0 -oC512 -Mdist -Hnewc | ${ADK_COMPRESSION_TOOL} >$@
  60. ${BUILD_DIR}/${INITRAMFS_PIGGYBACK}: ${TARGET_DIR}
  61. cd ${TARGET_DIR}; find . | sed -n '/^\.\//s///p' | sort | \
  62. cpio -R 0:0 -oC512 -Mdist -Hnewc >$@
  63. ${BIN_DIR}/${ROOTFSSQUASHFS}: ${TARGET_DIR}
  64. PATH='${TARGET_PATH}' \
  65. mksquashfs ${TARGET_DIR} ${BUILD_DIR}/root.squashfs \
  66. -nopad -noappend -root-owned $(MAKE_TRACE)
  67. cat ${BIN_DIR}/${ADK_TARGET}-${FS}-kernel \
  68. ${BUILD_DIR}/root.squashfs > \
  69. ${BUILD_DIR}/${ROOTFSSQUASHFS}
  70. imageclean:
  71. rm -f $(BIN_DIR)/$(ADK_TARGET)-* ${BUILD_DIR}/$(ADK_TARGET)-*