xref: /dragonfly/share/man/man7/development.7 (revision 5868d2b9)
1.\"
2.\" Copyright (c) 2008
3.\"	The DragonFly Project.  All rights reserved.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\"
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in
13.\"    the documentation and/or other materials provided with the
14.\"    distribution.
15.\" 3. Neither the name of The DragonFly Project nor the names of its
16.\"    contributors may be used to endorse or promote products derived
17.\"    from this software without specific, prior written permission.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22.\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
23.\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24.\" INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
25.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
29.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.Dd May 7, 2012
33.Dt DEVELOPMENT 7
34.Os
35.Sh NAME
36.Nm development
37.Nd quick starter for development with the DragonFly codebase
38.Sh DESCRIPTION
39.Dx
40uses the
41.Xr git 1
42distributed revision control system.
43If it is not already on the system, it needs to be installed via
44.Xr pkgsrc 7
45.Pa ( /usr/pkgsrc/devel/scmgit ) .
46.Pp
47The
48.Sx EXAMPLES
49section gives initial information to get going with development on
50.Dx .
51Please refer to the
52.Xr git 1
53manual pages and other related documents for further information on git's
54capabilities and how to use them.
55The
56.Sx SEE ALSO
57section below has some links.
58.Pp
59For information on how to build the
60.Dx
61system from source code, see
62.Xr build 7 .
63For information on how to build the LiveCD, LiveDVD or thumb drive image, see
64.Xr release 7 .
65.Pp
66For a specification of
67.Dx Ap s
68preferred source code style, refer to
69.Xr style 9 .
70An
71.Xr emacs 1
72function to switch C-mode to this style (more or less) can be found in
73.Pa /usr/share/misc/dragonfly.el .
74.Sh EXAMPLES
75A fresh copy of the repository can be cloned anywhere.
76Note that the directory to clone into
77.Pa ( /usr/src
78in the following example) must not exist, so all previous work in this
79directory has to be saved and the directory be removed prior to cloning.
80Also note that while the main repository is on
81.Pa crater ,
82it is recommended that one of the
83.Dx
84mirrors be used instead.
85.Pp
86Simple setup and updating of local repository is done using
87.Pa /usr/Makefile :
88.Bd -literal -offset 4n
89cd /usr
90make help		# get help
91make src-checkout	# initial setup
92make src-update
93.Ed
94.Pp
95Somewhat finer control can be achieved using
96.Xr git 1
97directly.
98To clone the repository and check out the master branch (this will take
99some time):
100.Bd -literal -offset 4n
101cd /usr
102git clone -o crater git://crater.dragonflybsd.org/dragonfly.git src
103cd src
104.Ed
105.Pp
106The repository can be held up to date by pulling frequently (to set up a
107.Xr cron 8
108job,
109.Xr git 1 Ap s
110.Fl Fl git-dir
111option can be used):
112.Bd -literal -offset 4n
113cd /usr/src
114git pull
115.Ed
116.Pp
117It is not recommended to work directly in the master branch.
118To create and checkout a working branch:
119.Bd -literal -offset 4n
120git checkout -b work
121.Ed
122.Pp
123To create and checkout a branch of the
124.Dx 2.0
125release (called
126.Sy rel2_0 ) :
127.Bd -literal -offset 4n
128git checkout -b rel2_0 crater/DragonFly_RELEASE_2_0
129.Ed
130.Pp
131Branches can be deleted just as easy:
132.Bd -literal -offset 4n
133git branch -d work
134.Ed
135.Pp
136After changes have been made to a branch, they can be committed:
137.Bd -literal -offset 4n
138git commit -a
139.Ed
140.Pp
141.Xr git-commit 1 Ap s
142.Fl m
143and
144.Fl F
145options can be used to specify a commit message on the command line or read
146it from a file, respectively.
147.Pp
148Finally, branches can be merged with the (updated) master by using
149.Cm rebase :
150.Bd -literal -offset 4n
151git checkout master
152git pull
153git checkout work
154git rebase master
155.Ed
156.Sh VENDOR IMPORTS
157When importing vendor sources, make sure that you don't import
158too many unnecessary sources.
159Especially test suites that are not used by the
160.Dx
161build are good candidates for being stripped away.
162These instructions assume that you have already extracted
163the source package into its final directory and that they are
164trimmed appropriately.
165.Pp
166.Em \&Do not change the vendor sources before importing them
167on the vendor branch!
168Necessary changes to the vendor sources can be applied to
169.Pa master
170after the import.
171.Pp
172For the following commands, we will import the imaginary package
173.Nm foo-2.3
174into
175.Pa /usr/src/contrib/foo .
176If this is the first import of
177.Nm foo ,
178you will have to choose the name of the vendor branch.
179Customarily, this will be
180.Pa vendor/FOO .
181However, if you intend to maintain multiple vendor sources for the
182same package
183.Em concurrently ,
184you should choose a branch name which includes part of the version,
185i.e.\&
186.Pa vendor/FOO2 .
187.Pp
188As a first step, we trick git to work on the vendor branch instead of on
189.Pa master .
190Be careful, since after issuing this command all your commits will go to the
191vendor branch, but you will commit
192.Em the whole working tree
193and not just the vendor sources!
194Thus you have to specify the exact directory for
195.Li git commit .
196In order to commit, you will have to add the new sources first.
197.Pp
198If the vendor branch already exists, make sure that you have a local vendor
199branch which is up to date.
200To this end, run:
201.Bd -literal -offset 4n
202git update-ref refs/heads/vendor/FOO origin/vendor/FOO
203.Ed
204.Pp
205The next commands perform the actual import.
206.Bd -literal -offset 4n
207git symbolic-ref HEAD refs/heads/vendor/FOO
208git add contrib/foo
209git commit -m "Import foo-2.3" contrib/foo
210.Ed
211.Pp
212With these commands we have imported the vendor sources on their own branch.
213In the next step, we merge the vendor branch into master.
214.Bd -literal -offset 4n
215git checkout master
216git merge vendor/FOO
217.Ed
218.Pp
219Now you are free to change the sources in contrib/foo, since you are
220back on the
221.Pa master
222branch.
223The first thing to do is to add
224.Pa README.DRAGONFLY
225and
226.Pa README.DELETED .
227The former documents how the imported sources can be obtained, including
228a checksum of the tarball.
229The latter lists all files and directories that have been removed from the
230source package.
231You should use the
232.Pa /usr/src/tools/tools/genreadmedeleted/genreadmedeleted
233shell script to generate this file.
234Commit the
235.Pa README Ns s
236first, then commit your local changes to the sources:
237.Bd -literal -offset 4n
238git add contrib/foo/README.D*
239git commit -m "foo: add our READMEs"
240.Ed
241.Pp
242Finally, push master and the vendor branch to crater:
243.Bd -literal -offset 4n
244git push crater master vendor/FOO
245.Ed
246.Sh SEE ALSO
247.Xr git 1 Pq Pa pkgsrc/devel/scmgit ,
248.Xr build 7 ,
249.Xr committer 7 ,
250.Xr release 7
251.Rs
252.%T "Documentation on git's page"
253.%O "http://git-scm.com/documentation"
254.Re
255.Rs
256.%T "Git Magic"
257.%O "http://www-cs-students.stanford.edu/~blynn/gitmagic/"
258.Re
259.Sh HISTORY
260The
261.Nm
262manual page was originally written by
263.An Matthew Dillon Aq dillon@FreeBSD.org
264and first appeared
265in
266.Fx 5.0 ,
267December 2002.
268It was rewritten when
269.Dx
270switched to
271.Xr git 1 .
272