building.rst 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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 additon 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/qmake
  60. Where ``x.z`` is the current version of Qt 5 that brew has installed
  61. on your machine.
  62. 5. For compilation of the client, follow the :ref:`generic-build-instructions`.
  63. 6. Install the Packages_ package creation tool.
  64. 7. In the build directory, run ``admin/osx/create_mac.sh <build_dir>
  65. <install_dir>``. If you have a developer signing certificate, you can specify
  66. its Common Name as a third parameter (use quotes) to have the package
  67. signed automatically.
  68. .. note:: Contrary to earlier versions, ownCloud 1.7 and later are packaged
  69. as a ``pkg`` installer. Do not call "make package" at any time when
  70. compiling for OS X, as this will build a disk image, and will not
  71. work correctly.
  72. Windows Development Build
  73. -----------------------
  74. If you want to test some changes and deploy them locally, you can build natively
  75. on Windows using MinGW. If you want to generate an installer for deployment, please
  76. follow `Windows Installer Build (Cross-Compile)`_ instead.
  77. 1. Get the required dependencies:
  78. * Make sure that you have CMake_ and Git_.
  79. * Download the Qt_ MinGW package. You will use the MinGW version bundled with it.
  80. * Download an `OpenSSL Windows Build`_ (the non-"Light" version)
  81. 2. Get the QtKeychain_ sources as well as the latest versions of the ownCloud client
  82. from Git as follows::
  83. git clone https://github.com/frankosterfeld/qtkeychain.git
  84. git clone git://github.com/owncloud/client.git
  85. 3. Open the Qt MinGW shortcut console from the Start Menu
  86. 4. Make sure that OpenSSL's ``bin`` directory as well as your qtkeychain source
  87. directories are in your PATH. This will allow CMake to find the library and
  88. headers, as well as allow the ownCloud client to find the DLLs at runtime::
  89. set PATH=C:\<OpenSSL Install Dir>\bin;%PATH%
  90. set PATH=C:\<qtkeychain Clone Dir>;%PATH%
  91. 5. Build qtkeychain **directly in the source directory** so that the DLL is built
  92. in the same directory as the headers to let CMake find them together through PATH::
  93. cd <qtkeychain Clone Dir>
  94. cmake -G "MinGW Makefiles" .
  95. mingw32-make
  96. cd ..
  97. 6. Create the build directory::
  98. mkdir client-build
  99. cd client-build
  100. 7. Build the client::
  101. cmake -G "MinGW Makefiles" ../client
  102. mingw32-make
  103. .. note:: You can try using ninja to build in parallel using
  104. ``cmake -G Ninja ../client`` and ``ninja`` instead.
  105. .. note:: Refer to the :ref:`generic-build-instructions` section for additional options.
  106. The ownCloud binary will appear in the ``bin`` directory.
  107. Windows Installer Build (Cross-Compile)
  108. ---------------------------------------
  109. Due to the large number of dependencies, building the client installer for Windows
  110. is **currently only officially supported on openSUSE**, by using the MinGW cross compiler.
  111. You can set up any currently supported version of openSUSE in a virtual machine if you do not
  112. have it installed already.
  113. In order to make setup simple, you can use the provided Dockerfile to build your own image.
  114. 1. Assuming you are in the root of the ownCloud Client's source tree, you can
  115. build an image from this Dockerfile like this::
  116. cd admin/win/docker
  117. docker build . -t owncloud-client-win32:<version>
  118. Replace ``<version>`` by the version of the client you are building, e.g.
  119. |version| for the release of the client that this document describes.
  120. If you do not wish to use docker, you can run the commands in ``RUN`` manually
  121. in a shell, e.g. to create your own build environment in a virtual machine.
  122. .. note:: Docker images are specific to releases. This one refers to |version|.
  123. Newer releases may have different dependencies, and thus require a later
  124. version of the docker image! Always pick the docker image fitting your release
  125. of ownCloud client!
  126. 2. From within the source tree Run the docker instance::
  127. docker run -v "$PWD:/home/user/client" owncloud-client-win32:<version> \
  128. /home/user/client/admin/win/docker/build.sh client/ $(id -u)
  129. It will run the build, create an NSIS based installer, as well as run tests.
  130. You will find the resulting binary in an newly created ``build-win32`` subfolder.
  131. If you do not wish to use docker, and ran the ``RUN`` commands above in a virtual machine,
  132. you can run the indented commands in the lower section of ``build.sh`` manually in your
  133. source tree.
  134. 4. Finally, you should sign the installer to avoid warnings upon installation.
  135. This requires a `Microsoft Authenticode`_ Certificate ``osslsigncode`` to sign the installer::
  136. osslsigncode -pkcs12 $HOME/.codesign/packages.pfx -h sha256 \
  137. -pass yourpass \
  138. -n "ACME Client" \
  139. -i "http://acme.com" \
  140. -ts "http://timestamp.server/" \
  141. -in ${unsigned_file} \
  142. -out ${installer_file}
  143. for ``-in``, use the URL to the time stamping server provided by your CA along with the Authenticode certificate. Alternatively,
  144. you may use the official Microsoft ``signtool`` utility on Microsoft Windows.
  145. If you're familiar with docker, you can use the version of ``osslsigncode`` that is part of the docker image.
  146. .. _generic-build-instructions:
  147. Generic Build Instructions
  148. --------------------------
  149. Compared to previous versions, building the desktop sync client has become easier. Unlike
  150. earlier versions, CSync, which is the sync engine library of the client, is now
  151. part of the client source repository and not a separate module.
  152. To build the most up-to-date version of the client:
  153. 1. Clone the latest versions of the client from Git_ as follows::
  154. git clone git://github.com/owncloud/client.git
  155. cd client
  156. git submodule init
  157. git submodule update
  158. 2. Create the build directory::
  159. mkdir client-build
  160. cd client-build
  161. 3. Configure the client build::
  162. cmake -DCMAKE_BUILD_TYPE="Debug" ..
  163. .. note:: You must use absolute paths for the ``include`` and ``library``
  164. directories.
  165. .. note:: On Mac OS X, you need to specify ``-DCMAKE_INSTALL_PREFIX=target``,
  166. where ``target`` is a private location, i.e. in parallel to your build
  167. dir by specifying ``../install``.
  168. .. 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
  169. 4. Call ``make``.
  170. The owncloud binary will appear in the ``bin`` directory.
  171. 5. (Optional) Call ``make install`` to install the client to the
  172. ``/usr/local/bin`` directory.
  173. The following are known cmake parameters:
  174. * ``QTKEYCHAIN_LIBRARY=/path/to/qtkeychain.dylib -DQTKEYCHAIN_INCLUDE_DIR=/path/to/qtkeychain/``:
  175. Used for stored credentials. When compiling with Qt5, the library is called ``qt5keychain.dylib.``
  176. You need to compile QtKeychain with the same Qt version.
  177. * ``WITH_DOC=TRUE``: Creates doc and manpages through running ``make``; also adds install statements,
  178. providing the ability to install using ``make install``.
  179. * ``CMAKE_PREFIX_PATH=/path/to/Qt5.2.0/5.2.0/yourarch/lib/cmake/``: Builds using Qt5.
  180. * ``BUILD_WITH_QT4=ON``: Builds using Qt4 (even if Qt5 is found).
  181. * ``CMAKE_INSTALL_PREFIX=path``: Set an install prefix. This is mandatory on Mac OS
  182. .. _ownCloud repository from OBS: http://software.opensuse.org/download/package?
  183. project=isv:ownCloud:desktop&package=owncloud-client
  184. .. _CMake: http://www.cmake.org/download
  185. .. _CSync: http://www.csync.org
  186. .. _Client Download Page: https://owncloud.org/install/#desktop
  187. .. _Git: http://git-scm.com
  188. .. _MacPorts: http://www.macports.org
  189. .. _Homebrew: http://mxcl.github.com/homebrew/
  190. .. _OpenSSL Windows Build: http://slproweb.com/products/Win32OpenSSL.html
  191. .. _Qt: http://www.qt.io/download
  192. .. _Microsoft Authenticode: https://msdn.microsoft.com/en-us/library/ie/ms537361%28v=vs.85%29.aspx
  193. .. _QtKeychain: https://github.com/frankosterfeld/qtkeychain
  194. .. _Packages: http://s.sudre.free.fr/Software/Packages/about.html
  195. .. _Index of repositories: http://download.opensuse.org/repositories/isv:/ownCloud:/desktop/