freedombone-image-makefile 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. #!/usr/bin/make
  2. #
  3. # A debian image builder, based upon freedom-maker
  4. #
  5. # This program is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation, either version 3 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. # Where to fetch packages
  18. MIRROR ?= http://httpredir.debian.org/debian
  19. BUILD_MIRROR ?= http://httpredir.debian.org/debian
  20. IMAGE_SIZE ?= 8G
  21. SUITE ?= jessie
  22. # include source packages in image?
  23. SOURCE ?= false
  24. # yes no
  25. BUILD = $(MACHINE)-$(ARCHITECTURE)
  26. TODAY := $(shell date +%Y-%m-%d)
  27. NAME = build/freedombone-$(TODAY)_$(BUILD)
  28. IMAGE = $(NAME).img
  29. ARCHIVE = $(NAME).tar.bz2
  30. SIGNATURE = $(ARCHIVE).sig
  31. OWNER = 1000
  32. TAR = tar --checkpoint=1000 --checkpoint-action=dot -cjvf
  33. SIGN = -gpg --output $(SIGNATURE) --detach-sig $(ARCHIVE)
  34. # settings for `make test`
  35. TEST_SSH_PORT = 2222
  36. TEST_FIRSTRUN_WAIT_TIME = 120 # seconds
  37. # Using taskset to pin build process to single core. This is a
  38. # workaround for a qemu-user-static issue that causes builds to
  39. # hang. (See Debian bug #769983 for details.)
  40. MAKE_IMAGE = ARCHITECTURE=$(ARCHITECTURE) MACHINE=$(MACHINE) SOURCE=$(SOURCE) \
  41. MIRROR=$(MIRROR) SUITE=$(SUITE) OWNER=$(OWNER) \
  42. BUILD_MIRROR=$(BUILD_MIRROR) \
  43. CUSTOM_PLINTH=$(CUSTOM_PLINTH) CUSTOM_SETUP=$(CUSTOM_SETUP) \
  44. IMAGE_SIZE=$(IMAGE_SIZE) taskset 0x01 freedombone-image-make $(NAME)
  45. # build Beaglebone SD card image
  46. beaglebone: prep
  47. $(eval ARCHITECTURE = armhf)
  48. $(eval MACHINE = beaglebone)
  49. $(MAKE_IMAGE)
  50. $(TAR) $(ARCHIVE) $(IMAGE)
  51. @echo ""
  52. $(SIGN)
  53. @echo "Build complete."
  54. # build Cubieboard2 SD card image
  55. cubieboard2: prep
  56. $(eval ARCHITECTURE = armhf)
  57. $(eval MACHINE = cubieboard2)
  58. $(MAKE_IMAGE)
  59. $(TAR) $(ARCHIVE) $(IMAGE)
  60. @echo ""
  61. $(SIGN)
  62. @echo "Build complete."
  63. # build an i386 image
  64. i386: prep
  65. $(eval ARCHITECTURE = i386)
  66. $(eval MACHINE = all)
  67. $(MAKE_IMAGE)
  68. $(TAR) $(ARCHIVE) $(IMAGE)
  69. @echo ""
  70. $(SIGN)
  71. @echo "Build complete."
  72. # build an amd64 image
  73. amd64: prep
  74. $(eval ARCHITECTURE = amd64)
  75. $(eval MACHINE = all)
  76. $(MAKE_IMAGE)
  77. $(TAR) $(ARCHIVE) $(IMAGE)
  78. @echo ""
  79. $(SIGN)
  80. @echo "Build complete."
  81. # build a virtualbox image
  82. virtualbox: virtualbox-i386
  83. virtualbox-i386: prep
  84. $(eval ARCHITECTURE = i386)
  85. $(eval MACHINE = virtualbox)
  86. $(MAKE_IMAGE)
  87. # Convert image to vdi hard drive
  88. VBoxManage convertdd $(NAME).img $(NAME).vdi
  89. $(TAR) $(ARCHIVE) $(NAME).vdi
  90. @echo ""
  91. $(SIGN)
  92. @echo "Build complete."
  93. virtualbox-amd64: prep
  94. $(eval ARCHITECTURE = amd64)
  95. $(eval MACHINE = virtualbox)
  96. $(MAKE_IMAGE)
  97. # Convert image to vdi hard drive
  98. VBoxManage convertdd $(NAME).img $(NAME).vdi
  99. $(TAR) $(ARCHIVE) $(NAME).vdi
  100. @echo ""
  101. $(SIGN)
  102. @echo "Build complete."
  103. test: test-virtualbox
  104. test-virtualbox: virtualbox
  105. $(eval VM_NAME = freedom-maker-test)
  106. VBoxManage createvm --name $(VM_NAME) --ostype "Debian" --register
  107. VBoxManage storagectl $(VM_NAME) --name "SATA Controller" --add sata \
  108. --controller IntelAHCI
  109. VBoxManage storageattach $(VM_NAME) --storagectl "SATA Controller" \
  110. --port 0 --device 0 --type hdd --medium $(NAME).vdi
  111. VBoxManage modifyvm $(VM_NAME) --pae on --memory 1024 --vram 128 \
  112. --nic1 nat --natpf1 ,tcp,,$(TEST_SSH_PORT),,22
  113. VBoxManage startvm $(VM_NAME) --type headless
  114. sleep $(TEST_FIRSTRUN_WAIT_TIME) # wait for first-run to complete
  115. echo frdm |sshpass -p frdm ssh -o UserKnownHostsFile=/dev/null \
  116. -o StrictHostKeyChecking=no -t -t \
  117. -p $(TEST_SSH_PORT) fbx@127.0.0.1 \
  118. "sudo plinth --diagnose" \
  119. |tee build/$(VM_NAME)-results_$(TODAY).log
  120. VBoxManage controlvm $(VM_NAME) poweroff
  121. VBoxManage modifyvm $(VM_NAME) --hda none
  122. VBoxManage unregistervm $(VM_NAME) --delete
  123. vendor/vmdebootstrap/vmdebootstrap: vendor-patches/vmdebootstrap/*.patch
  124. bin/fetch-new-vmdebootstrap
  125. prep: vendor/vmdebootstrap/vmdebootstrap
  126. mkdir -p build
  127. clean:
  128. -rm -f build/freedombone.log
  129. distclean: clean
  130. sudo rm -rf build