Presentation is loading. Please wait.

Presentation is loading. Please wait.

RPM101: A gentle intro to creating your own packages Richard Keech Red Hat Asia-Pacific.

Similar presentations


Presentation on theme: "RPM101: A gentle intro to creating your own packages Richard Keech Red Hat Asia-Pacific."— Presentation transcript:

1 RPM101: A gentle intro to creating your own packages Richard Keech Red Hat Asia-Pacific

2 Agenda Issues What's in an RPM SPEC files Rolling your own package

3 The RPM way For both core OS and add-ons Installation is not interactive ● Installation separated from configuration No such thing as a patch A file can only belong to one package Pristine source plus patches

4 RPM packaging Installed state becomes: ● Visible ● Verifiable ● Upgradable

5 RPM packaging Packages contain ● Files (obviously!) ● Scripts (install & uninstall) ● Metadata

6 Creating your own RPMs Benefits: ● Modular installation, removal and upgrading ● Rapid deployment ● Controlled configuration ● Integrates with OS dependencies Benefits – developers ● Repeatable builds ● Dependency handling ● Configuration control

7 Creating your own RPMs General approach: ● Create tar archive of manual install ● Create / adapt a SPEC file Outcome: ● End-usable package file ● 'Source' package file

8 Build tree /usr/src/redhat/ BUILD/ RPMS/ i386 noarch SOURCES/ SPECS/ SRPMS/

9 RPM Macros Variables and functions Defaults in /usr/lib/rpm/macros Overrides in /etc/rpm/macros.* and ~/.rpmmacros Users should set %{_topdir} macro, otherwise build will be in /usr/src/redhat

10 SPEC file: preamble Name: hello Version: 1.0 Release: 1 Summary: Hello, world! Group: Applications/Productivity License: Distributable Source0: hello-1.0.tar.gz Source1: hello.sh Source2: hello.csh BuildArch: i686 BuildRoot: /var/tmp/hello-root %description An enthusiastic greeting to the world of RPM building.

11 SPEC file: %prep %prep prepares sources ● Unpacks pristine sources into BUILD ● Applies any necessary patches Useful macros ● %setup ● %patch

12 SPEC file: %build %build compiles and prepares the software Runs as a shell script %configure macro make

13 SPEC file: %install %install prepares files for packaging Chroot tree - BuildRoot $RPM_BUILD_ROOT set %makeinstall

14 SPEC file: %clean %clean removes temporary files after the build Typically remove BuildRoot tree %clean rpm -rf $RPM_BUILD_ROOT

15 SPEC file: Scripts Should never be interactive %pre -- prior to file installation ● Adding users and groups %post -- after file installation ● chkconfig –add ● service re-start %preun – before file removal ● chkconfig --del %postun – after file removal rpm -q --scripts pkgname

16 SPEC file: %files %files lists all the files Sufficient to specify the base directory if all files are included %dir to specify empty directories %defattr(mode,user,group) filename %config %doc

17 SPEC file: %changelog %changelog records package history Date format: +”%a %b %d %Y” Show using rpm -q --changelog pkg

18 rpmbuild rpmbuild -bp specfile prep only rpmbuild -bc specfile prep and compile rpmbuild -bb specfile prep and compile and install rpmbuild -bs specfile build source pkg only rpmbuild -ba specfile all, ie binary and source pkg

19 Signing RPM packages GPG key required Signing is generally encouraged Signing is mandatory for many repos rpmbuild --sign rpmbuild --resign Macros: %_signature gpg %gpg_name My Name myname@mydomain.com Make public key available

20 References Red Hat RPM Guide 2005 http://docs.fedoraproject.org/drafts/rpm-guide-en/ http://docs.fedoraproject.org/drafts/rpm-guide-en/

21 Demo (time permitting)

22 Example: RPMs of Oracle DB Roll your own: encapsulation / backup of the Oracle install you'd do by hand find a spec file that does something similar Example: Red Hat product “Satellite” embeds Oracle Server 9.2.0.6 Example: Oracle Express available as RPM

23 RPMs of Oracle DB oracle-server-920-9.2.0.6.0-1.i386.rpm 162MB oracle-server-prod-9207-10rhgps.x86_64.rpm 1017MB

24 Recommendations / Observations Sysadmin and DBA collaborate to prepare RPM of your way of doing Oracle DBA can prepare and maintain their own scripts / utilities RPM package. Sysadmin can prepare and maintain their own custom Red Hat CD Easy to leverage one project for the next Red Hat & TPS can meld for highly repeatable, productized deliverables

25 Thank you Any questions?

26


Download ppt "RPM101: A gentle intro to creating your own packages Richard Keech Red Hat Asia-Pacific."

Similar presentations


Ads by Google