building.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. .. _building-label:
  2. ===============================
  3. Appendix A: Building the Client
  4. ===============================
  5. This section explains how to build the ownCloud Client from source for all
  6. major platforms. You should read this section if you want to develop for the
  7. desktop client.
  8. .. note:: Build instructions are subject to change as development proceeds.
  9. Please check the version for which you want to build.
  10. These instructions are updated to work with version 2.2 of the ownCloud Client.
  11. Getting Source Code
  12. -------------------
  13. The :ref:`generic-build-instructions` pull the latest code directly from
  14. GitHub, and work on Linux, Mac OS X, and Windows.
  15. See the next section for instructions on getting source code from Linux
  16. packages.
  17. Linux
  18. -----
  19. You may wish to use source packages for your Linux distribution, as these give
  20. you the exact sources from which the binary packages are built. These are
  21. hosted on the `ownCloud repository from OBS`_. Go to the `Index of
  22. repositories`_ to see all the Linux client repos.
  23. 1. At the `bottom of the page for each distribution
  24. <https://software.opensuse.org/download/package?project=isv:ownCloud:desktop&
  25. package=owncloud-client>`_ is a "Grab binary packages directly" section.
  26. These contain source RPMs for CentOS, RHEL, Fedora, SLES, and openSUSE.
  27. To get the .deb source packages add the source
  28. repo for your Debian or Ubuntu version, like this example for Debian 8
  29. (run as root)::
  30. echo 'deb-src
  31. http://download.opensuse.org/repositories/isv:/ownCloud:/desktop/Debian_8.0/ /' >> /etc/apt/sources.list.d/owncloud-client.list
  32. 2. Install the dependencies using the following commands for your specific Linux
  33. distribution. Make sure the repositories for source packages are enabled.
  34. * Debian/Ubuntu: ``apt-get update; apt-get build-dep owncloud-client``
  35. * openSUSE/SLES: ``zypper ref; zypper si -d owncloud-client``
  36. * Fedora/CentOS/RHEL: ``yum install yum-utils; yum-builddep owncloud-client``
  37. 3. Follow the :ref:`generic-build-instructions`, starting with step 2.
  38. Mac OS X
  39. --------
  40. In addition to needing XCode (along with the command line tools), developing in
  41. the Mac OS X environment requires extra dependencies. You can install these
  42. dependencies through MacPorts_ or Homebrew_. These dependencies are required
  43. only on the build machine, because non-standard libs are deployed in the app
  44. bundle.
  45. The tested and preferred way to develop in this environment is through the use
  46. of HomeBrew_. The ownCloud team has its own repository containing non-standard
  47. recipes.
  48. To set up your build environment for development using HomeBrew_:
  49. 1. Install Xcode
  50. 2. Install Xcode command line tools::
  51. xcode-select --install
  52. 3. Install homebrew::
  53. /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  54. 4. Add the ownCloud repository using the following command::
  55. brew tap owncloud/owncloud
  56. 5. Install any missing dependencies::
  57. brew install $(brew deps owncloud-client)
  58. 3. Add Qt from brew to the path::
  59. export PATH=/usr/local/Cellar/qt5/5.x.y/bin:$PATH
  60. Where ``x.z`` is the current version of Qt 5 that brew has installed
  61. on your machine.
  62. 4. Install qtkeychain from here: git clone https://github.com/frankosterfeld/qtkeychain.git
  63. make sure you make the same install prefix as later while building the client e.g. -
  64. ``DCMAKE_INSTALL_PREFIX=/Path/to/client-install``
  65. 5. For compilation of the client, follow the :ref:`generic-build-instructions`.
  66. 6. Install the Packages_ package creation tool.
  67. 7. In the build directory, run ``admin/osx/create_mac.sh <build_dir>
  68. <install_dir>``. If you have a developer signing certificate, you can specify
  69. its Common Name as a third parameter (use quotes) to have the package
  70. signed automatically.
  71. .. note:: Contrary to earlier versions, ownCloud 1.7 and later are packaged
  72. as a ``pkg`` installer. Do not call "make package" at any time when
  73. compiling for OS X, as this will build a disk image, and will not
  74. work correctly.
  75. Windows Development Build
  76. -------------------------
  77. If you want to test some changes and deploy them locally, you can build natively
  78. on Windows using MinGW. If you want to generate an installer for deployment, please
  79. follow `Windows Installer Build (Cross-Compile)`_ instead.
  80. 1. Get the required dependencies:
  81. * Make sure that you have CMake_ and Git_.
  82. * Download the Qt_ MinGW package. You will use the MinGW version bundled with it.
  83. * Download an `OpenSSL Windows Build`_ (the non-"Light" version)
  84. 2. Get the QtKeychain_ sources as well as the latest versions of the ownCloud client
  85. from Git as follows::
  86. git clone https://github.com/frankosterfeld/qtkeychain.git
  87. git clone git://github.com/owncloud/client.git
  88. 3. Open the Qt MinGW shortcut console from the Start Menu
  89. 4. Make sure that OpenSSL's ``bin`` directory as well as your qtkeychain source
  90. directories are in your PATH. This will allow CMake to find the library and
  91. headers, as well as allow the ownCloud client to find the DLLs at runtime::
  92. set PATH=C:\<OpenSSL Install Dir>\bin;%PATH%
  93. set PATH=C:\<qtkeychain Clone Dir>;%PATH%
  94. 5. Build qtkeychain **directly in the source directory** so that the DLL is built
  95. in the same directory as the headers to let CMake find them together through PATH::
  96. cd <qtkeychain Clone Dir>
  97. cmake -G "MinGW Makefiles" .
  98. mingw32-make
  99. cd ..
  100. 6. Create the build directory::
  101. mkdir client-build
  102. cd client-build
  103. 7. Build the client::
  104. cmake -G "MinGW Makefiles" ../client
  105. mingw32-make
  106. .. note:: You can try using ninja to build in parallel using
  107. ``cmake -G Ninja ../client`` and ``ninja`` instead.
  108. .. note:: Refer to the :ref:`generic-build-instructions` section for additional options.
  109. The ownCloud binary will appear in the ``bin`` directory.
  110. Windows Installer Build (Cross-Compile)
  111. ---------------------------------------
  112. Due to the large number of dependencies, building the client installer for Windows
  113. is **currently only officially supported on openSUSE**, by using the MinGW cross compiler.
  114. You can set up any currently supported version of openSUSE in a virtual machine if you do not
  115. have it installed already.
  116. In order to make setup simple, you can use the provided Dockerfile to build your own image.
  117. 1. Assuming you are in the root of the ownCloud Client's source tree, you can
  118. build an image from this Dockerfile like this::
  119. cd admin/win/docker
  120. docker build . -t owncloud-client-win32:<version>
  121. Replace ``<version>`` by the version of the client you are building, e.g.
  122. |version| for the release of the client that this document describes.
  123. If you do not wish to use docker, you can run the commands in ``RUN`` manually
  124. in a shell, e.g. to create your own build environment in a virtual machine.
  125. .. note:: Docker images are specific to releases. This one refers to |version|.
  126. Newer releases may have different dependencies, and thus require a later
  127. version of the docker image! Always pick the docker image fitting your release
  128. of ownCloud client!
  129. 2. From within the source tree Run the docker instance::
  130. docker run -v "$PWD:/home/user/client" owncloud-client-win32:<version> \
  131. /home/user/client/admin/win/docker/build.sh client/ $(id -u)
  132. It will run the build, create an NSIS based installer, as well as run tests.
  133. You will find the resulting binary in an newly created ``build-win32`` subfolder.
  134. If you do not wish to use docker, and ran the ``RUN`` commands above in a virtual machine,
  135. you can run the indented commands in the lower section of ``build.sh`` manually in your
  136. source tree.
  137. 4. Finally, you should sign the installer to avoid warnings upon installation.
  138. This requires a `Microsoft Authenticode`_ Certificate ``osslsigncode`` to sign the installer::
  139. osslsigncode -pkcs12 $HOME/.codesign/packages.pfx -h sha256 \
  140. -pass yourpass \
  141. -n "ACME Client" \
  142. -i "http://acme.com" \
  143. -ts "http://timestamp.server/" \
  144. -in ${unsigned_file} \
  145. -out ${installer_file}
  146. For ``-in``, use the URL to the time stamping server provided by your CA along with the Authenticode certificate. Alternatively,
  147. you may use the official Microsoft ``signtool`` utility on Microsoft Windows.
  148. If you're familiar with docker, you can use the version of ``osslsigncode`` that is part of the docker image.
  149. .. _generic-build-instructions:
  150. Generic Build Instructions
  151. --------------------------
  152. Compared to previous versions, building the desktop sync client has become easier. Unlike
  153. earlier versions, CSync, which is the sync engine library of the client, is now
  154. part of the client source repository and not a separate module.
  155. To build the most up-to-date version of the client:
  156. 1. Clone the latest versions of the client from Git_ as follows::
  157. git clone git://github.com/owncloud/client.git
  158. cd client
  159. git submodule init
  160. git submodule update
  161. 2. Create the build directory::
  162. mkdir client-build
  163. cd client-build
  164. 3. Configure the client build::
  165. cmake -DCMAKE_BUILD_TYPE="Debug" ..
  166. .. note:: You must use absolute paths for the ``include`` and ``library``
  167. directories.
  168. .. note:: On Mac OS X, you need to specify ``-DCMAKE_INSTALL_PREFIX=target``,
  169. where ``target`` is a private location, i.e. in parallel to your build
  170. dir by specifying ``../install``.
  171. ..note:: qtkeychain must be compiled with the same prefix e.g CMAKE_INSTALL_PREFIX=/Users/path/to/client/install/
  172. .. note:: Example:: cmake -DCMAKE_PREFIX_PATH=/usr/local/opt/qt5 -DCMAKE_INSTALL_PREFIX=/Users/path/to/client/install/ -D_OPENSSL_LIBDIR=/usr/local/opt/openssl/lib/ -D_OPENSSL_INCLUDEDIR=/usr/local/opt/openssl/include/ -DOPENSSL_INCLUDE_DIR=/usr/local/opt/openssl/include/ -DNO_SHIBBOLETH=1
  173. .. note:: Example:: cmake -DCMAKE_PREFIX_PATH=/usr/local/opt/qt5 -DCMAKE_INSTALL_PREFIX=/Users/path/to/client/install/ -D_OPENSSL_LIBDIR=/usr/local/opt/openssl/lib/ -D_OPENSSL_INCLUDEDIR=/usr/local/opt/openssl/include/ -D_OPENSSL_VERSION=1.0.2a -DOPENSSL_INCLUDE_DIR=/usr/local/opt/openssl/include/ -DNO_SHIBBOLETH=1
  174. qtkeychain must be compiled with the same prefix e.g CMAKE_INSTALL_PREFIX=/Users/path/to/client/install/ .
  175. 4. Call ``make``.
  176. The owncloud binary will appear in the ``bin`` directory.
  177. 5. (Optional) Call ``make install`` to install the client to the
  178. ``/usr/local/bin`` directory.
  179. The following are known cmake parameters:
  180. * ``QTKEYCHAIN_LIBRARY=/path/to/qtkeychain.dylib -DQTKEYCHAIN_INCLUDE_DIR=/path/to/qtkeychain/``:
  181. Used for stored credentials. When compiling with Qt5, the library is called ``qt5keychain.dylib.``
  182. You need to compile QtKeychain with the same Qt version.
  183. * ``WITH_DOC=TRUE``: Creates doc and manpages through running ``make``; also adds install statements,
  184. providing the ability to install using ``make install``.
  185. * ``CMAKE_PREFIX_PATH=/path/to/Qt5.2.0/5.2.0/yourarch/lib/cmake/``: Builds using Qt5.
  186. * ``BUILD_WITH_QT4=ON``: Builds using Qt4 (even if Qt5 is found).
  187. * ``CMAKE_INSTALL_PREFIX=path``: Set an install prefix. This is mandatory on Mac OS
  188. .. _ownCloud repository from OBS: http://software.opensuse.org/download/package?
  189. project=isv:ownCloud:desktop&package=owncloud-client
  190. .. _CMake: http://www.cmake.org/download
  191. .. _CSync: http://www.csync.org
  192. .. _Client Download Page: https://owncloud.org/install/#desktop
  193. .. _Git: http://git-scm.com
  194. .. _MacPorts: http://www.macports.org
  195. .. _Homebrew: http://mxcl.github.com/homebrew/
  196. .. _OpenSSL Windows Build: http://slproweb.com/products/Win32OpenSSL.html
  197. .. _Qt: http://www.qt.io/download
  198. .. _Microsoft Authenticode: https://msdn.microsoft.com/en-us/library/ie/ms537361%28v=vs.85%29.aspx
  199. .. _QtKeychain: https://github.com/frankosterfeld/qtkeychain
  200. .. _Packages: http://s.sudre.free.fr/Software/Packages/about.html
  201. .. _Index of repositories: http://download.opensuse.org/repositories/isv:/ownCloud:/desktop/