This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
configpm: about 1.5K less per thread
[perl5.git] / Porting / repository.pod
CommitLineData
0c97a5ed
JH
1=head1 NAME
2
3repository - Using the Perl repository
4
0cfb3454
GS
5=head1 Synopsis
6
7First, we assume here that you have already decided that you will
8need B<write> access to the repository. If all you need is B<read>
9access, there are much better ways to access the most current state of
10the perl repository, or explore individual files and patches therein.
11See L<perlhack> for details.
12
13This document describes what a Perl Porter needs to do to start using
14the Perl repository.
0c97a5ed
JH
15
16=head1 Prerequisites
17
18You'll need to get hold of the following software.
19
20=over 4
21
22=item Perforce
23
24Download a perforce client from:
25
26 http://www.perforce.com/perforce/loadprog.html
27
28You'll probably also want to look at:
29
30 http://www.perforce.com/perforce/technical.html
31
32where you can look at or download its documentation.
33
34=item ssh
35
36If you don't already have access to an ssh client, then look at its
37home site C<http://www.cs.hut.fi/ssh> which mentions ftp sites from
38which it's available. You only need to build the client parts (ssh
39and ssh-keygen should suffice).
40
41=back
42
43=head1 Creating an SSH Key Pair
44
45If you already use ssh and want to use the same key pair for perl
46repository access then you can skip the rest of this section.
47Otherwise, generate an ssh key pair for use with the repository
48by typing the command
49
50 ssh-keygen
51
52After generating a key pair and testing it, ssh-keygen will ask you
53to enter a filename in which to save the key. The default it offers
54will be the file F<~/.ssh/identity> which is suitable unless you
55particularly want to keep separate ssh identities for some reason.
56If so, you could save the perl repository private key in the file
57F<~/.ssh/perl>, for example, but I will use the standard filename
58in the remainder of the examples of this document.
59
60After typing in the filename, it will prompt you to type in a
61passphrase. The private key will itself be encrypted so that it is
62usable only when that passphrase is typed. (When using ssh, you will
63be prompted when it requires a pass phrase to unlock a private key.)
64If you provide a blank passphrase then no passphrase will be needed
65to unlock the key and, as a consequence, anyone who gains access to
66the key file gains access to accounts protected with that key
67(barring additional configuration to restrict access by IP address).
68
69When you have typed the passphrase in twice, ssh-keygen will confirm
70where it has saved the private key (in the filename you gave and
71with permissions set to be only readable by you), what your public
72key is (don't worry: you don't need to memorise it) and where it
73has saved the corresponding public key. The public key is saved in
74a filename corresponding to your private key's filename but with
75".pub" appended, usually F<~/.ssh/identity.pub>. That public key
76can be (but need not be) world readable. It is not used by your
77own system at all.
78
79=head1 Notifying the Repository Keeper
80
81Mail the contents of that public key file to the keeper of the perl
82repository (see L</Contact Information> below).
83When the key is added to the repository host's configuration file,
84you will be able to connect to it with ssh by using the corresponding
85private key file (after unlocking it with your chosen passphrase).
86
87=head1 Connecting to the Repository
88
89Connections to the repository are made by using ssh to provide a
90TCP "tunnel" rather than by using ssh to login to or invoke any
91ordinary commands on the repository. When you want to start a
92session using the repository, use the command
93
4bc101a5 94 ssh -l perlrep -f -q -x -L 1666:127.0.0.1:1666 sickle.activestate.com foo
0c97a5ed
JH
95
96If you are not using the default filename of F<~/.ssh/identity>
97to hold your perl repository private key then you'll need to add
98the option B<-i filename> to tell ssh where it is. Unless you chose
99a blank passphrase for that private key, ssh will prompt you for the
100passphrase to unlock that key. Then ssh will fork and put itself
101in the background, returning you (silently) to your shell prompt.
102The tunnel for repository access is now ready for use.
103
104For the sake of completeness (and for the case where the chosen
105port of 1666 is already in use on your machine), I'll briefly
106describe what all those ssh arguments are for.
107
108=over 4
109
4bc101a5 110=item B<-l perlrep>
0c97a5ed 111
4bc101a5
JH
112Use a remote username of perlrep. (The account on the repository which
113provides the end-point of the ssh tunnel is named "perlrep".)
0c97a5ed
JH
114
115=item B<-f>
116
117Tells ssh to fork and remain running in the background. Since ssh
118is only being used for its tunnelling capabilities, the command
119that ssh runs never does any I/O and can sit silently in the
120background.
121
122=item B<-q>
123
124Tells ssh to be quiet. Without this option, ssh will output a
125message each time you use a p4 command (since each p4 command
126tunnels over the ssh connection to reach the repository).
127
128=item B<-x>
129
130Tells ssh not to bother to set up a tunnel for X11 connections.
131The repository doesn't allow this anyway.
132
133=item B<-L 1666:127.0.0.1:1666>
134
135This is the important option. It tells ssh to listen out for
136connections made to port 1666 on your local machine. When such
137a connection is made, the ssh client tells the remote side
138(the corresponding ssh daemon on the repository) to make a
139connection to IP address 127.0.0.1, port 1666. Data flowing
140along that connection is tunnelled over the ssh connection
141(encrypted). The perforce daemon running on the repository
142only accepts connections from localhost and that is exactly
143where ssh-tunnelled connections appear to come from.
144
145If port 1666 is already in use on your machine then you can
146choose any non-privileged port (a number between 1024 and 65535)
147which happens to be free on your machine. It's the first of the
148three colon separated values that you should change. Picking
149port 2345 would mean changing the option to
150B<-L 2345:127.0.0.1:1666>. Whatever port number you choose should
151be used for the value of the P4PORT environment variable (q.v.).
152
153=item sickle.activestate.com
154
4bc101a5 155This is the canonical name of the host on which the perl repository
1cb8ef30 156resides.
0c97a5ed
JH
157
158=item foo
159
160This is a dummy place holder argument. Without an argument
161here, ssh will try to perform an interactive login to the
162repository which is not allowed. Ordinarily, this argument
163is for the one-off command which is to be executed on the
164remote host. However, the repository's ssh configuration
165file uses the "command=" option to force a particular
166command to run so the actual value of the argument is
167ignored. The command that's actually run merely pauses and
168waits for the ssh connection to drop, then exits.
169
170=back
171
172=head1 Problems
173
174You should normally get a prompt that asks for the passphrase
175for your RSA key when you connect with the ssh command shown
176above. If you see a prompt that looks like:
177
178 perlrep@sickle.activestate.com's password:
179
180Then you either don't have a ~/.ssh/identity file corresponding
181to your public key, or your ~/.ssh/identity file is not readable.
182Fix the problem and try again.
183
184=head1 Using the Perforce Client
185
186Remember to read the documentation for Perforce. You need
187to make sure that three environment variable are set
188correctly before using the p4 client with the perl repository.
189
190=over 4
191
192=item P4PORT
193
194Set this to localhost:1666 (the port for your ssh client to listen on)
195unless that port is already in use on your host. If it is, see
196the section above on the B<-L 1666:127.0.0.1:1666> option to ssh.
197
198=item P4CLIENT
199
200The value of this is the name by which Perforce knows your
2f6eead3 201host's workspace. You need to pick a name (normally, your
83d05790 202Perforce username, a dash, and your host's short name)
0c97a5ed 203when you first start using the perl repository and then
2f6eead3
RG
204stick with it.
205
206Perforce keeps track of the files you have on your machine. It
207does this through your client. When you first sync a version of a
208file, the file comes from the server to your machine. If you sync
209the same file again the server does nothing because it
210knows you already have the file.
211
212You should NOT use the same client on different machines. If you do
213you probably won't get the files you expect, and may end up with
214nasty corruption. Perforce allows you to have as many clients as
215you want. For example, sally-home, sally-openbsd, sally-laptop.
216
217Also, never change the client's root and view at the same time.
218See C<http://www.perforce.com/perforce/doc.002/manuals/p4guide/04_details.html#1048341>
219
0c97a5ed 220If you have multiple hosts sharing the same directory structure
2f6eead3
RG
221via NFS then you may be able to get away with only one client name,
222but be careful.
0c97a5ed
JH
223
224The C<p4 clients> command lists all currently known clients.
225
226=item P4USER
227
228This is the username by which perforce knows you. Use your
229username if you have a well known or obvious one or else pick
230a new one which other perl5-porters will recognise. There is
2f6eead3
RG
231a licence limit on the number of these usernames, so be sure not
232to use more than one.
233
234It is very important to set a password for your Perforce username,
235or else anyone can impersonate you. Use the C<p4 passwd> command
236to do this. Once a password is set for your account, you'll need
237to tell Perforce what it is. You can do this by setting the
238environment variable P4PASSWD, or you can use the C<-P> flag
239with the C<p4> command.
240
241There are a few techniques you can use to avoid having to either
242set an environment variable or type the password on every command.
243One is to create a shell alias, for example, in bash, add something like
244 alias p4='p4 -P secret'
245to your F<.bash_profile> file. Another way is to create a small shell
246script, for example
247 #!/bin/bash
248 p4 -P secret $@
249And use this instead of running C<p4> directly.
250
251With either of these, be sure the file containing your password
252(the F<.bash_profile> or shell script file) is only readable by you.
0c97a5ed
JH
253
254The C<p4 users> command lists all currently known users.
255
256=back
257
258Once these three environment variables are set, you can use the
259perforce p4 client exactly as described in its documentation.
260After setting these variables and connecting to the repository
83d05790
GS
261for the first time, you should use the C<p4 user> command to
262set a valid email address for yourself. Also use the C<p4 client>
263command to specify your workspace specifications for each
264individual client from which you will interact with the repository.
0c97a5ed
JH
265
266=head1 Ending a Repository Session
267
268When you have finished a session using the repository, you
269should kill off the ssh client process to break the tunnel.
270Since ssh forked itself into the background, you'll need to use
271something like ps with the appropriate options to find the ssh
272process and then kill it manually. The default signal of
273SIGTERM is fine.
274
275=head1 Overview of the Repository
276
277Please read at least the introductory sections of the Perforce
278User Guide (and perhaps the Quick Start Guide as well) before
279reading this section.
280
281Every repository user typically "owns" a "branch" of the mainline
282code in the repository. They hold the "pumpkin" for things in this
283area, and are usually the only user who will modify files there.
284This is not strictly enforced in order to allow the flexibility
285of other users stealing the pumpkin for short periods with the
286owner's permission.
287
288Here is the current structure of the repository:
289
290 /----+-----perl - Mainline development (bleadperl)
f704d51e 291 +-----perlio - PerlIO Pumpkin's Perl
0c97a5ed
JH
292 +-----vmsperl - VMS Pumpkin's Perl
293 +-----maint-5.004------perl - Maintainance branches
294 +-----maint-5.005------perl
295 +-----maint-5.6------perl
f704d51e 296 +-----maint-5.6------pureperl
0c97a5ed
JH
297
298Perforce uses a branching model that simply tracks relationships
299between files. It does not care about directories at all, so
300any file can be a branch of any other file--the fully qualified
301depot path name (of the form //depot/foo/bar.c) uniquely determines
302a file for the purpose of establishing branching relationships.
303Since a branch usually involves hundreds of files, such relationships
304are typically specified en masse using a branch map (try `p4 help branch`).
305`p4 branches` lists the existing branches that have been set up.
306`p4 branch -o branchname` can be used to view the map for a particular
307branch, if you want to determine the ancestor for a particular set of
308files.
309
310The mainline (aka "trunk") code in the Perl repository is under
311"//depot/perl/...". Most branches typically map its entire
312contents under a directory that goes by the same name as the branch
f704d51e
JH
313name. Thus the contents of the perlio branch are to be found
314in //depot/perlio.
0c97a5ed
JH
315
316Run `p4 client` to specify how the repository contents should map to
317your local disk. Most users will typically have a client map that
318includes at least their entire branch and the contents of the mainline.
319
320Run `p4 changes -l -m10` to check on the activity in the repository.
321//depot/perl/Porting/genlog is useful to get an annotated changelog
322that shows files and branches. You can use this listing to determine
323if there are any changes in the mainline that you need to merge into
324your own branch. A typical merging session looks like this:
325
f704d51e
JH
326 % cd ~/p4view/perlio
327 % p4 integrate -b perlio # to bring parent changes into perlio
328 % p4 resolve -am ./... # auto merge the changes
0c97a5ed
JH
329 % p4 resolve ./... # manual merge conflicting changes
330 % p4 submit ./... # check in
331
f704d51e 332If the owner of the mainline wants to bring the changes in perlio
0c97a5ed
JH
333back into the mainline, they do:
334
f704d51e 335 % p4 integrate -r -b perlio
0c97a5ed
JH
336 ...
337
338Generating a patch for change#42 is done as follows:
339
a2c6387b 340 % p4genpatch 42 > change-42.patch
0c97a5ed 341
a2c6387b 342F<p4genpatch> is to be found in //depot/perl/Porting/.
f704d51e
JH
343
344The usual routine to apply a patch is
345
346 % p4 edit file.c file.h
347 % patch < patch.txt
348
349(any necessary, re-Configure, make regen_headers, make clean, etc, here)
350
351 % make all test
352
353(preferably make all test in several platforms and under several
354different Configurations)
355
356 % while unhappy
357 do
358 $EDITOR
359 make all test
360 done
361 % p4 submit
362
363Other useful Perforce commands
364
365 % p4 describe -du 12345 # show change 12345
366
367Note: the output of "p4 describe" is not in proper diff format, use
a2c6387b 368the F<Porting/p4genpatch> to get a diff-compatible format.
44897049
HS
369(Note that it may be easier to get one already prepared: grep
370L<perlhack> for APC, and append eg "/diffs/12345.gz" to one of the
371URLs to get a usable patch.)
f704d51e
JH
372
373 % p4 diff -se ./... # have I modified something but forgotten
374 # to "p4 edit", easy faux pas with autogenerated
375 # files like proto.h, or if one forgets to
376 # look carefully which files a patch modifies
377 % p4 sync file.h # if someone else has modified file.h
378 % p4 opened # which files are opened (p4 edit) by me
379 % p4 opened -a # which files are opened by anybody
380 % p4 diff -du file.c # what changes have I done
381 % p4 revert file.h # never mind my changes
382 % p4 sync -f argh.c # forcibly synchronize your file
383 # from the repository
384 % p4 diff -sr | p4 -x - revert
385 # throw away (opened but) unchanged files
386 # (in Perforce it's a little bit too easy
387 # to checkin unchanged files)
388
389Integrate patch 12345 from the mainline to the maint-5.6 branch:
390(you have to in the directory that has both the mainline and
391the maint-5.6/perl as subdirectories)
392
393 % p4 integrate -d perl/...@12345,12345 maint-5.6/perl/...
394
395Integrate patches 12347-12350 from the perlio branch to the mainline:
396
397 % p4 integrate -d perlio/...@12347,12350 perl/...
0c97a5ed
JH
398
399=head1 Contact Information
400
b09defb6
JH
401The mail alias <perl-repository-keepers@perl.org> can be used to reach
402all current users of the repository.
0c97a5ed
JH
403
404The repository keeper is currently Gurusamy Sarathy
405<gsar@activestate.com>.
406
407=head1 AUTHORS
408
409Malcolm Beattie, mbeattie@sable.ox.ac.uk, 24 June 1997.
410
411Gurusamy Sarathy, gsar@activestate.com, 8 May 1999.
412
f704d51e
JH
413Slightly updated by Simon Cozens, simon@brecon.co.uk, 3 July 2000.
414
415More updates by Jarkko Hietaniemi, jhi@iki.fi, 28 June 2001.
0c97a5ed 416
2f6eead3
RG
417Perforce clarifications by Randall Gellens, rcg@users.sourceforge.net, 12 July 2001.
418
0c97a5ed 419=cut