Rpm
From Attie's Wiki
(Difference between revisions)
(Created page with "==Building an RPM package== Create the following directory structure: <source lang="bash"> mkdir -p rpm/SOURCES rpm/SPECS </source>") |
m (→List installed packages) |
||
(14 intermediate revisions by one user not shown) | |||
Line 1: | Line 1: | ||
+ | ==Manual Management== | ||
+ | ===Install=== | ||
+ | <source lang="bash"> | ||
+ | rpm [--nodeps] -i <rpmfile> | ||
+ | </source> | ||
+ | |||
+ | ===Uninstall=== | ||
+ | <source lang="bash"> | ||
+ | rpm -e <rpmpackage> | ||
+ | </source> | ||
+ | |||
+ | ===Extract without Installing=== | ||
+ | <source lang="bash"> | ||
+ | rpm2cpio myrpmfile.rpm | cpio -idmv | ||
+ | </source> | ||
+ | |||
+ | ===List installed packages=== | ||
+ | <source lang="bash"> | ||
+ | rpm -qa | ||
+ | </source> | ||
+ | |||
+ | ===List files inside RPM=== | ||
+ | <source lang="bash"> | ||
+ | rpm -qpl ${RPM_FILE} | ||
+ | </source> | ||
+ | |||
==Building an RPM package== | ==Building an RPM package== | ||
Create the following directory structure: | Create the following directory structure: | ||
<source lang="bash"> | <source lang="bash"> | ||
− | mkdir -p | + | mkdir -p ~/rpmbuild/SOURCES ~/rpmbuildrpm/SPECS |
+ | </source> | ||
+ | |||
+ | Create a tar file containing the source code, named like so: <code><packagename>-<version>.tgz</code>: | ||
+ | <source lang="bash"> | ||
+ | tar -cavf ~/rpmbuild/SOURCES/mylib-1.0.1.tgz --transform='s#^#mylib-1.0.1/#' *.c *.h makefile | ||
+ | </source> | ||
+ | |||
+ | Create a *.spec file using the following template, and store it in <code>~/rpmbuild/SPECS/mylib.spec</code>: | ||
+ | [http://www.rpm.org/max-rpm/s1-rpm-inside-macros.html This] is helpful for the <code>%prep</code> section macros. | ||
+ | <source lang="text"> | ||
+ | Name: mylib | ||
+ | Summary: Test library | ||
+ | %define version 1.0.1 | ||
+ | Release: 1 | ||
+ | Source: mylib-%{version}.tgz | ||
+ | |||
+ | Version: %{version} | ||
+ | License: LGPLv3 | ||
+ | #BuildRequires: make, gcc, binutils, coreutils, gzip | ||
+ | Group: System/Libraries | ||
+ | |||
+ | BuildRoot: /ver/tmp/${name}-buildroot | ||
+ | |||
+ | %description | ||
+ | Test library | ||
+ | |||
+ | %prep | ||
+ | %setup -q | ||
+ | |||
+ | %build | ||
+ | make configure | ||
+ | make | ||
+ | |||
+ | %install | ||
+ | rm -rf $RPM_BUILD_ROOT | ||
+ | mkdir -p $RPM_BUILD_ROOT/usr/include | ||
+ | mkdir -p $RPM_BUILD_ROOT/usr/lib | ||
+ | SYS_ROOT=$RPM_BUILD_ROOT make install | ||
+ | |||
+ | %clean | ||
+ | rm -rf $RPM_BUILD_ROOT | ||
+ | |||
+ | %files | ||
+ | /usr/lib/libmy.a | ||
+ | /usr/lib/libmy.a.%{version} | ||
+ | /usr/lib/libmy.so | ||
+ | /usr/lib/libmy.so.%{version} | ||
+ | /usr/lib/libmy.so.%{version}.dbg | ||
+ | /usr/include/my.h | ||
+ | |||
+ | %changelog | ||
+ | * Wed May 30 2012 Attie Grande <attie@attie.co.uk> | ||
+ | - created RPM build infrastructure | ||
+ | </source> | ||
+ | |||
+ | Build the RPM: | ||
+ | <source lang="bash"> | ||
+ | cd ~/rpmbuild | ||
+ | rpmbuild -ba SPECS/mylib.spec | ||
+ | </source> | ||
+ | |||
+ | ==Convert *.rpm to *.deb== | ||
+ | <source lang="bash"> | ||
+ | $ sudo apt-get install alien | ||
+ | $ sudo alien -k mylib-1.0.1-1.x86_64.rpm | ||
+ | $ ls | ||
+ | mylib-1.0.1-1.x86_64.rpm mylib_1.0.1-1_amd64.deb | ||
+ | </source> | ||
+ | |||
+ | And install... | ||
+ | <source lang="bash"> | ||
+ | sudo dpkg -i mylib_10.1-1_amd64.deb | ||
</source> | </source> |
Latest revision as of 11:58, 13 May 2014
Contents |
[edit] Manual Management
[edit] Install
rpm [--nodeps] -i <rpmfile>
[edit] Uninstall
rpm -e <rpmpackage>
[edit] Extract without Installing
rpm2cpio myrpmfile.rpm | cpio -idmv
[edit] List installed packages
rpm -qa
[edit] List files inside RPM
rpm -qpl ${RPM_FILE}
[edit] Building an RPM package
Create the following directory structure:
mkdir -p ~/rpmbuild/SOURCES ~/rpmbuildrpm/SPECS
Create a tar file containing the source code, named like so: <packagename>-<version>.tgz
:
tar -cavf ~/rpmbuild/SOURCES/mylib-1.0.1.tgz --transform='s#^#mylib-1.0.1/#' *.c *.h makefile
Create a *.spec file using the following template, and store it in ~/rpmbuild/SPECS/mylib.spec
:
This is helpful for the %prep
section macros.
Name: mylib Summary: Test library %define version 1.0.1 Release: 1 Source: mylib-%{version}.tgz Version: %{version} License: LGPLv3 #BuildRequires: make, gcc, binutils, coreutils, gzip Group: System/Libraries BuildRoot: /ver/tmp/${name}-buildroot %description Test library %prep %setup -q %build make configure make %install rm -rf $RPM_BUILD_ROOT mkdir -p $RPM_BUILD_ROOT/usr/include mkdir -p $RPM_BUILD_ROOT/usr/lib SYS_ROOT=$RPM_BUILD_ROOT make install %clean rm -rf $RPM_BUILD_ROOT %files /usr/lib/libmy.a /usr/lib/libmy.a.%{version} /usr/lib/libmy.so /usr/lib/libmy.so.%{version} /usr/lib/libmy.so.%{version}.dbg /usr/include/my.h %changelog * Wed May 30 2012 Attie Grande <attie@attie.co.uk> - created RPM build infrastructure
Build the RPM:
cd ~/rpmbuild rpmbuild -ba SPECS/mylib.spec
[edit] Convert *.rpm to *.deb
$ sudo apt-get install alien $ sudo alien -k mylib-1.0.1-1.x86_64.rpm $ ls mylib-1.0.1-1.x86_64.rpm mylib_1.0.1-1_amd64.deb
And install...
sudo dpkg -i mylib_10.1-1_amd64.deb