Adding a lot more examples

master
Toor 6 years ago
parent 80d384955c
commit 4bde1486f8

@ -10,3 +10,17 @@ Project list:
| ------------- |-------------|
| hello-world | Your first rpm package. Creates a hello world script and rpm from one spec file.|
| | |
# Using the install command
`install` as a command is provided to the system through the GNU Core utilities. It places an artifact to the specified directory in the filesystem with a specified set of permissions.
The below command is an example of using the install command to place the bello shell script we have in the `/usr/bin` directory with full permissions to the user, and read+execute permissions to the group and all users.
```bash
sudo install -m 0755 bello /usr/bin/bello
```
We can add an install directive to our make files so that we can run `make install`. _note make files are usually written by the developer and not the packager_

@ -0,0 +1,6 @@
# Bello
Don't forget to run chmod on the file
`chmod +x bello`

@ -0,0 +1,5 @@
#!/usr/bin/env bash
# This is an example of RAW interpreted code.
printf "Hello world from Bash\n"

@ -2,4 +2,9 @@ cello:
gcc -g -o cello cello.c
clean:
rm cello
rm cello
# $(DESTDIR) variable is a GNU make built-in and is commonly used to specify installation to a directory different than the root directory.
install:
mkdir -p $(DESTDIR)/usr/bin
install -m 0755 cello $(DESTDIR)/usr/bin/cello

@ -0,0 +1,7 @@
cello:
gcc -g -o cello cello.c
clean:
rm cello

@ -0,0 +1,38 @@
# Patching
A patch is a source code that updates other source code. It is formatted as a diff, because it represents what is different between two versions of text. You create a __diff__ with thie `diff` utility, which is then applied to the source code using the `patch` utility.
_NOTE_: Other version control systems like git provide their own methods of creating diffs or patching software.
This is an example where we are creating a patch from the original source code using `diff` and then applying it via `patch`.
## Patching in 6 easy-ish steps
Preserve the original source code
```bash
cp cello.c cello.c.orig
```
Change the source code
Generate a patch using the `diff` utility
```bash
diff -Naur cello.c.orig cello.c
```
Save the patch to a file
```bash
diff -Naur cello.c.orig cello.c > cello-output-first-patch.patch
```
Restore the original file
```bash
cp cello.c.orig cello.c
```
Patch the original with the contents of the new patch file using the `patch` utility
```bash
patch < cello-output-first.patch
```

@ -0,0 +1,10 @@
--- cello.c.orig 2019-06-25 11:46:59.195770714 -0400
+++ cello.c 2019-06-25 11:47:40.261944061 -0400
@@ -2,5 +2,6 @@
int main(){
printf("Hello world from C\n");
+ printf("This is my first patch!\n");
return 0;
}
\ No newline at end of file

@ -0,0 +1,7 @@
#include <stdio.h>
int main(){
printf("Hello world from C\n");
printf("This is my first patch!\n");
return 0;
}

@ -0,0 +1,6 @@
#include <stdio.h>
int main(){
printf("Hello world from C\n");
return 0;
}

@ -0,0 +1,8 @@
pello:
python -m compileall pello.py
clean:
rm -rf __pycache__

@ -0,0 +1,4 @@
#!/usr/bin/env python
# Since we are byte compiling this, this is an interpreted example of byte compiled code
print("Hello world from Python")
Loading…
Cancel
Save