Category Archives: Uncategorized

RedHat rpmbuild

RPM packaging: A simplified guide to creating your first RPM
How to create a Linux RPM package
RPM Packaging Guide
How to build rpm packages

What actually is $RPM_BUILD_ROOT?

├── src
│   └── source
├── build
│   └── executables, libraries, etc.
└── pkg
    ├── Makefile
    ├── myapp.spec
    └── package
        └── <empty>
BUILD_DIR      = $(realpath .)/../build
PKG_BUILD_ROOT = $(realpath .)/package
PKG_DIR        = /opt/myapp/mysubcomponent
PKG_NAME       = myapp
PKG_VERSION    = 1.0.0.5
PKG_RELEASE    = 1

all :
    rpmbuild -v -bb                        \
        -D "BUILD_DIR   $(BUILD_DIR)"      \
        -D "_topdir     $(PKG_BUILD_ROOT)" \
        -D "PKG_DIR     $(PKG_DIR)"        \
        -D "PKG_NAME    $(PKG_NAME)"       \
        -D "PKG_VERSION $(PKG_VERSION)"    \
        -D "PKG_RELEASE $(PKG_RELEASE)"    \
        myapp.spec

clean :
    rm -rf "$(PKG_BUILD_ROOT)"
# Tags ----------------------------------------------------

Name:           %{PKG_NAME}
Version:        %{PKG_VERSION}
Release:        %{PKG_RELEASE}
Summary:        MyApp Summary
License:        GPL
AutoReqProv:    No

%description
MyApp Description

# Phases --------------------------------------------------

# Unpacking the sources     %prep     outside of packaging
# Building the software     %build    outside of packaging

# Installing the software in PKG_BUILD_ROOT
%install
PKG_PROTO=${RPM_BUILD_ROOT}%{PKG_DIR}
install -v -d ${PKG_PROTO}
rsync -av %{BUILD_DIR}/ ${PKG_PROTO}/

# Package the files (= include these files into the RPM package)
%files
%defattr(-,root,root,-)
%{PKG_DIR}

# Cleaning up               %clean    outside of packaging

# Embedded Scripts  ---------------------------------------

%pre
echo "## INFO: %{PKG_NAME} : pre"

%post
echo "## INFO: %{PKG_NAME} : post"

%preun
echo "## INFO: %{PKG_NAME} : preun"

%postun
echo "## INFO: %{PKG_NAME} : postun"
$ tree package
package
├── BUILD
├── BUILDROOT
│   └── myapp-1.0.0.5-1.x86_64
│       └── opt
│           └── myapp
│               └── mysubcomponent
│                   ├── bin
│                   │   └── myexecutable
│                   ├── etc
│                   │   └── myconfig
│                   └── lib
│                       └── mylibrary.so
├── RPMS
│   └── x86_64
│       └── myapp-1.0.0.5-1.x86_64.rpm
├── SOURCES
├── SPECS
└── SRPMS
$ make
rpmbuild -v -bb                                                  \
            -D "BUILD_DIR   /home/andreas/src/myapp/build"       \
            -D "_topdir     /home/andreas/src/myapp/pkg/package" \
            -D "PKG_DIR     /opt/myapp/mysubcomponent"           \
            -D "PKG_NAME    myapp"                               \
            -D "PKG_VERSION 1.0.0.5"                             \
            -D "PKG_RELEASE 1"                                   \
            myapp.spec
Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.AW6YVB
+ umask 022
+ cd /home/andreas/src/myapp/pkg/package/BUILD
+ '[' /home/andreas/src/myapp/pkg/package/BUILDROOT/myapp-1.0.0.5-1.x86_64 '!=' / ']'
+ rm -rf /home/andreas/src/myapp/pkg/package/BUILDROOT/myapp-1.0.0.5-1.x86_64
++ dirname /home/andreas/src/myapp/pkg/package/BUILDROOT/myapp-1.0.0.5-1.x86_64
+ mkdir -p /home/andreas/src/myapp/pkg/package/BUILDROOT
+ mkdir /home/andreas/src/myapp/pkg/package/BUILDROOT/myapp-1.0.0.5-1.x86_64

