2020-02-11 20:33:51 +00:00
|
|
|
# Fedora GDB local patches policy
|
2017-12-08 04:31:26 +00:00
|
|
|
|
|
|
|
In order to make things easier for the Fedora GDB maintainer, we
|
|
|
|
choose to auto-generate the local patches by making use of an upstream
|
|
|
|
git repository. Below you can find a few instructions on how to work
|
|
|
|
using this method.
|
|
|
|
|
|
|
|
You need to run the following commands from the directory that
|
|
|
|
contains the "gdb.spec" file.
|
|
|
|
|
2020-02-11 20:33:51 +00:00
|
|
|
## Importing the GDB patches into a git repository
|
2017-12-08 04:31:26 +00:00
|
|
|
|
2020-02-11 20:33:51 +00:00
|
|
|
1) The local patches (`*.patch`) need to be imported into an upstream
|
2017-12-08 04:31:26 +00:00
|
|
|
git repository. For example, let's assume you cloned the repository
|
|
|
|
by doing:
|
|
|
|
|
2020-02-11 20:33:51 +00:00
|
|
|
`$ git clone git://sourceware.org/git/binutils-gdb.git`
|
2017-12-08 04:31:26 +00:00
|
|
|
|
2020-02-11 20:33:51 +00:00
|
|
|
> TIP: if you already have the repository cloned somewhere in your
|
|
|
|
> system, you can pass a "--reference <dir>" to the "git clone"
|
|
|
|
> command and it will use your local repository as much as possible
|
|
|
|
> to make the clone, speeding up things.
|
2017-12-08 04:31:26 +00:00
|
|
|
|
|
|
|
2) After cloning the upstream repository, you can import your patches
|
|
|
|
by using the script "generate-git-repo-from-patches.sh":
|
|
|
|
|
2020-02-11 20:33:51 +00:00
|
|
|
`$ sh generate-git-repo-from-patches.sh <REPOSITORY_DIR>`
|
2017-12-08 04:31:26 +00:00
|
|
|
|
|
|
|
The script will basically cd into the repository, checkout the
|
2020-02-11 20:33:51 +00:00
|
|
|
revision specified in the file `_git_upstream_commit`, iterate through
|
|
|
|
the file `_patch_order` and "git-am" every patch *in that order*.
|
2017-12-08 04:31:26 +00:00
|
|
|
This operation should complete without errors; if you find a problem
|
2020-02-11 20:33:51 +00:00
|
|
|
with `git-am`, it probably means that the revision specified in the
|
|
|
|
file `_git_upstream_commit` is wrong.
|
2017-12-08 04:31:26 +00:00
|
|
|
|
2020-02-11 20:33:51 +00:00
|
|
|
## Rebasing the patches against a newer version/release
|
2017-12-08 04:31:26 +00:00
|
|
|
|
|
|
|
1) First, cd into the upstream repository. All you have to do is
|
|
|
|
choose the revision against which you plan to rebase the patches, and
|
2020-02-11 20:33:51 +00:00
|
|
|
`git rebase <REVISION>`. git will do the rest, and you will be able
|
2017-12-08 04:31:26 +00:00
|
|
|
to perform conflict resolution by git's algorithm, which is smarter.
|
|
|
|
|
2020-02-11 20:33:51 +00:00
|
|
|
## Creating new patches
|
2017-12-08 04:31:26 +00:00
|
|
|
|
|
|
|
1) Create the new patch on top of the the others, as usual. Note that
|
2020-02-11 20:33:51 +00:00
|
|
|
you can use `git rebase` whenever you want to reorder patch order, or
|
2017-12-08 04:31:26 +00:00
|
|
|
even to delete a patch.
|
|
|
|
|
|
|
|
2) When writing the commit log, you must obey a few rules. The
|
2018-06-19 00:10:24 +00:00
|
|
|
subject line *must* be the filename of the patch. This line will be
|
|
|
|
used when exporting the patches from the git repository, and
|
|
|
|
(obviously) it gives the filename that should be used for this
|
|
|
|
specific patch.
|
2017-12-08 04:31:26 +00:00
|
|
|
|
|
|
|
3) You can also add comments that will go into the auto-generated
|
2020-02-11 20:33:51 +00:00
|
|
|
`Patch:` file (see below). To do that, use the special marker `;;` at
|
2017-12-08 04:31:26 +00:00
|
|
|
the beginning of the line. This way, a commit log that says:
|
|
|
|
|
2020-02-11 20:33:51 +00:00
|
|
|
~~~~~~~~~~~
|
2018-06-19 00:10:24 +00:00
|
|
|
test-patch.patch
|
2017-12-08 04:31:26 +00:00
|
|
|
|
|
|
|
;; This is a test patch
|
|
|
|
;; Second line
|
2020-02-11 20:33:51 +00:00
|
|
|
~~~~~~~~~~~
|
2017-12-08 04:31:26 +00:00
|
|
|
|
2020-02-11 20:33:51 +00:00
|
|
|
Will generate the following entry in the auto-generated `Patch:` file:
|
2017-12-08 04:31:26 +00:00
|
|
|
|
2020-02-11 20:33:51 +00:00
|
|
|
~~~~~~~~~~~
|
2017-12-08 04:31:26 +00:00
|
|
|
# This is a test patch
|
|
|
|
# Second line
|
|
|
|
PatchXYZ: test-patch.patch
|
2020-02-11 20:33:51 +00:00
|
|
|
~~~~~~~~~~~
|
2017-12-08 04:31:26 +00:00
|
|
|
|
2020-02-11 20:33:51 +00:00
|
|
|
## Exporting the GDB patches from the git repository
|
2017-12-08 04:31:26 +00:00
|
|
|
|
|
|
|
1) When you're done working with the patches, go back to the directory
|
2020-02-11 20:33:51 +00:00
|
|
|
that contains the `gdb.spec` file, and from there you run:
|
2017-12-08 04:31:26 +00:00
|
|
|
|
2020-02-11 20:33:51 +00:00
|
|
|
`$ sh generate-patches-from-git-repo.sh <REPOSITORY_DIR>`
|
2017-12-08 04:31:26 +00:00
|
|
|
|
2020-02-11 20:33:51 +00:00
|
|
|
This will regenerate all of the `*.patch` files (excluding the ones that
|
2017-12-08 04:31:26 +00:00
|
|
|
were also excluded from the git repository), and also regenerate a few
|
|
|
|
control files. These control files are:
|
|
|
|
|
2020-02-11 20:33:51 +00:00
|
|
|
- `_gdb.spec.Patch.include`: This file contains the `Patch:` directives.
|
2017-12-08 04:31:26 +00:00
|
|
|
|
2020-02-11 20:33:51 +00:00
|
|
|
- `_gdb.spec.patch.include`: This file contains the `%patch` directives.
|
2017-12-08 04:31:26 +00:00
|
|
|
|
2020-02-11 20:33:51 +00:00
|
|
|
- `_patch_order`: This file contains the patches, in the exact order
|
2017-12-08 04:31:26 +00:00
|
|
|
that they must be applied. It is used when importing the patches
|
|
|
|
into the git repository.
|
|
|
|
|
2020-02-11 20:33:51 +00:00
|
|
|
- `_git_upstream_commit`: This file contains the last upstream commit
|
2017-12-08 04:31:26 +00:00
|
|
|
against which the patches were rebased. It is used when importing
|
|
|
|
the patches into the git repository.
|
2018-02-05 18:01:55 +00:00
|
|
|
|
|
|
|
NOTE: If you did a rebase against a newer upstream version, you need
|
|
|
|
to specify the commit/tag/branch against which you rebased:
|
|
|
|
|
2020-02-11 20:33:51 +00:00
|
|
|
`$ sh generate-patches-from-git-repo.sh <REPOSITORY_DIR> <COMMIT_OR_TAG_OR_BRANCH>`
|
2018-02-05 18:01:55 +00:00
|
|
|
|
2020-02-11 20:33:51 +00:00
|
|
|
For example, if you rebased against `gdb-8.1-release`:
|
2018-02-05 18:01:55 +00:00
|
|
|
|
2020-02-11 20:33:51 +00:00
|
|
|
`$ sh generate-patches-from-git-repo.sh <REPOSITORY_DIR> gdb-8.1-release`
|