Build Samba from Source
Samba OS Requirements
Because of the constantly changing and ever expanding nature of Linux, the OS Requirements for Samba 4 have been moved from Step 2, to Samba_4/OS_Requirements. This not only includes the required packages for a successful Samba AD DC deployment, but also the required file system features. Please consider that page as a prerequisite to a successful Samba AD DC setup.
Step 1: Download Samba
Currently, there are three methods to download the current Samba sources, either as a tarball of the latest stable release, or a development version via git or rsync. If you hope to work with the team on a development version to resolve issues you may hit via code changes, we recommend using the git method for downloading Samba, as it makes getting updates easier, and also allows you to integrate test patches from Samba developers more easily in case of problems.
In the following examples we will assume that your top-level source is named samba-master. If you downloaded a tarball this will instead be based on the name of the tarball downloaded (e.g. samba-4.0.0 for the tarball samba-4.0.0.tar.gz). Also note that in the master branch the Samba 4 code in our current git tree is now located in the top level directory.
Downloading a tarball
If you wish to use a released version of Samba 4.0, you can download the latest Samba 4.0 tarball from the Samba website
Downloading via git
Git allows you to download the source tree via either the git or httpprotocols. In general, the git protocol is the preferred choice since it compresses the data being transferred. To download the source tree via git, run the following command:
$ git clone git://git.samba.org/samba.git samba-master
Alternatively, if you prefer to use the http protocol, run the following command:
$ git clone http://gitweb.samba.org/samba.git samba-master
Either command will create a directory called samba-master in the current directory.
Updating via git
If you already have downloaded the source tree via git and want to update the tree to the latest version, run the following command in your samba-master directory:
$ git pull
If you get an error like this:
fatal: Unable to create '[...]/samba_master/.git/index.lock': File exists.
Run the command below to reset your tree.
If you are having trouble compiling the source, it may be due to stale files. You can reset your git tree to correct these errors. To reset your git tree, run the following command in your samba-master directory:
$ git clean -x -f -d
Downloading via rsync
If git is not available to you, rsync is the next best choice. To download the source tree via rsync, run the following command:
$ rsync -avz samba.org::ftp/unpacked/samba_4_0_test/ samba-master
This command will create a directory called samba-master in the current directory, containing a checked out git repository. If you plan on using git to manage the tree, you will need to run the following commands in your samba-master directory:
$ cd samba-master/ $ rm .git/refs/tags/* $ rm -r .git/refs/remotes/ $ git config remote.origin.url git://git.samba.org/samba.git $ git config --add remote.origin.fetch +refs/tags/*:refs/tags/* (this line is optional) $ git fetch
Note you can ignore this error from git fetch:
error: refs/heads/master does not point to a valid object!
Refer to the Updating via git instructions on how to manage the source tree with git.