Upload
tanner-lovelace
View
4.033
Download
0
Embed Size (px)
DESCRIPTION
A talk I gave to the Triangle Linux Users Group ( http://www.trilug.org/ ) on 11-Jan-2003 on how to build RPM packages. Probably fairly outdated at this point.
Citation preview
Tanner Lovelace – Slide 1
RPM Packaging 101RPM Packaging 101
Tanner LovelaceTanner LovelaceTriangle Linux Users GroupTriangle Linux Users Group
11/Jan/200311/Jan/2003
Tanner Lovelace – Slide 2
OutlineOutline
• Package Management BasicsPackage Management Basics• RPM Package Management BasicsRPM Package Management Basics• Creating Your Own RPM PackagesCreating Your Own RPM Packages• Creating RPM Packages of Downloaded Creating RPM Packages of Downloaded
ProgramsPrograms• Advanced RPM PackagingAdvanced RPM Packaging
Tanner Lovelace – Slide 3
Package Management BasicsPackage Management Basics
• Why use package management?Why use package management?–OpenBSD base doesn’tOpenBSD base doesn’t–Most Linux systems doMost Linux systems do
• Keeps track of system packagesKeeps track of system packages–FilesFiles–DescriptionsDescriptions–ChecksumsChecksums–Other…Other…
• Allows easy upgrades and uninstallsAllows easy upgrades and uninstalls
Tanner Lovelace – Slide 4
RPM Package Management BasicsRPM Package Management Basics
• Developed by RedhatDeveloped by Redhat–Dominant distribution at the time was Dominant distribution at the time was
SlackwareSlackware»Slackware has packages, but not really a Slackware has packages, but not really a
package management systempackage management system»RPM was a big advance over SlackwareRPM was a big advance over Slackware
–Current stable version is 4.1Current stable version is 4.1–Most commonly used version today is 4.0.xMost commonly used version today is 4.0.x
»We will be covering 4.0.xWe will be covering 4.0.x
Tanner Lovelace – Slide 5
RPM Package ConceptsRPM Package Concepts
• Pristine SourcesPristine Sources–Most Linux software downloaded from the Most Linux software downloaded from the
InternetInternet–Any distribution specific customizations Any distribution specific customizations
should be kept separately in patchesshould be kept separately in patches»Makes it easier to handle new versionsMakes it easier to handle new versions
• Reproducible BuildsReproducible Builds–Building and packaging should be easy and Building and packaging should be easy and
reproduciblereproducible–Shell script automationShell script automation
Tanner Lovelace – Slide 6
Common RPM Installation CommandsCommon RPM Installation Commands
• InstallationInstallation–rpm –ihv <package name>rpm –ihv <package name>
• UpgradeUpgrade–rpm –Uhv <package name>rpm –Uhv <package name>
• FreshenFreshen–rpm –Fhv <package names…>rpm –Fhv <package names…>
• EraseErase–rpm –e <package name>rpm –e <package name>
Tanner Lovelace – Slide 7
Other Common RPM CommandsOther Common RPM Commands
• QueryQuery–rpm –q[option] <package name>rpm –q[option] <package name>
»-qi = Query Package Information-qi = Query Package Information» -ql = List Package Files-ql = List Package Files» -qf = Query which package a file belongs to.-qf = Query which package a file belongs to.» --queryformat – Construct Special Query--queryformat – Construct Special Query
»--querytags – List available tags--querytags – List available tags» -p – Specify non-installed rpm package-p – Specify non-installed rpm package» -a – Query -a – Query allall installed files installed files
Tanner Lovelace – Slide 8
Other Common RPM CommandsOther Common RPM Commands
• VerifyVerify– rpm –V[option] <package name>rpm –V[option] <package name>
» Compare information about installed package files with Compare information about installed package files with information stored in rpm database and note any information stored in rpm database and note any discrepencies.discrepencies.
» Compares size, MD5 sum, permissions, type, owner, Compares size, MD5 sum, permissions, type, owner, and group of each package fileand group of each package file
• Signature checkingSignature checking– rpm {-K|--checksig} <package name>rpm {-K|--checksig} <package name>
» Checks package gpg/pgp signatureChecks package gpg/pgp signature• Conversion to cpioConversion to cpio
– rpm2cpio cpio converts rpm files to cpio streamsrpm2cpio cpio converts rpm files to cpio streams
Tanner Lovelace – Slide 9
Setting up the RPM Build EnvironmentSetting up the RPM Build Environment
• NEVER BUILD RPMs AS ROOT!!!NEVER BUILD RPMs AS ROOT!!!• ~/.rpmmacros~/.rpmmacros
– %_topdir /path/to/rpm/build/env%_topdir /path/to/rpm/build/env» I typically use ~/RPMI typically use ~/RPM
– Optional temp directoryOptional temp directory» %_tmppath /path/to/tmp%_tmppath /path/to/tmp
• Create directoriesCreate directories– ~/RPM/BUILD~/RPM/BUILD– ~/RPM/RPMS/<arch>~/RPM/RPMS/<arch>– ~/RPM/RPMS/noarch~/RPM/RPMS/noarch– ~/RPM/SOURCES~/RPM/SOURCES– ~/RPM/SPECS~/RPM/SPECS– ~/RPM/SRPMS~/RPM/SRPMS
Tanner Lovelace – Slide 10
Creating Your Own RPMsCreating Your Own RPMs
• rpmbuild commandrpmbuild command–rpmbuild –ba – build binary and source rpmsrpmbuild –ba – build binary and source rpms–rpmbuild –bb – build binary rpmrpmbuild –bb – build binary rpm–rpmbuild –bs – build source rpmrpmbuild –bs – build source rpm
• Before version 4, the rpm command was used instead Before version 4, the rpm command was used instead of rpmbuild.of rpmbuild.–Compatibility aliases in 4.0Compatibility aliases in 4.0–Aliases removed in 4.1 (Redhat 8.0)Aliases removed in 4.1 (Redhat 8.0)
• Need source files, patches (if any) and a Need source files, patches (if any) and a specspec file. file.–Source and patch files go in SOURCES/Source and patch files go in SOURCES/–Spec file goes in SPECS/Spec file goes in SPECS/
Tanner Lovelace – Slide 11
RPM Spec FilesRPM Spec Files
• Instructions for building and packaging an rpm.Instructions for building and packaging an rpm.–Building – set of shell scriptsBuilding – set of shell scripts–Packaging – General info, lists of files, etc.Packaging – General info, lists of files, etc.
• Divided into sectionsDivided into sections–Headers (unlabeled section)Headers (unlabeled section)–%description%description–%prep%prep–%build%build–%install%install–%files%files–OthersOthers
Tanner Lovelace – Slide 12
Creating RPMs ExamplesCreating RPMs Examples
• See Pinky and the Brain Examples atSee Pinky and the Brain Examples athttp://home.fnal.gov/~dawson/rpms/howto/index.htmlhttp://home.fnal.gov/~dawson/rpms/howto/index.html
• Sub package exampleSub package example• Example of how to “rpm-ify” a package.Example of how to “rpm-ify” a package.• PatchingPatching• Conditional buildingConditional building
Tanner Lovelace – Slide 13
ReferencesReferences
• References will go here when presentation References will go here when presentation goes online..goes online..