0% found this document useful (0 votes)
55 views4 pages

7 Steps To Build A RPM Package From Source On CentOS - RedHat

7 Steps to Build a RPM Package From Source on CentOS
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
55 views4 pages

7 Steps To Build A RPM Package From Source On CentOS - RedHat

7 Steps to Build a RPM Package From Source on CentOS
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 4
2018 7 Steps to Bula RPM Package fom Source on CentOS / RedHat THE GEEK STUFF Lunas 08 | OpenSource | ved 7 Steps to Build a RPM Package from Source on CentOS / RedHat ‘by Kartikeyan Sadhasivam on Fbrusty 4, 2015 lam 8 Sometimes you might have access to an open source application source code but ght no have the RPM fle wo instal ton you system. ln that situation, you ca either compile the sourcecode and intl the application from soure code, o build 2 RPM file from source code youre, nd ue the RPM file to instal the appication. ‘There might aso bea station where you want o builds customn RPM package forthe application that you developed ‘This ttrial explains how to build a RPM package fom the sourcecode In order to build RPMs, you wil ned source code, which usally means a compressed trie tha lo includes the SPEC fe ‘The SPEC fle ypically contains instretons on ow to build RPM, what ils ate par of package and whet it shouldbe installed. The RPM performs the following task during the build process 1, Executes the commands and macros rationed in the prep seston ofthe spec ile 2 Checks the content ofthe lest. 5. Executes the commands and macros inthe uid setion ofthe spec file. Macros frm he ile Hs also exceed a this tp. 4. Creates the binary package file 5 Creates the source package file Save Now > “The binay package file conse of all source files long with any adtiona information to intl or uninstall he packags Ici usualy enabled with ll ho options for astaling the package that are platforms specifi. Binary package file contin compet applications or libris of funsons comple fora parcular architects. The tutes package usually consist ofthe orginal compreste ar le, spec le andthe patches which te reguited octal the binary package file [Lerus ses how to creat simple source and BIN RPM packages using tari you ate new to pm package, you may fst want wo understand how to use rom command to intl, upgrade and remove packages on CentOS oe RedHat |. Install rpm-build Package “To bild an rpm file based on the spc ile ha we just ereted, we ned owe rpmbuil command pmb command is part of rpm-buld package. Intl itas shown show below. hnipshww thogosksil con2018/02Hrpm-bul-packago-exampa/?tm_source=foudbener8itm_medun=TeadBuim_campagn=Foodik3A+TheGookStéle(T.. 18 2018 7 Steps to Bula RPM Package fom Source on CentOS / RedHat _pm-build it dependent on the following package Ifyou don’t have thet installed area, ym wil atomically instal these dependencies for you 2. RPM Build Directories rpm-build will automatically crete the following directory scars that willbe uted daring the RPM build 41g iF srootirommusta ewtrinons 2 rot root 4096 Feb 4 22:28 wlLo/ demrcurox. 2 reat root 486 Feb 4 22:21 SOURCES/ domecxrox. 2 oat root 4886 Feb 4 22:21 SRPNS/ Note:The above directory structures for both CentOS and Resat when using rpmbuild package. You can also use s/tiedhat rectory, but you need to change the ‘pli parameter accordingly during the rp build I you are doing hs on SuSE Enterprise Lin ase ast lpackages Gest". you want to use your own dircory structs ists ofthe toot pmbuil, you can use one ofthe falling option: + Ute-builroot osion ad specify the custom directory during the pmb 1 Sposfy the topirpaamter inthe mie file or pmmacto ie. 3. Download Source Tar File "Next, downlood the source tar file for the package tat you want to build and save it under SOURCES directory. For this example, I've use the source code ficecase opensource application, which a server software for steaming multi-media. Bu, the steps are exaly the same for building RPM or aay oer applistion. You jst have fo dowaload the corresponding sourcecode for the RPM tat you ae tying o bul 4 od /roat/rpnnusi4/sunees get ety: /dounoads niph.og/releases/leecast/tcecast.2.3.3.080.2 4. Create the SPEC File In ths step, we dec RPM in the builé process by creating a spec fle. The spe ile usuelly consists ofthe following cight diferent sections Preamble ~The preamble section contains information about te package being bul and define any dependencies to the package. a general, the preamble consists of entries, one prin hat sat wih ag followed by colon, and then some information 2. Yiprep =n ths section, we prepare the software for balding process. Any previous buds are removed during this process and the source ila) ies expanded, 5. One more key thing ito understand there re pre-defined macros avilable to perform various shorteut option to build spn. You may be using this macros when ‘you ty to ld an complex packages Inthe Below example, I hive wed micro called scp which removes any previous bul mr the source le and ‘hanes the ownership of the es. You can also sesh sept under “pep sein io perform iis action but setup acre simplifies the process y using predefined sh seis. 4 Yaesriton = he detripton section wsusly contain description about the package 5 bud = This the section tate responbe for perfoming the bud. Ustlly the bul section san sh sip é 1. Séintll the % intl ston i also exceed as thsrpt just ike peep and “bull, This ithe tp thai used fr the installation, Sales This secton contain the Hist of ies tht ae pat othe package Ifthe les are not part ofthe ile secon ten it wont be availabe in the package Complete paths ae required and yo can set the tries and ommership af the ils in thie recton 8 lean ~ This section instructs the RPM to cleanup any les that ate nat par ofthe applications normal build area. Les say foran example, the aplication creates a temporary dvectry strsture in eas part of is bul, wil pot be removed. By adding ash serpin Sclean section, the dectory can be removed Mer the build process completed Heres the SPEC ile cretd forthe iecast application to build an RPM fle cat /root/rpmbe/ Sots /Scacase. pee Somaey sgh Stroaning nedta eerver that sports multiple formate bpplscationg/Pultinecio Righ.ory toundstion Cengicecastorg Itepi//domloade-ot xipnorgveleses/Scacest/X(nane)-€ (vers on).t3"-82 been) Betbdoots A tnpoathy ane) -roct aescrsption Teac it string nthe server wlch currently sgprss Oa vorbls Station ara privately running sekeboe aed any things bette, cly"sn Support opon ttandares for comuinestion ane Sytoracton. sore hnipshww thogonksil conv2018/02Hrpm-bul-packago-exampa/?tm_source=TeudbenerButm_medun=TeadBuim_campagn=Foodik3AsTheCookStée(T.. 2 T2018 7 Steps to Bula RPM Package fom Source on CentOS / RedHat estup 4-9 loan) -Xeersion) (LAGS "Som 021 FLAGS" /eantigure ~pretbeot{ pets} -onanie-t{ mandir) -nsysconfirefete Spout poor” */° 7 om or $m, gutue Root foo gare sunt saote{ seta} eae/8(nane} (Strain. soor= “7 RR oe =r $08 BUTLD 8007 ESRI va a oe SE BEg EEC Eoagaman SE ee In this #20, under prep section you nay noticed the mero "Keetup qn X{nate}-t(version}”. This macro executes the following comand én the bucksroun faeces s0.9 Lip ae Fase sre/neahat/SOURCES/tewcast-2.3.3.tar.g2 | Ca oawvt = Be Re ln tabu section, you wil see the CFLAGS with configure options that defines the options that canbe using ding RPM installation andthe prefix option, mandatory sivectory tobe present for the nsallaton and syconfig tector unde which the system files need o be copied over. Below tat ine, you wil se the make uty which determines he is files needs tobe compiled and compiles them appropriately {n % inal section, the line below the Senta that sys appropriate locations so they ean be secested. ths install” is used to take the binaties compiled fom the previous step and install cope them othe Create the RPM File using rpmbuild (once the SPLC fi is ead, you can stat bldg your pm with rpm -b command, The -b opin it wed to perform al the phases ofthe build process. Ifyou se any ¢sfors during this phase, thea you ned to resolve i before re-attmipng again. The cor wil be usualy of Horary dependencies abd you can download ad instal i as necesay. 4 oa /roat/rpnnusta/srecs roma bu teecas. spec Eescuingtsprep)s inion se /va/tmp/rpnetp Kohat fo frstirpenusiaaunto 6 Frestromutiaraane Tesefoin/eris =e root ronbua/scuRces/iceast-2.3.9.tare2 a seecasten ba Tinfenaa if aera FREE igaie): iad oe Feeney eb ostirpenuttaroumio 1 Suse 1 Speonigare “tarefine/usn -andien/urr/share/nan =usysantetr fhecking for gant gine. . Checking wether to enable sutstbr-teciLe potions of ake Tirote: /root/rpmoutl/APns/ x86 6a/icecast-2.3.3-8-xB6_64.ro0 Erecting tan ian ve Tee psoas + "T* frace/rpmbst16/MUELDRGOT/teecast2.3.3-0.288 66 "1a" J {nn en Treotiromeslayein phot seeeset-. 3348-90664 Inipshww thogonksil con2018/02Hrpm-bul-packago-exampa/?tm_source=Teadbener8itm_medun=TeadBuin_campagn=Foodik3AsTheGookStéle(T.. 3 T2018 7 Steps to Bula RPM Package fom Source on CentOS / RedHat Note Ifyou ste using SuSE Linas, ifrpmbuil eno avilable, try sng “rpm -h" to bul he rpm package uring the above rpmbuild install, you might notice the following er messages: Error 1: XSLT configuration cou not be found trot bag bale stat fon /vor/tna/epa-tp. Boyne sul) En tld errors BSS GU Status fron var/tmp/npntne. 628,06 (bute) Son 1: Insta Hibast-devet For the xstconfig, you ned oisall ibs deve package as shown below “This wil also install he following dependence: + bast + ibgcrypetevel 2 libeprsrordovel ror 2 ibvorbis Error checking for Libvorbis.,. configure: error: mst have Oe Vorbis v1.8 or above installed trong exit seater (oon /vaticna/epactnp mghot (ee) Solution 2: Install bvorbi-devel For the Ogg Vorbis v1.0, instal the Hvorbie-dvel package as shown below “This will ale install the following dependence: + thoes + ioge-devel 2 ower 6, Verify the Source and Binary RPM Files ‘Once the rpbuild is completed, you ean verify the source spm and binary pm is xate inthe Below directories 1s 1 /rostfrpnbutna sons) Teecrisrs Droge noo SIED869 Ag 25 15:46 feecast-2.3.2-8.5P6.060 7. Install the RPM File to Verily ‘Asa fina sep, you can insll he binary sm to verify that it instls succesfully and all he dependencies are resolved, ct /rpmb ay RP 4 scacast-2.3.3-0.286 6.090 =k ron ARS / na \cacasto 23.98. E498 ring. tan pubkeys i /var/12b/con/ pubes) salen’ lea Say keys i Fear/Libion/punceye/™ sey ding keyring, fon ron opening "a enviroment /var/Ltb/rm edbenpolotnene 2: “rene bo “Sap vender sanity checks OF 1: Using legacy epa-ovdkey(s) From rpm 8: Eapected tees Seats Teta) sige (at) pode seat saasen) 8: MReeist ere: Seoiel 8: Sele Sinoey pokage (0) 3 Tes Seechatet Sate ae ee/tinoe 02 [After the sbove installation, you cn verify that your custom ee trp file was installed secesflly shown below lez) > Addsourcommgat Ifyou enjoyed this article, you might also like.. }sBLinu ss . + foklnducion 7 Av i ams hip ew thogookstu con/2018/02Hrpm-bul-packago-examla/2um_sourco=fouduenerSutm_medium=feed8uim_campa.gn=Foodh3Ae TheGookStile(T 48

You might also like