Makefile 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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. include $(TOPDIR)/rules.mk
  4. include $(TOPDIR)/mk/rootfs.mk
  5. PKG_NAME:= base-files
  6. PKG_VERSION:= 1.0
  7. PKG_RELEASE:= 90
  8. PKG_SECTION:= base
  9. PKG_DESCR:= basic files and scripts
  10. WRKDIST= ${WRKDIR}/base-files
  11. NO_DISTFILES:= 1
  12. include $(TOPDIR)/mk/package.mk
  13. $(eval $(call PKG_template,BASE_FILES,${PKG_NAME},${PKG_VERSION}-${PKG_RELEASE},${PKG_DEPENDS},${PKG_DESCR},${PKG_SECTION},force_etc))
  14. CONFIG_STYLE:= manual
  15. BUILD_STYLE:= manual
  16. INSTALL_STYLE:= manual
  17. do-install:
  18. $(CP) ./src/* $(IDIR_BASE_FILES)
  19. ifeq (${ADK_TARGET_ROOTFS_NFSROOT},y)
  20. @echo "#" > $(IDIR_BASE_FILES)/etc/network/interfaces
  21. endif
  22. ifeq (${ADK_TARGET_PACKAGE_IPKG},y)
  23. $(SED) 's,@ARCH@,$(ADK_TARGET_CPU_ARCH),g' $(IDIR_BASE_FILES)/etc/ipkg.conf
  24. $(SED) 's,@SYSTEM@,$(ADK_TARGET_SYSTEM),g' $(IDIR_BASE_FILES)/etc/ipkg.conf
  25. $(SED) 's,@LIBC@,$(ADK_TARGET_LIBC),g' $(IDIR_BASE_FILES)/etc/ipkg.conf
  26. ifneq ($(ADK_TARGET_ABI),)
  27. $(SED) 's,@ABI@,_$(ADK_TARGET_ABI),g' $(IDIR_BASE_FILES)/etc/ipkg.conf
  28. else
  29. $(SED) 's,@ABI@,,g' $(IDIR_BASE_FILES)/etc/ipkg.conf
  30. endif
  31. $(SED) 's,@HOST@,$(ADK_HOST),g' $(IDIR_BASE_FILES)/etc/ipkg.conf
  32. $(SED) 's,@VENDOR@,$(ADK_VENDOR),g' $(IDIR_BASE_FILES)/etc/ipkg.conf
  33. mkdir -p $(IDIR_BASE_FILES)/usr/lib/ipkg/lists
  34. endif
  35. echo /bin/sh >${IDIR_BASE_FILES}/etc/shells
  36. echo /bin/mksh >>${IDIR_BASE_FILES}/etc/shells
  37. ifneq (${ADK_PACKAGE_ASH},)
  38. echo /bin/ash >>${IDIR_BASE_FILES}/etc/shells
  39. endif
  40. ifneq (${ADK_PACKAGE_BASH},)
  41. echo /bin/bash >>${IDIR_BASE_FILES}/etc/shells
  42. endif
  43. ifneq (${ADK_PACKAGE_ZSH},)
  44. echo /bin/zsh >>${IDIR_BASE_FILES}/etc/shells
  45. endif
  46. mkdir -p $(IDIR_BASE_FILES)/etc/crontabs
  47. mkdir -p $(IDIR_BASE_FILES)/{dev,boot,root,sys,proc,tmp,mnt,media}
  48. mkdir -p $(IDIR_BASE_FILES)/etc/network/{if-pre-up.d,if-up.d,if-down.d,if-post-down.d}
  49. mkdir -p $(IDIR_BASE_FILES)/usr/{lib,bin}
  50. chmod 600 $(IDIR_BASE_FILES)/etc/shadow
  51. chmod 600 $(IDIR_BASE_FILES)/etc/network/interfaces
  52. (cd $(IDIR_BASE_FILES)/etc; ln -sf ../tmp/resolv.conf .)
  53. chmod 1777 ${IDIR_BASE_FILES}/tmp
  54. ln -sf ../proc/mounts $(IDIR_BASE_FILES)/etc/mtab
  55. rm -rf $(IDIR_BASE_FILES)/var
  56. ln -sf tmp $(IDIR_BASE_FILES)/var
  57. test -z $(ADK_RUNTIME_SHELL) || \
  58. cat ./files/inittab.shell >> $(IDIR_BASE_FILES)/etc/inittab
  59. ifeq ($(ADK_TARGET_WITH_VGA),y)
  60. test -z $(ADK_RUNTIME_SHELL) || \
  61. cat ./files/inittab.shellvga >> $(IDIR_BASE_FILES)/etc/inittab
  62. endif
  63. test -z $(ADK_RUNTIME_GETTY_VGA) || \
  64. cat ./files/inittab.vga >> $(IDIR_BASE_FILES)/etc/inittab
  65. test -z $(ADK_RUNTIME_GETTY_SERIAL) || \
  66. cat ./files/inittab.serial >> $(IDIR_BASE_FILES)/etc/inittab
  67. $(SED) 's#@DEVICE@#$(ADK_RUNTIME_CONSOLE_SERIAL_DEVICE)#g' $(IDIR_BASE_FILES)/etc/inittab
  68. $(SED) 's#@SPEED@#$(ADK_RUNTIME_CONSOLE_SERIAL_SPEED)#' $(IDIR_BASE_FILES)/etc/inittab
  69. test -z $(ADK_RUNTIME_HOSTNAME) || \
  70. echo $(ADK_RUNTIME_HOSTNAME) > $(IDIR_BASE_FILES)/etc/hostname; \
  71. echo "127.0.0.1 localhost" > $(IDIR_BASE_FILES)/etc/hosts
  72. echo "::1 localhost" >> $(IDIR_BASE_FILES)/etc/hosts
  73. echo "127.0.1.1 $(ADK_RUNTIME_HOSTNAME)" >> $(IDIR_BASE_FILES)/etc/hosts
  74. test -z $(ADK_RUNTIME_PASSWORD) || \
  75. $(SED) 's,\*NP\*,'"$$($(STAGING_HOST_DIR)/usr/bin/mkcrypt \
  76. ${ADK_RUNTIME_PASSWORD}),g" $(IDIR_BASE_FILES)/etc/shadow
  77. test -z $(GIT) || \
  78. $(GIT) log -1|head -1|sed -e 's#commit ##' \
  79. > $(IDIR_BASE_FILES)/etc/adkversion
  80. test -z $(ADK_TARGET_SYSTEM) || \
  81. echo $(ADK_TARGET_SYSTEM) > $(IDIR_BASE_FILES)/etc/adktarget
  82. echo $(ADK_RUNTIME_TMPFS_SIZE) > $(IDIR_BASE_FILES)/etc/tmpfs
  83. ifneq (${ADK_PACKAGE_CONFIG_IN_ETC},)
  84. gzip -9c ${TOPDIR}/.config >$(IDIR_BASE_FILES)/etc/adkconfig.gz
  85. chmod 600 $(IDIR_BASE_FILES)/etc/adkconfig.gz
  86. endif
  87. ifeq ($(ADK_TARGET_WITH_ROOT_RW),y)
  88. echo 'export IPKGTMPDIR=/root/.ipkg' >> $(IDIR_BASE_FILES)/etc/profile
  89. else
  90. echo 'export IPKGTMPDIR=/tmp' >> $(IDIR_BASE_FILES)/etc/profile
  91. endif
  92. ifeq ($(ADK_TARGET_SYSTEM_RASPBERRY_PI),y)
  93. echo 'export LD_LIBRARY_PATH=/opt/vc/lib' >> $(IDIR_BASE_FILES)/etc/profile
  94. endif
  95. # simple network configuration
  96. ifneq (${ADK_SIMPLE_NETWORK_CONFIG},)
  97. ${INSTALL_DIR} ${IDIR_BASE_FILES}/etc/network
  98. # network config local
  99. echo -e "auto lo\niface lo inet loopback" > ${IDIR_BASE_FILES}/etc/network/interfaces
  100. # network config eth0
  101. # configure nic with dhcp
  102. ifeq (${SIMPLE_NETWORK_CONFIG_ETH0_TYPE_NIC},y)
  103. echo -e "\nauto eth0\niface eth0 inet dhcp" >> ${IDIR_BASE_FILES}/etc/network/interfaces
  104. endif
  105. # configure nic with manual ip
  106. ifeq (${SIMPLE_NETWORK_CONFIG_ETH0_TYPE_NIC_MANUAL},y)
  107. echo -e "\nauto eth0\niface eth0 inet static" >> ${IDIR_BASE_FILES}/etc/network/interfaces
  108. echo -e " address ${SIMPLE_NETWORK_CONFIG_ETH0_IP}" >> ${IDIR_BASE_FILES}/etc/network/interfaces
  109. echo -e " netmask ${SIMPLE_NETWORK_CONFIG_ETH0_NM}" >> ${IDIR_BASE_FILES}/etc/network/interfaces
  110. echo -e " broadcast ${SIMPLE_NETWORK_CONFIG_ETH0_BC}" >> ${IDIR_BASE_FILES}/etc/network/interfaces
  111. echo -e " gateway ${SIMPLE_NETWORK_CONFIG_ETH0_GW}" >> ${IDIR_BASE_FILES}/etc/network/interfaces
  112. endif
  113. # configure bridge
  114. ifeq (${SIMPLE_NETWORK_CONFIG_ETH0_TYPE_BRIDGE},y)
  115. echo -e "\nauto br0\niface br0 inet manual" >> ${IDIR_BASE_FILES}/etc/network/interfaces
  116. echo -e " bridge-ports ${SIMPLE_NETWORK_CONFIG_ETH0_BRIDGE}" >> ${IDIR_BASE_FILES}/etc/network/interfaces
  117. endif
  118. #configure bridge with ip
  119. ifeq (${SIMPLE_NETWORK_CONFIG_ETH0_TYPE_BRIDGE_IP},y)
  120. echo -e "\nauto br0\niface br0 inet static" >> ${IDIR_BASE_FILES}/etc/network/interfaces
  121. echo -e " address ${SIMPLE_NETWORK_CONFIG_ETH0_IP}" >> ${IDIR_BASE_FILES}/etc/network/interfaces
  122. echo -e " netmask ${SIMPLE_NETWORK_CONFIG_ETH0_NM}" >> ${IDIR_BASE_FILES}/etc/network/interfaces
  123. echo -e " broadcast ${SIMPLE_NETWORK_CONFIG_ETH0_BC}" >> ${IDIR_BASE_FILES}/etc/network/interfaces
  124. echo -e " bridge-ports ${SIMPLE_NETWORK_CONFIG_ETH0_BRIDGE}" >> ${IDIR_BASE_FILES}/etc/network/interfaces
  125. endif
  126. # network config wlan0
  127. ifeq (${SIMPLE_NETWORK_CONFIG_WLAN0_TYPE_NIC},y)
  128. echo -e "\nauto wlan0\niface wlan0 inet dhcp" >> ${IDIR_BASE_FILES}/etc/network/interfaces
  129. endif
  130. # network config eth1
  131. # configure nic with dhcp
  132. ifeq (${SIMPLE_NETWORK_CONFIG_ETH1_TYPE_NIC},y)
  133. echo -e "\nauto eth1\niface eth1 inet dhcp" >> ${IDIR_BASE_FILES}/etc/network/interfaces
  134. endif
  135. # configure nic with manual ip
  136. ifeq (${SIMPLE_NETWORK_CONFIG_ETH1_TYPE_NIC_MANUAL},y)
  137. echo -e "\nauto eth1\niface eth1 inet static" >> ${IDIR_BASE_FILES}/etc/network/interfaces
  138. echo -e " address ${SIMPLE_NETWORK_CONFIG_ETH1_IP}" >> ${IDIR_BASE_FILES}/etc/network/interfaces
  139. echo -e " netmask ${SIMPLE_NETWORK_CONFIG_ETH1_NM}" >> ${IDIR_BASE_FILES}/etc/network/interfaces
  140. echo -e " broadcast ${SIMPLE_NETWORK_CONFIG_ETH1_BC}" >> ${IDIR_BASE_FILES}/etc/network/interfaces
  141. echo -e " gateway ${SIMPLE_NETWORK_CONFIG_ETH1_GW}" >> ${IDIR_BASE_FILES}/etc/network/interfaces
  142. endif
  143. # configure bridge
  144. ifeq (${SIMPLE_NETWORK_CONFIG_ETH1_TYPE_BRIDGE},y)
  145. echo -e "\nauto br0\niface br1 inet manual" >> ${IDIR_BASE_FILES}/etc/network/interfaces
  146. echo -e " bridge-ports ${SIMPLE_NETWORK_CONFIG_ETH1_BRIDGE}" >> ${IDIR_BASE_FILES}/etc/network/interfaces
  147. endif
  148. #configure bridge with ip
  149. ifeq (${SIMPLE_NETWORK_CONFIG_ETH1_TYPE_BRIDGE_IP},y)
  150. echo -e "\nauto br0\niface br1 inet static" >> ${IDIR_BASE_FILES}/etc/network/interfaces
  151. echo -e " address ${SIMPLE_NETWORK_CONFIG_ETH1_IP}" >> ${IDIR_BASE_FILES}/etc/network/interfaces
  152. echo -e " netmask ${SIMPLE_NETWORK_CONFIG_ETH1_NM}" >> ${IDIR_BASE_FILES}/etc/network/interfaces
  153. echo -e " broadcast ${SIMPLE_NETWORK_CONFIG_ETH1_BC}" >> ${IDIR_BASE_FILES}/etc/network/interfaces
  154. echo -e " bridge-ports ${SIMPLE_NETWORK_CONFIG_ETH1_BRIDGE}" >> ${IDIR_BASE_FILES}/etc/network/interfaces
  155. endif
  156. # newline at the end of interfaces file
  157. echo -en "\n" >> ${IDIR_BASE_FILES}/etc/network/interfaces
  158. # resolver config
  159. rm ${IDIR_BASE_FILES}/etc/resolv.conf
  160. echo -e "nameserver ${SIMPLE_NETWORK_CONFIG_RESOLV}" > ${IDIR_BASE_FILES}/etc/resolv.conf
  161. endif
  162. include ${TOPDIR}/mk/pkg-bottom.mk