© 2016 Steve Parker, BSc, RHCE Copyright © 2016 by Steve Parker. All Rights Reserved. No part of this publication or the information in it may be quoted from or reproduced in any form by means such as printing, scanning, photocopying or otherwise without prior written permission of the copyright holder. Linux® is the registered trademark of Linus Torvalds in the U.S. and other countries. Red Hat® is the registered trademark of Red Hat Inc. in the U.S. and other countries. The RPM Logo on the front cover by Carolingio93 is licensed under the Creative Commons Attribution-Share Alike 4.0 International, 3.0 Unported, 2.5 Generic, 2.0 Generic and 1.0 Generic license. All trademarks are acknowledged as belonging to their respective owners. Dedicated to my wife, Jackie. Table of Contents Formatting Conventions Used in this Book 1 Introduction 3 Why RPM? 4 Metadata 4 YUM 5 Preparation 6 Chapter 1: Preparing to Create RPMs 7 Step 1. Install VirtualBox 7 Step 2. Download Image 7 Step 3. Connect 9 Step 4. Install rpm-build 10 Chapter 2: Creating a Simple (but Useless!) Binary RPM 16 Building the Package (Take 1) 18 Chapter 3: Creating a Useful Binary RPM 21 Licensing 21 Building the Package (Take Two) 23 Adding Some Files 26 Placing the Files 28 Building the Package (Take Three) 29 Don’t Clean Up! 33 Chapter 4: Permissions 36 Chapter 5: Install-time Scripts 38 Preinstall Script 40 Postinstall Script 41 Pre-Uninstall Script 41 Post Uninstall Script 42 Install Count – Upgrading RPMs 43 Chapter 6: ChangeLog 47 Chapter 7: Replacing Configuration Files 51 Chapter 8: There must be an easier way! 54 Appendix A: Importing the OVA Appliance into VirtualBox 57 Appendix B: Configuring a Static IP Address 63 Appendix C: Configuring Repositories for rpm-build 65 Aside: Creating your own Repositories 67 Appendix D: Package Groups 69 Appendix E: Bibliography and Further Reading 71 Thank You! 72 Feedback 73 By The Same Author 74 Formatting Conventions Used in this Book The formatting conventions in this book are fairly standard; the main text is in a serif font, like the text you are currently reading. System files and commands (such as , rpmbuild , and so on) are shown in monospaced font. /etc/hosts Output from interactive sessions is show on a light gray background; commands that you type are in bold text, for example, here you would type “cd” and “mkdir rpmbuild”: [rpm@packaging ~]$ cd [rpm@packaging ~]$ mkdir rpmbuild Callout boxes are shown on a lighter background, with a border, and highlight particular noteworthy items, including a reminder of where you can download sample files from: If a line of input is too long to show on the width of the page of a printed book, then a backslash (\) character is shown to indicate that the command continues onto the next line (which will be indented). You can either type it in literally as shown, as multiple lines, like this: cp my-first-rpm-1.0-1.spec \ ~/rpmbuild/SPECS Or you can remove the backslash ( ) and the line-break, and enter it all one one line, like \ this: cp my-first-rpm-1.0-1.spec ~/rpmbuild/SPECS/ You will probably find the second option easier. Any shell you are using will accept either format. At times, it can be more clear to display the prompt as a single “ ” symbol, rather than its $ more usual, but longer format (like “ ”), so instead of this: [rpm@packaging take3]$
Description: