QNA > W > Cos'è Il Patching In Linux? Inoltre, Qual È Il Processo Di Pre-Patching E Post-Patching?
Domanda

Cos'è il patching in Linux? Inoltre, qual è il processo di pre-patching e post-patching?

Risposte
01/31/2022
Amil Puskaric

A patch is a small text document containing a delta of changes between two different versions of a source tree. Patches are created with the diff program.

Updating files with patch is often referred to as applying the patch or simply patching the files.

main-qimg-b7f520f8a70e9e191598489934c3aabe

patch command syntax

The basic syntax is as follows:
$ patch < patch.file $ patch source.code.file < patch.file $ patch -p LEVEL < {/path/to/patch/file}

To apply a patch, one could run the following command in a shell:
$ patch < /path/to/file

In this example, patch foo.c with patch.diff file:
$ patch foo.c < patch.diff

Patches can be undone, or reversed, with the '-R' option:
$ patch -R < /path/to/file

How do I create a patch?

To create a patch, one could run the following diff command:
$ diff -u oldfile-name-here newfile-name-here > patch.diff

alternatives

You can use the interdiff program (http://cyberelk.net/tim/patchutils/) to generate a patch representing the differences between two patches and then apply the result.

This will let you move from something like 4.7.2 to 4.7.3 in a single step. The -z flag to interdiff will even let you feed it patches in gzip or bzip2 compressed form directly without the use of zcat or bzcat or manual decompression.

Here’s how you’d go from 4.7.2 to 4.7.3 in a single step:

  1. interdiff -z ../patch-4.7.2.gz ../patch-4.7.3.gz | patch -p1

Although interdiff may save you a step or two you are generally advised to do the additional steps since interdiff can get things wrong in some cases.

Un'altra alternativa è ketchup, che è uno script python per scaricare e applicare automaticamente le patch (http://www.selenic.com/ketchup/).

main-qimg-7d8c360828005dd0f9fb4ffaccf25000-pjlq
Dare una risposta
Perché e come si formano i nodi negli alberi? :: L'ibisco ha dei semi o abbiamo bisogno di uno stelo per far crescere una nuova pianta?
Link utili