+ PKG_PROTO=/home/andreas/src/myapp/pkg/package/BUILDROOT/myapp-1.0.0.5-1.x86_64/opt/myapp/mysubcomponent
+ install -v -d /home/andreas/src/myapp/pkg/package/BUILDROOT/myapp-1.0.0.5-1.x86_64/opt/myapp/mysubcomponent
install: creating directory '/home/andreas/src/myapp/pkg/package/BUILDROOT/myapp-1.0.0.5-1.x86_64/opt'
install: creating directory '/home/andreas/src/myapp/pkg/package/BUILDROOT/myapp-1.0.0.5-1.x86_64/opt/myapp'
install: creating directory '/home/andreas/src/myapp/pkg/package/BUILDROOT/myapp-1.0.0.5-1.x86_64/opt/myapp/mysubcomponent'
+ rsync -av /home/andreas/src/myapp/build/ /home/andreas/src/myapp/pkg/package/BUILDROOT/myapp-1.0.0.5-1.x86_64/opt/myapp/mysubcomponent/
sending incremental file list
./
bin/
bin/myexecutable
etc/
etc/myconfig
lib/
lib/mylibrary.so
sent 14,794 bytes  received 187 bytes  29,962.00 bytes/sec
total size is 14,064  speedup is 0.94

+ /usr/lib/rpm/check-buildroot
+ /usr/lib/rpm/redhat/brp-compress
+ /usr/lib/rpm/redhat/brp-strip /usr/bin/strip
+ /usr/lib/rpm/redhat/brp-strip-comment-note /usr/bin/strip /usr/bin/objdump
+ /usr/lib/rpm/redhat/brp-strip-static-archive /usr/bin/strip
+ /usr/lib/rpm/brp-python-bytecompile /usr/bin/python 1
+ /usr/lib/rpm/redhat/brp-python-hardlink
+ /usr/lib/rpm/redhat/brp-java-repack-jars
Processing files: myapp-1.0.0.5-1.x86_64
Provides: myapp= 1.0.0.5-1. myapp(x86-64) = 1.0.0.5-1
Requires(interp): /bin/sh /bin/sh /bin/sh
Requires(rpmlib): rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1 rpmlib(CompressedFileNames) <= 3.0.4-1
Requires(pre): /bin/sh
Requires(post): /bin/sh
Requires(preun): /bin/sh
Checking for unpackaged file(s): /usr/lib/rpm/check-files /home/andreas/src/myapp/pkg/package/BUILDROOT/myapp-1.0.0.5-1.x86_64
Wrote: /home/andreas/src/myapp/pkg/package/RPMS/x86_64/myapp-1.0.0.5-1.x86_64.rpm
$ yum install /home/andreas/src/myapp/pkg/package/RPMS/x86_64/myapp-1.0.0.5-1.x86_64.rpm
[...]
Install  1 Package

Total size: 11 M
Installed size: 11 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
## INFO: myapp : pre
  Installing : myapp-1.0.0.5-1.x86_64
## INFO: myapp : post
  Verifying  : myapp-1.0.0.5-1.x86_64

Installed:
  myapp.x86_64 0:1.0.0.5-1

Complete!
$ yum erase myapp
[...]
Remove  1 Package

Installed size: 9.6 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
## INFO: myapp : preun
  Erasing    : myapp-1.0.0.5-1.x86_64
## INFO: myapp : postun
  Verifying  : myapp-1.0.0.5-1.x86_64

Removed:
  myapp-1.0.0.5-1.x86_64

Complete!

max-rpm

Directives For the %files list

The %dir Directive

As we mentioned in the Section called The %files List, if a
directory is specified in the %files list, the contents of
that directory, and the contents of every directory under it,
will automatically be included in the package.

While this feature can be handy (assuming you are sure that
every file under the directory should be packaged) there are
times when this could be a problem.

The way to get around this, is to use the %dir directive. 

Automatic Dependencies

Fedora

Packaging Tutorial: GNU Hello
Automatic Filtering of Provides and Requires

spec File

Spec file format

rsync

What actually is $RPM_BUILD_ROOT?

$RPM_BUILD_ROOT (or the equivalent %{buildroot} SPEC file macro) always
holds the directory under which RPM will look for any files to package.

Disable Automatic Dependency Processing

How do I prevent rpmbuild form injecting requirements into RPM package?
Disable rpmbuild automatic requirement finding (AutoReqProv: no)

RPM Naming Schemes

Understanding RPM Versions and Naming Schemes

[name]-[version]-[release].[arch].rpm

RPM Default attributes

What does %defattr mean in RPM spec files?

The %defattr Directive
  The %defattr directive allows setting of default attributes for files and directives.
  The %defattr has a similar format to the %attr directive:
    1. The default permissions, or "mode" for files.
    2. The default user id.
    3. The default group id.
    4. The default permissions, or "mode" for directories.

  The %attr directive has the following format:
    %defattr(file mode, user, group, dir mode)

