function fix_source_perms

Purpose

  1. Check and correct the permissions of the files and directories in the SRC_DIR.
  2. Patch the sources if patches and/or diff files are being used.

Notes

Usually it's a good idea to make sure that all files in the sources belong to root and that the permissions are correct. Sometimes this needs to be disabled, like when building sources inside a CVS or SVN directory. Using CORRECT_PERMS=NO will disable all permission corrections, or you can use CORRECT_SUID_PERMS to only disable the correction of files with suid permissions set.

src2pkg can apply most patches automatically just by placing them in the CWD where the src2pkg program or script is being run. They can also be place in a subdirectory of the CWD called patches: CWD/patches.

auto-patching is on, by default, but can be disabled by using AUTO_PATCH=NO. You can also specify the list of patches using the PATCHLIST='' variable. This is useful if you want to change the order in which patches are applied, although this can be done by changing the name as well. Patches are applied in the same sort order used by  the ls command. Prefixing the names with numbers is an easy way to control the order in which they are applied.

By default, patches are applied with -p1 option. If you need to use a different -p option the patch or diff file should be renamed using the -p options as part of the name. For example, to apply a gzipped diff file using the option -p0, you'd rename it like this: old-name.diff.gz becomes old-name.p0.diff.gz