Found the source RPM now what?

I need to make a change to a program (atd). I found the source code and I even found the one line in the one file I would like to change. However, I do not how to go about installing the RPM to build it. What do I do with this RPM file. Do I install it with yast Software Manager? To I just expand the contents into a directory and play with it there?

To install through RPM you can just type “sudo /sbin/yast2 absolute_path_of_path/rpm_name”. Otherwise you can right click on the RPM file and click “open with yast”. I hope it will help.

If it were me, and if I thought that line of code would benefit everyone, I would:
a. send the fix upstream (to the application developer) and ask they incorporate the code, and
b. send the fix to the rpm packager (if it looked like it might take the developer time to incorporate the code fix) and ask the packager to repackage the rpm with the fix.

Packaging one’s own rpm takes time and effort to learn the process, and do it properly.

Of course one can alway attempt the creation of a very crude single user rpm, using the program “checkinstall” in lieu of (or in addition to) “make install”. … Note the ./configure, make, su, make install, and/or checkinstall process is not for new users.

You need to extract the source(Wonders how you managed to mod it with out extracting it) then build a normal rpm.
Google search building rpm from src.rpm - Google Search

RH specific but principle should be similar though iirc when you extract the rpm the source will end up in the build environment.
RPM Building Crash Course

Hi,

there are several ways to do this. My preferred way is following:

  1. Install build package via yast/zypper.
  2. download the RPM you want to edit
  3. go to the directory where you downloaded the RPM and run unrpm (is part of the build package)
  4. do your changes and repack the src tarball or the better way create a patch file and edit the .spec file add Patch[number]: <patchfile> to the spec file and in the add in the setup section (%setup) %patch[number] maybe you have to add -p1 it depends how you created the patch. Maybe you also want to update the Release number and add a comment.
    For Example:

Patch4: fix-warnings.patch
Patch5: mypatch.patch
.
.
.
%setup -q
.
%patch4
%patch5 -p1
.

  1. insert the suse DVD into your drive and change to user root: run export BUILD_RPMS=/mnt/<suse DVD> change to the directory where your new src RPM resides and run build <rpmspecfile>.spec which should start the build process. You need to have min 1GB space in /var/tmp available depending on the package you build.
  2. if no errors occurred you will find your new rpm in /var/tmp/build-root/usr/src/packages/RPMS
  3. you can safely delete /var/tmp/build-root.

This methods builds the package in a separate chrooted environment which prevents your running system from *-devel packages pollution which are required to build the RPM.

For further readings:
Cool Solutions: Beginner’s Guide to Using Novell SUSE Linux’s Build Utility
Packaging/SUSE Package Conventions/RPM Style - openSUSE

Hope this helps

If I thought anybody else wanted this I would do exactly as you suggested. The problem is that I am doing the opposite of everyone else. Everyone else is trying to tighten security. I am trying to loosen it. :wink: At our offices we process data using the atd system running batch processes. The atd is very careful that no one unauthorized sees the output of these processes until they are finished. Then only the user submitting the job gets the mail message.

I need everybody to be able to see what these processes are doing as they are doing it. Right now I need to give all the employees the root password in order to see the files created by atd in the /var/spool/atspool directory. It would be much better to change the open in the atd.c to give everybody read permission than to give everybody the root password. :slight_smile:

Extracting it is easy! With over 30 years of (non Linux) system engineering, finding what to change was not difficult. With less than one year of occationally working with Linux, trying to stuff the thing back into an rpm is the tough part. lol!

Well between the replies I received and the suggestion of Googling “building rpm from src.rpm” this is starting to make some sense. I figured I would try to install the src.rpm package without any modifications first. Then I would try your suggestion of creating a patch file and adding it to the spec file. Looking at the current patch files they look very complex. Even though the change I need to make is quite small, only adding some additional permissions to the open function, trying to manually type in something that looks like the other patch files, considering I understand about half of the stuff, would be almost impossible. It seems more like something a computer program would easily generate if only I know the command and the proper option. :shame:

Hi
You need to use the diff command with the file you have modified called
say orig ans well as the unmodified version in the same directory in
the source tree eg /unzipped_src/somedir/src then you would use the
following command in the unzipped_src directory;


diff -Naur somedir/src/original-file.c somedir/src/original-file.c.orig

Now if the diff looks correct a + for your changes, then run the above
command, but pipe it into a file with the > mychages.diff at the end.


