LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-06-2012, 10:41 PM   #16
pinga123
Member
 
Registered: Sep 2009
Posts: 684

Original Poster
Blog Entries: 2

Rep: Reputation: 37

Quote:
Originally Posted by arizonagroovejet View Post
No, not 'ofcourse'. It depends on what's in the rpm. For example if the rpm contains binaries that a dynamically linked to shared libraries that aren't in the rpm then the rpm is only going to work on other systems which have the same versions (or compatible) of those libraries in the same locations. If the rpm depends on other packages then the rpm will only work on other systems where those packages are available.

I use SLED and openSUSE. Some rpms built for openSUSE will work on SLED but some won't. It very much depends on the rpm and which version of openSUSE it was built for and which version of SLED you're trying to use it on. I once found some software that was only available as an rpm which it was indicated was for use on RedHat. As it happened it worked on the version of SLED I was using, but there was no guarantee that it would.

If you find yourself wanting to create an rpm from a bunch of arbitrary files rather than from a source tarball check out
https://www.linuxquestions.org/quest...0/#post3680054

I m using Oracle Enterprise linux for building the rpm .It doesnt have
/usr/src/packages/SOURCES directory as given in the article .
However it has below directories.
Code:
# ls -ltr /usr/src
total 16
drwxr-xr-x 3 root root 4096 Jun  2  2011 kernels
drwxr-xr-x 7 root root 4096 Jun  2  2011 redhat


# ls -ltr /usr/src/redhat/
total 40
drwxr-xr-x 2 root root 4096 Mar 20  2008 SRPMS
drwxr-xr-x 2 root root 4096 Mar 20  2008 SPECS
drwxr-xr-x 2 root root 4096 Mar 20  2008 SOURCES
drwxr-xr-x 2 root root 4096 Mar 20  2008 BUILD
drwxr-xr-x 8 root root 4096 Jun  2  2011 RPMS
None of them provides any write access to normal users .What shall be my next course of action?

Last edited by pinga123; 03-06-2012 at 10:47 PM.
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 03-07-2012, 12:42 AM   #17
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
Quote:
What shall be my next course of action ?
The /usr/src/redhat/RPMS etc. environment or similar is created,
when 'rpm-build' is installed. You can see it as a usable example.

And /usr/src/ can be used by people who want to work as root.
The RPMS environment in /home/<user>/rpms/ works the same way, but safer.

.
 
Old 03-07-2012, 03:47 AM   #18
pinga123
Member
 
Registered: Sep 2009
Posts: 684

Original Poster
Blog Entries: 2

Rep: Reputation: 37
Quote:
Originally Posted by knudfl View Post
The /usr/src/redhat/RPMS etc. environment or similar is created,
when 'rpm-build' is installed. You can see it as a usable example.

And /usr/src/ can be used by people who want to work as root.
The RPMS environment in /home/<user>/rpms/ works the same way, but safer.

.
Dont find any such directory under my home folder.Do you want me to create rpms directory under the home folder?

Code:
$ ls -la /home/rpmuser/
total 32
drwx------ 3 rpmuser rpmuser 4096 Mar  7 08:59 .
drwxr-xr-x 6 root    root    4096 Mar  7 08:59 ..
-rw-r--r-- 1 rpmuser rpmuser   33 Mar  7 08:59 .bash_logout
-rw-r--r-- 1 rpmuser rpmuser  176 Mar  7 08:59 .bash_profile
-rw-r--r-- 1 rpmuser rpmuser  124 Mar  7 08:59 .bashrc
-rw-r--r-- 1 rpmuser rpmuser  515 Mar  7 08:59 .emacs
drwxr-xr-x 4 rpmuser rpmuser 4096 Mar  7 08:59 .mozilla
 
Old 03-07-2012, 03:54 AM   #19
arizonagroovejet
Senior Member
 
Registered: Jun 2005
Location: England
Distribution: openSUSE, Fedora, CentOS
Posts: 1,094

Rep: Reputation: 198Reputation: 198
If you don't want to use the default build directory, or the default build directory is only usable by root (and as someone said before you shouldn't build rpms as root), then create your own.
http://www.rpm.org/max-rpm/s1-rpm-an...uild-area.html
 
Old 03-07-2012, 04:19 AM   #20
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
# 18
Quote:
.. create rpms directory under the home folder ?
That's what this link is about :
http://www.linuxquestions.org/questi...1-a-766486/#13
 
