8

I am creating my first package using RPM on ubuntu machine.But I am getting so many difficulties.I tried so many commands to install rpmdevtools using "yum" but it is giving error as There are not repos enabled. When I try to install it using apt-get it gives error as Unable to locate the package.

Can anybody suggest the proper start to end procedure with commands to build a package using RPM?

Shah Ritesh
  • 111
  • 1
  • 2
  • 6

1 Answers1

20

rpmdev is mostly optional. rpm is enough. The following describes the minimum steps to package a script program into a RPM file on Debian.

Install rpmbuild:

apt-get install rpm

Create a helloworld program:

cat > helloworld <<EOF
#! /bin/bash
printf "Hello World!\n"
EOF
chmod +x helloworld

Create a minimal specification helloworld.spec:

Name:       helloworld
Version:    1.0
Release:    1%{?dist}
Summary:    Hello World
License:    GPLv3+
BuildArch:  noarch

%description
Hello World!

%prep

%build

%install
mkdir -p %{buildroot}/%{_bindir}
install -m 0755 %{name} %{buildroot}/%{_bindir}/%{name}

%files
%{_bindir}/%{name}

%changelog

Build the RPMs:

rpmbuild -ba --build-in-place --define "_topdir $(pwd)/rpm" helloworld.spec
mv rpm/SRPMS/*.rpm .
mv rpm/RPMS/*/*.rpm .
rm -rf rpm

But you will not be able to install it on Debian or Ubuntu. The installation requires Fedora or Red Hat.

ceving
  • 21,900
  • 13
  • 104
  • 178