Makefile 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. DOCKER_BINARY_URL := https://github.com/rancher/docker/releases/download/v1.7.1-ros-1/docker-1.7.1
  2. DOCKER_BINARY := $(shell basename $(DOCKER_BINARY_URL))
  3. pwd := $(shell pwd)
  4. include scripts/build-common
  5. include scripts/version
  6. compile: bin/rancheros
  7. all: clean ros-build-base package
  8. ros-build-base:
  9. docker build -t ros-build-base -f Dockerfile.base .
  10. ros-build:
  11. docker build -t ros-build .
  12. docker-run: ros-build
  13. docker rm -fv ros-build > /dev/null 2>&1 || :
  14. docker run -v /var/run/docker.sock:/var/run/docker.sock --name=ros-build -i ros-build
  15. CD := $(BUILD)/cd
  16. assets bin $(DIST)/artifacts $(CD)/boot/isolinux:
  17. mkdir -p $@
  18. ifdef CONTAINED
  19. assets/$(DOCKER_BINARY): assets
  20. cd assets && curl -OL "$(DOCKER_BINARY_URL)"
  21. assets/docker: assets/$(DOCKER_BINARY)
  22. mv assets/$(DOCKER_BINARY) $@
  23. chmod +x $@
  24. bin/rancheros: bin
  25. godep go build -tags netgo -ldflags "-X github.com/rancherio/os/config.VERSION $(VERSION) -linkmode external -extldflags -static" -o $@
  26. strip --strip-all $@
  27. copy-images:
  28. ./scripts/copy-images
  29. .PHONY: copy-images
  30. $(DIST)/artifacts/vmlinuz: $(DIST)/artifacts copy-images
  31. mv $(BUILD)/kernel/vmlinuz $@
  32. INITRD_DIR := $(BUILD)/initrd
  33. $(INITRD_DIR)/images.tar: bin/rancheros
  34. ln -sf bin/rancheros ./ros
  35. for i in `./ros c images -i os-config.yml`; do docker pull $$i; done
  36. docker save `./ros c images -i os-config.yml` > $@
  37. $(DIST)/artifacts/initrd: $(DIST)/artifacts bin/rancheros assets/docker copy-images $(INITRD_DIR)/images.tar
  38. mv $(BUILD)/kernel/lib $(INITRD_DIR)
  39. mv assets/docker $(INITRD_DIR)
  40. cp os-config.yml $(INITRD_DIR)
  41. cp bin/rancheros $(INITRD_DIR)/init
  42. cd $(INITRD_DIR) && find | cpio -H newc -o | lzma -c > $@
  43. $(DIST)/artifacts/rancheros.iso: $(DIST)/artifacts/initrd $(CD)/boot/isolinux
  44. cp $(DIST)/artifacts/initrd $(CD)/boot
  45. cp $(DIST)/artifacts/vmlinuz $(CD)/boot
  46. cp scripts/isolinux.cfg $(CD)/boot/isolinux
  47. cp /usr/lib/ISOLINUX/isolinux.bin $(CD)/boot/isolinux
  48. cp /usr/lib/syslinux/modules/bios/ldlinux.c32 $(CD)/boot/isolinux
  49. cd $(CD) && xorriso -publisher "Rancher Labs, Inc." \
  50. -as mkisofs \
  51. -l -J -R -V "RancherOS" \
  52. -no-emul-boot -boot-load-size 4 -boot-info-table \
  53. -b boot/isolinux/isolinux.bin -c boot/isolinux/boot.cat \
  54. -isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin \
  55. -o $@ $(CD)
  56. $(DIST)/artifacts/iso-checksums.txt: $(DIST)/artifacts/rancheros.iso
  57. cd $(DIST)/artifacts && for algo in 'sha256' 'md5'; do echo "$$algo: `$${algo}sum rancheros.iso`" >> $@; done
  58. package: \
  59. $(DIST)/artifacts/initrd \
  60. $(DIST)/artifacts/vmlinuz \
  61. $(DIST)/artifacts/rancheros.iso \
  62. $(DIST)/artifacts/iso-checksums.txt
  63. else
  64. bin/rancheros:
  65. @echo make $@ | make docker-run
  66. docker cp ros-build:/go/src/github.com/rancherio/os/$@ $(dir $@)
  67. .PHONY: bin/rancheros
  68. package:
  69. @echo make $@ | make docker-run
  70. docker cp ros-build:/go/src/github.com/rancherio/os/bin/rancheros bin
  71. docker cp ros-build:/go/src/github.com/rancherio/os/dist/artifacts dist
  72. endif
  73. version:
  74. @echo $(VERSION)
  75. clean:
  76. rm -rf bin build dist gopath .dockerfile
  77. .PHONY: all compile clean dist docker-run download package ros-build ros-build-base version