Adding patches through git

From WebOS Internals
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

WIP incomplete

Add kernel patches to be committed to the Preware feed by following this guide.

Prerequisites

  • SSH key generated, with the id_dsa.pub authorised for commital on git.webos-internals.org (rwhitby is able to do this)
  • GPL compliant patch to submit (preferably with a .patch extension)

Initialising your local repository

  • You will need to pull down the kernel/patches repository as a starting point with

<source lang="text">git clone git@git.webos-internals.org:kernels/patches.git</source>

A worked example is as follows:

<source lang="text"> mason~/kernels$ git clone git@git.webos-internals.org:kernels/patches.git Initialized empty Git repository in /home/sbromwich/kernels/patches/.git/ Enter passphrase for key '/home/sbromwich/.ssh/id_dsa': remote: Counting objects: 70, done. remote: Compressing objects: 100% (68/68), done. remote: Total 70 (delta 23), reused 0 (delta 0) Receiving objects: 100% (70/70), 15.21 KiB, done. Resolving deltas: 100% (23/23), done. mason~/kernels$ ls patches mason~/kernels$ ls -l total 4 drwxr-xr-x 5 sbromwich sbromwich 4096 Apr 22 22:17 patches mason~/kernels$ cd patches/ mason~/kernels/patches$ ls LICENSE overclocking sensors mason~/kernels/patches$ ls -l total 12 -rw-r--r-- 1 sbromwich sbromwich 88 Apr 22 22:17 LICENSE drwxr-xr-x 2 sbromwich sbromwich 4096 Apr 22 22:17 overclocking drwxr-xr-x 2 sbromwich sbromwich 4096 Apr 22 22:17 sensors mason~/kernels/patches$ </source>

  • Create a directory for your patch(es) and copy them in there.

Tag patches and submit to git

  • Find the next available git tag with

<source lang="text">git tag -l</source>

In the following case, the next tag is v1.4.1-10:

<source lang="text"> mason~/kernels/patches/prcm$ git tag -l v1.4.0-0 v1.4.0-1 v1.4.1-1 v1.4.1-2 v1.4.1-3 v1.4.1-4 v1.4.1-5 v1.4.1-6 v1.4.1-7 v1.4.1-8 v1.4.1-9 mason~/kernels/patches/prcm$ </source>

  • Tag the files with a meaningful commit message and the tag from the previous step:

<source lang="text"> mason~/kernels/patches/prcm$ git tag -a -m "PRCM resume from suspend fix/kludge" v1.4.1-10 mason~/kernels/patches/prcm$ </source>

  • Send the tagged files to the upstream repository with

<source lang="text">git push ; git push --tags</source>

For example:

<source lang="text"> mason~/kernels/patches/prcm$ git push ; git push --tags Enter passphrase for key '/home/sbromwich/.ssh/id_dsa': Everything up-to-date Enter passphrase for key '/home/sbromwich/.ssh/id_dsa': Counting objects: 1, done. Writing objects: 100% (1/1), 187 bytes, done. Total 1 (delta 0), reused 0 (delta 0) To git@git.webos-internals.org:kernels/patches.git

* [new tag]         v1.4.1-10 -> v1.4.1-10

mason~/kernels/patches/prcm$ </source>

Commit the tagged files to git

Committing the tagged files is the following three step process:

  • git add filenames
  • git commit -m "commit message" filenames
  • git push

Worked example:

<source lang="text"> mason~/kernels/patches/prcm$ git add * mason~/kernels/patches/prcm$ git commit -m "PRCM resume from suspend fix/kludge" * Created commit 16fbb97: PRCM resume from suspend fix/kludge

3 files changed, 84 insertions(+), 0 deletions(-)
create mode 100644 prcm/README
create mode 100644 prcm/prcm_clk.c.diff
create mode 100644 prcm/proc_pwr.c.diff

mason~/kernels/patches/prcm$ git push Enter passphrase for key '/home/sbromwich/.ssh/id_dsa': Counting objects: 7, done. Compressing objects: 100% (6/6), done. Writing objects: 100% (6/6), 1.96 KiB, done. Total 6 (delta 0), reused 0 (delta 0) To git@git.webos-internals.org:kernels/patches.git

  b949e1d..16fbb97  master -> master

mason~/kernels/patches/prcm$ </source>

Uh-oh, I screwed up a commit - how do I remove a file?

If you inadvertently commit a file in error, it is easy to remove with

<source lang="text"> git remove filename git commit -m "commit message" filename </source>

Worked example:

<source lang="text"> mason~/build/hardware/uber-kernel-pre/build$ git rm src-1.4.1-6/linux-2.6.24/.config rm 'hardware/uber-kernel-pre/build/src-1.4.1-6/linux-2.6.24/.config' mason~/build/hardware/uber-kernel-pre/build$ git commit -m "Removing .config that should not have been committed in the first place" src-1.4.1-6/linux-2.6.24/.config Created commit cd95fd3: Removing .config that should not have been committed in the first place

1 files changed, 0 insertions(+), 1892 deletions(-)
delete mode 100644 hardware/uber-kernel-pre/build/src-1.4.1-6/linux-2.6.24/.config

mason~/build/hardware/uber-kernel-pre/build$ </source>

If you have modified the file, you will need to force the commit with the -f flag, as follows:

<source lang="text"> mason~/build/hardware/uber-kernel-pre/build$ git rm -f src-1.4.1-6/linux-2.6.24/arch/arm/mach-omap3pe/prcm_pwr.c src-1.4.1-6/linux-2.6.24/include/linux/vermagic.h rm 'hardware/uber-kernel-pre/build/src-1.4.1-6/linux-2.6.24/arch/arm/mach-omap3pe/prcm_pwr.c' rm 'hardware/uber-kernel-pre/build/src-1.4.1-6/linux-2.6.24/include/linux/vermagic.h' mason~/build/hardware/uber-kernel-pre/build$ git commit -m "Removing commits that should not have been committed" src-1.4.1-6/linux-2.6.24/arch/arm/mach-omap3pe/prcm_pwr.c src-1.4.1-6/linux-2.6.24/include/linux/vermagic.h Created commit 73eb872: Removing commits that should not have been committed

2 files changed, 0 insertions(+), 1885 deletions(-)
delete mode 100644 hardware/uber-kernel-pre/build/src-1.4.1-6/linux-2.6.24/arch/arm/mach-omap3pe/prcm_pwr.c
delete mode 100644 hardware/uber-kernel-pre/build/src-1.4.1-6/linux-2.6.24/include/linux/vermagic.h

mason~/build/hardware/uber-kernel-pre/build$ </source>

git conceptual tutorial

An excellent conceptual tutorial on how git works is available at http://www.eecs.harvard.edu/~cduan/technical/git/ courtesy of Charles Duan.