Upgrade to Pro — share decks privately, control downloads, hide ads and more …

RPMing your apps and tools

Joshua Thijssen
February 22, 2014
300

RPMing your apps and tools

Joshua Thijssen

February 22, 2014
Tweet

Transcript

  1. 2 Joshua Thijssen Freelance consultant and trainer @ NoxLogic. Founder

    of the Dutch Web Alliance. Development in PHP, Python, C, Java. Lead developer of Saffire. Blog: http://adayinthelifeof.nl Email: [email protected] Twitter: @jaytaph
  2. ➡ Not only for RedHat ➡ Also all derivates: CentOS,

    Fedora etc ➡ Can also be used on Debian-like systems (but not recommended) 5
  3. 7

  4. ➡ Takes care of dependencies ➡ Less time to install

    ➡ No compilation needed ➡ Easier to maintain ➡ Can be automated easily (puppet, chef etc) 8
  5. [jthijssen@centos65 ~]$ yum search php xdebug Loaded plugins: downloadonly, fastestmirror

    Loading mirror speeds from cached hostfile * base: ftp.tudelft.nl * epel: mirror.muntinternet.net * extras: ftp.tudelft.nl * updates: ftp.tudelft.nl * webtatic: nl.repo.webtatic.com ========================================= N/S Matched: php, xdebug ========================================= php-pecl-xdebug.x86_64 : PECL package for debugging PHP scripts php54w-pecl-xdebug.x86_64 : PECL package for debugging PHP scripts php55w-pecl-xdebug.x86_64 : PECL package for debugging PHP scripts Full name and summary matches only, use "search all" for everything. 11
  6. [jthijssen@centos65 ~]$ yum info php-pecl-xdebug Loaded plugins: downloadonly, fastestmirror Loading

    mirror speeds from cached hostfile * base: ftp.tudelft.nl * epel: mirror.muntinternet.net * extras: ftp.tudelft.nl * updates: ftp.tudelft.nl * webtatic: nl.repo.webtatic.com Available Packages Name : php-pecl-xdebug Arch : x86_64 Version : 2.1.4 Release : 1.el6 Size : 143 k Repo : epel Summary : PECL package for debugging PHP scripts URL : http://pecl.php.net/package/xdebug License : PHP Description : The Xdebug extension helps you debugging your script by providing a lot of : valuable debug information. The debug information that Xdebug can provide : includes the following: : : * stack and function traces in error messages with: .... : Xdebug also provides: : : * profiling information for PHP scripts : * code coverage analysis : * capabilities to debug your scripts interactively with a debug client 12
  7. [jthijssen@centos65 ~]$ yum list installed Loaded plugins: downloadonly, fastestmirror Loading

    mirror speeds from cached hostfile * base: ftp.tudelft.nl * epel: mirror.muntinternet.net * extras: ftp.tudelft.nl * updates: ftp.tudelft.nl * webtatic: nl.repo.webtatic.com Installed Packages GeoIP.x86_64 1.4.8-1.el6 @epel MAKEDEV.x86_64 3.24-6.el6 @anaconda-CentOS-201311272149.x86_64/6.5 acl.x86_64 2.2.49-6.el6 @anaconda-CentOS-201311272149.x86_64/6.5 aic94xx-firmware.noarch 30-2.el6 @anaconda-CentOS-201311272149.x86_64/6.5 atmel-firmware.noarch 1.3-7.el6 @anaconda-CentOS-201311272149.x86_64/6.5 attr.x86_64 2.4.44-7.el6 @anaconda-CentOS-201311272149.x86_64/6.5 audit.x86_64 2.2-2.el6 @anaconda-CentOS-201311272149.x86_64/6.5 audit-libs.x86_64 2.2-2.el6 @anaconda-CentOS-201311272149.x86_64/6.5 authconfig.x86_64 6.1.12-13.el6 @anaconda-CentOS-201311272149.x86_64/6.5 b43-openfwwf.noarch 5.2-4.el6 @anaconda-CentOS-201311272149.x86_64/6.5 .... yum-plugin-downloadonly.noarch 1.1.30-14.el6 @base yum-plugin-fastestmirror.noarch 1.1.30-14.el6 @anaconda-CentOS-201311272149.x86_64/6.5 zd1211-firmware.noarch 1.4-4.el6 @anaconda-CentOS-201311272149.x86_64/6.5 zlib.x86_64 1.2.3-29.el6 @anaconda-CentOS-201311272149.x86_64/6.5 zsh.x86_64 4.3.10-7.el6 @base 13
  8. [jthijssen@centos65 ~]$ repoquery -q -l php-pecl-xdebug /etc/php.d/xdebug.ini /usr/bin/debugclient /usr/lib64/php/modules/xdebug.so /usr/share/doc/php-pecl-xdebug-2.1.4

    /usr/share/doc/php-pecl-xdebug-2.1.4/CREDITS /usr/share/doc/php-pecl-xdebug-2.1.4/Changelog /usr/share/doc/php-pecl-xdebug-2.1.4/LICENSE /usr/share/doc/php-pecl-xdebug-2.1.4/NEWS /usr/share/doc/php-pecl-xdebug-2.1.4/README /usr/share/pear/.pkgxml/php-pecl-xdebug.xml 14
  9. [jthijssen@centos65 ~]$ rpm -qf /home/jthijssen/.viminfo file /home/jthijssen/.viminfo is not owned

    by any package 15 [jthijssen@centos65 ~]$ rpm -qf /usr/bin/php php55w-cli-5.5.7-1.w6.x86_64
  10. [jthijssen@centos65 ~]$ yum whatprovides /usr/bin/php Loaded plugins: downloadonly, fastestmirror Loading

    mirror speeds from cached hostfile * base: ftp.tudelft.nl * epel: mirror.muntinternet.net * extras: ftp.tudelft.nl * updates: ftp.tudelft.nl * webtatic: nl.repo.webtatic.com php-cli-5.3.3-26.el6.x86_64 : Command-line interface for PHP Repo : base Matched from: Filename : /usr/bin/php php55w-cli-5.5.8-1.w6.x86_64 : Command-line interface for PHP Repo : webtatic Matched from: Filename : /usr/bin/php php-cli-5.3.3-27.el6_5.x86_64 : Command-line interface for PHP Repo : updates Matched from: Filename : /usr/bin/php .. php55w-cli-5.5.7-1.w6.x86_64 : Command-line interface for PHP Repo : installed Matched from: Other : Provides-match: /usr/bin/php 16
  11. [jthijssen@centos65 ~]$ yum whatprovides /usr/bin/php --disablerepo=* Loaded plugins: downloadonly, fastestmirror

    Loading mirror speeds from cached hostfile php55w-cli-5.5.7-1.w6.x86_64 : Command-line interface for PHP Repo : installed Matched from: Other : Provides-match: /usr/bin/php 17
  12. [jthijssen@centos65 ~]$ sudo yum install screen Loaded plugins: downloadonly, fastestmirror

    Loading mirror speeds from cached hostfile * base: ftp.tudelft.nl * epel: be.mirror.eurid.eu * extras: ftp.tudelft.nl * updates: ftp.tudelft.nl * webtatic: us-east.repo.webtatic.com Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package screen.x86_64 0:4.0.3-16.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================= Package Arch Version Repository Size ============================================================================================================================= Installing: screen x86_64 4.0.3-16.el6 base 494 k Transaction Summary ============================================================================================================================= Install 1 Package(s) Total download size: 494 k Installed size: 795 k Is this ok [y/N]: y Downloading Packages: screen-4.0.3-16.el6.x86_64.rpm | 494 kB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : screen-4.0.3-16.el6.x86_64 1/1 Verifying : screen-4.0.3-16.el6.x86_64 1/1 Installed: screen.x86_64 0:4.0.3-16.el6 Complete! 18
  13. [jthijssen@centos65 ~]$ sudo yum remove screen Loaded plugins: downloadonly, fastestmirror

    Setting up Remove Process Resolving Dependencies --> Running transaction check ---> Package screen.x86_64 0:4.0.3-16.el6 will be erased --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================= Package Arch Version Repository Size ============================================================================================================================= Removing: screen x86_64 4.0.3-16.el6 @base 795 k Transaction Summary ============================================================================================================================= Remove 1 Package(s) Installed size: 795 k Is this ok [y/N]: y Downloading Packages: Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Erasing : screen-4.0.3-16.el6.x86_64 1/1 Verifying : screen-4.0.3-16.el6.x86_64 1/1 Removed: screen.x86_64 0:4.0.3-16.el6 Complete! 19
  14. [jthijssen@centos65 ~]$ sudo yum install tig sudo yum install tig

    Loaded plugins: downloadonly, fastestmirror Loading mirror speeds from cached hostfile * base: ftp.tudelft.nl * epel: be.mirror.eurid.eu * extras: ftp.tudelft.nl * updates: ftp.tudelft.nl * webtatic: us-east.repo.webtatic.com Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package tig.x86_64 0:0.17-1.el6 will be installed --> Processing Dependency: git for package: tig-0.17-1.el6.x86_64 --> Running transaction check ---> Package git.x86_64 0:1.7.1-3.el6_4.1 will be installed --> Processing Dependency: perl-Git = 1.7.1-3.el6_4.1 for package: git-1.7.1-3.el6_4.1.x86_64 --> Processing Dependency: rsync for package: git-1.7.1-3.el6_4.1.x86_64 --> Processing Dependency: perl(Git) for package: git-1.7.1-3.el6_4.1.x86_64 --> Processing Dependency: perl(Error) for package: git-1.7.1-3.el6_4.1.x86_64 --> Processing Dependency: openssh-clients for package: git-1.7.1-3.el6_4.1.x86_64 --> Running transaction check ---> Package openssh-clients.x86_64 0:5.3p1-94.el6 will be installed ---> Package perl-Error.noarch 1:0.17015-4.el6 will be installed ---> Package perl-Git.noarch 0:1.7.1-3.el6_4.1 will be installed ---> Package rsync.x86_64 0:3.0.6-9.el6_4.1 will be installed --> Finished Dependency Resolution Dependencies Resolved ... 20
  15. ... ============================================================================================================================= Package Arch Version Repository Size ============================================================================================================================= Installing: tig

    x86_64 0.17-1.el6 epel 103 k Installing for dependencies: git x86_64 1.7.1-3.el6_4.1 base 4.6 M openssh-clients x86_64 5.3p1-94.el6 base 402 k perl-Error noarch 1:0.17015-4.el6 base 29 k perl-Git noarch 1.7.1-3.el6_4.1 base 28 k rsync x86_64 3.0.6-9.el6_4.1 base 334 k Transaction Summary ============================================================================================================================= Install 6 Package(s) Total download size: 5.5 M Installed size: 17 M Is this ok [y/N]: y Downloading Packages: (1/6): git-1.7.1-3.el6_4.1.x86_64.rpm | 4.6 MB 00:02 (2/6): openssh-clients-5.3p1-94.el6.x86_64.rpm | 402 kB 00:00 (3/6): perl-Error-0.17015-4.el6.noarch.rpm | 29 kB 00:00 (4/6): perl-Git-1.7.1-3.el6_4.1.noarch.rpm | 28 kB 00:00 (5/6): rsync-3.0.6-9.el6_4.1.x86_64.rpm | 334 kB 00:00 (6/6): tig-0.17-1.el6.x86_64.rpm | 103 kB 00:00 ----------------------------------------------------------------------------------------------------------------------------- Total 1.7 MB/s | 5.5 MB 00:03 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded ... 21
  16. ... Running Transaction Installing : 1:perl-Error-0.17015-4.el6.noarch 1/6 Installing : openssh-clients-5.3p1-94.el6.x86_64

    2/6 Installing : rsync-3.0.6-9.el6_4.1.x86_64 3/6 Installing : perl-Git-1.7.1-3.el6_4.1.noarch 4/6 Installing : git-1.7.1-3.el6_4.1.x86_64 5/6 Installing : tig-0.17-1.el6.x86_64 6/6 Verifying : 1:perl-Error-0.17015-4.el6.noarch 1/6 Verifying : perl-Git-1.7.1-3.el6_4.1.noarch 2/6 Verifying : git-1.7.1-3.el6_4.1.x86_64 3/6 Verifying : rsync-3.0.6-9.el6_4.1.x86_64 4/6 Verifying : tig-0.17-1.el6.x86_64 5/6 Verifying : openssh-clients-5.3p1-94.el6.x86_64 6/6 Installed: tig.x86_64 0:0.17-1.el6 Dependency Installed: git.x86_64 0:1.7.1-3.el6_4.1 openssh-clients.x86_64 0:5.3p1-94.el6 perl-Error.noarch 1:0.17015-4.el6 perl-Git.noarch 0:1.7.1-3.el6_4.1 rsync.x86_64 0:3.0.6-9.el6_4.1 Complete! [jthijssen@centos65 ~]$ 22
  17. [jthijssen@centos65 ~]$ sudo yum history list all Loaded plugins: downloadonly,

    fastestmirror ID | Login user | Date and time | Action(s) | Altered ------------------------------------------------------------------------------- 18 | <jthijssen> | 2014-02-03 13:06 | Erase | 1 17 | <jthijssen> | 2014-02-03 13:05 | Install | 6 16 | <jthijssen> | 2014-02-03 13:03 | Erase | 1 15 | <jthijssen> | 2014-02-03 13:02 | Install | 1 14 | <jthijssen> | 2014-02-03 12:56 | Install | 1 13 | <jthijssen> | 2013-12-14 22:52 | Install | 1 12 | <jthijssen> | 2013-12-14 22:16 | Install | 1 EE 11 | <jthijssen> | 2013-12-14 22:13 | Install | 3 < 10 | <jthijssen> | 2013-12-14 22:05 | Install | 1 > 9 | <jthijssen> | 2013-12-14 21:41 | Install | 7 8 | <jthijssen> | 2013-12-14 21:37 | Install | 4 7 | <jthijssen> | 2013-12-14 21:35 | Install | 13 6 | <jthijssen> | 2013-12-14 21:34 | I, U | 11 < 5 | <jthijssen> | 2013-12-14 21:33 | Install | 1 > 4 | <jthijssen> | 2013-12-14 21:25 | Install | 1 3 | root <root> | 2013-12-14 21:16 | Install | 1 2 | root <root> | 2013-12-14 21:16 | Install | 9 1 | System <unset> | 2013-12-14 20:48 | Install | 217 23
  18. [jthijssen@centos65 ~]$ sudo yum history package-list tig Loaded plugins: downloadonly,

    fastestmirror ID | Action(s) | Package ------------------------------------------------------------------------------- 18 | Erase | tig-0.17-1.el6.x86_64 17 | Install | tig-0.17-1.el6.x86_64 history package-list 24
  19. [jthijssen@centos65 ~]$ sudo yum history info 17 Loaded plugins: downloadonly,

    fastestmirror Transaction ID : 17 Begin time : Mon Feb 3 13:05:11 2014 Begin rpmdb : 263:a2126d6ecaf16f8878c953baeef645c1e06ddf3c End time : 13:05:14 2014 (3 seconds) End rpmdb : 269:f9b58f8d062d3696ce529614b6c2a36f3e992f4b User : <jthijssen> Return-Code : Success Command Line : install tig Transaction performed with: Installed rpm-4.8.0-37.el6.x86_64 @anaconda-CentOS-201311272149.x86_64/6.5 Installed yum-3.2.29-40.el6.centos.noarch @anaconda-CentOS-201311272149.x86_64/6.5 Installed yum-plugin-fastestmirror-1.1.30-14.el6.noarch @anaconda-CentOS-201311272149.x86_64/6.5 Packages Altered: Dep-Install git-1.7.1-3.el6_4.1.x86_64 @base Dep-Install openssh-clients-5.3p1-94.el6.x86_64 @base Dep-Install perl-Error-1:0.17015-4.el6.noarch @base Dep-Install perl-Git-1.7.1-3.el6_4.1.noarch @base Dep-Install rsync-3.0.6-9.el6_4.1.x86_64 @base Install tig-0.17-1.el6.x86_64 @epel history info 25
  20. ➡ Sources ➡ Patch files ➡ Any other stuff you

    like to add (docs, examples, custom stuff) ➡ SPEC file 28
  21. ➡ Building is pretty easy, ➡ as long as you

    get your SPEC file correct :/ ➡ Build with “rpmbuild” ➡ Don’t build as root! 29
  22. ➡ The SPEC file is a “script / config” file

    that tells rpmbuild how to build the RPM files. ➡ Can also be used for building SOURCE RPM files (that can be used to build the RPMs yourself) 32
  23. 34 ➡ Copy your source-files into SOURCES (but probably want

    to use urls in your spec files) ➡ Copy your spec-files into SPECS ➡ If you install a SOURCE RPM, this will be done for you.
  24. Name: autobugfix Version: 1.0 Release: 1%{?dist} Summary: Fixes bugs automatically,

    so you won't have to Group: Development/Tools License: BSD URL: https://autobugfix.noxlogic.nl Source0: http://autobugfix.noxlogic.nl/download/%{name}-%{version}.tar.gz Patch1: http://autobugfix.noxlogic.nl/download/hotfix-001.patch BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) BuildArch: noarch Packager: Joshua Thijssen <[email protected]> Requires: php-common %description This application will fix bugs while you type. Very useful when editting your code on your production platforms. .... 36
  25. ... %prep %setup -q %patch1 %build %install %{__rm} -rf %{buildroot}

    %{__mkdir} -p %{buildroot}/usr/local/noxlogic/bin %{__install} -m 755 bin/autobugfix %{buildroot}/usr/local/noxlogic/bin/autobugfix %{__mkdir} -p %{buildroot}%{_mandir}/man1 %{__cp} man/autobugfix.1 %{buildroot}%{_mandir}/man1 %clean %{__rm} -rf %{buildroot} ... 37
  26. ... %files %defattr(-,root,root,-) %doc doc/* %dir /usr/local %dir /usr/local/noxlogic %dir

    /usr/local/noxlogic/bin /usr/local/noxlogic/bin/autobugfix %{_mandir}/man1/autobugfix.1.gz %changelog 38
  27. [jthijssen@centos65 autobugfix]$ rpm -qip ~/rpmbuild/RPMS/noarch/autobugfix-1.0-1.el6.noarch.rpm Name : autobugfix Relocations: (not

    relocatable) Version : 1.0 Vendor: (none) Release : 1.el6 Build Date: Mon 03 Feb 2014 03:24:42 PM CET Install Date: (not installed) Build Host: centos65.virtualbox.local Group : Development/Tools Source RPM: autobugfix-1.0-1.el6.src.rpm Size : 1082 License: BSD Signature : (none) Packager : Joshua Thijssen <[email protected]> URL : https://autobugfix.noxlogic.nl Summary : Fixes bugs automatically, so you won't have to Description : This application will fix bugs while you type. Very useful when editting your code on your production platforms. 41
  28. 43 # %define nginx_home %{_localstatedir}/cache/nginx %define nginx_user nginx %define nginx_group

    nginx Summary: High performance web server Name: nginx Version: 1.4.5 Release: 1%{?dist}.ngx Vendor: nginx inc. URL: http://nginx.org/ Source0: http://nginx.org/download/%{name}-%{version}.tar.gz Source1: logrotate Source2: nginx.init Source3: nginx.sysconf Source4: nginx.conf Source5: nginx.vh.default.conf Source6: nginx.vh.example_ssl.conf Source7: nginx.suse.init License: 2-clause BSD-like license %if 0%{?suse_version} Group: Productivity/Networking/Web/Servers %else Group: System Environment/Daemons %endif BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root BuildRequires: zlib-devel BuildRequires: pcre-devel BuildRequires: perl %if 0%{?suse_version} BuildRequires: libopenssl-devel Requires(pre): pwdutils %else BuildRequires: openssl-devel Requires: initscripts >= 8.36 Requires(pre): shadow-utils Requires(post): chkconfig %endif
  29. 44 %files debug %attr(0755,root,root) %{_sbindir}/nginx.debug %pre # Add the "nginx"

    user getent group %{nginx_group} >/dev/null || groupadd -r %{nginx_group} getent passwd %{nginx_user} >/dev/null || \ useradd -r -g %{nginx_group} -s /sbin/nologin \ -d %{nginx_home} -c "nginx user" %{nginx_user} exit 0 %post # Register the nginx service if [ $1 -eq 1 ]; then /sbin/chkconfig --add nginx # print site info cat <<BANNER ---------------------------------------------------------------------- Thanks for using nginx! Please find the official documentation for nginx here: * http://nginx.org/en/docs/ Commercial subscriptions for nginx are available on: * http://nginx.com/products/ ---------------------------------------------------------------------- BANNER
  30. 46 ➡ yum install createrepo ➡ create structure on public

    web dir ➡ copy files over ➡ “createrepo” on each directory
  31. 49 # # /etc/yum.repos.d/noxlogic # [noxlogic] name=NoxLogic Packages baseurl=http://repo.noxlogic.nl/noxlogic/RPMS/$basearch enabled=1

    gpgcheck=0 [noxlogic-source] name=NoxLogic Source Packages baseurl=http://repo.noxlogic.nl/noxlogic/SRPMS enabled=0 gpgcheck=0
  32. 50 [jthijssen@centos65 ~]$ sudo yum repolist Loaded plugins: downloadonly, fastestmirror

    Loading mirror speeds from cached hostfile * base: centos.weepeetelecom.nl * epel: mirror.proserve.nl * extras: centos.mirror1.spango.com * updates: mirror.widexs.nl * webtatic: nl.repo.webtatic.com repo id repo name status base CentOS-6 - Base 6,367 epel Extra Packages for Enterprise Linux 6 - x86_64 10,433 extras CentOS-6 - Extras 14 noxlogic NoxLogic Packages 2 updates CentOS-6 - Updates 414 webtatic Webtatic Repository EL6 - x86_64 166 repolist: 17,396
  33. 51 [jthijssen@centos65 ~]$ yum --disablerepo=* --enablerepo=noxlogic list available Loaded plugins:

    downloadonly, fastestmirror Loading mirror speeds from cached hostfile Available Packages autobugfix.noarch 1.0-2.el6 noxlogic phpmyadmin.noarch 2.11.9.6-1.rf noxlogic
  34. [root@centos65 noxlogic]# yum info autobugfix Loaded plugins: downloadonly, fastestmirror Loading

    mirror speeds from cached hostfile * base: mirror.colocenter.nl * epel: mirror.1000mbps.com * extras: mirror.colocenter.nl * updates: centos.mirror.transip.nl * webtatic: nl.repo.webtatic.com Available Packages Name : autobugfix Arch : noarch Version : 1.0 Release : 1.el6 Size : 3.9 k Repo : noxlogic Summary : Fixes bugs automatically, so you won't have to URL : https://autobugfix.noxlogic.nl License : BSD Description : This application will fix bugs while you type. Very useful when editting your code on your : production platforms. 52
  35. [root@centos65 noxlogic]# yum install autobugfix .... ================================================================================================================= Package Arch Version

    Repository Size ================================================================================================================= Installing: autobugfix noarch 1.0-1.el6 noxlogic 3.9 k Transaction Summary ================================================================================================================= Install 1 Package(s) Total size: 3.9 k Installed size: 1.1 k Is this ok [y/N]: y Downloading Packages: Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : autobugfix-1.0-1.el6.noarch 1/1 Verifying : autobugfix-1.0-1.el6.noarch 1/1 Installed: autobugfix.noarch 0:1.0-1.el6 Complete! 53
  36. ➡ Some tips & tricks: ➡ when “developing” to clear

    your yum cache: yum clean all ➡ Or wait (default) 90 minutes before new updates will be visible. ➡ Make sure you copy and “createrepo” after creating packages. 54
  37. ➡ You probably want / need to: ➡ create a

    “repopackage”. RPM that manually installs the repositories inside yum.repos.d ➡ Really sign your packages as well! 55