Changeset 46981 for trunk/doc-new


Ignore:
Timestamp:
Feb 19, 2009, 3:01:43 AM (10 years ago)
Author:
markd@…
Message:

Clarify section on creating source code patches, and make the example more useful.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc-new/guide/xml/portfiledev.xml

    r41104 r46981  
    542542      <filename>patch-</filename><replaceable>&lt;directory&gt;</replaceable>-<replaceable>&lt;filename&gt;.diff</replaceable>,
    543543      as shown in this example:
    544       <filename>patch-src-Makefile.in.diff</filename>. Patch files should
    545       apply with "patch -p0'' from the working source directory of the
    546       port.</para>
     544      <filename>patch-src-Makefile.in.diff</filename>.</para>
    547545
    548546      <para>You may use patch files that patch multiple files under these
     
    571569          it.</para>
    572570
    573           <programlisting><prompt>%%</prompt> <userinput>cd foo-1.34/src</userinput>
     571          <programlisting><prompt>%%</prompt> <userinput>cd ~/Downloads/foo-1.34/src</userinput>
    574572<prompt>%%</prompt> <userinput>cp Makefile.in Makefile.in.orig</userinput></programlisting>
    575573        </listitem>
    576574
    577575        <listitem>
    578           <para>Edit the file to make it as you want it to be after it is
    579           fetched.</para>
    580         </listitem>
    581 
    582         <listitem>
    583           <para>Now use the Unix command <command>diff -u</command> to create
    584           a "unified" diff patch file.</para>
    585 
    586           <programlisting><prompt>%%</prompt> <userinput>cd foo-1.34</userinput>
    587 <prompt>%%</prompt> <userinput>diff -u Makefile.in.orig Makefile.in &gt; patch-Makefile.in.diff</userinput></programlisting>
     576          <para>Edit the file and modify the text to reflect your
     577          corrections.</para>
     578        </listitem>
     579
     580        <listitem>
     581          <para>Now <command>cd</command> to the top-level directory of the
     582          unpacked source, and use the Unix command <command>diff -u</command>
     583          to create a "unified" diff patch file.</para>
     584
     585          <programlisting><prompt>%%</prompt> <userinput>cd ~/Downloads/foo-1.34</userinput>
     586<prompt>%%</prompt> <userinput>diff -u src/Makefile.in.orig src/Makefile.in &gt; patch-src-Makefile.in.diff</userinput></programlisting>
     587
     588          <para>You should execute the <command>diff</command> command from
     589          the top-level directory of the unpacked source code, because during
     590          the patch phase MacPorts by default uses the patch argument
     591          <option>-p0</option>, which does not strip prefixes containing any
     592          leading slashes from file names found in the patch file (as opposed
     593          to <option>-p1</option> hat strips one, etc), and any path not
     594          relative to the top-level directory of the unpacked source will fail
     595          during the patch phase.</para>
    588596
    589597          <note>
    590             <para>You must execute the <command>diff</command> command in the
    591             top-level of the unpacked source code. Otherwise the
    592             <command>patch</command> command will look for the file to be
    593             patched in the wrong path and fail.</para>
     598            <para>If you find an existing source file patch you wish to use
     599            that contains leading path information (diff was executed from a
     600            directory higher than the top-level source directory), you will
     601            need to use the <link linkend="reference.phases.patch">patch phase
     602            keyword</link> <code>patch.pre_args</code> to specify some
     603            prefixes containing leading slashes be stripped off.</para>
    594604          </note>
    595605        </listitem>
     
    601611          support to a <filename>Makefile.in</filename> file.</para>
    602612
    603           <programlisting>--- Makefile.in.orig   2007-06-01 16:30:47.000000000 -0700
    604 +++ Makefile.in       2007-06-20 10:10:59.000000000 -0700
     613          <programlisting>--- src/Makefile.in.orig   2007-06-01 16:30:47.000000000 -0700
     614+++ src/Makefile.in       2007-06-20 10:10:59.000000000 -0700
    605615@@ -131,23 +131,23 @@
    606616        $(INSTALL_DATA)/gdata $(INSTALL_DATA)/perl
     
    615625
    616626        <listitem>
    617           <para>Place the patch <filename>patch-Makefile.in.diff</filename> in
    618           the directory <filename>${portpath}/files</filename> and use it in a
    619           port using the <code>patchfiles</code> keyword.
    620           <varname>${portpath}</varname> may be in a local Portfile repository
    621           for development purposes, or the patch may be committed to the
    622           global MacPorts repository for distribution.</para>
    623 
    624           <programlisting>patchfiles          patch-Makefile.in.diff</programlisting>
     627          <para>Place the patch
     628          <filename>patch-src-Makefile.in.diff</filename> in the directory
     629          <filename>${portpath}/files</filename> and use it in a port using
     630          the <code>patchfiles</code> keyword. <varname>${portpath}</varname>
     631          may be in a local Portfile repository during development, or
     632          <filename>files/</filename> may be in a port's
     633          <varname>${portpath}</varname> in the global MacPorts
     634          repository.</para>
     635
     636          <programlisting>patchfiles          patch-src-Makefile.in.diff</programlisting>
    625637        </listitem>
    626638      </orderedlist>
Note: See TracChangeset for help on using the changeset viewer.