Old 03-07-2012, 04:56 AM   #21
pinga123
Member
 
Registered: Sep 2009
Posts: 684

Original Poster
Blog Entries: 2

Rep: Reputation: 37
Quote:
Originally Posted by knudfl View Post
# 18


That's what this link is about :
http://www.linuxquestions.org/questi...1-a-766486/#13
I m sorry to say but this is getting confusing day by day.


I m listing the stuff i understood till now.

I want to create rpm that is not built by compiling from source code.However they contains a bunch of files.
I just need to package them in order to be able to install them on multiple machines.

1st i have created a normal user as rpmbuild should be done by normal user and not the root.
Code:
# adduser rpmuser
# passwd rpmuser
Changing password for user rpmuser.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.

Then created below folders under home directory.

Code:
$ mkdir mybuild
$ mkdir mybuild/BUILD
$ mkdir mybuild/RPMS
$ mkdir mybuild/RPMS/i386
$ mkdir mybuild/SOURCES
$ mkdir mybuild/SPECS
$ mkdir mybuild/SRPMS

Created .rpmrc file in home directory to include below lines.
Code:
topdir: /home/rpmuser
M i going in right way?
 
Old 03-07-2012, 05:27 AM   #22
arizonagroovejet
Senior Member
 
Registered: Jun 2005
Location: England
Distribution: openSUSE, Fedora, CentOS
Posts: 1,094

Rep: Reputation: 198Reputation: 198
Quote:
Originally Posted by pinga123 View Post
Created .rpmrc file in home directory to include below lines.
Code:
topdir: /home/rpmuser
The directory you've set up in which to build rpms isn't /home/rpmuser it's /home/rpmuser/mybuild
 
Old 03-07-2012, 05:36 AM   #23
pinga123
Member
 
Registered: Sep 2009
Posts: 684

Original Poster
Blog Entries: 2

Rep: Reputation: 37
Quote:
Originally Posted by arizonagroovejet View Post
The directory you've set up in which to build rpms isn't /home/rpmuser it's /home/rpmuser/mybuild
Now edited the file.
Code:
topdir: /home/rpmuser/mybuild
My Spec file looks like below.
Code:
$ cat myrpm.spec
Summary: Summary to be included in RPM package
Name: MyRPM
Version: 1.1
Release: 1
Group: Virtual
License: free
#Source: MyRPM.tar.gz
BuildRoot: /home/rpmuser/mybuild

%description
Description to be included in RPM package

%prep
%setup -q

%build

%install
cp -rvf \home\rpmuser\mybuild\SOURCES \home\rpmuser\bin

%clean
if( [ \$RPM_BUILD_ROOT != '/' ] ); then rm -rf \$RPM_BUILD_ROOT; fi;

%files
/.

%post
I get below error.
Code:
$ rpmbuild myrpm.spec
error: bad option 'topdir' at /home/rpmuser/.rpmrc:1
error: No source number 0
error: bad option 'topdir' at /home/rpmuser/.rpmrc:1
Basically i need certain scripts files which are located in \home\rpmuser\mybuild\SOURCES to be copied to /home/rpmuser/bin .

Last edited by pinga123; 03-07-2012 at 05:48 AM.
 
Old 03-07-2012, 06:23 AM   #24
arizonagroovejet
Senior Member
 
Registered: Jun 2005
Location: England
Distribution: openSUSE, Fedora, CentOS
Posts: 1,094

Rep: Reputation: 198Reputation: 198
Quote:
Originally Posted by pinga123 View Post
Code:
$ rpmbuild myrpm.spec
error: bad option 'topdir' at /home/rpmuser/.rpmrc:1
error: No source number 0
error: bad option 'topdir' at /home/rpmuser/.rpmrc:1
Hmmm. Well that's what it says in the documentation I referred you to but come to think of it it's not what I do. I use ~/.rpmmacros

Code:
$ cat ~/.rpmmacros 
%_topdir      /home/me/rpmbuild
So try deleting the .rpmrc file and using .rpmmacros instead.
There's some talk about this way back in 2001
https://www.redhat.com/archives/rpm-.../msg00076.html
Maybe the documentation I linked to is way out of date or just wrong or something annoyingly unhelpful like that

Quote:
Originally Posted by pinga123 View Post
Basically i need certain scripts files which are located in \home\rpmuser\mybuild\SOURCES to be copied to /home/rpmuser/bin .
You're doing several things wrong.

