SlideShare a Scribd company logo
1 of 65
Download to read offline
Bundling Packages and 
Deploying Applications 
with RPM 
Alexander Shopov 
<ash@kambanaria.org>
[ash@edge ~]$ whoami 
By day: Software Engineer at Cisco {,Nov. 28} 
By night: OSS contributor 
Coordinator of Bulgarian Gnome TP 
Contacts: 
E-mail: ash@kambanaria.org 
Jabber: al_shopov@jabber.minus273.org 
LinkedIn: http://www.linkedin.com/in/alshopov 
SlideShare: http://www.slideshare.net/al_shopov 
GitHub: https://github.com/alshopov 
Web: Just search “al_shopov”
Please Learn And Share 
License: Creative Commons Attribution 4.0 
International 
CC-BY v4.0
Why Package at All?
NICE & 
NEAT
As Number of Components Grows 
Complexity (Interactions) Grows as 
Power of 2
As Years of Maintenence Grow 
Complexity Grows at Least Linearly
As Both Number of Components 
and Years Grow – Complexity 
Explodes
Why RPM 
● Widely used packaging format; 
● Used to mean: “Red Hat Package Manager”, now 
it is “RPM Package Manager”; 
● Popular with Enterprise-ish distributions: 
– Fedora; 
– Red Hat; 
– CentOS; 
– Oracle's Linux; 
– SUSE. 
● The other popular format in Linux is “deb” used in 
Debian/Ubuntu.
Where Does RPM Stand? 
Inno, NullSoft, InstallShiled, 
Wix, Windows Installer, 
Installer for Mac OS 
Compiling 
Source to Binary 
Make, imake, auto-tools, 
project/solution files, etc. 
Packaging 
Binary to Packages
Where Does RPM Stand? 
RPM 
Compiling 
Packaging 
Source to Binary 
Binary to Packages Make, imake, auto-tools, 
Inno, NullSoft, InstallShiled, 
project/solution files, etc. 
Wix, Windows Installer, 
Installer for Mac OS
The Packaging Process 
SPECS 
SOURCES 
BUILD 
BUILDROOT 
RPMS
The Packaging Process 
SOURCES 
BUILD 
BUILDROOT 
RPMS 
SPECS 
%prep 
%install 
%files 
● Uncompress & patch 
– rpmbuild -bp 
● Configure/compile 
– rpmbuild -bc 
● Install to a virtual file 
system – place, copy 
– rpmbuild -bi 
● List files to be packaged 
– rpmbuild -bb/-bs/-ba
Structure of RPM file 
● Lead/identifier/magic ( starts with abed dbee - hex) 
● Signature - optional 
● Header – tagged structure – 
tags/type/number/size/data for them 
● Payload – archive. gzipped cpio (1977 by Dick Haight 
UNIX 1.0) → gzipped tar (UNIX 7th ed. – 1979) 
Payload 
Identifier 
Signature 
Header
Structure of RPM Package Name 
● name-version-release.architecture.rpm 
● gzip-1.3.12-19.el6_4.x86_64.rpm 
● Name – what package is or does and purpose 
● Version – upstream version 
● Release – version of RPM (prefix for distro) 
● Architecture of the rpm 
– noarch 
– src
Common and Rarer Archiectures 
Suffix Architecture Fedora RedHat CentOS Oracle 
i686 32bit Intel x x x x 
x86_64 64bit AMD x x x x 
ia64 64bit Intel x x x 
s390 24/31/32bit G4/5/6 x x 
s390x IBM System Z – 64bit z900 x x 
ppc 32bit PowerPC x x 
ppc64 64bit PowerPC BE x x 
ppc64le 64bit PowerPC LE ( 
arm 32bit ARM5-7 ) 
armhfp 32bit ARM7 x 
aaarch64 64bit ARM8+ x
Important Packages to Install 
● redhat-rpm-config 
● rpm-build 
● rpmdevtools 
● rpmlint 
● Other if you want to contribute to 
Fedora/Redhat/CentOS. Oracle have not 
published for them
redhat-rpm-config 
● /etc/rpm/macros* - others also install here - 
macros here perl,python, nodejs, java 
● /usr/lib/rpm/redhat – macros and shell scripts
rpm-build 
● rpmbuild – command to actually build 
● rpmspec – query spec files 
● gendiff – diff wrapper
rpmlint 
● rpmlint – check errors in specs and packages 
● rpmdiff – check differences between packages
rpmdevtools 
● rpmfile, rpmls, rpmpeek, rpmelfsym, rpmargs 
● /etc/rpmdevtools – spec templates 
● rpmdev-bumpspec – auto increment and 
maintain spec files 
● rpmdev-setuptree – create the spec tree 
● rpmdev-newinit, rpmdev-newspec
Let's Build A Package! 
● Let's build Tomcat 8 package 
● Proper ownership of files 
● Add a startup/shtdown script 
● Deploy a small package in Tomcat 
● Make the package take the place of ROOT 
context 
● Switch provider of JPA – from Derby to Oracle 
RDBMS
Prepare The Build Environment 
● yum install rpmdevtools 
● Dependencies: 
– fakeroot 
– fakeroot-libs 
– rpm-build
DON'T BUILD AS ROOT! 
ROOT
FAKE IT! 
LEAVE IT TO 
FAKEROOT
Create Designated User for Building 
of RPM 
● useradd packager (will make a user group with 
same name) 
● passwd packager 
● Do not add designated user to groups: 
– root/wheel 
– adm/sys/shutdown/sshd, others 
– oinstall/dba/oper (if you have Oracle RDBMS on 
the same machine for some weird reason)
Create RPM Building Environment 
● rpmdev-setuptree 
● ~/.rpmmacros 
– %_topdir %(echo $HOME)/rpmbuild 
● ls ~/rpmbuild/ 
– BUILD RPMS SOURCES SPECS SRPMS 
– mkdir ~/rpmbuild/BUILDROOT 
● rpm --eval '%buildroot' 
– /home/packager/rpmbuild/BUILDROOT/%{name}-% 
{version}-%{release}.i386
Starting the Build 
rpmdev-newspec -o ~/rpmbuild/SPECS/counterbean.spec 
preamble 
%prep 
%build 
%install 
%clean 
%files 
%changelog 
Name: counterbean 
Version: 
Release: 1%{?dist} 
Summary: 
Group: 
License: 
URL: 
Source0: 
BuildRequires: 
Requires: 
%description 
%prep 
%setup -q 
%build 
%configure 
make %{?_smp_mflags} 
%install 
rm -rf $RPM_BUILD_ROOT 
make install DESTDIR=$RPM_BUILD_ROOT 
%clean 
rm -rf $RPM_BUILD_ROOT 
%files 
%defattr(-,root,root,-) 
%doc 
%changelog
Fix the Preamble 
Name: counterbean 
Version: 2.0.1 
Release: 1%{?dist} 
Summary: Keep a keen eye on beans for counting purposes 
# one of '/usr/share/doc/rpm-*/GROUPS' 
Group: Applications/Productivity 
License: ASL 2.0 
URL: https://github.com/alshopov/counterbean 
Source0: apache-tomcat-8.0.14.tar.gz 
# BuildRequires: TODO 
# Requires: TODO 
# no need to set BuildRoot/٪buildroot/$RPM_BUILD_ROOT 
# it is set for us 
# BuildRoot:
Fix the Preamble 
Name: counterbean 
Version: 2.0.1 
Release: 1%{?dist} 
Summary: Keep a keen Comments eye on beans start for with counting “#” 
purposes 
# one of '/usr/share/doc/rpm-*/Place GROUPS' 
comments on lines 
Group: Applications/Productivity 
License: ASL 2.0 
URL: https://github.com/alshopov/counterbean 
Source0: apache-tomcat-8.0.14.tar.gz 
# BuildRequires: TODO 
# Requires: TODO 
# no need to set BuildRoot/٪buildroot/$RPM_BUILD_ROOT 
# it is set for us 
# BuildRoot:
Fix the Preamble 
Name: counterbean 
Version: 2.0.1 
Release: 1%{?dist} 
Summary: Keep a keen eye on beans for counting purposes 
# one of '/usr/share/doc/rpm-*/Group: Applications/Productivity 
The GROUPS' 
Voldemort Character – 
License: ASL 2.0 
Do not name “%” 
URL: https://github.com/alshopov/counterbean 
Source0: apache-tomcat-8.0.14.tar.gz 
# BuildRequires: TODO 
# Requires: TODO 
# no need to set BuildRoot/٪buildroot/$RPM_BUILD_ROOT 
# it is set for us 
# BuildRoot:
Fix the Preamble 
Name: counterbean 
Version: 2.0.1 
Release: 1%{?dist} 
Summary: Keep a keen We eye will fix on these beans later 
for counting purposes 
# one of '/usr/share/doc/rpm-*/GROUPS' 
Group: Applications/Productivity 
License: ASL 2.0 
URL: https://github.com/alshopov/counterbean 
Source0: apache-tomcat-8.0.14.tar.gz 
# BuildRequires: TODO 
# Requires: TODO 
# no need to set BuildRoot/٪buildroot/$RPM_BUILD_ROOT 
# it is set for us 
# BuildRoot:
%define prefix /opt/%{name} 
%description 
A sample Java application for packaging demo purposes. 
You can also use it to count: 
* beans; 
* kogs; 
* minions. 
%prep 
# -q: no output, -c: create directory 
%setup -q -c 
%install 
install -m 0755 -d ${RPM_BUILD_ROOT}%{prefix} 
cp -r apache-tomcat-8.0.14/* ${RPM_BUILD_ROOT}%{prefix} 
%clean 
rm -fr ${RPM_BUILD_ROOT} 
%files 
%defattr(-,root,root,-) 
/opt/counterbean 
%doc 
%changelog 
* Mon Oct 13 2014 Alexander Shopov <ash@kambanaria.org> 
- Initial version containing only tomcat.
[root@localhost ashopov]# yum install  
~packager/rpmbuild/RPMS/i386/counterbean-2.0.1-1.el6.i386.rpm 
Loaded plugins: refresh-packagekit, security 
Setting up Install Process 
Examining /home/packager/rpmbuild/RPMS/i386/counterbean-2.0.1-1.el6.i386.rpm: 
counterbean-2.0.1-1.el6.i386 
Marking /home/packager/rpmbuild/RPMS/i386/counterbean-2.0.1-1.el6.i386.rpm to be installed 
Resolving Dependencies 
--> Running transaction check 
---> Package counterbean.i386 0:2.0.1-1.el6 will be installed 
--> Finished Dependency Resolution 
Dependencies Resolved 
====================================================================================== 
Package Arch Version Repository Size 
====================================================================================== 
Installing: 
counterbean i386 2.0.1-1.el6 /counterbean-2.0.1-1.el6.i386 12 M 
Transaction Summary 
====================================================================================== 
Install 1 Package(s) 
Total size: 12 M 
Installed size: 12 M 
Is this ok [y/N]: y 
Downloading Packages: 
Running rpm_check_debug 
Running Transaction Test 
Transaction Test Succeeded 
Running Transaction 
Installing : counterbean-2.0.1-1.el6.i386 1/1 
Verifying : counterbean-2.0.1-1.el6.i386 1/1 
Installed: 
counterbean.i386 0:2.0.1-1.el6 
Complete!
Try To Start 
[packager@localhost ~]$ /opt/counterbean/bin/startup.sh 
Neither the JAVA_HOME nor the JRE_HOME environment variable is defined 
At least one of these environment variable is needed to run this program 
[packager@localhost ~]$
We Forgot Dependencies 
[root@localhost ~]# yum provides '*/java' 
Loaded plugins: refresh-packagekit, security 
⋮⋮⋮ 
graphviz-java-2.26.0-7.el6.i686 : Java extension for graphviz 
Repo : public_ol6_latest 
Matched from: 
Filename : /usr/lib/graphviz/java 
⋮⋮⋮ 
1:java-1.6.0-openjdk-1.6.0.0-6.1.13.4.el6_5.i686 : OpenJDK Runtime Environment 
Repo : public_ol6_latest 
Matched from: 
Filename : /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre/bin/java 
⋮⋮⋮ 
[packager@localhost ~]$ yum provides jre 
Loaded plugins: refresh-packagekit, security 
⋮⋮⋮ 
1:java-1.6.0-openjdk-1.6.0.0-5.1.13.3.el6_5.i686 : OpenJDK Runtime Environment 
Repo : public_ol6_latest 
Matched from: 
Other : jre 
⋮⋮⋮ 
1:java-1.7.0-openjdk-1.7.0.51-2.4.4.1.0.1.el6_5.i686 : OpenJDK Runtime Environment 
Repo : public_ol6_latest 
Matched from: 
Other : jre 
⋮⋮⋮
Add Dependencies 
Release: 2%{?dist} 
Requires: jre 
%changelog 
* Mon Oct 13 2014 Alexander Shopov <ash@kambanaria.org> 
Add jre as runtime dependency 
* Mon Oct 13 2014 Alexander Shopov <ash@kambanaria.org> 
Initial version containing only tomcat.
[root@localhost ashopov]# yum install  
~packager/rpmbuild/RPMS/i386/counterbean-2.0.1-2.el6.i386.rpm 
Loaded plugins: refresh-packagekit, security 
Setting up Install Process 
Examining /home/packager/rpmbuild/RPMS/i386/counterbean-2.0.1-2.el6.i386.rpm: 
counterbean-2.0.1-2.el6.i386 
Marking /home/packager/rpmbuild/RPMS/i386/counterbean-2.0.1-2.el6.i386.rpm as an 
update to counterbean-2.0.1-1.el6.i386 
Resolving Dependencies 
--> Running transaction check 
---> Package counterbean.i386 0:2.0.1-1.el6 will be updated 
---> Package counterbean.i386 0:2.0.1-2.el6 will be an update 
--> Processing Dependency: jre for package: counterbean-2.0.1-2.el6.i386 
--> Running transaction check 
---> Package java-1.7.0-openjdk.i686 1:1.7.0.65-2.5.1.2.0.1.el6_5 will be installed 
--> Finished Dependency Resolution 
Dependencies Resolved
Parametrize the SPEC 
Name: counterbean 
Version: 2.0.1 
Release: 3%{?dist} 
Summary: Keep a keen eye on beans for counting purposes 
Group: Applications/Productivity 
License: ASL 2.0 
URL: https://github.com/alshopov/counterbean 
Requires: jre 
%define tc_ver 8.0.14 
Source0: apache-tomcat-%{tc_ver}.tar.gz 
%description 
… 
%define prefix /opt/%{name} 
%prep 
… 
%install 
install -m 0755 -d ${RPM_BUILD_ROOT}%{prefix} 
cp -r apache-tomcat-%{tc_ver}/* ${RPM_BUILD_ROOT}%{prefix} 
%clean 
… 
%files 
… 
%changelog 
…
Root Owns Everything – Let's Fix 
Release: 4%{?dist} 
%files 
%defattr(-,%{name},%{name},-) 
/opt/%{name} 
%changelog 
* Tue Oct 14 2014 Alexander Shopov <ash@kambanaria.org> 
Make 'counterbean' user own everything 
…
But When We Install… 
warning: user counterbean does not exist - using root 
warning: group counterbean does not exist - using root
We Must First Create The User 
Release: 5%{?dist} 
Requires(pre): shadow-utils 
%pre 
getent group %{name} >/dev/null || groupadd -r %{name} 
getent passwd %{name} >/dev/null ||  
useradd -r -g %{name} -d %{prefix} -s /sbin/nologin  
-c "Account to own and run %{name}" %{name} 
exit 0 
%changelog 
* Tue Oct 14 2014 Alexander Shopov <ash@kambanaria.org> 
Create user and group for 'counterbean' 
…
Create Template 
[packager@localhost rpmbuild]$ rpmdev-newinit --help 
⋮⋮⋮ 
The template used is /etc/rpmdevtools/template.init. 
[packager@localhost rpmbuild]$ rpmdev-newinit  
/rpmbuild/SOURCES/counterbean.init 
Skeleton init script has been created to 
"/home/packager/rpmbuild/SOURCES/counterbean.init". 
# The template used is /etc/rpmdevtools/template.init.
#!/bin/sh 
# 
# counterbean - <summary> 
# 
# chkconfig: <default runlevel(s)> <start> <stop> 
# description: <description, split multiple lines 
# with a backslash> 
# http://fedoraproject.org/wiki/FCNewInit/Initscripts 
### BEGIN INIT INFO 
# Provides: 
# Required-Start: 
# Required-Stop: 
# Should-Start: 
# Should-Stop: 
# Default-Start: 
# Default-Stop: 
# Short-Description: 
# Description: 
### END INIT INFO 
# Source function library. 
. /etc/rc.d/init.d/functions 
exec="/usr/sbin/counterbean" 
prog=$(basename $exec) 
[ -e /etc/sysconfig/$prog ] &&  
. /etc/sysconfig/$prog 
lockfile=/var/lock/subsys/$prog 
start() { 
echo -n $"Starting $prog: " 
# if not running, start it up here, usually something like "daemon $exec" 
retval=$? 
echo 
[ $retval -eq 0 ] && touch $lockfile 
return $retval 
} 
Template Contents 
stop() { 
echo -n $"Stopping $prog: " 
# stop it here, often "killproc $prog" 
retval=$? 
echo 
[ $retval -eq 0 ] && rm -f $lockfile 
return $retval 
} 
restart() { 
stop 
start 
} 
case "$1" in 
start|stop|restart) 
$1 
;; 
force-reload) 
restart 
;; 
status) 
status $prog 
;; 
try-restart|condrestart) 
if status $prog >/dev/null ; then 
restart 
fi 
;; 
reload) 
# If config can be reloaded without restarting, implement it here, 
# remove the "exit", and add "reload" to the usage message below. 
# For example: 
# status $prog >/dev/null || exit 7 
# killproc $prog -HUP 
action $"Service ${0##*/} does not support the reload action: " /bin/false 
exit 3 
;; 
*) 
echo $"Usage: $0 {start|stop|status|restart|try-restart|force-reload}" 
exit 2 
esac
Startup Script 
#!/bin/sh 
# 
# counterbean - count bean, kogs, minions 
# 
# chkconfig: 345 98 02 
# description: small demo RDBMS Java web app 
# Source function library. 
. /etc/rc.d/init.d/functions 
start_cmd="runuser counterbean -g counterbean -s 
/bin/sh -c '/opt/counterbean/bin/startup.sh' " 
stop_cmd="runuser counterbean -g counterbean -s 
/bin/sh -c '/opt/counterbean/bin/shutdown.sh' " 
prog=counterbean 
lockfile=/var/lock/subsys/$prog 
start() { 
echo -n $"Starting $prog: " 
$start_cmd 
retval=$? 
echo 
[ $retval -eq 0 ] && touch $lockfile 
return $retval 
} 
stop() { 
echo -n $"Stopping $prog: " 
$stop_cmd 
retval=$? 
echo 
[ $retval -eq 0 ] && rm -f $lockfile 
return $retval 
} 
restart() { 
stop 
start 
} 
case "$1" in 
start|stop|restart) 
$1 
;; 
status) 
status $prog 
;; 
*) 
echo $"Usage: $0 {start|stop|restart|status}" 
exit 2 
esac
Use The Script 
Release: 6%{?dist} 
Requires: coreutils, jre, chkconfig, initscripts 
Requires(pre): shadow-utils 
%define tc_ver 8.0.14 
Source0: apache-tomcat-%{tc_ver}.tar.gz 
Source1: %{name}.init 
%install 
install -m 0755 -d ${RPM_BUILD_ROOT}%{prefix} 
cp -r apache-tomcat-%{tc_ver}/* ${RPM_BUILD_ROOT}%{prefix} 
install %{SOURCE1} -D ${RPM_BUILD_ROOT}/etc/rc.d/init.d/%{name} 
%defattr(-,%{name},%{name},-) 
/opt/%{name} 
%attr(-,root,root) /etc/rc.d/init.d/%{name} 
%changelog 
* Wed Oct 15 2014 Alexander Shopov <ash@kambanaria.org> 
Proper startup scripts 
…
Use The Script 
%pre 
getent group %{name} >/dev/null || groupadd -r %{name} 
getent passwd %{name} >/dev/null ||  
useradd -r -g %{name} -d %{prefix} -s /sbin/nologin  
-c "Account to own and run %{name}" %{name} 
exit 0 
%post 
/sbin/chkconfig --add %{name} 
if [ "$1" = 1 ]; then 
/sbin/service %{name} start > /dev/null 2>&1 
fi 
exit 0 
%preun 
if [ "$1" = 0 ]; then 
/sbin/service %{name} stop > /dev/null 2>&1 
fi 
exit 0 
%postun 
if [ "$1" -ge 1 ]; then 
/sbin/service %{name} restart > /dev/null 2>&1 
fi 
exit 0
%pre, %post, %preun, 
%postun? 
● Scripts that get executed on install, upgrade, 
remove; 
● There are others: 
– %triggerin, %triggerun, %triggerpostun: 
ADVANCED – dependencies on packages; 
– %pretrans, %posttrans: VERY ADVANCED, 
avoid (will fail in chroot, initial install, usually written 
in Lua.
Execution of Scripts 
install upgrade uninstall 
%pre $1 == 1 $1 == 2 Not run 
%post $1 == 1 $1 == 2 Not run 
%preun Not run $1 == 1 $1 == 0 
%postun Not run $1 == 1 $1 == 0 
1 2 3 4 5 6 
%pre of new 
package 
package 
install 
%post of 
new 
package 
%preun of 
old package 
removal of 
old 
package 
%postun of 
old package 
$1 == 2 $1 == 2 $1 == 1 $1 == 1
Introducing CounterBean – 
Enterprise version
Very Modern App
Very Modern App 
HTML5 
Bootstrap 3.2
Very Modern App 
Servlet 3.0 
No web.xml 
Servlet 3.0 
Annotations
Very Modern App 
In-Memory Derby 
JPA 2.1 
With EclipseLink 2.5.x
When Deploying It 
● Remove default applications from Tomcat 
● Make it the ROOT application 
– Expand as ROOT in Tomcat's webapps folder 
– Remove context.xml 
● Migrate to Oracle RDBMS 
– Fix persistence.xml 
– Add Oracle's driver
Make Counterbean the Default App 
Release: 7%{?dist} 
%define tc_ver 8.0.14 
%define cb_ver 1.0-SNAPSHOT 
Source0: apache-tomcat-%{tc_ver}.tar.gz 
Source1: %{name}-%{cb_ver}.war 
Source2: %{name}.init 
%install 
install -m 0755 -d ${RPM_BUILD_ROOT}%{prefix} 
cp -r apache-tomcat-%{tc_ver}/* ${RPM_BUILD_ROOT}%{prefix} 
# Remove default applications 
rm -fr ${RPM_BUILD_ROOT}%{prefix}/webapps 
# Ensure ROOT exists and unzip counterbean to it 
install -m 0755 -d ${RPM_BUILD_ROOT}%{prefix}/webapps/ROOT 
unzip %{SOURCE1} -d ${RPM_BUILD_ROOT}%{prefix}/webapps/ROOT 
# Sets the context, we need the default 
rm -fr ${RPM_BUILD_ROOT}%{prefix}/webapps/ROOT/META-INF/context.xml 
install %{SOURCE2} -D ${RPM_BUILD_ROOT}/etc/rc.d/init.d/%{name}
The DBA Prepares the RDBMS 
SQL> CREATE USER counterbean IDENTIFIED BY counterbean; 
User created. 
SQL> GRANT RESOURCE, CONNECT TO counterbean; 
Grant succeeded. 
SQL> ALTER USER counterbean QUOTA 50M ON USERS; 
User altered.
The DBA Prepares the RDBMS 
AKA “Mr. Generous DBA” 
SQL> CREATE USER counterbean IDENTIFIED BY counterbean; 
User created. 
SQL> GRANT RESOURCE, CONNECT TO counterbean; 
Grant succeeded. 
SQL> ALTER USER counterbean QUOTA 50M ON USERS; 
User altered.
Use Oracle RDBMS 
Release: 8%{?dist} 
⋮⋮⋮ 
Source2: %{name}.init 
Source3: ojdbc7.jar 
Source4: persistence.xml 
%install 
⋮⋮⋮ 
# Sets the context, we need the default 
rm -fr ${RPM_BUILD_ROOT}%{prefix}/webapps/ROOT/META-INF/context.xml 
install %{SOURCE2} -D ${RPM_BUILD_ROOT}/etc/rc.d/init.d/%{name} 
# Replace JDBC driver 
rm ${RPM_BUILD_ROOT}%{prefix}/webapps/ROOT/WEB-INF/lib/derby-*.jar 
cp %{SOURCE3} ${RPM_BUILD_ROOT}%{prefix}/webapps/ROOT/WEB-INF/lib/ 
# Replace persistence.xml 
cp %{SOURCE4} ${RPM_BUILD_ROOT}%{prefix} 
/webapps/ROOT/WEB-INF/classes/META-INF/persistence.xml
Final File Touches 
Release: 9%{?dist} 
%files 
%defattr(-,%{name},%{name},-) 
/opt/%{name} 
%attr(-,root,root) /etc/rc.d/init.d/%{name} 
%doc /opt/%{name}/LICENSE 
%doc /opt/%{name}/NOTICE 
%doc /opt/%{name}/RELEASE-NOTES 
%doc /opt/%{name}/RUNNING.txt 
%attr(755,%{name},%{name}) %ghost /opt%{name}/conf/Catalina/ 
%ghost /opt/%{name}/logs/ 
%ghost /opt/%{name}/work/ 
%config /opt/%{name}/webapps/ROOT/WEB-INF/classes/META-INF/persistence.xml
Publishing RPMs As Yum 
Repositories 
yum install createrepo 
mkdir -p /somewhere/{SRPMS,i386,x86_64} 
# copy RPMs to the directories 
for arch in /somewhere/*; do 
pushd ${arch} 
createrepo . 
popd 
done
Using the New Repository 
cat /etc/yum.repos.d/example.repo 
[example] 
name=Example Repository 
baseurl=ftp://example.com/somewhere/$basearch 
enabled=1
Popular RPM Commands 
rpm -ivh counterbean-2.0.1-10.el6.i386 
# Install, Verbose, Hashes show progress 
rpm -U *.rpm # Upgrade 
rpm -F *.rpm # Freshen – install if exists 
rpm -qa | grep -i counterbean # Query All 
rpm -qpR counterbean-2.0.1-10.el6.i386 
# Query what the package Provide and Requires 
rpm -ql counterbean # Query List files in package 
rpm -e counterbean # Erase 
rpm -qf /etc/passwd # Query for package of File 
rpm -qi counterbean # infomration 
# do the query on a package rather than the RPM DB 
rpm -qip counterbean-2.0.1-10.el6.i386 # or -qilp 
rpm -Vp # verify package – changes to files 
rpm --rebuilddb # rebuild database
Popular YUM Commands 
yum install counterbean # install, -y automatically 
yum remove counterbean # uninstalls 
yum update -y # auto upgrades all 
yum search counterbean # find such a package 
yum info counterbean # info about a package 
yum list # list packages 
# available|installed|extras|updates|obsoletes 
yum group[list|info|install|update|remove] # groups 
yum provides /etc/passwd 
yum repolist # enables repositories 
yum repolist all # all 
yum --[enable|disable]repo=repo_id # enable/disable
Further Resources 
● Max RPM Book: http://www.rpm.org/max-rpm/ 
● GuruLabs RPM Guide: 
https://www.gurulabs.com/downloads/GURULABS-RPM-LAB/GUR 
ULABS-RPM-GUIDE-v1.0.PDF 
● Fedora Project 
– How to Create an RPM Package: 
https://fedoraproject.org/wiki/How_to_create_an_RPM_package 
– Packaging Guidelines: 
https://fedoraproject.org/wiki/Packaging:Guidelines 
● Clint Savage, How to Make an RPM: 
https://www.youtube.com/watch?v=4J_Iksu1fgo 
● Jeff's Linux Vids: 
https://www.youtube.com/channel/UC96flr-XcwMTeyZOhGPfkLw

More Related Content

What's hot

A Journey to Boot Linux on Raspberry Pi
A Journey to Boot Linux on Raspberry PiA Journey to Boot Linux on Raspberry Pi
A Journey to Boot Linux on Raspberry PiJian-Hong Pan
 
Snort296x centos6x 2
Snort296x centos6x 2Snort296x centos6x 2
Snort296x centos6x 2Trinh Tuan
 
J Ruby On Rails Presentation
J Ruby On Rails PresentationJ Ruby On Rails Presentation
J Ruby On Rails Presentationrailsconf
 
Ansible ex407 and EX 294
Ansible ex407 and EX 294Ansible ex407 and EX 294
Ansible ex407 and EX 294IkiArif1
 
Advanced Level Training on Koha / TLS (ToT)
Advanced Level Training on Koha / TLS (ToT)Advanced Level Training on Koha / TLS (ToT)
Advanced Level Training on Koha / TLS (ToT)Ata Rehman
 
Deploying and maintaining your software with RPM/APT
Deploying and maintaining your software with RPM/APTDeploying and maintaining your software with RPM/APT
Deploying and maintaining your software with RPM/APTJoshua Thijssen
 
Redhat 6 & 7
Redhat 6 & 7Redhat 6 & 7
Redhat 6 & 7r9social
 
aptly: Debian repository management tool
aptly: Debian repository management toolaptly: Debian repository management tool
aptly: Debian repository management toolAndrey Smirnov
 
Red Hat Certified Engineer (RHCE) EX294 Exam Questions
Red Hat Certified Engineer (RHCE) EX294 Exam QuestionsRed Hat Certified Engineer (RHCE) EX294 Exam Questions
Red Hat Certified Engineer (RHCE) EX294 Exam QuestionsStudy Material
 
Presentation iv implementasi 802x eap tls peap mscha pv2
Presentation iv implementasi  802x eap tls peap mscha pv2Presentation iv implementasi  802x eap tls peap mscha pv2
Presentation iv implementasi 802x eap tls peap mscha pv2Hell19
 
图文详解安装Net backup 6.5备份恢复oracle 10g rac 数据库
图文详解安装Net backup 6.5备份恢复oracle 10g rac 数据库图文详解安装Net backup 6.5备份恢复oracle 10g rac 数据库
图文详解安装Net backup 6.5备份恢复oracle 10g rac 数据库maclean liu
 
Tested install-isp config3-ubuntu-16-04
Tested install-isp config3-ubuntu-16-04Tested install-isp config3-ubuntu-16-04
Tested install-isp config3-ubuntu-16-04SANTIAGO HERNÁNDEZ
 
Jagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratchJagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratchlinuxlab_conf
 

What's hot (19)

A Journey to Boot Linux on Raspberry Pi
A Journey to Boot Linux on Raspberry PiA Journey to Boot Linux on Raspberry Pi
A Journey to Boot Linux on Raspberry Pi
 
Snort296x centos6x 2
Snort296x centos6x 2Snort296x centos6x 2
Snort296x centos6x 2
 
J Ruby On Rails Presentation
J Ruby On Rails PresentationJ Ruby On Rails Presentation
J Ruby On Rails Presentation
 
Ansible ex407 and EX 294
Ansible ex407 and EX 294Ansible ex407 and EX 294
Ansible ex407 and EX 294
 
Advanced Level Training on Koha / TLS (ToT)
Advanced Level Training on Koha / TLS (ToT)Advanced Level Training on Koha / TLS (ToT)
Advanced Level Training on Koha / TLS (ToT)
 
Deploying and maintaining your software with RPM/APT
Deploying and maintaining your software with RPM/APTDeploying and maintaining your software with RPM/APT
Deploying and maintaining your software with RPM/APT
 
Ex200
Ex200Ex200
Ex200
 
Redhat 6 & 7
Redhat 6 & 7Redhat 6 & 7
Redhat 6 & 7
 
aptly: Debian repository management tool
aptly: Debian repository management toolaptly: Debian repository management tool
aptly: Debian repository management tool
 
Presentation1
Presentation1Presentation1
Presentation1
 
OTRS
OTRSOTRS
OTRS
 
Red Hat Certified Engineer (RHCE) EX294 Exam Questions
Red Hat Certified Engineer (RHCE) EX294 Exam QuestionsRed Hat Certified Engineer (RHCE) EX294 Exam Questions
Red Hat Certified Engineer (RHCE) EX294 Exam Questions
 
Presentation iv implementasi 802x eap tls peap mscha pv2
Presentation iv implementasi  802x eap tls peap mscha pv2Presentation iv implementasi  802x eap tls peap mscha pv2
Presentation iv implementasi 802x eap tls peap mscha pv2
 
Linux networking
Linux networkingLinux networking
Linux networking
 
PHP selber bauen
PHP selber bauenPHP selber bauen
PHP selber bauen
 
图文详解安装Net backup 6.5备份恢复oracle 10g rac 数据库
图文详解安装Net backup 6.5备份恢复oracle 10g rac 数据库图文详解安装Net backup 6.5备份恢复oracle 10g rac 数据库
图文详解安装Net backup 6.5备份恢复oracle 10g rac 数据库
 
Tested install-isp config3-ubuntu-16-04
Tested install-isp config3-ubuntu-16-04Tested install-isp config3-ubuntu-16-04
Tested install-isp config3-ubuntu-16-04
 
Jagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratchJagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratch
 
Arch Linux Cheat
Arch Linux CheatArch Linux Cheat
Arch Linux Cheat
 

Similar to Bundling Packages and Deploying Applications with RPM

OSDC 2013 | Software Packaging with RPM Demystified by Andrew Ford
OSDC 2013 | Software Packaging with RPM Demystified by Andrew FordOSDC 2013 | Software Packaging with RPM Demystified by Andrew Ford
OSDC 2013 | Software Packaging with RPM Demystified by Andrew FordNETWAYS
 
Toolbox of a Ruby Team
Toolbox of a Ruby TeamToolbox of a Ruby Team
Toolbox of a Ruby TeamArto Artnik
 
9 steps to install and configure postgre sql from source on linux
9 steps to install and configure postgre sql from source on linux9 steps to install and configure postgre sql from source on linux
9 steps to install and configure postgre sql from source on linuxchinkshady
 
Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014biicode
 
Bringing-it-all-together-overview-of-rpm-packaging-in-fedora
Bringing-it-all-together-overview-of-rpm-packaging-in-fedoraBringing-it-all-together-overview-of-rpm-packaging-in-fedora
Bringing-it-all-together-overview-of-rpm-packaging-in-fedoraLalatendu Mohanty
 
OpenStack for Centos
OpenStack for CentosOpenStack for Centos
OpenStack for CentosChandan Kumar
 
Extending OpenShift Origin: Build Your Own Cartridge with Bill DeCoste of Red...
Extending OpenShift Origin: Build Your Own Cartridge with Bill DeCoste of Red...Extending OpenShift Origin: Build Your Own Cartridge with Bill DeCoste of Red...
Extending OpenShift Origin: Build Your Own Cartridge with Bill DeCoste of Red...OpenShift Origin
 
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis OverviewLeo Lorieri
 
How to make debian package from scratch (linux)
How to make debian package from scratch (linux)How to make debian package from scratch (linux)
How to make debian package from scratch (linux)Thierry Gayet
 
Instrumentación de entrega continua con Gitlab
Instrumentación de entrega continua con GitlabInstrumentación de entrega continua con Gitlab
Instrumentación de entrega continua con GitlabSoftware Guru
 
Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)
Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)
Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)Simon Boulet
 
Qt native built for raspberry zero
Qt native built for  raspberry zeroQt native built for  raspberry zero
Qt native built for raspberry zeroSoheilSabzevari2
 
Happy porting x86 application to android
Happy porting x86 application to androidHappy porting x86 application to android
Happy porting x86 application to androidOwen Hsu
 
2.5 use rpm and yum package management
2.5 use rpm and yum package management2.5 use rpm and yum package management
2.5 use rpm and yum package managementAcácio Oliveira
 
ERP System Implementation Kubernetes Cluster with Sticky Sessions
ERP System Implementation Kubernetes Cluster with Sticky Sessions ERP System Implementation Kubernetes Cluster with Sticky Sessions
ERP System Implementation Kubernetes Cluster with Sticky Sessions Chanaka Lasantha
 
101 2.5 use rpm and yum package management
101 2.5 use rpm and yum package management101 2.5 use rpm and yum package management
101 2.5 use rpm and yum package managementAcácio Oliveira
 
101 2.5 use rpm and yum package management
101 2.5 use rpm and yum package management101 2.5 use rpm and yum package management
101 2.5 use rpm and yum package managementAcácio Oliveira
 
An Overview of the IHK/McKernel Multi-kernel Operating System
An Overview of the IHK/McKernel Multi-kernel Operating SystemAn Overview of the IHK/McKernel Multi-kernel Operating System
An Overview of the IHK/McKernel Multi-kernel Operating SystemLinaro
 

Similar to Bundling Packages and Deploying Applications with RPM (20)

OSDC 2013 | Software Packaging with RPM Demystified by Andrew Ford
OSDC 2013 | Software Packaging with RPM Demystified by Andrew FordOSDC 2013 | Software Packaging with RPM Demystified by Andrew Ford
OSDC 2013 | Software Packaging with RPM Demystified by Andrew Ford
 
Toolbox of a Ruby Team
Toolbox of a Ruby TeamToolbox of a Ruby Team
Toolbox of a Ruby Team
 
9 steps to install and configure postgre sql from source on linux
9 steps to install and configure postgre sql from source on linux9 steps to install and configure postgre sql from source on linux
9 steps to install and configure postgre sql from source on linux
 
Rpm Introduction
Rpm IntroductionRpm Introduction
Rpm Introduction
 
Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014
 
Bringing-it-all-together-overview-of-rpm-packaging-in-fedora
Bringing-it-all-together-overview-of-rpm-packaging-in-fedoraBringing-it-all-together-overview-of-rpm-packaging-in-fedora
Bringing-it-all-together-overview-of-rpm-packaging-in-fedora
 
OpenStack for Centos
OpenStack for CentosOpenStack for Centos
OpenStack for Centos
 
Extending OpenShift Origin: Build Your Own Cartridge with Bill DeCoste of Red...
Extending OpenShift Origin: Build Your Own Cartridge with Bill DeCoste of Red...Extending OpenShift Origin: Build Your Own Cartridge with Bill DeCoste of Red...
Extending OpenShift Origin: Build Your Own Cartridge with Bill DeCoste of Red...
 
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
 
How to make debian package from scratch (linux)
How to make debian package from scratch (linux)How to make debian package from scratch (linux)
How to make debian package from scratch (linux)
 
RPM Packaging 101 (Old)
RPM Packaging 101 (Old)RPM Packaging 101 (Old)
RPM Packaging 101 (Old)
 
Instrumentación de entrega continua con Gitlab
Instrumentación de entrega continua con GitlabInstrumentación de entrega continua con Gitlab
Instrumentación de entrega continua con Gitlab
 
Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)
Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)
Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)
 
Qt native built for raspberry zero
Qt native built for  raspberry zeroQt native built for  raspberry zero
Qt native built for raspberry zero
 
Happy porting x86 application to android
Happy porting x86 application to androidHappy porting x86 application to android
Happy porting x86 application to android
 
2.5 use rpm and yum package management
2.5 use rpm and yum package management2.5 use rpm and yum package management
2.5 use rpm and yum package management
 
ERP System Implementation Kubernetes Cluster with Sticky Sessions
ERP System Implementation Kubernetes Cluster with Sticky Sessions ERP System Implementation Kubernetes Cluster with Sticky Sessions
ERP System Implementation Kubernetes Cluster with Sticky Sessions
 
101 2.5 use rpm and yum package management
101 2.5 use rpm and yum package management101 2.5 use rpm and yum package management
101 2.5 use rpm and yum package management
 
101 2.5 use rpm and yum package management
101 2.5 use rpm and yum package management101 2.5 use rpm and yum package management
101 2.5 use rpm and yum package management
 
An Overview of the IHK/McKernel Multi-kernel Operating System
An Overview of the IHK/McKernel Multi-kernel Operating SystemAn Overview of the IHK/McKernel Multi-kernel Operating System
An Overview of the IHK/McKernel Multi-kernel Operating System
 

More from Alexander Shopov

Knots - the Lazy Data Transfer Objects for Dealing with the Microservices Craze
Knots - the Lazy Data Transfer Objects for Dealing with the Microservices CrazeKnots - the Lazy Data Transfer Objects for Dealing with the Microservices Craze
Knots - the Lazy Data Transfer Objects for Dealing with the Microservices CrazeAlexander Shopov
 
Нови приключения на преводачите
Нови приключения на преводачитеНови приключения на преводачите
Нови приключения на преводачитеAlexander Shopov
 
Beyond the Final Frontier of jQuery Selectors
Beyond the Final Frontier of jQuery SelectorsBeyond the Final Frontier of jQuery Selectors
Beyond the Final Frontier of jQuery SelectorsAlexander Shopov
 
I Know Kung Fu - Juggling Java Bytecode
I Know Kung Fu - Juggling Java BytecodeI Know Kung Fu - Juggling Java Bytecode
I Know Kung Fu - Juggling Java BytecodeAlexander Shopov
 
Lifting The Veil - Reading Java Bytecode During Lunchtime
Lifting The Veil - Reading Java Bytecode During LunchtimeLifting The Veil - Reading Java Bytecode During Lunchtime
Lifting The Veil - Reading Java Bytecode During LunchtimeAlexander Shopov
 
Lifting The Veil - Reading Java Bytecode
Lifting The Veil - Reading Java BytecodeLifting The Veil - Reading Java Bytecode
Lifting The Veil - Reading Java BytecodeAlexander Shopov
 

More from Alexander Shopov (10)

700 Tons of Code Later
700 Tons of Code Later700 Tons of Code Later
700 Tons of Code Later
 
Knots - the Lazy Data Transfer Objects for Dealing with the Microservices Craze
Knots - the Lazy Data Transfer Objects for Dealing with the Microservices CrazeKnots - the Lazy Data Transfer Objects for Dealing with the Microservices Craze
Knots - the Lazy Data Transfer Objects for Dealing with the Microservices Craze
 
Нови приключения на преводачите
Нови приключения на преводачитеНови приключения на преводачите
Нови приключения на преводачите
 
In Vogue Dynamic
In Vogue DynamicIn Vogue Dynamic
In Vogue Dynamic
 
Beyond the Final Frontier of jQuery Selectors
Beyond the Final Frontier of jQuery SelectorsBeyond the Final Frontier of jQuery Selectors
Beyond the Final Frontier of jQuery Selectors
 
Oracle's Take On NoSQL
Oracle's Take On NoSQLOracle's Take On NoSQL
Oracle's Take On NoSQL
 
I Know Kung Fu - Juggling Java Bytecode
I Know Kung Fu - Juggling Java BytecodeI Know Kung Fu - Juggling Java Bytecode
I Know Kung Fu - Juggling Java Bytecode
 
Lifting The Veil - Reading Java Bytecode During Lunchtime
Lifting The Veil - Reading Java Bytecode During LunchtimeLifting The Veil - Reading Java Bytecode During Lunchtime
Lifting The Veil - Reading Java Bytecode During Lunchtime
 
Caching in HTTP
Caching in HTTPCaching in HTTP
Caching in HTTP
 
Lifting The Veil - Reading Java Bytecode
Lifting The Veil - Reading Java BytecodeLifting The Veil - Reading Java Bytecode
Lifting The Veil - Reading Java Bytecode
 

Recently uploaded

Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 

Recently uploaded (20)

Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 

Bundling Packages and Deploying Applications with RPM

  • 1. Bundling Packages and Deploying Applications with RPM Alexander Shopov <ash@kambanaria.org>
  • 2. [ash@edge ~]$ whoami By day: Software Engineer at Cisco {,Nov. 28} By night: OSS contributor Coordinator of Bulgarian Gnome TP Contacts: E-mail: ash@kambanaria.org Jabber: al_shopov@jabber.minus273.org LinkedIn: http://www.linkedin.com/in/alshopov SlideShare: http://www.slideshare.net/al_shopov GitHub: https://github.com/alshopov Web: Just search “al_shopov”
  • 3. Please Learn And Share License: Creative Commons Attribution 4.0 International CC-BY v4.0
  • 6. As Number of Components Grows Complexity (Interactions) Grows as Power of 2
  • 7. As Years of Maintenence Grow Complexity Grows at Least Linearly
  • 8. As Both Number of Components and Years Grow – Complexity Explodes
  • 9. Why RPM ● Widely used packaging format; ● Used to mean: “Red Hat Package Manager”, now it is “RPM Package Manager”; ● Popular with Enterprise-ish distributions: – Fedora; – Red Hat; – CentOS; – Oracle's Linux; – SUSE. ● The other popular format in Linux is “deb” used in Debian/Ubuntu.
  • 10. Where Does RPM Stand? Inno, NullSoft, InstallShiled, Wix, Windows Installer, Installer for Mac OS Compiling Source to Binary Make, imake, auto-tools, project/solution files, etc. Packaging Binary to Packages
  • 11. Where Does RPM Stand? RPM Compiling Packaging Source to Binary Binary to Packages Make, imake, auto-tools, Inno, NullSoft, InstallShiled, project/solution files, etc. Wix, Windows Installer, Installer for Mac OS
  • 12. The Packaging Process SPECS SOURCES BUILD BUILDROOT RPMS
  • 13. The Packaging Process SOURCES BUILD BUILDROOT RPMS SPECS %prep %install %files ● Uncompress & patch – rpmbuild -bp ● Configure/compile – rpmbuild -bc ● Install to a virtual file system – place, copy – rpmbuild -bi ● List files to be packaged – rpmbuild -bb/-bs/-ba
  • 14. Structure of RPM file ● Lead/identifier/magic ( starts with abed dbee - hex) ● Signature - optional ● Header – tagged structure – tags/type/number/size/data for them ● Payload – archive. gzipped cpio (1977 by Dick Haight UNIX 1.0) → gzipped tar (UNIX 7th ed. – 1979) Payload Identifier Signature Header
  • 15. Structure of RPM Package Name ● name-version-release.architecture.rpm ● gzip-1.3.12-19.el6_4.x86_64.rpm ● Name – what package is or does and purpose ● Version – upstream version ● Release – version of RPM (prefix for distro) ● Architecture of the rpm – noarch – src
  • 16. Common and Rarer Archiectures Suffix Architecture Fedora RedHat CentOS Oracle i686 32bit Intel x x x x x86_64 64bit AMD x x x x ia64 64bit Intel x x x s390 24/31/32bit G4/5/6 x x s390x IBM System Z – 64bit z900 x x ppc 32bit PowerPC x x ppc64 64bit PowerPC BE x x ppc64le 64bit PowerPC LE ( arm 32bit ARM5-7 ) armhfp 32bit ARM7 x aaarch64 64bit ARM8+ x
  • 17. Important Packages to Install ● redhat-rpm-config ● rpm-build ● rpmdevtools ● rpmlint ● Other if you want to contribute to Fedora/Redhat/CentOS. Oracle have not published for them
  • 18. redhat-rpm-config ● /etc/rpm/macros* - others also install here - macros here perl,python, nodejs, java ● /usr/lib/rpm/redhat – macros and shell scripts
  • 19. rpm-build ● rpmbuild – command to actually build ● rpmspec – query spec files ● gendiff – diff wrapper
  • 20. rpmlint ● rpmlint – check errors in specs and packages ● rpmdiff – check differences between packages
  • 21. rpmdevtools ● rpmfile, rpmls, rpmpeek, rpmelfsym, rpmargs ● /etc/rpmdevtools – spec templates ● rpmdev-bumpspec – auto increment and maintain spec files ● rpmdev-setuptree – create the spec tree ● rpmdev-newinit, rpmdev-newspec
  • 22. Let's Build A Package! ● Let's build Tomcat 8 package ● Proper ownership of files ● Add a startup/shtdown script ● Deploy a small package in Tomcat ● Make the package take the place of ROOT context ● Switch provider of JPA – from Derby to Oracle RDBMS
  • 23. Prepare The Build Environment ● yum install rpmdevtools ● Dependencies: – fakeroot – fakeroot-libs – rpm-build
  • 24. DON'T BUILD AS ROOT! ROOT
  • 25. FAKE IT! LEAVE IT TO FAKEROOT
  • 26. Create Designated User for Building of RPM ● useradd packager (will make a user group with same name) ● passwd packager ● Do not add designated user to groups: – root/wheel – adm/sys/shutdown/sshd, others – oinstall/dba/oper (if you have Oracle RDBMS on the same machine for some weird reason)
  • 27. Create RPM Building Environment ● rpmdev-setuptree ● ~/.rpmmacros – %_topdir %(echo $HOME)/rpmbuild ● ls ~/rpmbuild/ – BUILD RPMS SOURCES SPECS SRPMS – mkdir ~/rpmbuild/BUILDROOT ● rpm --eval '%buildroot' – /home/packager/rpmbuild/BUILDROOT/%{name}-% {version}-%{release}.i386
  • 28. Starting the Build rpmdev-newspec -o ~/rpmbuild/SPECS/counterbean.spec preamble %prep %build %install %clean %files %changelog Name: counterbean Version: Release: 1%{?dist} Summary: Group: License: URL: Source0: BuildRequires: Requires: %description %prep %setup -q %build %configure make %{?_smp_mflags} %install rm -rf $RPM_BUILD_ROOT make install DESTDIR=$RPM_BUILD_ROOT %clean rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root,-) %doc %changelog
  • 29. Fix the Preamble Name: counterbean Version: 2.0.1 Release: 1%{?dist} Summary: Keep a keen eye on beans for counting purposes # one of '/usr/share/doc/rpm-*/GROUPS' Group: Applications/Productivity License: ASL 2.0 URL: https://github.com/alshopov/counterbean Source0: apache-tomcat-8.0.14.tar.gz # BuildRequires: TODO # Requires: TODO # no need to set BuildRoot/٪buildroot/$RPM_BUILD_ROOT # it is set for us # BuildRoot:
  • 30. Fix the Preamble Name: counterbean Version: 2.0.1 Release: 1%{?dist} Summary: Keep a keen Comments eye on beans start for with counting “#” purposes # one of '/usr/share/doc/rpm-*/Place GROUPS' comments on lines Group: Applications/Productivity License: ASL 2.0 URL: https://github.com/alshopov/counterbean Source0: apache-tomcat-8.0.14.tar.gz # BuildRequires: TODO # Requires: TODO # no need to set BuildRoot/٪buildroot/$RPM_BUILD_ROOT # it is set for us # BuildRoot:
  • 31. Fix the Preamble Name: counterbean Version: 2.0.1 Release: 1%{?dist} Summary: Keep a keen eye on beans for counting purposes # one of '/usr/share/doc/rpm-*/Group: Applications/Productivity The GROUPS' Voldemort Character – License: ASL 2.0 Do not name “%” URL: https://github.com/alshopov/counterbean Source0: apache-tomcat-8.0.14.tar.gz # BuildRequires: TODO # Requires: TODO # no need to set BuildRoot/٪buildroot/$RPM_BUILD_ROOT # it is set for us # BuildRoot:
  • 32. Fix the Preamble Name: counterbean Version: 2.0.1 Release: 1%{?dist} Summary: Keep a keen We eye will fix on these beans later for counting purposes # one of '/usr/share/doc/rpm-*/GROUPS' Group: Applications/Productivity License: ASL 2.0 URL: https://github.com/alshopov/counterbean Source0: apache-tomcat-8.0.14.tar.gz # BuildRequires: TODO # Requires: TODO # no need to set BuildRoot/٪buildroot/$RPM_BUILD_ROOT # it is set for us # BuildRoot:
  • 33. %define prefix /opt/%{name} %description A sample Java application for packaging demo purposes. You can also use it to count: * beans; * kogs; * minions. %prep # -q: no output, -c: create directory %setup -q -c %install install -m 0755 -d ${RPM_BUILD_ROOT}%{prefix} cp -r apache-tomcat-8.0.14/* ${RPM_BUILD_ROOT}%{prefix} %clean rm -fr ${RPM_BUILD_ROOT} %files %defattr(-,root,root,-) /opt/counterbean %doc %changelog * Mon Oct 13 2014 Alexander Shopov <ash@kambanaria.org> - Initial version containing only tomcat.
  • 34. [root@localhost ashopov]# yum install ~packager/rpmbuild/RPMS/i386/counterbean-2.0.1-1.el6.i386.rpm Loaded plugins: refresh-packagekit, security Setting up Install Process Examining /home/packager/rpmbuild/RPMS/i386/counterbean-2.0.1-1.el6.i386.rpm: counterbean-2.0.1-1.el6.i386 Marking /home/packager/rpmbuild/RPMS/i386/counterbean-2.0.1-1.el6.i386.rpm to be installed Resolving Dependencies --> Running transaction check ---> Package counterbean.i386 0:2.0.1-1.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ====================================================================================== Package Arch Version Repository Size ====================================================================================== Installing: counterbean i386 2.0.1-1.el6 /counterbean-2.0.1-1.el6.i386 12 M Transaction Summary ====================================================================================== Install 1 Package(s) Total size: 12 M Installed size: 12 M Is this ok [y/N]: y Downloading Packages: Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : counterbean-2.0.1-1.el6.i386 1/1 Verifying : counterbean-2.0.1-1.el6.i386 1/1 Installed: counterbean.i386 0:2.0.1-1.el6 Complete!
  • 35. Try To Start [packager@localhost ~]$ /opt/counterbean/bin/startup.sh Neither the JAVA_HOME nor the JRE_HOME environment variable is defined At least one of these environment variable is needed to run this program [packager@localhost ~]$
  • 36. We Forgot Dependencies [root@localhost ~]# yum provides '*/java' Loaded plugins: refresh-packagekit, security ⋮⋮⋮ graphviz-java-2.26.0-7.el6.i686 : Java extension for graphviz Repo : public_ol6_latest Matched from: Filename : /usr/lib/graphviz/java ⋮⋮⋮ 1:java-1.6.0-openjdk-1.6.0.0-6.1.13.4.el6_5.i686 : OpenJDK Runtime Environment Repo : public_ol6_latest Matched from: Filename : /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre/bin/java ⋮⋮⋮ [packager@localhost ~]$ yum provides jre Loaded plugins: refresh-packagekit, security ⋮⋮⋮ 1:java-1.6.0-openjdk-1.6.0.0-5.1.13.3.el6_5.i686 : OpenJDK Runtime Environment Repo : public_ol6_latest Matched from: Other : jre ⋮⋮⋮ 1:java-1.7.0-openjdk-1.7.0.51-2.4.4.1.0.1.el6_5.i686 : OpenJDK Runtime Environment Repo : public_ol6_latest Matched from: Other : jre ⋮⋮⋮
  • 37. Add Dependencies Release: 2%{?dist} Requires: jre %changelog * Mon Oct 13 2014 Alexander Shopov <ash@kambanaria.org> Add jre as runtime dependency * Mon Oct 13 2014 Alexander Shopov <ash@kambanaria.org> Initial version containing only tomcat.
  • 38. [root@localhost ashopov]# yum install ~packager/rpmbuild/RPMS/i386/counterbean-2.0.1-2.el6.i386.rpm Loaded plugins: refresh-packagekit, security Setting up Install Process Examining /home/packager/rpmbuild/RPMS/i386/counterbean-2.0.1-2.el6.i386.rpm: counterbean-2.0.1-2.el6.i386 Marking /home/packager/rpmbuild/RPMS/i386/counterbean-2.0.1-2.el6.i386.rpm as an update to counterbean-2.0.1-1.el6.i386 Resolving Dependencies --> Running transaction check ---> Package counterbean.i386 0:2.0.1-1.el6 will be updated ---> Package counterbean.i386 0:2.0.1-2.el6 will be an update --> Processing Dependency: jre for package: counterbean-2.0.1-2.el6.i386 --> Running transaction check ---> Package java-1.7.0-openjdk.i686 1:1.7.0.65-2.5.1.2.0.1.el6_5 will be installed --> Finished Dependency Resolution Dependencies Resolved
  • 39. Parametrize the SPEC Name: counterbean Version: 2.0.1 Release: 3%{?dist} Summary: Keep a keen eye on beans for counting purposes Group: Applications/Productivity License: ASL 2.0 URL: https://github.com/alshopov/counterbean Requires: jre %define tc_ver 8.0.14 Source0: apache-tomcat-%{tc_ver}.tar.gz %description … %define prefix /opt/%{name} %prep … %install install -m 0755 -d ${RPM_BUILD_ROOT}%{prefix} cp -r apache-tomcat-%{tc_ver}/* ${RPM_BUILD_ROOT}%{prefix} %clean … %files … %changelog …
  • 40. Root Owns Everything – Let's Fix Release: 4%{?dist} %files %defattr(-,%{name},%{name},-) /opt/%{name} %changelog * Tue Oct 14 2014 Alexander Shopov <ash@kambanaria.org> Make 'counterbean' user own everything …
  • 41. But When We Install… warning: user counterbean does not exist - using root warning: group counterbean does not exist - using root
  • 42. We Must First Create The User Release: 5%{?dist} Requires(pre): shadow-utils %pre getent group %{name} >/dev/null || groupadd -r %{name} getent passwd %{name} >/dev/null || useradd -r -g %{name} -d %{prefix} -s /sbin/nologin -c "Account to own and run %{name}" %{name} exit 0 %changelog * Tue Oct 14 2014 Alexander Shopov <ash@kambanaria.org> Create user and group for 'counterbean' …
  • 43. Create Template [packager@localhost rpmbuild]$ rpmdev-newinit --help ⋮⋮⋮ The template used is /etc/rpmdevtools/template.init. [packager@localhost rpmbuild]$ rpmdev-newinit /rpmbuild/SOURCES/counterbean.init Skeleton init script has been created to "/home/packager/rpmbuild/SOURCES/counterbean.init". # The template used is /etc/rpmdevtools/template.init.
  • 44. #!/bin/sh # # counterbean - <summary> # # chkconfig: <default runlevel(s)> <start> <stop> # description: <description, split multiple lines # with a backslash> # http://fedoraproject.org/wiki/FCNewInit/Initscripts ### BEGIN INIT INFO # Provides: # Required-Start: # Required-Stop: # Should-Start: # Should-Stop: # Default-Start: # Default-Stop: # Short-Description: # Description: ### END INIT INFO # Source function library. . /etc/rc.d/init.d/functions exec="/usr/sbin/counterbean" prog=$(basename $exec) [ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog lockfile=/var/lock/subsys/$prog start() { echo -n $"Starting $prog: " # if not running, start it up here, usually something like "daemon $exec" retval=$? echo [ $retval -eq 0 ] && touch $lockfile return $retval } Template Contents stop() { echo -n $"Stopping $prog: " # stop it here, often "killproc $prog" retval=$? echo [ $retval -eq 0 ] && rm -f $lockfile return $retval } restart() { stop start } case "$1" in start|stop|restart) $1 ;; force-reload) restart ;; status) status $prog ;; try-restart|condrestart) if status $prog >/dev/null ; then restart fi ;; reload) # If config can be reloaded without restarting, implement it here, # remove the "exit", and add "reload" to the usage message below. # For example: # status $prog >/dev/null || exit 7 # killproc $prog -HUP action $"Service ${0##*/} does not support the reload action: " /bin/false exit 3 ;; *) echo $"Usage: $0 {start|stop|status|restart|try-restart|force-reload}" exit 2 esac
  • 45. Startup Script #!/bin/sh # # counterbean - count bean, kogs, minions # # chkconfig: 345 98 02 # description: small demo RDBMS Java web app # Source function library. . /etc/rc.d/init.d/functions start_cmd="runuser counterbean -g counterbean -s /bin/sh -c '/opt/counterbean/bin/startup.sh' " stop_cmd="runuser counterbean -g counterbean -s /bin/sh -c '/opt/counterbean/bin/shutdown.sh' " prog=counterbean lockfile=/var/lock/subsys/$prog start() { echo -n $"Starting $prog: " $start_cmd retval=$? echo [ $retval -eq 0 ] && touch $lockfile return $retval } stop() { echo -n $"Stopping $prog: " $stop_cmd retval=$? echo [ $retval -eq 0 ] && rm -f $lockfile return $retval } restart() { stop start } case "$1" in start|stop|restart) $1 ;; status) status $prog ;; *) echo $"Usage: $0 {start|stop|restart|status}" exit 2 esac
  • 46. Use The Script Release: 6%{?dist} Requires: coreutils, jre, chkconfig, initscripts Requires(pre): shadow-utils %define tc_ver 8.0.14 Source0: apache-tomcat-%{tc_ver}.tar.gz Source1: %{name}.init %install install -m 0755 -d ${RPM_BUILD_ROOT}%{prefix} cp -r apache-tomcat-%{tc_ver}/* ${RPM_BUILD_ROOT}%{prefix} install %{SOURCE1} -D ${RPM_BUILD_ROOT}/etc/rc.d/init.d/%{name} %defattr(-,%{name},%{name},-) /opt/%{name} %attr(-,root,root) /etc/rc.d/init.d/%{name} %changelog * Wed Oct 15 2014 Alexander Shopov <ash@kambanaria.org> Proper startup scripts …
  • 47. Use The Script %pre getent group %{name} >/dev/null || groupadd -r %{name} getent passwd %{name} >/dev/null || useradd -r -g %{name} -d %{prefix} -s /sbin/nologin -c "Account to own and run %{name}" %{name} exit 0 %post /sbin/chkconfig --add %{name} if [ "$1" = 1 ]; then /sbin/service %{name} start > /dev/null 2>&1 fi exit 0 %preun if [ "$1" = 0 ]; then /sbin/service %{name} stop > /dev/null 2>&1 fi exit 0 %postun if [ "$1" -ge 1 ]; then /sbin/service %{name} restart > /dev/null 2>&1 fi exit 0
  • 48. %pre, %post, %preun, %postun? ● Scripts that get executed on install, upgrade, remove; ● There are others: – %triggerin, %triggerun, %triggerpostun: ADVANCED – dependencies on packages; – %pretrans, %posttrans: VERY ADVANCED, avoid (will fail in chroot, initial install, usually written in Lua.
  • 49. Execution of Scripts install upgrade uninstall %pre $1 == 1 $1 == 2 Not run %post $1 == 1 $1 == 2 Not run %preun Not run $1 == 1 $1 == 0 %postun Not run $1 == 1 $1 == 0 1 2 3 4 5 6 %pre of new package package install %post of new package %preun of old package removal of old package %postun of old package $1 == 2 $1 == 2 $1 == 1 $1 == 1
  • 50. Introducing CounterBean – Enterprise version
  • 52. Very Modern App HTML5 Bootstrap 3.2
  • 53. Very Modern App Servlet 3.0 No web.xml Servlet 3.0 Annotations
  • 54. Very Modern App In-Memory Derby JPA 2.1 With EclipseLink 2.5.x
  • 55. When Deploying It ● Remove default applications from Tomcat ● Make it the ROOT application – Expand as ROOT in Tomcat's webapps folder – Remove context.xml ● Migrate to Oracle RDBMS – Fix persistence.xml – Add Oracle's driver
  • 56. Make Counterbean the Default App Release: 7%{?dist} %define tc_ver 8.0.14 %define cb_ver 1.0-SNAPSHOT Source0: apache-tomcat-%{tc_ver}.tar.gz Source1: %{name}-%{cb_ver}.war Source2: %{name}.init %install install -m 0755 -d ${RPM_BUILD_ROOT}%{prefix} cp -r apache-tomcat-%{tc_ver}/* ${RPM_BUILD_ROOT}%{prefix} # Remove default applications rm -fr ${RPM_BUILD_ROOT}%{prefix}/webapps # Ensure ROOT exists and unzip counterbean to it install -m 0755 -d ${RPM_BUILD_ROOT}%{prefix}/webapps/ROOT unzip %{SOURCE1} -d ${RPM_BUILD_ROOT}%{prefix}/webapps/ROOT # Sets the context, we need the default rm -fr ${RPM_BUILD_ROOT}%{prefix}/webapps/ROOT/META-INF/context.xml install %{SOURCE2} -D ${RPM_BUILD_ROOT}/etc/rc.d/init.d/%{name}
  • 57. The DBA Prepares the RDBMS SQL> CREATE USER counterbean IDENTIFIED BY counterbean; User created. SQL> GRANT RESOURCE, CONNECT TO counterbean; Grant succeeded. SQL> ALTER USER counterbean QUOTA 50M ON USERS; User altered.
  • 58. The DBA Prepares the RDBMS AKA “Mr. Generous DBA” SQL> CREATE USER counterbean IDENTIFIED BY counterbean; User created. SQL> GRANT RESOURCE, CONNECT TO counterbean; Grant succeeded. SQL> ALTER USER counterbean QUOTA 50M ON USERS; User altered.
  • 59. Use Oracle RDBMS Release: 8%{?dist} ⋮⋮⋮ Source2: %{name}.init Source3: ojdbc7.jar Source4: persistence.xml %install ⋮⋮⋮ # Sets the context, we need the default rm -fr ${RPM_BUILD_ROOT}%{prefix}/webapps/ROOT/META-INF/context.xml install %{SOURCE2} -D ${RPM_BUILD_ROOT}/etc/rc.d/init.d/%{name} # Replace JDBC driver rm ${RPM_BUILD_ROOT}%{prefix}/webapps/ROOT/WEB-INF/lib/derby-*.jar cp %{SOURCE3} ${RPM_BUILD_ROOT}%{prefix}/webapps/ROOT/WEB-INF/lib/ # Replace persistence.xml cp %{SOURCE4} ${RPM_BUILD_ROOT}%{prefix} /webapps/ROOT/WEB-INF/classes/META-INF/persistence.xml
  • 60. Final File Touches Release: 9%{?dist} %files %defattr(-,%{name},%{name},-) /opt/%{name} %attr(-,root,root) /etc/rc.d/init.d/%{name} %doc /opt/%{name}/LICENSE %doc /opt/%{name}/NOTICE %doc /opt/%{name}/RELEASE-NOTES %doc /opt/%{name}/RUNNING.txt %attr(755,%{name},%{name}) %ghost /opt%{name}/conf/Catalina/ %ghost /opt/%{name}/logs/ %ghost /opt/%{name}/work/ %config /opt/%{name}/webapps/ROOT/WEB-INF/classes/META-INF/persistence.xml
  • 61. Publishing RPMs As Yum Repositories yum install createrepo mkdir -p /somewhere/{SRPMS,i386,x86_64} # copy RPMs to the directories for arch in /somewhere/*; do pushd ${arch} createrepo . popd done
  • 62. Using the New Repository cat /etc/yum.repos.d/example.repo [example] name=Example Repository baseurl=ftp://example.com/somewhere/$basearch enabled=1
  • 63. Popular RPM Commands rpm -ivh counterbean-2.0.1-10.el6.i386 # Install, Verbose, Hashes show progress rpm -U *.rpm # Upgrade rpm -F *.rpm # Freshen – install if exists rpm -qa | grep -i counterbean # Query All rpm -qpR counterbean-2.0.1-10.el6.i386 # Query what the package Provide and Requires rpm -ql counterbean # Query List files in package rpm -e counterbean # Erase rpm -qf /etc/passwd # Query for package of File rpm -qi counterbean # infomration # do the query on a package rather than the RPM DB rpm -qip counterbean-2.0.1-10.el6.i386 # or -qilp rpm -Vp # verify package – changes to files rpm --rebuilddb # rebuild database
  • 64. Popular YUM Commands yum install counterbean # install, -y automatically yum remove counterbean # uninstalls yum update -y # auto upgrades all yum search counterbean # find such a package yum info counterbean # info about a package yum list # list packages # available|installed|extras|updates|obsoletes yum group[list|info|install|update|remove] # groups yum provides /etc/passwd yum repolist # enables repositories yum repolist all # all yum --[enable|disable]repo=repo_id # enable/disable
  • 65. Further Resources ● Max RPM Book: http://www.rpm.org/max-rpm/ ● GuruLabs RPM Guide: https://www.gurulabs.com/downloads/GURULABS-RPM-LAB/GUR ULABS-RPM-GUIDE-v1.0.PDF ● Fedora Project – How to Create an RPM Package: https://fedoraproject.org/wiki/How_to_create_an_RPM_package – Packaging Guidelines: https://fedoraproject.org/wiki/Packaging:Guidelines ● Clint Savage, How to Make an RPM: https://www.youtube.com/watch?v=4J_Iksu1fgo ● Jeff's Linux Vids: https://www.youtube.com/channel/UC96flr-XcwMTeyZOhGPfkLw