Changeset 27222 for trunk/doc


Ignore:
Timestamp:
Jul 25, 2007, 5:50:57 AM (12 years ago)
Author:
markd@…
Message:

Add a section for creating patchfiles.

File:
1 edited

Legend:

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

    r27195 r27222  
    55  <title>Portfile Development</title>
    66
    7   <para>This chapter gives an introduction to port phases, creating a local
    8   Portfile repository for development, and shows how to create
    9   <filename>Portfile</filename>s by example.</para>
     7  <para>This chapter covers a brief introduction to port phases, how to create
     8  a local Portfile repository for development, and creating
     9  <filename>Portfile</filename>s.</para>
    1010
    1111  <section>
     
    349349    </section>
    350350  </section>
     351
     352  <section>
     353    <title>Creating Patch Files</title>
     354
     355    <para>Patch files are files created with the Unix command
     356    <command>diff</command> that are applied using the command
     357    <command>patch</command> to modify text files to fix bugs or extend
     358    functionality. </para>
     359
     360    <section>
     361      <title>Portfile Patches</title>
     362
     363      <para>If you wish to contribute modifications or fixes to a Portfile,
     364      you should do so in the form of a patch.</para>
     365
     366      <orderedlist>
     367        <listitem>
     368          <para>Make a copy of the Portfile you wish to modify. Both the
     369          Portfile and its copy must be in the same directory, though it may
     370          be any directory.</para>
     371
     372          <programlisting><prompt>%%</prompt> <userinput>cp Portfile Portfile.org</userinput></programlisting>
     373        </listitem>
     374
     375        <listitem>
     376          <para>Edit the file to make it as you want it to be after it is
     377          fetched.</para>
     378        </listitem>
     379
     380        <listitem>
     381          <para>Now use the Unix command diff to create a "unified" diff patch
     382          file.</para>
     383
     384          <programlisting><prompt>%%</prompt> <userinput>diff -u Portfile.org Portfile &gt; Portfile.diff</userinput></programlisting>
     385        </listitem>
     386      </orderedlist>
     387
     388      <para>Now you may attach the Portfile.diff to a MacPorts Trac ticket for
     389      the port author to evaluate.</para>
     390    </section>
     391
     392    <section>
     393      <title>Source Code Patches</title>
     394
     395      <para>Necessary or useful patches to application source code should be
     396      sent to the application developer (not the port author) so the
     397      modifications may be included in the next version, and the port patch
     398      eventually removed.</para>
     399
     400      <orderedlist>
     401        <listitem>
     402          <para>Locate the file you wish to patch in its original location
     403          within the unpacked source directory and make a duplicate of
     404          it.</para>
     405
     406          <programlisting><prompt>%%</prompt> <userinput>cd foo-1.34/src</userinput>
     407<prompt>%%</prompt> <userinput>cp Makefile.in Makefile.in.org</userinput></programlisting>
     408        </listitem>
     409
     410        <listitem>
     411          <para>Edit the file to make it as you want it to be after it is
     412          fetched.</para>
     413        </listitem>
     414
     415        <listitem>
     416          <para>Now use the Unix command diff to create a "unified" diff patch
     417          file.</para>
     418
     419          <programlisting><prompt>%%</prompt> <userinput>cd foo-1.34</userinput>
     420<prompt>%%</prompt> <userinput>diff -u Makefile.in.org Makefile.in &gt; patch-Makefile.in</userinput></programlisting>
     421
     422          <note>
     423            <para>You must execute the diff command in the top-level of the
     424            unpacked source code. Otherwise the patch command will look for
     425            the file to be patched in the wrong place and fail.</para>
     426          </note>
     427        </listitem>
     428
     429        <listitem>
     430          <para>A patch made using "-u" ("unified") is the easiest to
     431          interpret by humans and this type should always be used for ports.
     432          See the example below where a patch file adds DESTDIR support to a
     433          <filename>Makefile.in</filename> file.</para>
     434
     435          <programlisting>--- Makefile.in.org   2007-06-01 16:30:47.000000000 -0700
     436+++ Makefile.in       2007-06-20 10:10:59.000000000 -0700
     437@@ -131,23 +131,23 @@
     438        $(INSTALL_DATA)/gdata $(INSTALL_DATA)/perl
     439
     440 install-lib:
     441-       -mkdir -p $(INSTALL_LIB)
     442+       -mkdir -p $(DESTDIR)$(INSTALL_LIB)
     443        $(PERL) tools/install_lib -s src -l $(INSTALL_LIB) $(LIBS)
     444-       cp $(TEXT) $(INSTALL_LIB)/
     445+       cp $(TEXT) $(DESTDIR)$(INSTALL_LIB)/</programlisting>
     446        </listitem>
     447
     448        <listitem>
     449          <para>Now you may use the patch file
     450          <filename>patch-Makefile.in</filename> in a port using the
     451          patchfiles keyword.</para>
     452
     453          <programlisting>patchfiles              patch-Makefile.in</programlisting>
     454        </listitem>
     455      </orderedlist>
     456    </section>
     457  </section>
    351458</chapter>
Note: See TracChangeset for help on using the changeset viewer.