You don't put files in to /home/rpmuser/mybuild/SOURCES ( note / not \ ) you put them in to /home/rpmuser/mybuild/SOURCES/nameofrpm So if your rpm is called myrpm but them in /home/rpmuser/mybuild/SOURCES/myrpm

If you use rpmbuild it expects there to be a source tarball. If you don't have a source tarball and want to package a bunch of files in a directory you need to use buildrpm the wrapper script I described in that other post of mine I linked to. (You always need a source tarball to build and rpm the buildrpm script creates it for you so save you the effort of repeatedly creating a new tarball each time you change something.)

This line in your spec file
Code:
cp -rvf \home\rpmuser\mybuild\SOURCES \home\rpmuser\bin
Is completely wrong. You're using \ when it should be / and you are copying the files to the wrong place. You need to create a directory in $RPM_BUILD_ROOT and put the files in there. Go back to that post of mine I previously linked to and read it again including the example spec file.

Using an rpm to put files in to a user's home directory is usual but I can't think of a reason off hand not to do it.
 
1 members found this post helpful.
Old 03-08-2012, 11:31 PM   #25
pinga123
Member
 
Registered: Sep 2009
Posts: 684

Original Poster
Blog Entries: 2

Rep: Reputation: 37
Heres modifying the the process. I was able to build the rpm however not sure if whatever i have followed is correct or not.(Will read the rpm build process in detail)
How can i modify it to include more than one script files.

Here is the process .

I want to create rpm that is not built by compiling from source code.However they contains a bunch of files.
I just need to package them in order to be able to install them on multiple machines.

1st i have created a normal user as rpmbuild should be done by normal user and not the root.
Code:
# adduser rpmuser
# passwd rpmuser
Changing password for user rpmuser.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
Then created below folders under home directory.
Code:
$ mkdir mybuild
$ mkdir rpmbuild/BUILD
$ mkdir rpmbuild/RPMS
$ mkdir rpmbuild/RPMS/i386
$ mkdir rpmbuild/SOURCES
$ mkdir rpmbuild/SPECS
$ mkdir rpmbuild/SRPMS

Code:
Created .rpmmacros file in home directory to include below lines.
touch ~/.rpmmacros
%_topdir      /home/rpmuser/rpmbuild
Created directory
Code:
mkdir -p /home/rpmuser/rpmbuild/SOURCES/myrpm
Edited spec file as below.

Code:
$ cat ~/rpmbuild/SPECS/myrpm.spec
Summary:        my script
Name:           myrpm
Version:        1
Release:        0
License:        none
Source:         %{name}.tar.gz
BuildArch:      noarch
BuildRoot:      %{_tmppath}/%{name}-build
Group:          System/Base
Vendor:         Your name here

%description
This package contains my script

%prep
%setup -n %{name}

%build

%install
mkdir -p $RPM_BUILD_ROOT/usr/local/bin
install -m 700 myscript.sh $RPM_BUILD_ROOT/usr/local/bin/

%clean
rm -rf $RPM_BUILD_ROOT
rm -rf %{_tmppath}/%{name}
rm -rf %{_topdir}/BUILD/%{name}

%files
%defattr(-,root,root)
/usr/local/bin/myscript.sh

%post
/usr/local/bin/myscript.sh

%changelog

Copy the script files to below location.
Code:
$ ls -ltr /home/rpmuser/rpmbuild/SOURCES/myrpm/
total 0
-rw-rw-r-- 1 rpmuser rpmuser 0 Mar  9 09:37 myscript.sh
Created buildrpm file(with little modification) @ below location.
Code:
$ ls -ltr /home/rpmuser/rpmbuild
total 24
-rw-rw-r-- 1 rpmuser rpmuser  805 Mar  9 09:57 buildrpm
drwxrwxr-x 2 rpmuser rpmuser 4096 Mar  9 10:02 SPECS
drwxrwxr-x 2 rpmuser rpmuser 4096 Mar  9 10:02 SRPMS
drwxrwxr-x 3 rpmuser rpmuser 4096 Mar  9 10:02 SOURCES
drwxrwxr-x 4 rpmuser rpmuser 4096 Mar  9 10:02 RPMS
drwxrwxr-x 2 rpmuser rpmuser 4096 Mar  9 10:02 BUILD
content of the file.
Code:
$ cat buildrpm
#!/bin/bash

