[DOC PATCH] Thread::Signal.pm
[p5sagit/p5-mst-13.2.git] / Porting / repository.pod
CommitLineData
0c97a5ed 1=head1 NAME
2
3repository - Using the Perl repository
4
0cfb3454 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 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 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 112Use a remote username of perlrep. (The account on the repository which
113provides the end-point of the ssh tunnel is named "perlrep".)
0c97a5ed 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
156resides. Its IP address is 199.60.48.20.
0c97a5ed 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
202Perforce username, a dash, and your hostname)
0c97a5ed 203when you first start using the perl repository and then
2f6eead3 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 221via NFS then you may be able to get away with only one client name,
222but be careful.
0c97a5ed 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 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 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
261for the first time, you should use the C<p4 user> and
262C<p4 client> commands to tell perforce the details of your
263new username and your new client workspace specifications.
264
265=head1 Ending a Repository Session
266
267When you have finished a session using the repository, you
268should kill off the ssh client process to break the tunnel.
269Since ssh forked itself into the background, you'll need to use
270something like ps with the appropriate options to find the ssh
271process and then kill it manually. The default signal of
272SIGTERM is fine.
273
274=head1 Overview of the Repository
275
276Please read at least the introductory sections of the Perforce
277User Guide (and perhaps the Quick Start Guide as well) before
278reading this section.
279
280Every repository user typically "owns" a "branch" of the mainline
281code in the repository. They hold the "pumpkin" for things in this
282area, and are usually the only user who will modify files there.
283This is not strictly enforced in order to allow the flexibility
284of other users stealing the pumpkin for short periods with the
285owner's permission.
286
287Here is the current structure of the repository:
288
289 /----+-----perl - Mainline development (bleadperl)
f704d51e 290 +-----perlio - PerlIO Pumpkin's Perl
0c97a5ed 291 +-----vmsperl - VMS Pumpkin's Perl
292 +-----maint-5.004------perl - Maintainance branches
293 +-----maint-5.005------perl
294 +-----maint-5.6------perl
f704d51e 295 +-----maint-5.6------pureperl
0c97a5ed 296
297Perforce uses a branching model that simply tracks relationships
298between files. It does not care about directories at all, so
299any file can be a branch of any other file--the fully qualified
300depot path name (of the form //depot/foo/bar.c) uniquely determines
301a file for the purpose of establishing branching relationships.
302Since a branch usually involves hundreds of files, such relationships
303are typically specified en masse using a branch map (try `p4 help branch`).
304`p4 branches` lists the existing branches that have been set up.
305`p4 branch -o branchname` can be used to view the map for a particular
306branch, if you want to determine the ancestor for a particular set of
307files.
308
309The mainline (aka "trunk") code in the Perl repository is under
310"//depot/perl/...". Most branches typically map its entire
311contents under a directory that goes by the same name as the branch
f704d51e 312name. Thus the contents of the perlio branch are to be found
313in //depot/perlio.
0c97a5ed 314
315Run `p4 client` to specify how the repository contents should map to
316your local disk. Most users will typically have a client map that
317includes at least their entire branch and the contents of the mainline.
318
319Run `p4 changes -l -m10` to check on the activity in the repository.
320//depot/perl/Porting/genlog is useful to get an annotated changelog
321that shows files and branches. You can use this listing to determine
322if there are any changes in the mainline that you need to merge into
323your own branch. A typical merging session looks like this:
324
f704d51e 325 % cd ~/p4view/perlio
326 % p4 integrate -b perlio # to bring parent changes into perlio
327 % p4 resolve -am ./... # auto merge the changes
0c97a5ed 328 % p4 resolve ./... # manual merge conflicting changes
329 % p4 submit ./... # check in
330
f704d51e 331If the owner of the mainline wants to bring the changes in perlio
0c97a5ed 332back into the mainline, they do:
333
f704d51e 334 % p4 integrate -r -b perlio
0c97a5ed 335 ...
336
337Generating a patch for change#42 is done as follows:
338
a2c6387b 339 % p4genpatch 42 > change-42.patch
0c97a5ed 340
a2c6387b 341F<p4genpatch> is to be found in //depot/perl/Porting/.
f704d51e 342
343The usual routine to apply a patch is
344
345 % p4 edit file.c file.h
346 % patch < patch.txt
347
348(any necessary, re-Configure, make regen_headers, make clean, etc, here)
349
350 % make all test
351
352(preferably make all test in several platforms and under several
353different Configurations)
354
355 % while unhappy
356 do
357 $EDITOR
358 make all test
359 done
360 % p4 submit
361
362Other useful Perforce commands
363
364 % p4 describe -du 12345 # show change 12345
365
366Note: the output of "p4 describe" is not in proper diff format, use
a2c6387b 367the F<Porting/p4genpatch> to get a diff-compatible format.
f704d51e 368
369 % p4 diff -se ./... # have I modified something but forgotten
370 # to "p4 edit", easy faux pas with autogenerated
371 # files like proto.h, or if one forgets to
372 # look carefully which files a patch modifies
373 % p4 sync file.h # if someone else has modified file.h
374 % p4 opened # which files are opened (p4 edit) by me
375 % p4 opened -a # which files are opened by anybody
376 % p4 diff -du file.c # what changes have I done
377 % p4 revert file.h # never mind my changes
378 % p4 sync -f argh.c # forcibly synchronize your file
379 # from the repository
380 % p4 diff -sr | p4 -x - revert
381 # throw away (opened but) unchanged files
382 # (in Perforce it's a little bit too easy
383 # to checkin unchanged files)
384
385Integrate patch 12345 from the mainline to the maint-5.6 branch:
386(you have to in the directory that has both the mainline and
387the maint-5.6/perl as subdirectories)
388
389 % p4 integrate -d perl/...@12345,12345 maint-5.6/perl/...
390
391Integrate patches 12347-12350 from the perlio branch to the mainline:
392
393 % p4 integrate -d perlio/...@12347,12350 perl/...
0c97a5ed 394
395=head1 Contact Information
396
b09defb6 397The mail alias <perl-repository-keepers@perl.org> can be used to reach
398all current users of the repository.
0c97a5ed 399
400The repository keeper is currently Gurusamy Sarathy
401<gsar@activestate.com>.
402
403=head1 AUTHORS
404
405Malcolm Beattie, mbeattie@sable.ox.ac.uk, 24 June 1997.
406
407Gurusamy Sarathy, gsar@activestate.com, 8 May 1999.
408
f704d51e 409Slightly updated by Simon Cozens, simon@brecon.co.uk, 3 July 2000.
410
411More updates by Jarkko Hietaniemi, jhi@iki.fi, 28 June 2001.
0c97a5ed 412
2f6eead3 413Perforce clarifications by Randall Gellens, rcg@users.sourceforge.net, 12 July 2001.
414
0c97a5ed 415=cut