📄 perlhack.pod
字号:
$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 checkingfile checksums before updating. Not all NFS systems supportreliable utime support (when used over the NFS).=back=item rsync'ing the patchesThe source tree is maintained by the pumpking who applies patches tothe files in the tree. These patches are either created by thepumpking himself using C<diff -c> after updating the file manually orby applying patches sent in by posters on the perl5-porters list.These patches are also saved and rsync'able, so you can apply themyourself to the source files.Presuming you are in a directory where your patches reside, you canget them in sync with # rsync -avz rsync://public.activestate.com/perl-current-diffs/ .This makes sure the latest available patch is downloaded to yourpatch directory.It's then up to you to apply these patches, using something like # last="`cat ../perl-current/.patch`.gz" # rsync -avz rsync://public.activestate.com/perl-current-diffs/ . # find . -name '*.gz' -newer $last -exec gzcat {} \; >blead.patch # cd ../perl-current # patch -p1 -N <../perl-current-diffs/blead.patchor, since this is only a hint towards how it works, use CPAN-patchaperlfrom Andreas K鰊ig to have better control over the patching process.=back=head2 Why rsync the source tree=over 4=item It's easier to rsync the source treeSince you don't have to apply the patches yourself, you are sure allfiles in the source tree are in the right state.=item It's more reliableWhile both the rsync-able source and patch areas are automaticallyupdated every few minutes, keep in mind that applying patches maysometimes mean careful hand-holding, especially if your version ofthe C<patch> program does not understand how to deal with new files,files with 8-bit characters, or files without trailing newlines.=back=head2 Why rsync the patches=over 4=item It's easier to rsync the patchesIf you have more than one machine that you want to keep in track withbleadperl, it's easier to rsync the patches only once and then applythem to all the source trees on the different machines.In case you try to keep in pace on 5 different machines, for whichonly one of them has access to the WAN, rsync'ing all the sourcetrees should than be done 5 times over the NFS. Havingrsync'ed the patches only once, I can apply them to all the sourcetrees automatically. Need you say more ;-)=item It's a good referenceIf 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 diveinto the sources. If you are a seasoned perl core diver, you don'tneed no manuals, tips, roadmaps, perlguts.pod or other aids to findyour way around. But if you are a starter, the patches may help youin finding where you should start and how to change the bits thatbug you.The file B<Changes> is updated on occasions the pumpking sees as hisown little sync points. On those occasions, he releases a tar-ball ofthe current source tree (i.e. perl@7582.tar.gz), which will be anexcellent point to start with when choosing to use the 'rsync thepatches' scheme. Starting with perl@7582, which means a set of sourcefiles on which the latest applied patch is number 7582, you apply allsucceeding patches available from then on (7583, 7584, ...).You can use the patches later as a kind of search archive.=over 4=item Finding a start pointIf you want to fix/change the behaviour of function/feature Foo, justscan the patches for patches that mention Foo either in the subject,the comments, or the body of the fix. A good chance the patch showsyou the files that are affected by that patch which are very likelyto be the starting point of your journey into the guts of perl.=item Finding how to fix a bugIf you've found I<where> the function/feature Foo misbehaves, but youdon't know how to fix it (but you do know the change you want tomake), you can, again, peruse the patches for similar changes andlook how others apply the fix.=item Finding the source of misbehaviourWhen you keep in sync with bleadperl, the pumpking would love toI<see> that the community efforts really work. So after each of hissync points, you are to 'make test' to check if everything is stillin working order. If it is, you do 'make ok', which will send an OKreport to I<perlbug@perl.org>. (If you do not have access to a mailerfrom the system you just finished successfully 'make test', you cando 'make okfile', which creates the file C<perl.ok>, which you canthan take to your favourite mailer and mail yourself).But of course, as always, things will not always lead to a successpath, and one or more test do not pass the 'make test'. Beforesending in a bug report (using 'make nok' or 'make nokfile'), checkthe mailing list if someone else has reported the bug already and ifso, confirm it by replying to that message. If not, you might want totrace 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 ofpatches to see which patch changed what file and what change causedthe misbehaviour. If you note that in the bug report, it saves theone trying to solve it, looking for that point.=backIf searching the patches is too bothersome, you might consider usingperl's bugtron to find more information about discussions andramblings on posted bugs.If you want to get the best of both worlds, rsync both the sourcetree for convenience, reliability and ease and rsync the patchesfor reference.=back=head2 Working with the sourceBecause you cannot use the Perforce client, you cannot easily generatediffs against the repository, nor will merges occur when you updatevia rsync. If you edit a file locally and then rsync against thelatest source, changes made in the remote copy will I<overwrite> yourlocal versions!The best way to deal with this is to maintain a tree of symlinks tothe rsync'd source. Then, when you want to edit a file, you removethe symlink, copy the real file into the other tree, and edit it. Youcan then diff your edited file against the original to generate apatch, and you can safely update the original tree.Perl's F<Configure> script can generate this tree of symlinks for you.The following example assumes that you have used rsync to pull a copyof the Perl source into the F<perl-rsync> directory. In the directoryabove that one, you can execute the following commands: mkdir perl-dev cd perl-dev ../perl-rsync/Configure -Dmksymlinks -Dusedevel -D"optimize=-g"This will start the Perl configuration process. After a few prompts,you should see something like this: Symbolic links are supported. Checking how to test for symbolic links... Your builtin 'test -h' may be broken. Trying external '/usr/bin/test -h'. You can test for symbolic links with '/usr/bin/test -h'. Creating the symbolic links... (First creating the subdirectories...) (Then creating the symlinks...)The specifics may vary based on your operating system, of course.After you see this, you can abort the F<Configure> script, and youwill see that the directory you are in has a tree of symlinks to theF<perl-rsync> directories and files.If you plan to do a lot of work with the Perl source, here are someBourne shell script functions that can make your life easier: function edit { if [ -L $1 ]; then mv $1 $1.orig cp $1.orig $1 vi $1 else vi $1 fi } function unedit { if [ -L $1.orig ]; then rm $1 mv $1.orig $1 fi }Replace "vi" with your favorite flavor of editor.Here is another function which will quickly generate a patch for thefiles which have been edited in your symlink tree: mkpatchorig() { local diffopts for f in `find . -name '*.orig' | sed s,^\./,,` do case `echo $f | sed 's,.orig$,,;s,.*\.,,'` in c) diffopts=-p ;; pod) diffopts='-F^=' ;; *) diffopts= ;; esac diff -du $diffopts $f `echo $f | sed 's,.orig$,,'` done }This function produces patches which include enough context to makeyour changes obvious. This makes it easier for the Perl pumpking(s)to review them when you send them to the perl5-porters list, and thatmeans they're more likely to get applied.This function assumed a GNU diff, and may require some tweaking forother diff variants.=head2 Perlbug administrationThere is a single remote administrative interface for modifying bug status,category, open issues etc. using the B<RT> bugtracker system, maintainedby Robert Spier. Become an administrator, and close any bugs you can getyour sticky mitts on: http://bugs.perl.org/To email the bug system administrators: "perlbug-admin" <perlbug-admin@perl.org>=head2 Submitting patchesAlways submit patches to I<perl5-porters@perl.org>. If you'repatching a core module and there's an author listed, send the author acopy (see L<Patching a core module>). This lets other porters reviewyour patch, which catches a surprising number of errors in patches.Either use the diff program (available in source code form fromftp://ftp.gnu.org/pub/gnu/ , or use Johan Vromans' I<makepatch>(available from I<CPAN/authors/id/JV/>). Unified diffs are preferred,but context diffs are accepted. Do not send RCS-style diffs or diffswithout context lines. More information is given in theI<Porting/patching.pod> file in the Perl source distribution. Pleasepatch against the latest B<development> version. (e.g., even if you'refixing a bug in the 5.8 track, patch against the latest B<development>version rsynced from rsync://public.activestate.com/perl-current/ )If changes are accepted, they are applied to the development branch. Thenthe 5.8 pumpking decides which of those patches is to be backported to themaint branch. Only patches that survive the heat of the developmentbranch get applied to maintenance versions.Your patch should update the documentation and test suite. SeeL<Writing a test>. If you have added or removed files in the distribution,edit the MANIFEST file accordingly, sort the MANIFEST file usingC<make manisort>, and include those changes as part of your patch.Patching documentation also follows the same order: if accepted, a patchis first applied to B<development>, and if relevant then it's backportedto B<maintenance>. (With an exception for some patches that documentbehaviour that only appears in the maintenance branch, but which haschanged in the development version.)To report a bug in Perl, use the program I<perlbug> which comes withPerl (if you can't get Perl to work, send mail to the addressI<perlbug@perl.org> or I<perlbug@perl.com>). Reporting bugs throughI<perlbug> feeds into the automated bug-tracking system, access towhich is provided through the web at http://rt.perl.org/rt3/ . Itoften pays to check the archives of the perl5-porters mailing list tosee whether the bug you're reporting has been reported before, and ifso whether it was considered a bug. See above for the location ofthe searchable archives.The CPAN testers ( http://testers.cpan.org/ ) are a group ofvolunteers who test CPAN modules on a variety of platforms. PerlSmokers ( http://www.nntp.perl.org/group/perl.daily-build andhttp://www.nntp.perl.org/group/perl.daily-build.reports/ )automatically test Perl source releases on platforms with variousconfigurations. Both efforts welcome volunteers. In order to getinvolved in smoke testing of the perl itself visitL<http://search.cpan.org/dist/Test-Smoke>. In order to start smoketesting CPAN modules visit L<http://search.cpan.org/dist/CPAN-YACSmoke/>or L<http://search.cpan.org/dist/POE-Component-CPAN-YACSmoke/> orL<http://search.cpan.org/dist/CPAN-Reporter/>.It's a good idea to read and lurk for a while before chipping in.That way you'll get to see the dynamic of the conversations, learn thepersonalities of the players, and hopefully be better prepared to makea useful contribution when do you speak up.If after all this you still think you want to join the perl5-portersmailing list, send mail to I<perl5-porters-subscribe@perl.org>. Tounsubscribe, send mail to I<perl5-porters-unsubscribe@perl.org>.To hack on the Perl guts, you'll need to read the following things:=over 3=item L<perlguts>This is of paramount importance, since it's the documentation of whatgoes where in the Perl source. Read it over a couple of times and itmight start to make sense - don't worry if it doesn't yet, because thebest way to study it is to read it in conjunction with poking at Perl
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -