aboutsummaryrefslogtreecommitdiff
path: root/content/blog/miscellaneous/building-rpms.md
blob: 1b3bfec844d50f46ae106c7ce5ae4b73a4b0cb8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
---
title: "Building rpm packages"
date: 2016-02-22
description: How to build locally an rpm package
tags:
  - Centos
  - rhel
---

## Setup your environment

First of all, you have to use a non-root account.

 - Create the necessary directories : `mkdir -p ~/rpmbuild/{BUILD,RPMS,S{OURCE,PEC,RPM}S}`
 - Tell rpmbuild where to build by adding the following in your `.rpmmacros` file : `echo -e “%_topdir\t$HOME/rpmbuild” » ~/.rpmmacros`

## Building package

There are several ways to build a rpm, depending on what kind of stuff you have to deal with.

### Building from a tar.gz archive containing a .spec file

Run the following on you .tar.gz archive : `rpmbuild -tb memcached-1.4.0.tar.gz`. When the building process ends, you will find your package in a `$HOME/rpmbuild/RPMS/x86_64/` like directory, depending on your architecture.

### Building from a spec file

 - `rpmbuild -v -bb ./contrib/redhat/collectd.spec`
 - If you are missing some dependencies : `rpmbuild -v -bb ./contrib/redhat/collectd.spec 2>&1 |awk '/is needed/ {print $1;}'|xargs yum install -y`