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