This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
integrate changes#7472,7474..7478,7481,7485,7489,7493,7494,7496,
[perl5.git] / pod / perlhack.pod
index 3abc1f7..21d8850 100644 (file)
@@ -194,6 +194,8 @@ around.  It refers to the standard distribution.  ``Hacking on the
 core'' means you're changing the C source code to the Perl
 interpreter.  ``A core module'' is one that ships with Perl.
 
+=head2 Keeping in sync
+
 The source code to the Perl interpreter, in its different versions, is
 kept in a repository managed by a revision control system (which is
 currently the Perforce program, see http://perforce.com/).  The
@@ -206,20 +208,256 @@ public release are available at this location:
 
     ftp://ftp.linux.activestate.com/pub/staff/gsar/APC/
 
-Selective parts are also visible via the rsync protocol.  To get all
-the individual changes to the mainline since the last development
-release, use the following command:
-
-    rsync -avz rsync://ftp.linux.activestate.com/perl-diffs perl-diffs
-
-Use this to get the latest source tree in full:
-
-    rsync -avz rsync://ftp.linux.activestate.com/perl-current perl-current
+If you are a member of the perl5-porters mailing list, it is a good
+thing to keep in touch with the most recent changes. If not only to
+verify if what you would have posted as a bug report isn't already
+solved in the most recent available perl development branch, also
+known as perl-current, bleading edge perl, bleedperl or bleadperl.
 
 Needless to say, the source code in perl-current is usually in a perpetual
 state of evolution.  You should expect it to be very buggy.  Do B<not> use
 it for any purpose other than testing and development.
 
+Keeping in sync with the most recent branch can be done in several ways,
+but the most convenient and reliable way is using B<rsync>, available at
+ftp://rsync.samba.org/pub/rsync/ .  (You can also get the most recent
+branch by FTP.)
+
+If you choose to keep in sync using rsync, there are two approaches
+to doing so:
+
+=over 4
+
+=item rsync'ing the source tree
+
+Presuming you are in the directory where your perl source resides
+and you have rsync installed and available, you can `upgrade' to
+the bleadperl using:
+
+ # rsync -avz rsync://ftp.linux.activestate.com/perl-current/ .
+
+This takes care of updating every single item in the source tree to
+the latest applied patch level, creating files that are new (to your
+distribution) and setting date/time stamps of existing files to
+reflect the bleadperl status.
+
+You can than check what patch was the latest that was applied by
+looking in the file B<.patch>, which will show the number of the
+latest patch.
+
+If you have more than one machine to keep in sync, and not all of
+them have access to the WAN (so you are not able to rsync all the
+source trees to the real source), there are some ways to get around
+this problem.
+
+=over 4
+
+=item Using rsync over the LAN
+
+Set up a local rsync server which makes the rsynced source tree
+available to the LAN and sync the other machines against this
+directory.
+
+From http://rsync.samba.org/README.html:
+
+   "Rsync uses rsh or ssh for communication. It does not need to be
+    setuid and requires no special privileges for installation.  It
+    does not require a inetd entry or a deamon.  You must, however,
+    have a working rsh or ssh system.  Using ssh is recommended for
+    its security features."
+
+=item Using pushing over the NFS
+
+Having the other systems mounted over the NFS, you can take an
+active pushing approach by checking the just updated tree against
+the other not-yet synced trees. An example would be
+
+  #!/usr/bin/perl -w
+
+  use strict;
+  use File::Copy;
+
+  my %MF = map {
+      m/(\S+)/;
+      $1 => [ (stat $1)[2, 7, 9] ];    # mode, size, mtime
+      } `cat MANIFEST`;
+
+  my %remote = map { $_ => "/$_/pro/3gl/CPAN/perl-5.7.1" } qw(host1 host2);
+
+  foreach my $host (keys %remote) {
+      unless (-d $remote{$host}) {
+         print STDERR "Cannot Xsync for host $host\n";
+         next;
+         }
+      foreach my $file (keys %MF) {
+         my $rfile = "$remote{$host}/$file";
+         my ($mode, $size, $mtime) = (stat $rfile)[2, 7, 9];
+         defined $size or ($mode, $size, $mtime) = (0, 0, 0);
+         $size == $MF{$file}[1] && $mtime == $MF{$file}[2] and next;
+         printf "%4s %-34s %8d %9d  %8d %9d\n",
+             $host, $file, $MF{$file}[1], $MF{$file}[2], $size, $mtime;
+         unlink $rfile;
+         copy ($file, $rfile);
+         utime time, $MF{$file}[2], $rfile;
+         chmod $MF{$file}[0], $rfile;
+         }
+      }
+
+though this is not perfect. It could be improved with checking
+file checksums before updating. Not all NFS systems support
+reliable utime support (when used over the NFS).
+
+=back
+
+=item rsync'ing the patches
+
+The source tree is maintained by the pumpking who applies patches to
+the files in the tree. These patches are either created by the
+pumpking himself using C<diff -c> after updating the file manually or
+by applying patches sent in by posters on the perl5-porters list.
+These patches are also saved and rsync'able, so you can apply them
+yourself to the source files.
+
+Presuming you are in a directory where your patches reside, you can
+get them in sync with
+
+ # rsync -avz rsync://ftp.linux.activestate.com/perl-current-diffs/ .
+
+This makes sure the latest available patch is downloaded to your
+patch directory.
+
+It's then up to you to apply these patches, using something like
+
+ # last=`ls -rt1 *.gz | tail -1`
+ # rsync -avz rsync://ftp.linux.activestate.com/perl-current-diffs/ .
+ # find . -name '*.gz' -newer $last -exec gzcat {} \; >blead.patch
+ # cd ../perl-current
+ # patch -p1 -N <../perl-current-diffs/blead.patch
+
+or, since this is only a hint towards how it works, use CPAN-patchaperl
+from Andreas König to have better control over the patching process.
+
+=back
+
+=head3 Why rsync the source tree
+
+=over 4
+
+=item It's easier
+
+Since you don't have to apply the patches yourself, you are sure all
+files in the source tree are in the right state.
+
+=item It's more recent
+
+According to Gurusamy Sarathy:
+
+   "... The rsync mirror is automatic and syncs with the repository
+    every five minutes.
+
+   "Updating the patch  area  still  requires  manual  intervention
+    (with all the goofiness that implies,  which you've noted)  and
+    is typically on a daily cycle.   Making this process  automatic
+    is on my tuit list, but don't ask me when."
+
+=item It's more reliable
+
+Well, since the patches are updated by hand, I don't have to say any
+more ... (see Sarathy's remark).
+
+=back
+
+=head3 Why rsync the patches
+
+=over 4
+
+=item It's easier
+
+If you have more than one machine that you want to keep in track with
+bleadperl, it's easier to rsync the patches only once and then apply
+them to all the source trees on the different machines.
+
+In case you try to keep in pace on 5 different machines, for which
+only one of them has access to the WAN, rsync'ing all the source
+trees should than be done 5 times over the NFS. Having
+rsync'ed the patches only once, I can apply them to all the source
+trees automatically. Need you say more ;-)
+
+=item It's a good reference
+
+If you do not only like to have the most recent development branch,
+but also like to B<fix> bugs, or extend features, you want to dive
+into the sources. If you are a seasoned perl core diver, you don't
+need no manuals, tips, roadmaps, perlguts.pod or other aids to find
+your way around. But if you are a starter, the patches may help you
+in finding where you should start and how to change the bits that
+bug you.
+
+The file B<Changes> is updated on occasions the pumpking sees as his
+own little sync points. On those occasions, he releases a tar-ball of
+the current source tree (i.e. perl@7582.tar.gz), which will be an
+excellent point to start with when choosing to use the 'rsync the
+patches' scheme. Starting with perl@7582, which means a set of source
+files on which the latest applied patch is number 7582, you apply all
+succeeding patches available from than on (7583, 7584, ...).
+
+You can use the patches later as a kind of search archive.
+
+=over 4
+
+=item Finding a start point
+
+If you want to fix/change the behaviour of function/feature Foo, just
+scan the patches for patches that mention Foo either in the subject,
+the comments, or the body of the fix. A good chance the patch shows
+you the files that are affected by that patch which are very likely
+to be the starting point of your journey into the guts of perl.
+
+=item Finding how to fix a bug
+
+If you've found I<where> the function/feature Foo misbehaves, but you
+don't know how to fix it (but you do know the change you want to
+make), you can, again, peruse the patches for similar changes and
+look how others apply the fix.
+
+=item Finding the source of misbehaviour
+
+When you keep in sync with bleadperl, the pumpking would love to
+I<see> that the community efforts realy work. So after each of his
+sync points, you are to 'make test' to check if everything is still
+in working order. If it is, you do 'make ok', which will send an OK
+report to perlbug@perl.org. (If you do not have access to a mailer
+from the system you just finished successfully 'make test', you can
+do 'make okfile', which creates the file C<perl.ok>, which you can
+than take to your favourite mailer and mail yourself).
+
+But of course, as always, things will not allways lead to a success
+path, and one or more test do not pass the 'make test'. Before
+sending in a bug report (using 'make nok' or 'make nokfile'), check
+the mailing list if someone else has reported the bug already and if
+so, confirm it by replying to that message. If not, you might want to
+trace the source of that misbehaviour B<before> sending in the bug,
+which will help all the other porters in finding the solution.
+
+Here the saved patches come in very handy. You can check the list of
+patches to see which patch changed what file and what change caused
+the misbehaviour. If you note that in the bug report, it saves the
+one trying to solve it, looking for that point.
+
+=back
+
+If searching the patches is too bothersome, you might consider using
+perl's bugtron to find more information about discussions and
+ramblings on posted bugs.
+
+=back
+
+If you want to get the best of both worlds, rsync both the source
+tree for convenience, reliability and ease and rsync the patches
+for reference.
+
+=head2 Submitting patches
+
 Always submit patches to I<perl5-porters@perl.org>.  This lets other
 porters review your patch, which catches a surprising number of errors
 in patches.  Either use the diff program (available in source code
@@ -827,7 +1065,7 @@ the tied C<push> is implemented; see C<av_push> in F<av.c>:
      7 call_method("PUSH", G_SCALAR|G_DISCARD);
      8 LEAVE;
      9 POPSTACK;
-       
+
 The lines which concern the mark stack are the first, fifth and last
 lines: they save away, restore and remove the current position of the
 argument stack. 
@@ -950,7 +1188,7 @@ useful options are probably
 
 Some of the functionality of the debugging code can be achieved using XS
 modules.
-    
+
     -Dr => use re 'debug'
     -Dx => use O 'Debug'
 
@@ -1012,7 +1250,7 @@ Run until the next breakpoint.
 
 Run until the end of the current function, then stop again.
 
-=item
+=item 'enter'
 
 Just pressing Enter will do the most recent operation again - it's a
 blessing when stepping through miles of source code.
@@ -1256,7 +1494,7 @@ this text in the description of C<pack>:
 All done. Now let's create the patch. F<Porting/patching.pod> tells us
 that if we're making major changes, we should copy the entire directory
 to somewhere safe before we begin fiddling, and then do
-    
+
     diff -ruN old new > patch
 
 However, we know which files we've changed, and we can simply do this:
@@ -1454,6 +1692,12 @@ working on and the changes they're making.
 
 =item *
 
+Do read the README associated with your operating system, e.g. README.aix
+on the IBM AIX OS. Don't hesitate to supply patches to that README if
+you find anything missing or changed over a new OS release.
+
+=item *
+
 Find an area of Perl that seems interesting to you, and see if you can
 work out how it works. Scan through the source, and step over it in the
 debugger. Play, poke, investigate, fiddle! You'll probably get to