palvarez89

Untitled

Jun 30th, 2014
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.16 KB | None | 0 0
  1. [[!meta title="How To: Cross-bootstrap"]]
  2.  
  3. Cross-bootstrap
  4. ===============
  5.  
  6. These are the steps to cross-bootstrap baserock from one architecture
  7. to another.
  8.  
  9. 1. Select a target architecture to do the cross-bootstrap
  10. ---------------------------------------------------------
  11.  
  12. We only have morphologies to do cross-bootstrapping for `x86_64`,
  13. `ppc64` and `armv7lhf`, so if your target architecture is one of them
  14. you only have to pick one of the morphologies.
  15.  
  16. On the other hand, if your intention is to do a cross-bootstrap
  17. to another architecture you have to create a new morphology as follows:
  18.  
  19. * Create a `cross-bootstrap-system-TARGET_ARCH-generic.morph` file
  20. (where TARGET_ARCH is the target architecture) and edit it so that
  21. it contains the following:
  22.  
  23. arch: TARGET_ARCH
  24. description: A system that produces the minimum needed to build a devel system
  25. kind: system
  26. name: cross-bootstrap-system-TARGET_ARCH-generic
  27. strata:
  28. - morph: build-essential
  29. ref: master
  30. repo: baserock:baserock/morphs
  31. - morph: core
  32. ref: master
  33. repo: baserock:baserock/morphs
  34. - morph: cross-bootstrap
  35. ref: master
  36. repo: baserock:baserock/morphs
  37.  
  38. * You must **replace** TARGET_ARCH for the target architecture in the
  39. morphology. The morphology has to be commited and pushed in a git
  40. repository. For this example we assume the morphology is in
  41. `baserock:baserock/morphs` repository and in the `master` branch of it.
  42.  
  43. 2. Generate a bootstrap baserock tarball
  44. ----------------------------------------
  45.  
  46. Now is time to Cross-build baserock. We cross-build the
  47. `cross-bootstrap-system-TARGET_ARCH-generic` using the
  48. `cross-bootstrap` command in `morph`. With this command morph generates
  49. a tarball of the system with a script to do finish the building in the
  50. target architecture:
  51.  
  52. * Execute `morph cross-bootstrap` for the morphology file created:
  53.  
  54. morph cross-bootstrap TARGET_ARCH baserock:baserock/morphs master cross-bootstrap-system-TARGET_ARCH-generic
  55.  
  56. * Once `morph` finishes building, it will tell you where the tarball
  57. is.
  58.  
  59. 3. Native building of the cross-bootstrap process
  60. -------------------------------------------------
  61.  
  62. This is the second part of the cross-build process and it has to be
  63. done in the target architecture.
  64.  
  65. * First of all you have to use the system created. To do that you
  66. have two options:
  67.  
  68. 1. If you have linux running in the target architecture you can
  69. copy the tarball there, uncompress it and then chroot into it
  70. with:
  71.  
  72. chroot /path/to/uncompressed/tarball /bin/sh
  73.  
  74. 1. If you do not have a compatible Linux-based OS for the target
  75. architecture you can boot the cross-bult system directly (e.g.
  76. using NFS boot). You will need to build a kernel yourself if
  77. you take this approach.
  78.  
  79. * Once you are into the filesystem created, you have to execute the
  80. `native-bootstrap` script (located in '/'). This script ends
  81. building everything.
  82.  
  83.  
  84. 4. Using the bootstrap system
  85. -----------------------------
  86.  
  87. With the bootstrap system now we can use `morph` to build systems.
  88. Normally you will want to build a devel-system to start using it
  89. instead of the bootstrap system.
  90.  
  91. * First of all you have to use the system created. To do that you
  92. have two options:
  93.  
  94. 1. If you have linux running in the target architecture you can
  95. copy the tarball there, uncompress it and then chroot into it
  96. with:
  97.  
  98. chroot /path/to/uncompressed/tarball /bin/sh
  99.  
  100. 1. If you prefer, you also can boot the system (e.g. with NFS
  101. boot). The problem to do this is that the system doesn't have
  102. Kernel.
  103.  
  104. ### 4a. Extra steps with chroot
  105.  
  106. * Morph uses `linux-user-chroot` when building, and this does not
  107. work inside a chroot. There are two options for fixing this:
  108.  
  109. 1. Create a bind mount to hide the chroot:
  110. `cd /path/to/uncompressed/tarball && mount --bind . .`
  111. 1. Move the bootstrap filesystem to the top level of another disk.
  112. We haven't investigated why it works.
  113.  
  114. To test that this works you should be able to run the following
  115. **into the chroot environment**.
  116.  
  117. linux-user-chroot / /bin/sh
  118.  
  119. * Now you have to mount some special filesystems inside the chroot:
  120.  
  121. cd /path/to/uncompressed/tarball
  122. mount -t proc proc proc/
  123. mount -t sysfs sys sys/
  124. mount -o bind /dev dev/
  125. mount -o bind /tmp tmp/
  126.  
  127. * And then, you are ready to chroot into it:
  128.  
  129. chroot . /bin/sh
  130. PATH=/bin:/usr/bin:/sbin:/usr/sbin
  131. LD_LIBRARY_PATH=/lib:/lib64
  132. ldconfig
  133.  
  134. ### 4b. Extra steps if you booted the cross-bootstrap system directly
  135.  
  136. * Mount sysfs and proc.
  137.  
  138. mount -t sysfs none /sys
  139. mount -t proc none /proc
  140.  
  141. * To be able to ssh into it:
  142.  
  143. /usr/sbin/sshd-keygen
  144. /usr/sbin/sshd
  145.  
  146.  
  147. ### 4c. Build a devel system
  148.  
  149. Now you are ready to start [using baserock], build and deploy a
  150. devel system.
  151.  
  152. [using baserock]: http://wiki.baserock.org/devel-with/
Advertisement
Add Comment
Please, Sign In to add comment