Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
i m trying to create a rpm from a installer.bin file. and strip off some unneeded files before creating this RPM from the installer so that RPM package wont have ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Dec 2012
    Posts
    19

    Unhappy Creating RPM from .installer.bin. file


    i m trying to create a rpm from a installer.bin file. and strip off some unneeded files before creating this RPM from the installer so that RPM package wont have those files.. any help????

  2. #2
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    howdy, and welcome aboard!

    making an RPM is not too hard. and once you get the hang of it, you can do it quickly and effortlessly.

    first thing to do is get your environment up. the most important thing to remember: never build RPMS as root!

    as a regular user, create the base RPM dirs, e.g.:
    Code:
    cd ~
    mkdir rpms
    cd rpms
    mkdir BUILD RPMS SOURCES SPECS SRPMS
    now create an RPM config file in your home dir. this is the file name:
    Code:
    ~/.rpmmacros
    in it put some macros that are important:
    Code:
    # adds Packager info to RPM
    %packager RPM Dev
    
    # disables automatic creation of -debuginfo RPM
    %debug_package %{nil}
    
    # abbreviation for distribution name
    %dist .el6
    
    # set toplevel for all rpm subdirs (e.g., system _topdir is /usr/src/redhat)
    %_topdir %(echo $HOME/rpms)
    
    # gpg username
    %_gpg_name "user@localhost"
    
    # buildroot dir
    %buildroot /var/tmp/%{name}-%{version}-%{release}
    you'll want to modify this file to reflect your %dist, %packager and %_gpg_name (if you plan to sign your RPMS), at the least.

    now, as root, install the required packages used to make RPMS. On a RH/Fedora/CentOS box, you can install it like:
    Code:
    yum install rpm-build
    down the road, you'll also likely need other packages, if you are going to be compiling programs from source, e.g.:
    Code:
    yum install gcc make binutils
    now you're ready to make your first RPM! Making an RPM takes at least two things:
    1. a SPEC file (like installation instructions for the package)
    2. the SOURCE tarball (contains the source/binary files you will be installing)
    First focus on the SPEC file. If you use the vim editor, you will have built-in syntax highlighting, which in my opinion is a must, esp. for an RPM-making n00b. In fact, if you make a blank file with a ".spec" file extension, and open it in vim, it will create a skeleton RPM spec file for you. well, provided you have a recent enough version of vim.

    So do this:
    Code:
    cd ~/rpms/SPECS
    vi foo.spec
    That assumes that vi is aliased to vim, btw. You should see a skeleton SPEC file in the vim screen. Fill in the required fields like this:
    Code:
    Name:           foo
    Version:        1.0
    Release:        1%{?dist}
    Summary:        my first rpm
    #Group:         
    License:        GPL
    #URL:           
    Source0:        %{name}-%{version}.tar.gz
    #BuildRequires: 
    #Requires:      
    
    %description
    meh
    
    %prep
    %setup -q
    
    %build
    
    %install
    rm -rf %{buildroot}
    mkdir -p %{buildroot}/tmp
    cp foo.txt %{buildroot}/tmp
    
    
    %files
    /tmp/foo.txt
    
    %changelog
    * Thu Dec 13 2012 User <user@fake.com> - 1.0-1
    - first RPM package
    Notice that the Name and Version are used in the source tarball filename.

    Now create a "fake" SOURCE tarball.
    Code:
    cd ~/rpms/SOURCES
    mkdir foo-1.0
    touch foo-1.0/foo.txt
    tar zcf foo-1.0.tar.gz foo-1.0
    Now attempt to build the RPM, e.g.:
    Code:
    rpmbuild -bb ~/rpms/SPECS/foo.spec
    That will spew a bunch of building output and hopefully near the end tell you:
    Code:
    Wrote: /home/user/rpms/RPMS/i386/foo-1.0-1.fc17.i386.rpm
    Presto, a totally useless, perfectly legitimate RPM.

  3. #3
    Just Joined!
    Join Date
    Dec 2012
    Posts
    19
    thank you for the help Atreyu..

    Not to be rude. but i know few things about RPM. i m like intermediate level.. :P.. i think i can do the one from the tarball... but...........But i might not be clear on my subject. sorry for that... i might be confused..

    i was creating a RPM from installer.bin , which has the embedded tarball.
    now here is the problem:
    1. i dont know how to extract that tarball without running "sh" on that .bin file.
    2. when i create a RPM from that .bin installer, it copies the files that i wanted.. but.. the software's rc file gives diff DIR and PATH name (where i built the RPM: ~/rpmbuild/buildroot/ .....).
    3. i have tried few different ways but didnt work n now i cannot think of any other way.

    need more help....

  4. #4
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Quote Originally Posted by nslinux View Post
    i was creating a RPM from installer.bin , which has the embedded tarball.
    okay, you can try and extract the tarball from the bin file. it may not be a tarball, and could be a binary, but in any case you can try this.

    open the file in vi. it should be text at the top, and if you scroll down, you should eventually see some non-text looking garbage. That garbage is likely either uuencoded or binary data, crammed into the text file. here's an example of binary data in a text file:

    Code:
    #!/bin/bash
    # script commands, etc.
    exit 0
    @
    @
    @
    @
    all those @ signs after the exit represent the binary (in vi).

    here's what uuencoded data might look like:
    Code:
    #!/bin/bash
    # script commands, etc.
    exit 0
    begin 644 -
    M9FEL93$`````````````````````````````````````````````````````
    M````````````````````````````````````````````````````````````
    so what you want to do is find the line number where the uuencoded/binary data starts. you can do this in vi with the :se number command. or from the shell with awk like this:
    Code:
    awk '/^exit 0/{print FNR}' install.bin
    substituting for exit 0 whatever string represents the final line of text in your bin file. then add one to the number, to get the first line of data. Say that number is 28. Now do this to extract just the data from the file and write it to another file:
    Code:
    tail -n +28 install.bin > decoded.raw
    now see what kind of file that data is using the file command, e.g.:
    Code:
    file decoded.raw
    if you're lucky, it will say something like:
    Code:
    decoded.raw: POSIX tar archive
    and then you can do normal tar operations on the file, e.g.:
    Code:
    tar tf decoded.raw
    if you are unlucky, it is a binary file, e.g.:
    Code:
    decoded.raw: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), not stripped
    as was the case with a java installer .bin file that I tested this on. however, in the case of the java binary file, it simply extracted everything to the cwd when I ran it, so maybe that will work for you.

  5. #5
    Just Joined!
    Join Date
    Dec 2012
    Posts
    19
    thank you atreyu.

    i will try this method too.

    btw i did got that rpm working with different method.... but for that i have to create the rpm with the "root" which is a big no no in rpm thing.. but its running like its suppose to... hopefully it wont give me any problem in future...

  6. #6
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Quote Originally Posted by nslinux View Post
    btw i did got that rpm working with different method.... but for that i have to create the rpm with the "root" which is a big no no in rpm thing.. but its running like its suppose to... hopefully it wont give me any problem in future...
    it is not in the future (in the resultant binary RPM) that building an rpm as root will get you, it is in when things like the command "rm -rf ${blah}" is run during the build process and something goes haywire...you have been warned ;)

  7. #7
    Just Joined!
    Join Date
    Dec 2012
    Posts
    19
    ya i totally understand your warning.
    i will try to do your method one more time.... but in the spec file i haven't put any cmd that deletes any files system.... i did test it in cmd line in VM before executing it...

    But really appreciate your help... thanks once again...

  8. #8
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Quote Originally Posted by nslinux View Post
    i will try to do your method one more time.... but in the spec file i haven't put any cmd that deletes any files system....
    i have to tell you, i used to build RPMS as root all the time. and for other things, i still do use root all the time (way too much, probably, but I'm a risk taker). but all it took was ONE time that I put a typo in a SPEC file and my biscuits got burned. now I never build as root!

    i did test it in cmd line in VM before executing it...
    do you mean you tested the resultant binary RPM in a VM, or do you mean you built the RPM in a VM? The latter would be the safer method. I use Mock to build RPMS now, and I've been quite happy with it. It does not use a VM, but rather a chrooted environment, although there is nothing stopping you from running Mock in a VM, for two-layer protection.

  9. #9
    Just Joined!
    Join Date
    Dec 2012
    Posts
    19
    yes m creating and testing RPMs in a VM.

  10. #10
    Just Joined!
    Join Date
    Jul 2013
    Posts
    1
    Can you let me know how you did this? I'm trying to do the exact same thing but didn't find a solution.

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •