RPM 파일을 만들려면 어떻게해야합니까?
단지 몇 가지 의존성으로 Linux 바이너리 "foobar"를 배포하기 위해 RPM 파일을 만들고 싶습니다. 구성 파일 /etc/foobar.conf가 있으며 / usr / bin / foobar에 설치해야합니다.
불행히도 RPM에 대한 문서 는 27 장으로 구성되어 있으며 다른 플랫폼 용 .deb 및 EXE 설치 프로그램을 만드는 데 바쁘기 때문에 앉아서 읽을 시간이 없습니다.
RPM을 만들려면 어떻게해야합니까? foobar 바이너리와 foobar.conf가 현재 작업 디렉토리에 있다고 가정하십시오.
나는 종종 리눅스에서 독점적 인 앱을 패키징 할 때 바이너리 바이너리를 사용합니다. 따라서 가능한 경우 TRUE RPM을 사용하는 것이 좋습니다. 그러나 나는 산만하다.
따라서 (이진) 프로그램을 포장하는 기본 단계는 다음과 같습니다-프로그램이 버전 1.0의 toybinprog이고 /etc/toybinprog/toybinprog.conf에 conf를 설치하고 bin을 설치한다고 가정합니다. / usr / bin에서 tobinprog :
1. RPM <4.6,4.7에 대한 rpm 빌드 환경을 만듭니다.
mkdir -p ~/rpmbuild/{RPMS,SRPMS,BUILD,SOURCES,SPECS,tmp}
cat <<EOF >~/.rpmmacros
%_topdir %(echo $HOME)/rpmbuild
%_tmppath %{_topdir}/tmp
EOF
cd ~/rpmbuild
2. 프로젝트의 타르볼 생성
mkdir toybinprog-1.0
mkdir -p toybinprog-1.0/usr/bin
mkdir -p toybinprog-1.0/etc/toybinprog
install -m 755 toybinprog toybinprog-1.0/usr/bin
install -m 644 toybinprog.conf toybinprog-1.0/etc/toybinprog/
tar -zcvf toybinprog-1.0.tar.gz toybinprog-1.0/
3. 소스 디렉토리에 복사
cp toybinprog-1.0.tar.gz SOURCES/
cat <<EOF > SPECS/toybinprog.spec
# Don't try fancy stuff like debuginfo, which is useless on binary-only
# packages. Don't strip binary too
# Be sure buildpolicy set to do nothing
%define __spec_install_post %{nil}
%define debug_package %{nil}
%define __os_install_post %{_dbpath}/brp-compress
Summary: A very simple toy bin rpm package
Name: toybinprog
Version: 1.0
Release: 1
License: GPL+
Group: Development/Tools
SOURCE0 : %{name}-%{version}.tar.gz
URL: http://toybinprog.company.com/
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
%description
%{summary}
%prep
%setup -q
%build
# Empty section.
%install
rm -rf %{buildroot}
mkdir -p %{buildroot}
# in builddir
cp -a * %{buildroot}
%clean
rm -rf %{buildroot}
%files
%defattr(-,root,root,-)
%config(noreplace) %{_sysconfdir}/%{name}/%{name}.conf
%{_bindir}/*
%changelog
* Thu Apr 24 2009 Elia Pinto <devzero2000@rpm5.org> 1.0-1
- First Build
EOF
4. 소스와 바이너리 rpm을 빌드하십시오
rpmbuild -ba SPECS/toybinprog.spec
그리고 그게 전부입니다.
이 도움을 바랍니다
응용 프로그램 배포자 인 fpm은 고객의 요구에 완벽하게 부합합니다 . 이 여기에 예를 보여줍니다 방법 소스에서 응용 프로그램을 패키지로. FPM은 deb 파일과 RPM 파일을 모두 생성 할 수 있습니다.
빠른 RPM 구축을 위해 Togo를 확인하십시오.
https://github.com/genereese/togo-rpm
이 프로젝트에는 빠른 시작 안내서가 있으며 3 분 이내에 기본 RPM을 만들 수있었습니다.
원래 질문에 제공된 데이터를 사용한 예 :
1) 스크립트를 사용하여 프로젝트 디렉토리를 작성하십시오.
$ togo project create foobar; cd foobar
2) ./root 아래에 원하는 디렉토리 구조를 만들고 파일을 복사하십시오.
$ mkdir -p root/etc; cp /path/to/foobar.conf root/etc/
$ mkdir -p root/usr/bin; cp /path/to/foobar root/usr/bin/
3) RPM 소유에서 시스템 소유 디렉토리를 제외하십시오.
$ togo file exclude root/etc root/usr/bin
4) (선택 사항) 생성 된 스펙을 수정하여 패키지 설명 / 종속성 / 버전 / 무엇 등을 변경하십시오.
$ vi spec/header
5) RPM을 빌드하십시오.
$ togo build package
그리고 RPM은 ./rpms 디렉토리에 뱉어집니다.
마찬가지로, 몇 개의 파일만으로 rpm을 만들어야했습니다. 이 파일들은 소스로 제어되었고 어리석은 것처럼 보였으므로 rpm untar로 만들기 위해 taring하는 것을 원하지 않았습니다. 나는 다음을 생각해 냈다.
환경을 설정하십시오.
mkdir -p ~/rpm/{BUILD,RPMS}
echo '%_topdir %(echo "$HOME")/rpm' > ~/.rpmmacros
다음 내용으로 스펙 파일 foobar.spec을 작성하십시오.
Summary: Foo to the Bar Name: foobar Version: 0.1 Release: 1 Group: Foo/Bar License: FooBarPL Source: %{expand:%%(pwd)} BuildRoot: %{_topdir}/BUILD/%{name}-%{version}-%{release} %description %{summary} %prep rm -rf $RPM_BUILD_ROOT mkdir -p $RPM_BUILD_ROOT/usr/bin mkdir -p $RPM_BUILD_ROOT/etc cd $RPM_BUILD_ROOT cp %{SOURCEURL0}/foobar ./usr/bin/ cp %{SOURCEURL0}/foobar.conf ./etc/ %clean rm -r -f "$RPM_BUILD_ROOT" %files %defattr(644,root,root) %config(noreplace) %{_sysconfdir}/foobar.conf %defattr(755,root,root) %{_bindir}/foobar
rpm을 빌드하십시오.
rpmbuild -bb foobar.spec
There's a little hackery there specifying the 'source' as your current directory, but it seemed far more elegant then the alternative, which was to, in my case, write a separate script to create a tarball, etc, etc.
Note: In my particular situation, my files were arranged in folders according to where they needed to go, like this:
./etc/foobar.conf
./usr/bin/foobar
and so the prep section became:
%prep
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT
cd $RPM_BUILD_ROOT
tar -cC %{SOURCEURL0} --exclude 'foobar.spec' -f - ./ | tar xf -
Which is a little cleaner.
Also, I happen to be on a RHEL5.6 with rpm versions 4.4.2.3, so your mileage may vary.
If make config
works for your program or you have a shell script which copies your two files to the appropriate place you can use checkinstall. Just go to the directory where your makefile is in and call it with the parameter -R
(for RPM) and optionally with the installation script.
Easy way to build rpm package from binary (these steps were tested with Fedora 18):
1) First you have to install rpmdevtools, so run these commands (attention: run as normal user)
$ sudo yum install rpmdevtools rpmlint
$ rpmdev-setuptree
2) In the ~/rpmbuild/SPECS folder create new file: package_name.spec
3) Open it with an editor (like gedit) and write this:
Name: package_name
Version: 1.0
Release: 1
Summary: Short description (first char has to be uppercase)
License: GPL
URL: www. your_website/
BuildRequires: package_required >= (or ==, or <=) 1.0.3 (for example)
%description
Description with almost 79 characters (first char has to be uppercase)
#This is a comment (just as example)
%files
/usr/bin/binary_file.bin
/usr/share/applications/package_name.desktop
/usr/share/pixmaps/package_name.png
%changelog
* date Packager's Name <packager's_email> version-revision
- Summary of changes
#For more details see: docs.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/Packagers_Guide/sect-Packagers_Guide-Creating_a_Basic_Spec_File.html
4) Make ~/rpmbuild/BUILDROOT/package_name-version-release.i386 and reproduce the paths where the files will be placed So in this case for example create:
- ~/rpmbuild/BUILDROOT/package_name-version-release.i386/usr/bin/
- ~/rpmbuild/BUILDROOT/package_name-version-release.i386/usr/share/applications/
- ~/rpmbuild/BUILDROOT/package_name-version-release.i386/usr/share/pixmaps/
5) Put in these folders the files that you want insert in the package:
- ~/rpmbuild/BUILDROOT/package_name-version-release.i386/usr/bin/binary_file.bin
- ~/rpmbuild/BUILDROOT/package_name-version-release.i386/usr/share/applications/package_name.desktop
- ~/rpmbuild/BUILDROOT/package_name-version-release.i386/usr/share/pixmaps/package_name.png
usr/share/pixmaps/package_name.png is the icon of binary usr/share/applications/package_name.desktop are the rules to insert the program in the menu entries
6) package_name.desktop must be like this:
[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=example
GenericName=Short description
Comment=Comment of the application
Exec=package_name
Icon=package_name
Terminal=false
Categories=System;
Categories are these: standards.freedesktop.org/menu-spec/latest/apa.html
7) Run $ rpmbuild -bb ~/rpmbuild/SPECS/package_name.spec
8) Your package was built into ~/rpmbuild/RPMS folder
if you install this package it's install:
- /usr/bin/binary_file.bin
- /usr/share/applications/package_name.desktop
- /usr/share/pixmaps/package_name.png
Thanks to: losurs.org/docs/tips/redhat/binary-rpms
For more details to build rpm take a look at this link.
GUI java software to build rpm: https://sourceforge.net/projects/javarpmbuilder/
If you are familiar with Maven there also rpm-maven-plugin
which simplifies making RPMs: you have to write only pom.xml
which will be then used to build RPM. RPM build environment is created implicitly by the plugin.
Process of generating RPM from source file:
- download source file with.gz extention.
- install rpm-build and rpmdevtools from yum install. (rpmbuild folder will be generated...SPECS,SOURCES,RPMS.. folders will should be generated inside the rpmbuild folder).
- copy the source code.gz to SOURCES folder.(rpmbuild/SOURCES)
- Untar the tar ball by using the following command. go to SOURCES folder :rpmbuild/SOURCES where tar file is present. command: e.g tar -xvzf httpd-2.22.tar.gz httpd-2.22 folder will be generated in the same path.
- go to extracted folder and then type below command: ./configure --prefix=/usr/local/apache2 --with-included-apr --enable-proxy --enable-proxy-balancer --with-mpm=worker --enable-mods-static=all (.configure may vary according to source for which RPM has to built-- i have done for apache HTTPD which needs apr and apr-util dependency package).
- run below command once the configure is successful: make
- after successfull execution od make command run: checkinstall in tha same folder. (if you dont have checkinstall software please download latest version from site) Also checkinstall software has bug which can be solved by following way::::: locate checkinstallrc and then replace TRANSLATE = 1 to TRANSLATE=0 using vim command. Also check for exclude package: EXCLUDE="/selinux"
- checkinstall will ask for option (type R if you want tp build rpm for source file)
- Done .rpm file will be built in RPMS folder inside rpmbuild/RPMS file... ALL the BEST ....
RPMs are usually built from source, not the binaries.
You need to write the spec file that covers how to configure and compile your application; also, which files to include in your RPM.
A quick glance at the manual shows that most of what you need is covered in Chapter 8 -- also, as most RPM-based distributions have sources available, there's literally a zillion of examples of different approaches you could look at.
참고URL : https://stackoverflow.com/questions/880227/what-is-the-minimum-i-have-to-do-to-create-an-rpm-file
'IT story' 카테고리의 다른 글
@using 선언 대신 Razor 페이지에 네임 스페이스를 추가하는 방법은 무엇입니까? (0) | 2020.06.15 |
---|---|
공공 서비스로 Google OTP를 사용할 수 있습니까? (0) | 2020.06.15 |
관리되지 않는 리소스 란 정확히 무엇입니까? (0) | 2020.06.15 |
업그레이드 가능한 홈 브루 수식을 어떻게 알 수 있습니까? (0) | 2020.06.15 |
Node.js의 약속 이해 (0) | 2020.06.15 |