install

Baeldung: The install Command in Linux

rsync

When is -av NOT the appropriate option for rsync?

-v

verbose

-a

archive mode

includes:

-r, --recursive recurse into directories
-l, --links copy symlinks as symlinks
-p, --perms preserve permissions
-t, --times preserve modification times
-g, --group preserve group
-o, --owner preserve owner (super-user only)
-D same as --devices --specials
--devices preserve device files (super-user only)
--specials preserve special files

and excludes:

-H, --hard-links preserve hard links
-A, --acls preserve ACLs (implies -p)
-X, --xattrs preserve extended attributes

Event/Alert/Monitoring Applications

  • Elastic beats
  • Redis
  • logstash
  • Splunk
  • BigPanda
  • servicenow
  • Kafka

Elastic Stack

Was ist der ELK Stack? (ELK = Elasticsearch, Logstash und Kibana ==> Elastic Stack mit Beats)
How to forward events from logstash to Splunk
Deploying Redis with the ELK Stack
Sending logs from filebeat to redis and then logstash
Filebeats: Configure the Redis output

BigPanda

Splunk Integration
Cribl Integration
Sleeping Good At Night — Kafka Configurations Tweaks

BigPanda’s pipeline handles millions of events per second using micro services architecture which is heavily dependent on Kafka.We are using Kafka as an events streaming platform which helps our micro services “talk” with each other.

Splunk

Set up and use HTTP Event Collector in Splunk Web
Supported integrations

Cribl

Elastic + Cribl help organizations migrate SIEM and keep it simple

YouTube

BigPanda

Getting Started with BigPanda (Playlist)
Fast Track Video Series #7 – Getting started with BigPanda
Machine Learning & AIOps: Why IT Operations & Monitoring Teams Should Care
UBS invests in BigPanda to help drive digital disruption and innovation in AIOps

Elastic Stack

How to install and configure elasticsearch Auditbeat [7.x] | Auditbeat tutorial for beginners
[ Elasticsearch 12 ] How to configure and use AuditBeat
View Your System Logs with Elastic in Under 10 Minutes
Everything you Always Wanted to Know about Filebeat * But Were Afraid to Ask
Webinar: Elastic: Was sind Beats (Webinar vom 11. Mai 2022)

Kafka

Course | Apache Kafka Fundamentals (Playlist), Confluent
Apache Kafka Tutorials | Kafka 101, Confluent
Apache Kafka in 1 hour for C# Developers – Guilherme Ferreira – NDC London 2023, NDC Conferences
System Design: Why is Kafka fast?, ByteByteGo
Apache Kafka for Beginners (3+ hours long), Bogdan Stashchuk
Was ist Kafka?, IBM Technology

C++ Debugging with gdb

$ readelf -S <executable>
[...]
  [29] .debug_aranges    PROGBITS         0000000000000000  0001e5dd
       00000000000025d0  0000000000000000           0     0     1
  [30] .debug_info       PROGBITS         0000000000000000  00020bad
       00000000000fe146  0000000000000000           0     0     1
  [31] .debug_abbrev     PROGBITS         0000000000000000  0011ecf3
       00000000000078ba  0000000000000000           0     0     1
  [32] .debug_line       PROGBITS         0000000000000000  001265ad
       0000000000009e15  0000000000000000           0     0     1
  [33] .debug_str        PROGBITS         0000000000000000  001303c2
       00000000000461b1  0000000000000001  MS       0     0     1
  [34] .debug_ranges     PROGBITS         0000000000000000  00176573
       00000000000027d0  0000000000000000           0     0     1
[...]

C++ const

Const Correctness / C vs. C++ Differences
error: passing xxx as ‘this’ argument of xxx discards qualifiers

you’re calling a non-const member function on const object which is not allowed because non-const member functions make NO PROMISE not to modify the object

What is the meaning of ‘const’ at the end of a member function declaration?
declaring a const instance of a class

error: passing xxx as 'this' argument of xxx discards qualifiers
error: passing ‘const Foo’ as ‘this’ argument of ‘void Foo::bar()’ discards qualifiers [-fpermissive]
class Foo {
  public:
    Foo() {};
    virtual ~Foo() {};
    
    // must be const:
    // void bar() const {};
    void bar() {};
};

int
main(int argc, char *argv[])
{
  const Foo foo;

  foo.bar();

  return 0;
}