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.

177 lines
4.3 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. uncrustify
  42. }
  43. deps_opensuse() {
  44. zypper install -y \
  45. make \
  46. meson \
  47. pkgconfig \
  48. gcc \
  49. vala \
  50. gobject-introspection-devel \
  51. json-glib-devel \
  52. libgee-devel \
  53. gnutls-devel \
  54. libnotify-devel \
  55. at-spi2-core-devel \
  56. gtk3-devel \
  57. glib-networking \
  58. tree \
  59. uncrustify
  60. }
  61. deps_archlinux() {
  62. pacman -Syu --noconfirm \
  63. base-devel \
  64. meson \
  65. pkg-config \
  66. gcc \
  67. vala \
  68. glib2 \
  69. gobject-introspection \
  70. json-glib \
  71. libgee \
  72. libnotify \
  73. at-spi2-core \
  74. gtk3 \
  75. gnutls \
  76. glib-networking \
  77. tree \
  78. uncrustify
  79. }
  80. deps_ubuntu_xenial() {
  81. apt-get update && \
  82. apt-get install -y \
  83. meson/xenial-backports \
  84. pkg-config \
  85. valac \
  86. libgirepository1.0-dev \
  87. libjson-glib-dev \
  88. libgee-0.8-dev \
  89. libgnutls28-dev \
  90. libnotify-dev \
  91. libgtk-3-dev \
  92. glib-networking \
  93. tree \
  94. uncrustify
  95. }
  96. install_deps() {
  97. case "$1" in
  98. fedora)
  99. deps_fedora
  100. ;;
  101. opensuse)
  102. deps_opensuse
  103. ;;
  104. archlinux)
  105. deps_archlinux
  106. ;;
  107. ubuntu-xenial)
  108. deps_ubuntu_xenial
  109. ;;
  110. *)
  111. echo "unsupported distro $1"
  112. exit 1
  113. esac
  114. }
  115. build() {
  116. set -ex
  117. ./extra/fmt check && \
  118. mkdir -p build && \
  119. cd build && \
  120. meson .. && \
  121. ninja && \
  122. ninja test \
  123. || false
  124. DESTDIR=$PWD/install-dir ninja install
  125. (cd install-dir; LC_ALL=C tree -pan . > ../current-tree)
  126. diff -up ../extra/install-tree current-tree
  127. }
  128. build_in_container() {
  129. install_deps $1
  130. build
  131. }
  132. spin_container() {
  133. case "$1" in
  134. fedora)
  135. DOCKER_IMG=fedora
  136. ;;
  137. archlinux)
  138. DOCKER_IMG=base/archlinux
  139. ;;
  140. opensuse)
  141. DOCKER_IMG=opensuse:tumbleweed
  142. ;;
  143. ubuntu-xenial)
  144. DOCKER_IMG=ubuntu:xenial
  145. ;;
  146. *)
  147. echo "unsupported distro $1"
  148. exit 1
  149. esac
  150. # run a container, mount sources at /mnt, st
  151. docker run --rm \
  152. -v $PWD:/mnt \
  153. -w /mnt \
  154. -e IN_CONTAINER=1 \
  155. $DOCKER_IMG \
  156. /mnt/extra/travis-build "$@"
  157. }
  158. if [ -z "$NO_BUILD" ]; then
  159. if [ "$IN_CONTAINER" = "1" ]; then
  160. build_in_container "$@"
  161. else
  162. spin_container "$@"
  163. fi
  164. fi