Cheers Malcolm °¿° (Linux Counter #276890)
SUSE Linux Enterprise Desktop 11 (i586) Kernel 2.6.27.15-2-default
up 21:44, 1 user, load average: 0.39, 1.07, 0.64
GPU GeForce 6600 TE/6200 TE - Driver Version: 180.35

I cannot get the original source rpm to install. I figured that was a good first step. Up to now I have exclusively used the Software Manager of Yast. However, no matter what I try I cannot get it to recognize the src rpm’s. I have the src rmp in the same directory as other rpm’s that the Software Manager sees. :frowning:

How do you mean install? It should install it under
the /usr/src/packages directories…?

I normally right-click and extract from a GUI, then just move the files
(source tarballs, patches, spec file etc to /usr/src/packages/SOURCES
and build from there.


Cheers Malcolm °¿° (Linux Counter #276890)
SUSE Linux Enterprise Desktop 11 (i586) Kernel 2.6.27.15-2-default
up 1 day 21:58, 1 user, load average: 1.22, 0.57, 0.29
GPU GeForce 6600 TE/6200 TE - Driver Version: 180.35

By “install” I meant being able to use the programs in the package. :frowning: I tried using:
/sbin/yast2 -i /home/me/at-3.1.8-1068.15.src.rpm

That played with the yast program but the atd program was not compiled and installed.

I tried:

rpm -i /home/me/at-3.1.8-1068.15.src.rpm
warning: /home/me/at-3.1.8-1068.15.src.rpm: Header V3 RSA/SHA256 signature: NOKEY, key ID 3dbdc284

Again the atd program was not compiled and installed.

That is what I wanted. If I can get that to work then I can rebuild the rpm to the modified version and install that. :slight_smile:

Hi
You need to unpack the src rpm, then build a new rpm from that. Since
you installed it, it should have unpacked down in /usr/src/packages.

Have you looked down in /usr/src/packages subdirectories as it should be
there, look in the SPECS directory for atd.spec

To build a rpm from a source rpm (This will not modify the source)


rpmbuild --rebuild <name_of_src_rpm>

To build a rpm from a spec file it needs to be in
the /usr/src/packages/SPECS directory, source (tarballs diff files etc)
needs to be in /usr/src/packages/SOURCES directory then to build from
this you would use the command;


rpmbuild -ba <name_of_spec_file>


Cheers Malcolm °¿° (Linux Counter #276890)
SUSE Linux Enterprise Desktop 11 (i586) Kernel 2.6.27.15-2-default
up 2 days 2:15, 1 user, load average: 0.11, 0.18, 0.17
GPU GeForce 6600 TE/6200 TE - Driver Version: 180.35

So all that yast did when I installed the src rpm is it was unpacked into the /usr/src/packages? Yes, it is there. The fact that yast did not give me an error I suspect it was the one that put the files there. How do I get it back out of there when I am done?

I do not understand what is the difference between these two. Except in one of them you said I should use --rebuild <name_of_src_rpm> and in the other -ba <name_of_spec_file>. The advantage for me of the second option is at least I know what the <name_of_spec_file> is, “at.spec”.

Do these create something that can be used to install a package so the programs in the package are available for use on the computer? :\

Hi
The rebuild one will create (depending on the spec file) all the rpms
related to your system architecture eg i586, debug lang etc if those
where in the spec file.

The -ba one against the spec file is the same except it will also
produce a src rpm.

You need to look at the man page for rpmbuild to see how/what the
different options achieve :slight_smile:

At the end of the day you will get a binary package that can be
installed via the rpm, zypper or yast command.


Cheers Malcolm °¿° (Linux Counter #276890)
SUSE Linux Enterprise Desktop 11 (i586) Kernel 2.6.27.15-2-default
up 2 days 4:41, 1 user, load average: 0.14, 0.17, 0.14
GPU GeForce 6600 TE/6200 TE - Driver Version: 180.35

This created an output patch file that looks much like the other patch files in the package.

However, are you sure the order is correct? I did this.


diff -Naur atd.c atd.c.orig >my.patch

And it produced this.


--- atd.c       2009-03-01 23:29:24.000000000 +0300
+++ atd.c.orig  2002-01-18 07:15:27.000000000 +0300
@@ -337,8 +337,7 @@
     }
 
     if ((fd_out = open(filename,
-                   O_WRONLY | O_CREAT | O_EXCL,
-                   S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH)) < 0)
+                   O_WRONLY | O_CREAT | O_EXCL, S_IWUSR | S_IRUSR)) < 0)
        perr("Cannot create output file");
 
     write_string(fd_out, "Subject: Output from your job ");

I cannot tell what the other patch files in the package were doing. However, it looks like the lines beginning with the ‘+’ and ‘-’ are reversed. The current file shows the lines I want added beginning with the ‘-’ and the line I want removed beginning with the ‘+’. As I said I do not know what the other patch files I looked at were doing but one of them have a large section where each line started with a ‘+’ as if it was to be added. :open_mouth:

I think it might be at the end of the next day or two. :slight_smile:

I did look at the man page for rpmbuild. Years ago I fixed roofs. We used tarbuckets not Tarballs. What is a Tarball? :shame: Is that the “at_3.1.8-11.tar.gz” file I unpacked to see the source?

I did actually get some helpful information from the man page. However, I think it also raised many more questions. It seemed that the options I understood created a binary rpm that could then be installed. That would be the -ba option. My understanding is that I should add my patch file into the …/SOURCE directory and add my patch file to the at.spec file. Then do the rpmbuild -ba at.spec command. That will create two rpm files one a i386 binary rpm and one src rpm.

Then to remove things I would do a rpmbuild --clean to remove things. However, I am not sure what about the specific command.


rpmbuild --clean ????

Hi
You need to do it the other way then, the orig file first, so your
changes have the +


Cheers Malcolm °¿° (Linux Counter #276890)
SUSE Linux Enterprise Desktop 11 (i586) Kernel 2.6.27.15-2-default
up 2 days 9:40, 2 users, load average: 0.08, 0.17, 0.17
GPU GeForce 6600 TE/6200 TE - Driver Version: 180.35

It looks like it will take longer than two days.

I tried to build it and received this message.


rpmbuild -ba at.spec
error: Failed build dependencies:
        libselinux-devel is needed by at-3.1.8-1068.15.i586

There is the idea of two steps forward and one step back. What is this package? Actually, I do not care that much what it is. Do I need to find that package and install it? Where can I find it? I tried looking at the openSUSE 10.3 disk and it was not there.

Software.openSUSE.org try here