Source string Read only

(itstool) path: sect2/para
812/8120
Context English State
Patch files are stored in <varname>PATCHDIR</varname>, usually <filename>files/</filename>, from where they will be automatically applied. All patches must be relative to <varname>WRKSRC</varname>. Typically <varname>WRKSRC</varname> is a subdirectory of <varname>WRKDIR</varname>, the directory where the distfile is extracted. Use <command>make -V WRKSRC</command> to see the actual path. The patch names are to follow these rules:
Avoid having more than one patch modify the same file. For example, having both <filename>patch-foobar.c</filename> and <filename>patch-foobar.c2</filename> making changes to <filename>${WRKSRC}/foobar.c</filename> makes them fragile and difficult to debug.
When creating names for patch files, replace each underscore (<literal>_</literal>) with two underscores (<literal>__</literal>) and each slash (<literal>/</literal>) with one underscore (<literal>_</literal>). For example, to patch a file named <filename>src/freeglut_joystick.c</filename>, name the corresponding patch <filename>patch-src_freeglut__joystick.c</filename>. Do not name patches like <filename>patch-aa</filename> or <filename>patch-ab</filename>. Always use the path and file name in patch names. Using <command>make makepatch</command> automatically generates the correct names.
A patch may modify multiple files if the changes are related and the patch is named appropriately. For example, <filename>patch-add-missing-stdlib.h</filename>.
Only use characters <literal>[-+._a-zA-Z0-9]</literal> for naming patches. In particular, <emphasis>do not use <literal>::</literal> as a path separator,</emphasis> use <literal>_</literal> instead.
Minimize the amount of non-functional whitespace changes in patches. It is common in the Open Source world for projects to share large amounts of a code base, but obey different style and indenting rules. When taking a working piece of functionality from one project to fix similar areas in another, please be careful: the resulting patch may be full of non-functional changes. It not only increases the size of the ports repository but makes it hard to find out what exactly caused the problem and what was changed at all.
If a file must be deleted, do it in the <_:buildtarget-1/> target rather than as part of the patch.
Manual Patch Generation
Manual patch creation is usually not necessary. Automatic patch generation as described earlier in this section is the preferred method. However, manual patching may be required occasionally.
Patches are saved into files named <filename>patch-*</filename> where <replaceable>*</replaceable> indicates the pathname of the file that is patched, such as <filename>patch-Imakefile</filename> or <filename>patch-src-config.h</filename>.
After the file has been modified, <citerefentry><refentrytitle>diff</refentrytitle><manvolnum>1</manvolnum></citerefentry> is used to record the differences between the original and the modified version. <option>-u</option> causes <citerefentry><refentrytitle>diff</refentrytitle><manvolnum>1</manvolnum></citerefentry> to produce <quote>unified</quote> diffs, the preferred form.
<prompt>%</prompt> <userinput>diff -u <replaceable>file</replaceable>.orig <replaceable>file</replaceable> &gt; patch-<replaceable>pathname-file</replaceable></userinput>
When generating patches for new, added files, <option>-N</option> is used to tell <citerefentry><refentrytitle>diff</refentrytitle><manvolnum>1</manvolnum></citerefentry> to treat the non-existent original file as if it existed but was empty:
<prompt>%</prompt> <userinput>diff -u -N <replaceable>newfile</replaceable>.orig <replaceable>newfile</replaceable> &gt; patch-<replaceable>pathname-newfile</replaceable></userinput>
Do not add <literal>$FreeBSD$</literal> RCS strings in patches. When patches are added to the <application>Subversion</application> repository with <command>svn add</command>, the <literal>fbsd:nokeywords</literal> property is set to <literal>yes</literal> automatically so keywords in the patch are not modified when committed. The property can be added manually with <command>svn propset fbsd:nokeywords yes <replaceable>files...</replaceable></command>.
Using the recurse (<option>-r</option>) option to <citerefentry><refentrytitle>diff</refentrytitle><manvolnum>1</manvolnum></citerefentry> to generate patches is fine, but please look at the resulting patches to make sure there is no unnecessary junk in there. In particular, diffs between two backup files, <filename>Makefile</filename>s when the port uses <command>Imake</command> or GNU <command>configure</command>, etc., are unnecessary and have to be deleted. If it was necessary to edit <filename>configure.in</filename> and run <command>autoconf</command> to regenerate <command>configure</command>, do not take the diffs of <command>configure</command> (it often grows to a few thousand lines!). Instead, define <literal>USES=autoreconf</literal> and take the diffs of <filename>configure.in</filename>.
Simple Automatic Replacements
Simple replacements can be performed directly from the port <filename>Makefile</filename> using the in-place mode of <citerefentry><refentrytitle>sed</refentrytitle><manvolnum>1</manvolnum></citerefentry>. This is useful when changes use the value of a variable:
post-patch:
@${REINPLACE_CMD} -e 's|/usr/local|${PREFIX}|g' ${WRKSRC}/Makefile
Only use <citerefentry><refentrytitle>sed</refentrytitle><manvolnum>1</manvolnum></citerefentry> to replace variable content. You must use patch files instead of <citerefentry><refentrytitle>sed</refentrytitle><manvolnum>1</manvolnum></citerefentry> to replace static content.
Quite often, software being ported uses the CR/LF convention in source files. This may cause problems with further patching, compiler warnings, or script execution (like <literal>/bin/sh^M not found</literal>.) To quickly convert all files from CR/LF to just LF, add this entry to the port <filename>Makefile</filename>:
USES= dos2unix
A list of specific files to convert can be given:
USES= dos2unix
DOS2UNIX_FILES= util.c util.h
Use <varname>DOS2UNIX_REGEX</varname> to convert a group of files across subdirectories. Its argument is a <citerefentry><refentrytitle>find</refentrytitle><manvolnum>1</manvolnum></citerefentry>-compatible regular expression. More on the format is in <citerefentry><refentrytitle>re_format</refentrytitle><manvolnum>7</manvolnum></citerefentry>. This option is useful for converting all files of a given extension. For example, convert all source code files, leaving binary files intact:
USES= dos2unix
DOS2UNIX_REGEX= .*\.([ch]|cpp)
A similar option is <varname>DOS2UNIX_GLOB</varname>, which runs <command>find</command> for each element listed in it.
USES= dos2unix
DOS2UNIX_GLOB= *.c *.cpp *.h
The base directory for the conversion can be set. This is useful when there are multiple distfiles and several contain files which require line-ending conversion.
USES= dos2unix
DOS2UNIX_WRKSRC= ${WRKDIR}
Patching Conditionally

Loading…

No matching activity found.

Browse all component changes

Things to check

Long untranslated

The string has not been translated for a long time

Reset

Glossary

English English
No related strings found in the glossary.

Source information

Source string comment
(itstool) path: sect2/para
Labels
No labels currently set.
Flags
read-only
Source string location
book.translate.xml:1025
Source string age
11 months ago
Translation file
string