diff --git a/rpm_packaging_guide_tut/README.md b/rpm_packaging_guide_tut/README.md index 8a862b2..0d9fbe2 100644 --- a/rpm_packaging_guide_tut/README.md +++ b/rpm_packaging_guide_tut/README.md @@ -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_ + diff --git a/rpm_packaging_guide_tut/bello/README.md b/rpm_packaging_guide_tut/bello/README.md new file mode 100644 index 0000000..9a8db30 --- /dev/null +++ b/rpm_packaging_guide_tut/bello/README.md @@ -0,0 +1,6 @@ +# Bello + +Don't forget to run chmod on the file + +`chmod +x bello` + diff --git a/rpm_packaging_guide_tut/bello/bello b/rpm_packaging_guide_tut/bello/bello new file mode 100755 index 0000000..7bf8af4 --- /dev/null +++ b/rpm_packaging_guide_tut/bello/bello @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +# This is an example of RAW interpreted code. + + +printf "Hello world from Bash\n" \ No newline at end of file diff --git a/rpm_packaging_guide_tut/cello/Makefile b/rpm_packaging_guide_tut/cello/Makefile index 8ad2a7e..384b9d7 100644 --- a/rpm_packaging_guide_tut/cello/Makefile +++ b/rpm_packaging_guide_tut/cello/Makefile @@ -2,4 +2,9 @@ cello: gcc -g -o cello cello.c clean: - rm cello \ No newline at end of file + 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 \ No newline at end of file diff --git a/rpm_packaging_guide_tut/patching/Makefile b/rpm_packaging_guide_tut/patching/Makefile new file mode 100644 index 0000000..2bcc394 --- /dev/null +++ b/rpm_packaging_guide_tut/patching/Makefile @@ -0,0 +1,7 @@ +cello: + + gcc -g -o cello cello.c + +clean: + + rm cello \ No newline at end of file diff --git a/rpm_packaging_guide_tut/patching/README.md b/rpm_packaging_guide_tut/patching/README.md new file mode 100644 index 0000000..585c27d --- /dev/null +++ b/rpm_packaging_guide_tut/patching/README.md @@ -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 +``` \ No newline at end of file diff --git a/rpm_packaging_guide_tut/patching/cello-output-first.patch b/rpm_packaging_guide_tut/patching/cello-output-first.patch new file mode 100644 index 0000000..f3d649c --- /dev/null +++ b/rpm_packaging_guide_tut/patching/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 diff --git a/rpm_packaging_guide_tut/patching/cello.c b/rpm_packaging_guide_tut/patching/cello.c new file mode 100644 index 0000000..d65b6ae --- /dev/null +++ b/rpm_packaging_guide_tut/patching/cello.c @@ -0,0 +1,7 @@ +#include + +int main(){ + printf("Hello world from C\n"); + printf("This is my first patch!\n"); + return 0; +} \ No newline at end of file diff --git a/rpm_packaging_guide_tut/patching/cello.c.orig b/rpm_packaging_guide_tut/patching/cello.c.orig new file mode 100644 index 0000000..8e72100 --- /dev/null +++ b/rpm_packaging_guide_tut/patching/cello.c.orig @@ -0,0 +1,6 @@ +#include + +int main(){ + printf("Hello world from C\n"); + return 0; +} \ No newline at end of file diff --git a/rpm_packaging_guide_tut/pello/.gitignore b/rpm_packaging_guide_tut/pello/.gitignore new file mode 100644 index 0000000..ba0430d --- /dev/null +++ b/rpm_packaging_guide_tut/pello/.gitignore @@ -0,0 +1 @@ +__pycache__/ \ No newline at end of file diff --git a/rpm_packaging_guide_tut/pello/Makefile b/rpm_packaging_guide_tut/pello/Makefile new file mode 100644 index 0000000..0944359 --- /dev/null +++ b/rpm_packaging_guide_tut/pello/Makefile @@ -0,0 +1,8 @@ +pello: + + python -m compileall pello.py + + +clean: + + rm -rf __pycache__ diff --git a/rpm_packaging_guide_tut/pello/pello.py b/rpm_packaging_guide_tut/pello/pello.py new file mode 100644 index 0000000..9522873 --- /dev/null +++ b/rpm_packaging_guide_tut/pello/pello.py @@ -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")