Opensource Development

An introduction to diffs and patches

A “patch” refers to a specific collection of differences between files that can be applied to a source code tree using the Unix diff utility.

“unified” diff

This is the expected view for patches in most of the modern software development world.
  • To show the differences in a unified diff format
  • 
    $ diff -Naur sources-orig/ sources-fixed/        
            
  • diff into a patch file
  • 
    $ diff -Naur sources-orig/ sources-fixed/ > myfixes.patch
            
  • apply the changes using the patch tool
  • Given that their current working directory is in the base of the source code tree ,
    
    $ patch -p1 < ../myfixes.patch        
    		
    The -p1 option will strip one path component from the file names, so that a/include/linux/pm_qos.h will be treated as include/linux/pm_qos.h.
    This is a relative path which has to resolve from your current working directory.

git diff

Compare and get the difference in git.


$ git diff 5f42224c074c819eaceff4d82c780afaf114f0ae 459a1d16c63ad6fd6759c6b68b9412fc641350d0
diff --git a/debian.intel/changelog b/debian.intel/changelog
index 6a01c950cc1f..92aa0842475c 100644
--- a/debian.intel/changelog
+++ b/debian.intel/changelog
@@ -1,14 +1,10 @@
-linux-intel (5.11.0-1003.3) focal; urgency=medium
+linux-intel (5.11.0-1003.3) UNRELEASED; urgency=medium
...

Build Kernel

Setup Build Environment


$ sudo apt build-dep linux 

Kernel Source

  • Ubuntu kernel
  • Ubuntu Kernel PPA
    • v5.13-rc2/
    • To obtain the source from which they are built fetch the commit below:
      
      git://git.launchpad.net/~ubuntu-kernel-test/ubuntu/+source/linux/+git/mainline-crack cod/mainline/v5.13-rc2
        		

Upgrade the Kernel

Linux Package

  • ~kernel-ppa/mainline
    • v5.13-rc2/
    • 
      -rw-rw-r-- 1 ubuntu ubuntu  2521948 May 16 23:46 linux-headers-5.13.0-051300rc2-generic_5.13.0-051300rc2.202105162330_amd64.deb
      -rw-rw-r-- 1 ubuntu ubuntu 11726896 May 16 23:42 linux-headers-5.13.0-051300rc2_5.13.0-051300rc2.202105162330_all.deb
      -rw-rw-r-- 1 ubuntu ubuntu 11657044 May 16 23:46 linux-image-unsigned-5.13.0-051300rc2-generic_5.13.0-051300rc2.202105162330_amd64.deb
      -rw-rw-r-- 1 ubuntu ubuntu 67510368 May 16 23:46 linux-modules-5.13.0-051300rc2-generic_5.13.0-051300rc2.202105162330_amd64.deb
            		
  • linux-intel package in Ubuntu
  • “Canonical Kernel Team” team
    • “PPA for Canonical Kernel Team”
    •       
      $ sudo apt-add-repository ppa:canonical-kernel-team/ppa -y
      Hit:1 http://tw.archive.ubuntu.com/ubuntu focal InRelease
      Hit:2 http://tw.archive.ubuntu.com/ubuntu focal-updates InRelease
      Hit:3 http://tw.archive.ubuntu.com/ubuntu focal-backports InRelease
      Get:4 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
      Get:5 http://ppa.launchpad.net/canonical-kernel-team/ppa/ubuntu focal InRelease [17.6 kB]   
      Hit:6 http://ppa.launchpad.net/canonical-kernel-team/unstable/ubuntu focal InRelease        
      Get:7 http://ppa.launchpad.net/canonical-kernel-team/ppa/ubuntu focal/main i386 Packages [15.1 kB]
      Get:8 http://ppa.launchpad.net/canonical-kernel-team/ppa/ubuntu focal/main amd64 Packages [126 kB]
      Get:9 http://ppa.launchpad.net/canonical-kernel-team/ppa/ubuntu focal/main Translation-en [39.2 kB]
      Fetched 312 kB in 5s (62.5 kB/s)        
      Reading package lists... Done
      
      $ apt-cache search linux-intel
      linux-image-unsigned-5.11.0-1003-intel - Linux kernel image for version 5.11.0 on 64 bit x86 SMP
      linux-image-unsigned-5.11.0-1004-intel - Linux kernel image for version 5.11.0 on 64 bit x86 SMP
      linux-intel - Complete Generic Linux kernel and headers
      linux-intel-cloud-tools-5.11.0-1003 - Linux kernel version specific cloud tools for version 5.11.0-1003
      linux-intel-cloud-tools-5.11.0-1004 - Linux kernel version specific cloud tools for version 5.11.0-1004
      linux-intel-cloud-tools-common - Linux kernel version specific cloud tools for version 5.11.0
      linux-intel-headers-5.11.0-1003 - Header files related to Linux kernel version 5.11.0
      linux-intel-headers-5.11.0-1004 - Header files related to Linux kernel version 5.11.0
      linux-intel-source-5.11.0 - Linux kernel source for version 5.11.0 with Ubuntu patches
      linux-intel-tools-5.11.0-1003 - Linux kernel version specific tools for version 5.11.0-1003
      linux-intel-tools-5.11.0-1004 - Linux kernel version specific tools for version 5.11.0-1004
      linux-intel-tools-common - Linux kernel version specific tools for version 5.11.0
      linux-intel-tools-host - Linux kernel VM host tools
      linux-modules-5.11.0-1003-intel - Linux kernel extra modules for version 5.11.0 on 64 bit x86 SMP
      linux-modules-5.11.0-1004-intel - Linux kernel extra modules for version 5.11.0 on 64 bit x86 SMP
      linux-modules-extra-5.11.0-1003-intel - Linux kernel extra modules for version 5.11.0 on 64 bit x86 SMP
      linux-modules-extra-5.11.0-1004-intel - Linux kernel extra modules for version 5.11.0 on 64 bit x86 SMP
      
      $ sudo apt install -y linux-intel
      $ sudo reboot
                  	
    • Unstable Kernel Builds
      • linux-oem-5.13:
      • 
        $ sudo add-apt-repository ppa:canonical-kernel-team/unstable -y
        $ apt-key adv --recv-keys --keyserver keyserver.ubuntu.com --verbose 110e21d8b0e2a1f0243af6820856f197b892acea
        $ sudo apt-get update    
        $ sudo apt install linux-oem-20.04c -y
        
        
                    	

Install

$ sudo dpkg -i linux*5.13.0*.deb

留言

熱門文章