maui-contents.bbclass 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. #
  2. # Copyright (C) 2011 Colin Walters <walters@verbum.org>
  3. # Copyright (C) 2012 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
  4. #
  5. LICENSE = "MIT"
  6. LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=3f40d7994397109285ec7b81fdeb3b58 \
  7. file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
  8. inherit rootfs_${IMAGE_PKGTYPE}
  9. do_rootfs[depends] += "linux-maui:do_deploy"
  10. PACKAGE_INSTALL += " \
  11. task-maui-contents-runtime \
  12. ldd \
  13. libltdl7 \
  14. libicule51 \
  15. "
  16. DEPENDS += "task-maui-contents-runtime makedevs-native \
  17. virtual/fakeroot-native \
  18. "
  19. EXCLUDE_FROM_WORLD = "1"
  20. do_rootfs[nostamp] = "1"
  21. do_rootfs[dirs] = "${TOPDIR}"
  22. do_rootfs[lockfiles] += "${IMAGE_ROOTFS}.lock"
  23. do_build[nostamp] = "1"
  24. do_rootfs[umask] = "022"
  25. def maui_get_devtable_list(d):
  26. return bb.which(d.getVar('BBPATH', 1), 'files/device_table-minimal.txt')
  27. # Must call real_do_rootfs() from inside here, rather than as a separate
  28. # task, so that we have a single fakeroot context for the whole process.
  29. fakeroot do_rootfs () {
  30. set -x
  31. rm -rf ${IMAGE_ROOTFS}
  32. rm -rf ${MULTILIB_TEMP_ROOTFS}
  33. mkdir -p ${IMAGE_ROOTFS}
  34. mkdir -p ${DEPLOY_DIR_IMAGE}
  35. rootfs_${IMAGE_PKGTYPE}_do_rootfs
  36. set -x
  37. # Delete all rpm files and directories
  38. rm -rf ${IMAGE_ROOTFS}/etc/rpm{,-postinsts}
  39. # Delete all of the legacy sysvinit scripts; we use systemd
  40. rm -rf ${IMAGE_ROOTFS}/etc/init.d
  41. rm -rf ${IMAGE_ROOTFS}/etc/rc*.d
  42. # Empty out the default passwd file
  43. rm -f ${IMAGE_ROOTFS}/etc/passwd ${IMAGE_ROOTFS}/etc/group \
  44. ${IMAGE_ROOTFS}/etc/shadow ${IMAGE_ROOTFS}/etc/gshadow
  45. # root has no password by default
  46. cat > ${IMAGE_ROOTFS}/etc/passwd << EOF
  47. root::0:0:root:/root:/bin/sh
  48. EOF
  49. cat > ${IMAGE_ROOTFS}/etc/group << EOF
  50. root:x:0:root
  51. EOF
  52. touch ${IMAGE_ROOTFS}/etc/shadow ${IMAGE_ROOTFS}/etc/gshadow
  53. chmod 0600 ${IMAGE_ROOTFS}/etc/shadow ${IMAGE_ROOTFS}/etc/gshadow
  54. # Delete backup files
  55. rm -f ${IMAGE_ROOTFS}/etc/passwd- ${IMAGE_ROOTFS}/etc/group- \
  56. ${IMAGE_ROOTFS}/etc/shadow- ${IMAGE_ROOTFS}/etc/gshadow-
  57. # Add "altfiles" NSS module to /etc/nsswitch.conf
  58. sed -i -e '/^passwd:/cpasswd: files altfiles' \
  59. -e '/^group:/cgroup: files altfiles' \
  60. ${IMAGE_ROOTFS}/etc/nsswitch.conf
  61. # Intersection of defaults between RHEL and Debian
  62. cat > ${IMAGE_ROOTFS}/etc/hosts <<EOF
  63. 127.0.0.1 localhost
  64. ::1 localhost6 ip6-localhost
  65. EOF
  66. # Remove su because we only support pkexec
  67. cat > ${IMAGE_ROOTFS}/bin/su <<EOF
  68. #!/bin/sh
  69. exec pkexec /usr/bin/bash
  70. EOF
  71. chmod u=rwx,g=rx,o=rx ${IMAGE_ROOTFS}/bin/su
  72. # Adjustments for /etc -> {/var,/run} here
  73. ln -sf /run/resolv.conf ${IMAGE_ROOTFS}/etc/resolv.conf
  74. # Fix un-world-readable config file; no idea why this isn't.
  75. chmod a+r ${IMAGE_ROOTFS}/etc/securetty
  76. # Clear out the default fstab; everything we need right now is mounted
  77. # in the initramfs.
  78. cat < /dev/null > ${IMAGE_ROOTFS}/etc/fstab
  79. # Install defaults
  80. rm -f ${IMAGE_ROOTFS}/etc/localtime
  81. ln -s ../usr/share/zoneinfo/Europe/London ${IMAGE_ROOTFS}/etc/localtime
  82. echo LANG=\"en_US.UTF-8\" > ${IMAGE_ROOTFS}/etc/locale.conf
  83. # Do UsrMove for bin and sbin
  84. cd ${IMAGE_ROOTFS}/bin
  85. for x in *; do
  86. if test -L ${x} && test -x ../usr/bin/${x}; then
  87. rm ${x}
  88. else
  89. mv ${x} ../usr/bin/${x}
  90. fi
  91. done
  92. cd -
  93. if test -d ${IMAGE_ROOTFS}/bin/.debug; then
  94. mkdir -p ${IMAGE_ROOTFS}/usr/bin/.debug
  95. mv ${IMAGE_ROOTFS}/bin/.debug/* ${IMAGE_ROOTFS}/usr/bin/.debug
  96. rmdir ${IMAGE_ROOTFS}/bin/.debug
  97. fi
  98. rmdir ${IMAGE_ROOTFS}/bin
  99. ln -s usr/bin ${IMAGE_ROOTFS}/bin
  100. mv ${IMAGE_ROOTFS}/sbin/* ${IMAGE_ROOTFS}/usr/sbin
  101. if test -d ${IMAGE_ROOTFS}/sbin/.debug; then
  102. mkdir -p ${IMAGE_ROOTFS}/usr/sbin/.debug
  103. mv ${IMAGE_ROOTFS}/sbin/.debug/* ${IMAGE_ROOTFS}/usr/sbin/.debug
  104. rmdir ${IMAGE_ROOTFS}/sbin/.debug
  105. fi
  106. rmdir ${IMAGE_ROOTFS}/sbin
  107. ln -s usr/sbin ${IMAGE_ROOTFS}/sbin
  108. # Now, we need to fix up any symbolic links that were
  109. # trying to do ../usr/
  110. for d in ${IMAGE_ROOTFS}/usr/bin ${IMAGE_ROOTFS}/usr/sbin; do
  111. find $d -maxdepth 1 -type l | while read f; do
  112. target=$(readlink $f)
  113. fixed_target=$(echo $target | sed -e 's,^[.][.]/usr,,')
  114. ln -sf $fixed_target $f
  115. done
  116. done
  117. # Undo libattr/libacl weirdness
  118. rm -f ${IMAGE_ROOTFS}/lib/lib{acl,attr}.a
  119. rm -f ${IMAGE_ROOTFS}/usr/lib/lib{acl,attr}.so
  120. # Complete UsrMove for lib
  121. mv ${IMAGE_ROOTFS}/lib/* ${IMAGE_ROOTFS}/usr/lib
  122. if test -d ${IMAGE_ROOTFS}/lib/.debug; then
  123. mkdir -p ${IMAGE_ROOTFS}/usr/lib/.debug
  124. mv ${IMAGE_ROOTFS}/lib/.debug/* ${IMAGE_ROOTFS}/usr/lib/.debug
  125. rmdir ${IMAGE_ROOTFS}/lib/.debug
  126. fi
  127. rmdir ${IMAGE_ROOTFS}/lib
  128. ln -s usr/lib ${IMAGE_ROOTFS}/lib
  129. # And now merge /usr/sbin into /usr/bin
  130. if test -d ${IMAGE_ROOTFS}/usr/sbin/.debug; then
  131. mkdir -p ${IMAGE_ROOTFS}/usr/bin/.debug
  132. mv ${IMAGE_ROOTFS}/usr/sbin/.debug/* ${IMAGE_ROOTFS}/usr/bin/.debug
  133. rmdir ${IMAGE_ROOTFS}/usr/sbin/.debug
  134. fi
  135. cd ${IMAGE_ROOTFS}/usr/sbin
  136. for x in *; do
  137. if test -L ${x} && test -x ../bin/${x}; then
  138. rm ${x}
  139. else
  140. mv ${x} ../bin
  141. fi
  142. done
  143. cd -
  144. rmdir ${IMAGE_ROOTFS}/usr/sbin
  145. ln -s bin ${IMAGE_ROOTFS}/usr/sbin
  146. # Remove all .la files
  147. find ${IMAGE_ROOTFS}/usr/lib -name \*.la -delete
  148. # And ensure systemd is /sbin/init
  149. ln -s ../lib/systemd/systemd ${IMAGE_ROOTFS}/usr/bin/init
  150. ln -s systemctl ${IMAGE_ROOTFS}/usr/bin/halt
  151. ln -s systemctl ${IMAGE_ROOTFS}/usr/bin/poweroff
  152. ln -s systemctl ${IMAGE_ROOTFS}/usr/bin/reboot
  153. ln -s systemctl ${IMAGE_ROOTFS}/usr/bin/runlevel
  154. ln -s systemctl ${IMAGE_ROOTFS}/usr/bin/shutdown
  155. ln -s systemctl ${IMAGE_ROOTFS}/usr/bin/telinit
  156. # Rename kernel files replacing bzImage- with vmlinuz-
  157. for kernel in $(find ${IMAGE_ROOTFS}/boot -type f -name "bzImage-*"); do
  158. newname=$(echo ${kernel} | sed -e 's,bzImage-,vmlinuz-,g')
  159. mv "${kernel}" "${newname}"
  160. done
  161. rm -rf ${WORKDIR}/contents
  162. mkdir ${WORKDIR}/contents
  163. cd ${WORKDIR}/contents
  164. # The default toplevel directories used as mount targets
  165. for d in dev proc run sys var; do
  166. mkdir $d
  167. done
  168. # Special ostree mount
  169. mkdir sysroot
  170. # Some FHS targets; these all live in /var hence are preserved
  171. # across upgrade
  172. ln -s var/opt opt
  173. ln -s var/srv srv
  174. ln -s var/mnt mnt
  175. ln -s var/roothome root
  176. # This one is dynamic, so just lives in /run
  177. ln -s run/media media
  178. # Special OSTree link, so it's /ostree both on
  179. # the real disk and inside the chroot
  180. ln -s sysroot/ostree ostree
  181. # /tmp is always /sysroot/tmp
  182. ln -s sysroot/tmp tmp
  183. # By default, /home -> var/home -> ../sysroot/home
  184. ln -s var/home home
  185. # These are the only directories we take from the OE build
  186. mv ${IMAGE_ROOTFS}/usr .
  187. mv ${IMAGE_ROOTFS}/etc .
  188. mv ${IMAGE_ROOTFS}/boot .
  189. # Except /usr/local -> ../var/usrlocal
  190. rm -rf usr/local
  191. ln -s ../var/usrlocal usr/local
  192. # Also move the toplevel compat links
  193. mv ${IMAGE_ROOTFS}/lib .
  194. mv ${IMAGE_ROOTFS}/bin .
  195. mv ${IMAGE_ROOTFS}/sbin .
  196. # Ok, let's globally fix permissions in the OE content;
  197. # everything is root owned, all directories are u=rwx,g=rx,og=rx.
  198. chown -R -h 0:0 usr etc boot
  199. for x in usr etc boot; do
  200. find $x -type d -exec chmod u=rwx,g=rx,og=rx "{}" \;
  201. done
  202. rm -rf ${IMAGE_ROOTFS}
  203. mv ${WORKDIR}/contents ${IMAGE_ROOTFS}
  204. IMAGE_NAME_NODATE=${IMAGE_BASENAME}-${MACHINE}.tar.gz
  205. DEST=${WORKDIR}/${IMAGE_NAME_NODATE}
  206. (cd ${IMAGE_ROOTFS} && tar -zcv -f ${DEST} .)
  207. mv ${DEST} ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME_NODATE}
  208. }
  209. log_check() {
  210. true
  211. }
  212. do_fetch[noexec] = "1"
  213. do_unpack[noexec] = "1"
  214. do_patch[noexec] = "1"
  215. do_configure[noexec] = "1"
  216. do_compile[noexec] = "1"
  217. do_install[noexec] = "1"
  218. do_populate_sysroot[noexec] = "1"
  219. do_package[noexec] = "1"
  220. do_package_write_ipk[noexec] = "1"
  221. do_package_write_deb[noexec] = "1"
  222. do_package_write_rpm[noexec] = "1"
  223. addtask rootfs before do_build
  224. # stub out for now
  225. rootfs_install_all_locales () {
  226. true
  227. }
  228. rootfs_install_complementary () {
  229. true
  230. }