Compare commits
4 Commits
30da72a32f
...
c1330a5951
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c1330a5951 | ||
|
|
4e01e3a4eb | ||
|
|
0079e2de1c | ||
|
|
8b67227745 |
84
10 Minute Guide to diff and patch.md
Normal file
84
10 Minute Guide to diff and patch.md
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
# 10 Minute Guide to diff and patch
|
||||||
|
|
||||||
|
## Summary
|
||||||
|
|
||||||
|
This is copied pretty much verbatim from [The 10-Minute Guide to Patch and Diff](http://jungels.net/articles/diff-patch-ten-minutes.html)
|
||||||
|
|
||||||
|
I just wanted to have a local copy to refer to, so I can start making patch files instead of tediously copy/pasting changes and updates in shell scripts.
|
||||||
|
|
||||||
|
## Procedure
|
||||||
|
|
||||||
|
Situation one: you are trying to compile a package from source, and you discover that somebody has already done the work for you of modifying it slightly to compile on your system. They have made their work available as a "patch", but you're not sure how to make use of it. The answer is that you apply the patch to the original source code with a command line tool called, appropriately, patch.
|
||||||
|
|
||||||
|
Situation two: you have downloaded the source code to an open source package and after an hour or so of minor edits, you manage to make it compile on your system. You would like to make your work available to other programmers, or to the authors of the package, without redistributing the entire modified package. Now you are in a situation where you need to create a patch of your own, and the tool you need is diff.
|
||||||
|
|
||||||
|
This is a quick guide to diff and patch which will help you in these situations by describing the tools as they are most commonly used. It tells you enough to get started right away. Later, you can learn the ins and outs of diff and patch at your leisure, using the man pages.
|
||||||
|
|
||||||
|
## Applying patches with patch
|
||||||
|
|
||||||
|
To apply a patch to a single file, change to the directory where the file is located and call patch:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
patch < foo.patch
|
||||||
|
```
|
||||||
|
|
||||||
|
These instructions assume the patch is distributed in unified format, which identifies the file the patch should be applied to. If not, you can specify the file on the command line:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
patch foo.txt < bar.patch
|
||||||
|
```
|
||||||
|
|
||||||
|
Applying patches to entire directories (perhaps the more common case) is similar, but you have to be careful about setting a "p level". What this means is that, within patch files, the files to be patched are identified by path names which may be different now that the files are located on your computer rather than on the computer where the patch was created. The p level instructs patch to ignore parts of the path name so that it can identify the files correctly. Most often a p level of one will work, so you use:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
patch -p1 < baz.patch
|
||||||
|
```
|
||||||
|
|
||||||
|
You should change to the top level source directory before running this command. If a patch level of one does not correctly identify any levels to patch, inspect the patch file for file names. If you see a name like
|
||||||
|
|
||||||
|
```bash
|
||||||
|
/users/stephen/package/src/net/http.c
|
||||||
|
```
|
||||||
|
|
||||||
|
and you are working in a directory that contains net/http.c, use
|
||||||
|
|
||||||
|
```bash
|
||||||
|
patch -p5 < baz.patch
|
||||||
|
```
|
||||||
|
|
||||||
|
In general, count up one for each path separator (slash character) that you remove from the beginning of the path, until what's left is a path that exists in your working directory. The count you reach is the p level.
|
||||||
|
|
||||||
|
To remove a patch, use the -R flag, ie
|
||||||
|
|
||||||
|
```bash
|
||||||
|
patch -p5 -R < baz.patch
|
||||||
|
```
|
||||||
|
|
||||||
|
## Creating patches with diff
|
||||||
|
|
||||||
|
Using diff is simple whether you are working with single files or entire source directories. To create a patch for a single file, use the form:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
diff -u original.c new.c > original.patch
|
||||||
|
```
|
||||||
|
|
||||||
|
To create a patch for an entire source tree, make a copy of the tree:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cp -R original new
|
||||||
|
```
|
||||||
|
|
||||||
|
Make any changes required in the directory new/. Then create a patch with the following command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
diff -rupN original/ new/ > original.patch
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Reference:
|
||||||
|
|
||||||
|
- [The 10 Minute Guide to Patch and Diff](http://jungels.net/articles/diff-patch-ten-minutes.html)
|
||||||
|
|
||||||
|
Tags:
|
||||||
|
howto
|
||||||
13
Almost line-speed file-copy using netcat.md
Normal file
13
Almost line-speed file-copy using netcat.md
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
# Almost line-speed file-copy using netcat
|
||||||
|
|
||||||
|
Receiving end:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
nc -l -p 9999 | tar xvfp -
|
||||||
|
```
|
||||||
|
|
||||||
|
Sender:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
tar cfp - /PATH/ | nc RECEIVER 9999
|
||||||
|
```
|
||||||
20
CPU Steal .md
Normal file
20
CPU Steal .md
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
# CPU Steal
|
||||||
|
|
||||||
|
CPU steal is the percentage of time that a virtual CPU has to wait for the physical CPU while the hypervisor is fulfilling processes from another virtual CPU. In short, CPU steal occurs when a shared CPU core is delayed in processing a request. This typically occurs when there is resource contention occurring, but that is not always the case.
|
||||||
|
|
||||||
|
|
||||||
|
> My Linode's processes are not performing as expected. What can I do to see if CPU steal is occurring?
|
||||||
|
> If you're noticing that your Linode's performance is suffering, there is a possibility that CPU steal is occurring. The best starting point to diagnose a potential CPU steal issue is to run the following commands.
|
||||||
|
|
||||||
|
|
||||||
|
```shell
|
||||||
|
iostat 10 10 && for x in `seq 1 1 30`; do ps -eo state,pid,cmd | grep "^D"; echo "-"; sleep 2; done && top -bn 1 | head -15
|
||||||
|
```
|
||||||
|
|
||||||
|
[explanation](https://www.linode.com/community/questions/18168/what-is-cpu-steal-and-how-does-it-affect-my-linode)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Notes
|
||||||
|
|
||||||
|
* `iostat` requires the `sysstat` package be installed on the host
|
||||||
Reference in New Issue
Block a user