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.

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