ppabuild.sh 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #!/bin/sh
  2. ##############################################################################
  3. ## This is used to package .deb packages and upload them to the launchpad
  4. ## ppa servers for building. It requires one argument (passed via env):
  5. ##
  6. ## ethbranch: the branch to use for webthree-umbrella, either develop or
  7. ## release
  8. ## debplatform: target ubuntu "release", i.e. trusty, vivid, wily or xenial
  9. ## (we should switch to numbered releases at some point)
  10. ##
  11. ## The "debian" directories can be found in github.com/ethereum/ethereum-ppa
  12. ## The develop branch will be used for anything before wily, while wily and
  13. ## xenial have their own branches.
  14. ##
  15. ## The gnupg key for "build@ethdev.com" has to be present in order to sign
  16. ## the package.
  17. ##
  18. ## Caveats: A package with the same version number should not be uploaded
  19. ## multiple times to the build servers. This is not a big problem for the
  20. ## develop snapshots as the version will change with every commit, but
  21. ## for release packages, the version will be taken from the CMakeLists.txt
  22. ## file. This means that this script should only be run once for every
  23. ## release. If the source package was uploaded before, add '-sd' to the
  24. ## debuild command (see below).
  25. ##############################################################################
  26. set -e
  27. distribution=${debplatform}
  28. echo "building for ${debplatform}"
  29. if [ -z "$distribution" ]
  30. then distribution=trusty
  31. fi
  32. arch=amd64
  33. mainrepo=webthree-umbrella
  34. now=$(date +"%Y%m%d")
  35. project="cpp-ethereum"
  36. ppabranch=develop
  37. if [ "${distribution}" = "wily" ]; then
  38. ppabranch=wily
  39. elif [ "${distribution}" = "xenial" ]; then
  40. ppabranch=xenial
  41. fi
  42. codebranch=${ethbranch}
  43. pparepo=ethereum/ethereum
  44. if [ -z "$codebranch" ]
  45. then
  46. codebranch=develop
  47. fi
  48. if [ "$codebranch" = "develop" ]
  49. then
  50. pparepo=ethereum/ethereum-dev
  51. fi
  52. echo codebranch=${codebranch}
  53. echo pparepo=${pparepo}
  54. keyid=703F83D0
  55. email=builds@ethereum.org
  56. mainppa="http://ppa.launchpad.net/ethereum/ethereum/ubuntu"
  57. devppa="http://ppa.launchpad.net/ethereum/ethereum-dev/ubuntu"
  58. # clone source repo
  59. git clone https://github.com/ethereum/${mainrepo}.git -b ${codebranch} --recursive
  60. # create source tarball"
  61. cd ${mainrepo}
  62. version=`grep -oP "$project VERSION \"?\K[0-9.]+(?=\")"? CMakeLists.txt`
  63. version="${version}"
  64. revision=`git rev-parse --short HEAD`
  65. if [ "${codebranch}" = "release" ]; then
  66. debversion=${version}~${distribution}
  67. else
  68. debversion=${version}-SNAPSHOT-${BUILD_NUMBER}-${now}-${revision}~${distribution}
  69. fi
  70. echo debversion=${debversion}
  71. tar --exclude .git -czf ../${project}_${debversion}.orig.tar.gz .
  72. # get debian/ direcotry
  73. wget https://github.com/ethereum/ethereum-ppa/archive/${ppabranch}.tar.gz -O- |
  74. tar -zx --exclude package.sh --exclude README.md --strip-components=1
  75. # bump version
  76. EMAIL="$email" dch -v ${debversion}-0ubuntu1 "git build of ${revision}"
  77. # build source package
  78. # If packages is rejected because original source is already present, add
  79. # -sd to remove it from the .changes file
  80. debuild -S -sa -us -uc
  81. # set PPA dependencies for pbuilder
  82. echo "OTHERMIRROR=\"deb [trusted=yes] ${mainppa} ${distribution} main|deb-src [trusted=yes] ${mainppa} ${distribution} main|deb [trusted=yes] ${devppa} ${distribution} main|deb-src [trusted=yes] ${devppa} ${distribution} main|deb [trusted=yes]\"" > ~/.pbuilderrc
  83. # do the build
  84. #pdebuild --buildresult . --pbuilder /usr/sbin/cowbuilder --architecture amd64 -- --buildresult . --basepath /var/cache/pbuilder/${distribution}-${arch}-ethereum.cow
  85. # prepare .changes file for Launchpad
  86. sed -i -e s/UNRELEASED/${distribution}/ -e s/urgency=medium/urgency=low/ ../*.changes
  87. # sign the package
  88. debsign -k ${keyid} ../${project}_${debversion}-0ubuntu1_source.changes
  89. # uploa
  90. dput ppa:${pparepo} ../${project}_${debversion}-0ubuntu1_source.changes