What is the minimum I have to do to create an RPM file?

前端 未结 9 1477
误落风尘
误落风尘 2020-12-04 04:20

I just want to create an RPM file to distribute my Linux binary \"foobar\", with only a couple of dependencies. It has a config file, /etc/foobar.conf and should be installe

相关标签:
9条回答
  • 2020-12-04 05:20

    I often do binary rpm per packaging proprietary apps - also moster as websphere - on linux. So my experience could be useful also a you, besides that it would better to do a TRUE RPM if you can. But i digress.

    So the a basic step for packaging your (binary) program is as follow - in which i suppose the program is toybinprog with version 1.0, have a conf to be installed in /etc/toybinprog/toybinprog.conf and have a bin to be installed in /usr/bin called tobinprog :

    1. create your rpm build env for RPM < 4.6,4.7

    mkdir -p ~/rpmbuild/{RPMS,SRPMS,BUILD,SOURCES,SPECS,tmp}
    
    cat <<EOF >~/.rpmmacros
    %_topdir   %(echo $HOME)/rpmbuild
    %_tmppath  %{_topdir}/tmp
    EOF
    
    cd ~/rpmbuild
    

    2. create the tarball of your project

    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. Copy to the sources dir

    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. build the source and the binary rpm

    rpmbuild -ba SPECS/toybinprog.spec
    

    And that's all.

    Hope this help

    0 讨论(0)
  • 2020-12-04 05:25

    Process of generating RPM from source file:

    1. download source file with.gz extention.
    2. 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).
    3. copy the source code.gz to SOURCES folder.(rpmbuild/SOURCES)
    4. 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.
    5. 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).
    6. run below command once the configure is successful: make
    7. 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"
    8. checkinstall will ask for option (type R if you want tp build rpm for source file)
    9. Done .rpm file will be built in RPMS folder inside rpmbuild/RPMS file... ALL the BEST ....
    0 讨论(0)
  • 2020-12-04 05:25

    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.

    0 讨论(0)
提交回复
热议问题