mconnect - KDE Connect protocol implementation in Vala/C
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

171 lines
4.1 KiB

  1. #!/bin/bash -xe
  2. #
  3. # This program is free software; you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License version 2 as
  5. # published by the Free Software Foundation.
  6. #
  7. # This program is distributed in the hope that it will be useful,
  8. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. # GNU General Public License for more details.
  11. #
  12. # You should have received a copy of the GNU General Public License along
  13. # with this program; if not, write to the Free Software Foundation, Inc.,
  14. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  15. #
  16. # AUTHORS
  17. # Maciek Borzecki <maciek.borzecki (at] gmail.com>
  18. # Travis build script. The script reexecs itself inside the container (setting
  19. # IN_CONTAINER=1). The proceeds to install build dependencies and runs through
  20. # the whole build process. Source tree is bind-mounted at /mnt and the container
  21. # has its workdir set to /mnt
  22. #
  23. # NOTE: it is assumed that the script is run while at the top of source tree
  24. # (i.e. $PWD is your checked out tree, this crucial for properly mounting the
  25. # source code into the container).
  26. deps_fedora() {
  27. dnf install --best -y --refresh \
  28. meson \
  29. pkgconfig \
  30. gcc \
  31. vala \
  32. gobject-introspection-devel \
  33. json-glib-devel \
  34. libgee-devel \
  35. gnutls-devel \
  36. libnotify-devel \
  37. at-spi2-core-devel \
  38. gtk3-devel \
  39. glib-networking \
  40. tree
  41. }
  42. deps_opensuse() {
  43. zypper install -y \
  44. make \
  45. meson \
  46. pkgconfig \
  47. gcc \
  48. vala \
  49. gobject-introspection-devel \
  50. json-glib-devel \
  51. libgee-devel \
  52. gnutls-devel \
  53. libnotify-devel \
  54. at-spi2-core-devel \
  55. gtk3-devel \
  56. glib-networking \
  57. tree
  58. }
  59. deps_archlinux() {
  60. pacman -Syu --noconfirm \
  61. base-devel \
  62. meson \
  63. pkg-config \
  64. gcc \
  65. vala \
  66. glib2 \
  67. gobject-introspection \
  68. json-glib \
  69. libgee \
  70. libnotify \
  71. at-spi2-core \
  72. gtk3 \
  73. gnutls \
  74. glib-networking \
  75. tree
  76. }
  77. deps_ubuntu_xenial() {
  78. apt-get update && \
  79. apt-get install -y \
  80. meson/xenial-backports \
  81. pkg-config \
  82. valac \
  83. libgirepository1.0-dev \
  84. libjson-glib-dev \
  85. libgee-0.8-dev \
  86. libgnutls28-dev \
  87. libnotify-dev \
  88. libgtk-3-dev \
  89. glib-networking \
  90. tree
  91. }
  92. install_deps() {
  93. case "$1" in
  94. fedora)
  95. deps_fedora
  96. ;;
  97. opensuse)
  98. deps_opensuse
  99. ;;
  100. archlinux)
  101. deps_archlinux
  102. ;;
  103. ubuntu-xenial)
  104. deps_ubuntu_xenial
  105. ;;
  106. *)
  107. echo "unsupported distro $1"
  108. exit 1
  109. esac
  110. }
  111. build() {
  112. set -ex
  113. mkdir build && \
  114. cd build && \
  115. meson .. && \
  116. ninja && \
  117. ninja test
  118. DESTDIR=$PWD/install-dir ninja install
  119. (cd install-dir; LC_ALL=C tree -pan . > ../current-tree)
  120. diff -up ../extra/install-tree current-tree
  121. }
  122. build_in_container() {
  123. install_deps $1
  124. build
  125. }
  126. spin_container() {
  127. case "$1" in
  128. fedora)
  129. DOCKER_IMG=fedora
  130. ;;
  131. archlinux)
  132. DOCKER_IMG=base/archlinux
  133. ;;
  134. opensuse)
  135. DOCKER_IMG=opensuse:tumbleweed
  136. ;;
  137. ubuntu-xenial)
  138. DOCKER_IMG=ubuntu:xenial
  139. ;;
  140. *)
  141. echo "unsupported distro $1"
  142. exit 1
  143. esac
  144. # run a container, mount sources at /mnt, st
  145. docker run --rm \
  146. -v $PWD:/mnt \
  147. -w /mnt \
  148. -e IN_CONTAINER=1 \
  149. $DOCKER_IMG \
  150. /mnt/extra/travis-build "$@"
  151. }
  152. if [ -z "$NO_BUILD" ]; then
  153. if [ "$IN_CONTAINER" = "1" ]; then
  154. build_in_container "$@"
  155. else
  156. spin_container "$@"
  157. fi
  158. fi