build.sh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/bash
  2. export PATH=/bin:/usr/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin
  3. subdirs=$*
  4. if [ ! -n "$subdirs" ]; then
  5. subdirs=`find . -type d -name '*-*' -printf '%f '`
  6. fi
  7. if [ ! -d ./ubuntu-trusty ]; then
  8. echo 'Must run from linux-build-farm subfolder.'
  9. exit 1
  10. fi
  11. rm -f zt1-src.tar.gz
  12. cd ..
  13. git archive --format=tar.gz --prefix=ZeroTierOne/ -o linux-build-farm/zt1-src.tar.gz HEAD
  14. cd linux-build-farm
  15. # Note that --privileged is used so we can bind mount VM shares when building in a VM.
  16. # It has no other impact or purpose, but probably doesn't matter here in any case.
  17. for distro in $subdirs; do
  18. echo
  19. echo "--- BUILDING FOR $distro ---"
  20. echo
  21. cd $distro
  22. cd x64
  23. mv ../../zt1-src.tar.gz .
  24. docker build -t zt1-build-${distro}-x64 .
  25. mv zt1-src.tar.gz ../..
  26. cd ..
  27. cd x86
  28. mv ../../zt1-src.tar.gz .
  29. docker build -t zt1-build-${distro}-x86 .
  30. mv zt1-src.tar.gz ../..
  31. cd ..
  32. rm -f *.deb *.rpm
  33. if [ ! -n "`echo $distro | grep -F debian`" -a ! -n "`echo $distro | grep -F ubuntu`" ]; then
  34. docker run --rm -v `pwd`:/artifacts --privileged -it zt1-build-${distro}-x64 /bin/bash -c 'cd /ZeroTierOne ; make redhat ; cd .. ; cp `find /root/rpmbuild -type f -name *.rpm` /artifacts ; ls -l /artifacts'
  35. docker run --rm -v `pwd`:/artifacts --privileged -it zt1-build-${distro}-x86 /bin/bash -c 'cd /ZeroTierOne ; make redhat ; cd .. ; cp `find /root/rpmbuild -type f -name *.rpm` /artifacts ; ls -l /artifacts'
  36. else
  37. docker run --rm -v `pwd`:/artifacts --privileged -it zt1-build-${distro}-x64 /bin/bash -c 'cd /ZeroTierOne ; make debian ; cd .. ; cp *.deb /artifacts ; ls -l /artifacts'
  38. docker run --rm -v `pwd`:/artifacts --privileged -it zt1-build-${distro}-x86 /bin/bash -c 'cd /ZeroTierOne ; make debian ; cd .. ; cp *.deb /artifacts ; ls -l /artifacts'
  39. fi
  40. cd ..
  41. done
  42. rm -f zt1-src.tar.gz