if [ -z "$1" ];then
   echo "You didn't specify anything to build";
   exit 1;
fi

cd ~/rpmbuild/SOURCES
# delete older versions of the rpm since there's no point having old
# versions in there when we still have the src.rpms in the SRPMS dir
find ~/rpmbuild/RPMS -name ${1}-[0-9]\* -exec rm -f {} \;
#find /usr/src/packages/RPMS -name ${1}-[0-9]\* -exec rm -f {} \;


# if there's a directory containing the source, as there will be
# for all our own packages, then delete any .tar.gz file that may exist
# for the package and create a new one.
if [ -d ${1} ] ;then
   rm -f ${1}.tar.gz;
   tar zcf${h_or_not} ${1}.tar.gz ${1};
fi

# build the package

rpmbuild -ba ../SPECS/${1}.spec

# if there is a directory, then delete the .tar.gz again
if [ -d ${1} ] ;then
   rm -f ${1}.tar.gz;
fi
Finally.
Code:
$ sh buildrpm myrpm
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.70406
+ umask 022
+ cd /home/rpmuser/rpmbuild/BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ cd /home/rpmuser/rpmbuild/BUILD
+ rm -rf myrpm
+ /bin/gzip -dc /home/rpmuser/rpmbuild/SOURCES/myrpm.tar.gz
+ tar -xvvf -
drwxrwxr-x rpmuser/rpmuser   0 2012-03-09 09:37:30 myrpm/
-rw-rw-r-- rpmuser/rpmuser   0 2012-03-09 09:37:30 myrpm/myscript.sh
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd myrpm
++ /usr/bin/id -u
+ '[' 503 = 0 ']'
++ /usr/bin/id -u
+ '[' 503 = 0 ']'
+ /bin/chmod -Rf a+rX,u+w,g-w,o-w .
+ exit 0
Executing(%build): /bin/sh -e /var/tmp/rpm-tmp.70406
+ umask 022
+ cd /home/rpmuser/rpmbuild/BUILD
+ cd myrpm
+ LANG=C
+ export LANG
+ unset DISPLAY
+ exit 0
Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.70406
+ umask 022
+ cd /home/rpmuser/rpmbuild/BUILD
+ cd myrpm
+ LANG=C
+ export LANG
+ unset DISPLAY
+ mkdir -p /var/tmp/myrpm-build/usr/local/bin
+ install -m 700 myscript.sh /var/tmp/myrpm-build/usr/local/bin/
+ /usr/lib/rpm/find-debuginfo.sh /home/rpmuser/rpmbuild/BUILD/myrpm
0 blocks
find: /var/tmp/myrpm-build/usr/lib: No such file or directory
+ /usr/lib/rpm/redhat/brp-compress
+ /usr/lib/rpm/redhat/brp-strip-static-archive /usr/bin/strip
+ /usr/lib/rpm/redhat/brp-strip-comment-note /usr/bin/strip /usr/bin/objdump
+ /usr/lib/rpm/brp-python-bytecompile
+ /usr/lib/rpm/redhat/brp-java-repack-jars
Processing files: myrpm-1-0
Requires(interp): /bin/sh
Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1
Requires(post): /bin/sh
Checking for unpackaged file(s): /usr/lib/rpm/check-files /var/tmp/myrpm-build
Wrote: /home/rpmuser/rpmbuild/SRPMS/myrpm-1-0.src.rpm
Wrote: /home/rpmuser/rpmbuild/RPMS/noarch/myrpm-1-0.noarch.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.30105
+ umask 022
+ cd /home/rpmuser/rpmbuild/BUILD
+ cd myrpm
+ rm -rf /var/tmp/myrpm-build
+ rm -rf /var/tmp/myrpm
+ rm -rf /home/rpmuser/rpmbuild/BUILD/myrpm
+ exit 0

Last edited by pinga123; 03-09-2012 at 12:26 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create RPM jaikris Linux - Software 22 06-08-2010 02:53 PM
create rpm in mandriva munna_dude Programming 2 10-03-2007 11:59 PM
how to create a RPM jp-lack Linux - General 1 05-04-2007 06:57 AM
Create Rpm sjacobs Linux - Software 0 11-03-2005 07:19 AM
how to create .rpm package shalin Programming 1 07-13-2004 10:12 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration