2016-07-21 05:15:54 +03:00
HACKING ON SYSTEMD
We welcome all contributions to systemd. If you notice a bug or a missing
feature, please feel invited to fix it, and submit your work as a github Pull
Request (PR):
https://github.com/systemd/systemd/pull/new
Please make sure to follow our Coding Style when submitting patches. See
CODING_STYLE for details. Also have a look at our Contribution Guidelines:
https://github.com/systemd/systemd/blob/master/.github/CONTRIBUTING.md
2017-11-04 23:02:35 +03:00
When adding new functionality, tests should be added. For shared functionality
(in src/basic and src/shared) unit tests should be sufficient. The general
policy is to keep tests in matching files underneath src/test,
e.g. src/test/test-path-util.c contains tests for any functions in
src/basic/path-util.c. If adding a new source file, consider adding a matching
test executable. For features at a higher level, tests in src/test/ are very
strongly recommended. If that is no possible, integration tests in test/ are
encouraged.
2016-07-21 05:15:54 +03:00
Please always test your work before submitting a PR. For many of the components
of systemd testing is straight-forward as you can simply compile systemd and
run the relevant tool from the build directory.
For some components (most importantly, systemd/PID1 itself) this is not
possible, however. In order to simplify testing for cases like this we provide
a set of "mkosi" build files directly in the source tree. "mkosi" is a tool for
building clean OS images from an upstream distribution in combination with a
fresh build of the project in the local working directory. To make use of this,
please acquire "mkosi" from https://github.com/systemd/mkosi first, unless your
distribution has packaged it already and you can get it from there. After the
tool is installed it is sufficient to type "mkosi" in the systemd project
directory to generate a disk image "image.raw" you can boot either in
systemd-nspawn or in an UEFI-capable VM:
# systemd-nspawn -bi image.raw
or:
2017-06-21 00:16:16 +03:00
# qemu-system-x86_64 -enable-kvm -m 512 -smp 2 -bios /usr/share/edk2/ovmf/OVMF_CODE.fd -hda image.raw
2016-07-21 05:15:54 +03:00
Every time you rerun the "mkosi" command a fresh image is built, incorporating
all current changes you made to the project tree.
Alternatively, you may install the systemd version from your git check-out
directly on top of your host system's directory tree. This mostly works fine,
but of course you should know what you are doing as you might make your system
unbootable in case of a bug in your changes. Also, you might step into your
package manager's territory with this. Be careful!
And never forget: most distributions provide very simple and convenient ways to
install all development packages necessary to build systemd. For example, on
Fedora the following command line should be sufficient to install all of
systemd's build dependencies:
# dnf builddep systemd
Putting this all together, here's a series of commands for preparing a patch
for systemd (this example is for Fedora):
2016-11-06 05:21:17 +03:00
$ sudo dnf builddep systemd # install build dependencies
$ sudo dnf install mkosi # install tool to quickly build images
2016-07-21 05:15:54 +03:00
$ git clone https://github.com/systemd/systemd.git
$ cd systemd
$ vim src/core/main.c # or wherever you'd like to make your changes
2017-07-14 02:38:50 +03:00
$ meson build # configure the build
$ ninja -C build # build it locally, see if everything compiles fine
$ ninja -C build test # run some simple regression tests
2016-07-21 05:15:54 +03:00
$ sudo mkosi # build a test image
$ sudo systemd-nspawn -bi image.raw # boot up the test image
$ git add -p # interactively put together your patch
$ git commit # commit it
2017-07-14 02:38:50 +03:00
$ git push REMOTE HEAD:refs/heads/BRANCH
# where REMOTE is your "fork" on github
# and BRANCH is a branch name.
2016-07-21 05:15:54 +03:00
2017-07-14 02:38:50 +03:00
And after that, head over to your repo on github and click "Compare & pull request"
2016-07-21 05:15:54 +03:00
Happy hacking!