Deploying and maintaining your software with RPM/APT
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Deploying and maintaining your software with RPM/APT

on

  • 1,471 views

 

Statistics

Views

Total Views
1,471
Views on SlideShare
1,417
Embed Views
54

Actions

Likes
4
Downloads
31
Comments
0

2 Embeds 54

http://nuestrascozillas.blogspot.com.es 36
http://nuestrascozillas.blogspot.com 18

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Deploying and maintaining your software with RPM/APT Presentation Transcript

  • 1. Deploying and maintaining software with RPM / APT Loadays - 16 & 17 April 2011 Antwerp - Belgiumhttp://joind.in/3315
  • 2. Who am I?
  • 3. Who am I?Joshua Thijssen (32)
  • 4. Who am I?Joshua Thijssen (32)Senior Software Engineer @ Enrise
  • 5. Who am I?Joshua Thijssen (32)Senior Software Engineer @ EnriseDevelopment in PHP, Python, Perl,C, Java....
  • 6. Who am I?Joshua Thijssen (32)Senior Software Engineer @ EnriseDevelopment in PHP, Python, Perl,C, Java....Blogs: http://www.adayinthelifeof.nl http://www.enrise.com/blog
  • 7. Who am I?Joshua Thijssen (32)Senior Software Engineer @ EnriseDevelopment in PHP, Python, Perl,C, Java....Blogs: http://www.adayinthelifeof.nl http://www.enrise.com/blogEmail: joshua@enrise.com
  • 8. Who am I?Joshua Thijssen (32)Senior Software Engineer @ EnriseDevelopment in PHP, Python, Perl,C, Java....Blogs: http://www.adayinthelifeof.nl http://www.enrise.com/blogEmail: joshua@enrise.comTwitter: @jaytaphIdenti.ca: jaytaph
  • 9. What is this talk about? What are and why use package managers? About RPM About DEB Discussion‣ QUESTIONS? RAISE YOUR HAND OR YELL LOUD
  • 10. Word of warningThis talk is focussed on developers, notsystem administrators in general.
  • 11. Why use packagemanagers?
  • 12. Why use a package manager (1)
  • 13. Why use a package manager (1) Takes care of dependencies
  • 14. Why use a package manager (1) Takes care of dependencies Less time to install
  • 15. Why use a package manager (1) Takes care of dependencies Less time to install No compilation needed
  • 16. Why use a package manager (1) Takes care of dependencies Less time to install No compilation needed Scrutinized by many users (stability)
  • 17. Why use a package manager (1) Takes care of dependencies Less time to install No compilation needed Scrutinized by many users (stability) Quick patches
  • 18. Why use a package manager (2)‣ WHY NOT USE A PACKAGE MANAGER?
  • 19. Why use a package manager (2) Not processor specific (i386,i686,x64)‣ WHY NOT USE A PACKAGE MANAGER?
  • 20. Why use a package manager (2) Not processor specific (i386,i686,x64) Missing feature X‣ WHY NOT USE A PACKAGE MANAGER?
  • 21. Why use a package manager (2) Not processor specific (i386,i686,x64) Missing feature X Always behind latest versions‣ WHY NOT USE A PACKAGE MANAGER?
  • 22. Why use a package manager (2) Not processor specific (i386,i686,x64) Missing feature X Always behind latest versions Installing newer versions can be a pain‣ WHY NOT USE A PACKAGE MANAGER?
  • 23. Why use a package manager (2) Not processor specific (i386,i686,x64) Missing feature X Always behind latest versions Installing newer versions can be a pain Multiversioning (php5.2 + php5.3 ???)‣ WHY NOT USE A PACKAGE MANAGER?
  • 24. Packageformats vs package frontends APT = Advanced Packaging Tool ‣ uses .DEB packages RPM = RedHat Package Manager ‣ uses .RPM packages‣ QUESTIONS? RAISE YOUR HAND OR YELL LOUD
  • 25. The DEB vs RPM war
  • 26. .deb vs .rpm Different formats DEB for Debian based systems RPM for RedHat based system
  • 27. I like deb because... Maintaining custom packages is easier Asks what to do with your config (instead of rpm{save|new}) Creations are isolated (name.x.y dir)
  • 28. I hate deb because... Creation is hard (all separate files) Too many tools and possibilities (but that could be a pro as well)
  • 29. I like rpm because... Creating is easy as π (spec file)
  • 30. I hate rpm because... Everything in one directory. Spec file outside that directory. Macros can be confusing.
  • 31. .deb vs .rpm Use what your system uses. Use what you like when creating your own distribution.
  • 32. Creating anRPM package
  • 33. Anatomy of a .rpm package proprietary’ish format. Use rpm2cpio to extract.
  • 34. Anatomy of a .rpm packagejthijssen@debian-jth:~/rpm$ rpm -qivlp --scripts enrise.rpmName : enrise-repo Relocations: (not relocatable)Version : 1.2 Vendor: EnriseRelease : 1 Build Date: Fri 21 Jan 2011 11:09:29 AM CETInstall Date: (not installed) Build Host: rpmbuilder.enrise.comGroup : Enrise Source RPM: enrise-repo-1.2-1.src.rpmSize : 1522 License: GPLSignature : RSA/SHA1, Fri 21 Jan 2011 11:09:31 AM CET, Key ID 84781eb0796900bdPackager : Joshua ThijssenSummary : Enrise Repository ConfigurationDescription :This is the main configuration file (for /etc/yum.repos.d) to start using therepository.postinstall program: /bin/shdrwxr-xr-x 2 root root 0 Jan 21 11:09 /etc/pkidrwxr-xr-x 2 root root 0 Jan 21 11:09 /etc/pki/rpm-gpg-rw-r--r-- 1 root root 967 Jan 21 11:09 /etc/pki/rpm-gpg/RPM-GPG-KEY-enrisedrwxr-xr-x 2 root root 0 Jan 21 11:09 /etc/yum.repos.d-rw-r--r-- 1 root root 555 Jan 21 11:09 /etc/yum.repos.d/enrise.repo
  • 35. Building a package Your sources Your patches Your other stuff SPEC file‣ DON’T FORGET TO BRING...
  • 36. Building a package Sources: myapp-v1.0.tar.gz Patches: myapp-v1.0-hotfix.patch Other files: myapp.init Spec: myapp.spec
  • 37. SPEC fileSummary: Enrise Database PatcherVendor: EnriseName: patchdbVersion: 3.0Release: 1Source0: patchdb-%{version}.tar.gzLicense: GPLGroup: EnriseBuildArch: noarchBuildRoot: %{_tmppath}/%{name}-%{version}-buildroot%descriptionThis is the database patch script that allows you to quickly patch up a database to thecorrect version.
  • 38. SPEC file%prep%setup -q%build%installrm -rf $RPM_BUILD_ROOTmkdir -p $RPM_BUILD_ROOT/usr/local/enrise/binmkdir -p $RPM_BUILD_ROOT/usr/share/man/man1cp bin/patchdb $RPM_BUILD_ROOT/usr/local/enrise/bincp man/patchdb.1 $RPM_BUILD_ROOT/usr/share/man/man1%cleanrm -rf $RPM_BUILD_ROOT
  • 39. SPEC file%pre%post%files%doc doc/*%dir /usr/local%dir /usr/local/enrise%dir /usr/local/enrise/bin/usr/share/man/man1/patchdb.1.gz/usr/local/enrise/bin/patchdb
  • 40. Creating your (S)RPM’s# rpmbuild -ba <specfile>
  • 41. Setting up acustomrepository
  • 42. Creating a repository[me@intranet01 SPECS]# cat ~/.rpmmacros%packager Joshua Thijssen%_topdir /usr/src/enriserepo/rpm%_tmppath /usr/src/enriserepo/rpm/tmp%_signature gpg%_gpg_name Enrise Repository <repository@enrise.com>%_gpgbin /usr/bin/gpg
  • 43. Creating a repository#!/bin/sh# Export source-dirs from SVN,Git,etc into SOURCES# Create tar.gz filescd SOURCESfor dir in $1* ; do if [ -d $dir ] ; then echo "Tarballing $dir..." tar czf $dir.tar.gz $dir fidonecd ..>>>>
  • 44. Creating a repository<<<<# Build RPMSsrpmbuild --quiet -ba SPECS/$1*.spec --sign 2>&1 | grep -v gpg: WARNING# Add *ALL* files to the repository and re-create xml filesREPOROOT=/data/www/enrise.com/repo.enrise.com/public/enrise/bin/cp SRPMS/* $REPOROOT/SRPMS//bin/cp RPMS/x86_64/* $REPOROOT/x86_64//bin/cp RPMS/noarch/* $REPOROOT/noarch/createrepo -v $REPOROOT/x86_64createrepo -v $REPOROOT/noarchcreaterepo -v $REPOROOT/SRPMS
  • 45. Creating a repositorydrwxr-sr-x 3 src apache 4096 Jan 21 11:13 .drwxr-sr-x 5 src apache 4096 Oct 5 2010 ..-rw-r--r-- 1 src apache 4219 Jan 21 11:12 enrise-repo-1.2-1.src.rpm-rw-r--r-- 1 src apache 7095 Jan 21 11:12 patchdb-3.0-1.src.rpmdrwxr-sr-x 2 src apache 4096 Jan 21 11:13 repodata-rw-r--r-- 1 src apache 4323 Jan 21 11:12 varnishrotate-1.0-1.src.rpm-rw-r--r-- 1 src apache 3256951 Jan 21 11:12 zfm-1.1-2.src.rpm./repodata:total 24drwxr-sr-x 2 src apache 4096 Jan 21 11:13 .drwxr-sr-x 3 src apache 4096 Jan 21 11:13 ..-rw-r--r-- 1 src apache 658 Jan 21 11:13 filelists.xml.gz-rw-r--r-- 1 src apache 567 Jan 21 11:13 other.xml.gz-rw-r--r-- 1 src apache 1376 Jan 21 11:13 primary.xml.gz-rw-r--r-- 1 src apache 951 Jan 21 11:13 repomd.xml
  • 46. Using your repositoryhttp://moodleman.moodle.com.au/wp-content/uploads/2008/09/repository.jpg
  • 47. Using a repository Add repository to /etc/yum.repos.d Add key to /etc/pki/rpm-gpg yum!
  • 48. Using a repositoryAutomate as wellAdd your /etc/yum.repos.d files + keyfiles in package.“initial wget”rpm -hiv myrepo.rpm
  • 49. Creating and using debian’s .DEBhttp://moodleman.moodle.com.au/wp-content/uploads/2008/09/repository.jpg
  • 50. Anatomy of a .deb packagejthijssen@debian-jth:~/deb$ ar tv apache2.2-common_2.2.9-10+lenny9_i386.debrw-r--r-- 0/0 4 Dec 11 20:00 2010 debian-binaryrw-r--r-- 0/0 13251 Dec 11 20:00 2010 control.tar.gzrw-r--r-- 0/0 770323 Dec 11 20:00 2010 data.tar.gzjthijssen@debian-jth:~/deb$ cat debian-binary2.0jthijssen@debian-jth:~/deb$ tar xvzf control.tar.gz././conffiles./postinst./preinst./control./postrm./md5sums
  • 51. Anatomy of a .deb package jthijssen@debian-jth:~/deb$ cat control Package: apache2.2-common Source: apache2 Version: 2.2.9-10+lenny9 Architecture: i386 Maintainer: Debian Apache Maintainers <debian-apache@lists.debian.org> Installed-Size: 3416 Depends: libapr1, libaprutil1, libc6 (>= 2.7-1), libssl0.9.8 (>= 0.9.8f-5), zlib1g (>= 1:1.1.4), apache2-utils, net-tools, libmagic1, mime-support, lsb- base, procps, perl, psmisc Recommends: ssl-cert Suggests: www-browser, apache2-doc, apache2-suexec | apache2-suexec-custom‣ CAT CONTROL
  • 52. Anatomy of a .deb package Conflicts: apache2-common, libapache2-mod-mime-xattr (<= 0.3-2), libapache2- mod-mono (<= 1.1.17-3), libapache2-mod-php4 (<= 4:4.4.4-2), libapache2-mod- php5 (<= 5.1.6-3), libapache2-mod-proxy-html (<= 2.4.3-2), libapache2-mod- scgi (<= 1.11-1), libapache2-mod-speedycgi (<= 2.22-3), libapache2-modxslt (<= 2005072700-1), libapache2-redirtoservername (<= 0.1-1), libapache2- webauth (<= 3.5.3-1), libapache2-webkdc (<= 3.5.3-1) Replaces: apache2-common Section: web Priority: optional Homepage: http://httpd.apache.org/ Description: Apache HTTP Server common files The Apache Software Foundations goal is to build a secure, efficient and extensible HTTP server as standards-compliant open source software. The result has long been the number one web server on the Internet.‣ CAT CONTROL (continued)
  • 53. Anatomy of a .deb packagejthijssen@debian-jth:~/deb$ head conffiles/etc/logrotate.d/apache2/etc/apache2/conf.d/security/etc/apache2/conf.d/charset/etc/apache2/envvars/etc/apache2/sites-available/default-ssl/etc/apache2/sites-available/defaultjthijssen@debian-jth:~/deb$ head postinst#!/bin/sh -eif [ "$1" != "configure" ]; then exit 0fiif [ -e /usr/sbin/apache2 ]; then if [ "`dpkg-statoverride --list /usr/sbin/apache2`" = "" ]; then
  • 54. Creating a .deb packageDirectory: <appname>-<major>.<minor>jthijssen@debian-jth:~/myapp-1.0$ dh_make -s -n -e jthijssen@enrise.com‣ CREATE ./DEBIAN DIRECTORY TEMPLATE
  • 55. Creating a .deb package Source: myapp Section: unknown Priority: extra Maintainer: jthijssen <jthijssen@enrise.com> Build-Depends: debhelper (>= 7) Standards-Version: 3.7.3 Homepage: <insert the upstream URL, if relevant> Package: myapp Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} Description: <insert up to 60 chars description> <insert long description, indented with spaces>‣ EDIT ./DEBIAN/CONTROL ETC..
  • 56. Creating a .deb packagemyapp.1 .TH myapp 1 "16 April 2011" "MyApp 1.00" .SH NAME myapp - My Own Hello World Application. .SH SYNOPSIS myapp .SH DESCRIPTION Simple application that will print hello world to the standard output. .SH AUTHOR This manpage was written by Joshua Thijssen <jthijssen@enrise.com>. ." end of man pagemyapp.manpages myapp.1‣ EDIT ./DEBIAN/MYAPP.1 ETC..
  • 57. Creating a .deb package case "$1" in install|upgrade) touch /myapp.install ;;‣ EDIT ./DEBIAN/{PREINST,PRERM} ETC..
  • 58. Creating a .deb package usr/local/enrise/bin‣ EDIT ./DEBIAN/DIRS
  • 59. Creating a .deb package jthijssen@debian-jth:~/myapp-1.0$ dpkg_buildpackage jthijssen@debian-jth:~$ ls -la myapp* -rw-r--r-- 1 jthijssen jthijssen 2992 2011-04-11 15:50 myapp_1.0_all.deb -rw-r--r-- 1 jthijssen jthijssen 716 2011-04-11 15:50 myapp_1.0.dsc -rw-r--r-- 1 jthijssen jthijssen 1313 2011-04-11 15:50 myapp_1.0_i386.changes -rw-r--r-- 1 jthijssen jthijssen 4683 2011-04-11 15:50 myapp_1.0.tar.gz‣ ACTUAL BUILDING OF THE PACKAGE
  • 60. Creating a .deb package jthijssen@debian-jth:~/myapp-1.0$ lintian ../myapp_1.0_all.deb E: myapp: dir-in-usr-local usr/local/enrise/ E: myapp: dir-in-usr-local usr/local/enrise/bin/ E: myapp: file-in-usr-local usr/local/enrise/bin/myapp W: myapp: file-in-unusual-dir usr/local/enrise/bin/myapp W: myapp: readme-debian-contains-debmake-template W: myapp: copyright-lists-upstream-authors-with-dh_make-boilerplate‣ LINTIAN CHECK
  • 61. Using your repositoryhttp://moodleman.moodle.com.au/wp-content/uploads/2008/09/repository.jpg
  • 62. Creating a repositoryjthijssen@deb:~$ mkdir -p /var/www/repo/enrise/{binary,source}jthijssen@deb:~$ cp *.deb /var/www/repo/enrise/binaryjthijssen@deb:~$ cp *.dsc *.tar.gz /var/www/repo/enrise/sourcejthijssen@deb:~$ cd /var/www/repo/enrisejthijssen@deb:enrise$ dpkg-scanpackages binary /dev/null | gzip -9c > binary/Packages.gzjthijssen@deb:enrise$ dpkg-scansources source /dev/null | gzip -9c > source/Sources.gz
  • 63. Using your repository/etc/apt/sources.listdeb http://repo.url/enrise binary/deb-src http://repo.url/enrise source/jthijssen@deb:~$ apt-get updatejthijssen@deb:~$ apt-get install myapp
  • 64. Question & discussionhttp://farm1.static.flickr.com/73/163450213_18478d3aa6_d.jpg
  • 65. Please rate my talk on joind.in: http://joind.in/3315‣ THANK YOU FOR YOUR ATTENTION