Discussion:
how to build a patched binary rpm from a source rpm?
Robert P. J. Day
2007-10-16 15:21:16 UTC
Permalink
what's the canonical way to build a modified binary rpm from the
original source rpm? i can download the source rpm, install it under
my own "rpms/" directory, then run:

$ rpmbuild -bp <spec file>

to run the prep stage.

at that point, i can mess with the source, but it's not clear what
command to invoke to have the build pick up at that point and finish
off the build to create the (now modified) binary rpm.

i would have thought this would involve "--short-circuit" in some
way, but that doesn't seem possible.

help?

rday
--
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://crashcourse.ca
========================================================================
Matthew Miller
2007-10-16 15:26:23 UTC
Permalink
Post by Robert P. J. Day
what's the canonical way to build a modified binary rpm from the
original source rpm? i can download the source rpm, install it under
$ rpmbuild -bp <spec file>
to run the prep stage.
at that point, i can mess with the source, but it's not clear what
command to invoke to have the build pick up at that point and finish
off the build to create the (now modified) binary rpm.
Mess with the source, generate a patch, and then add it to the spec file.
Add a short string and number to the end of the release tag (so "Release: 1"
becomes "Release 1.rday.1" or similar), and then do rpmbuild -ba on that.

That way, when you want to rebuild it again, you've already got your patch.
And when there's a new version of the upstream package, if the affected code
wasn't touched, you can just carry your patch forward.
--
Matthew Miller ***@mattdm.org <http://mattdm.org/>
Boston University Linux ------> <http://linux.bu.edu/>
Robert P. J. Day
2007-10-16 15:30:25 UTC
Permalink
Post by Matthew Miller
Post by Robert P. J. Day
what's the canonical way to build a modified binary rpm from the
original source rpm? i can download the source rpm, install it under
$ rpmbuild -bp <spec file>
to run the prep stage.
at that point, i can mess with the source, but it's not clear what
command to invoke to have the build pick up at that point and finish
off the build to create the (now modified) binary rpm.
Mess with the source, generate a patch, and then add it to the spec
file. Add a short string and number to the end of the release tag
(so "Release: 1" becomes "Release 1.rday.1" or similar), and then do
rpmbuild -ba on that.
That way, when you want to rebuild it again, you've already got your
patch. And when there's a new version of the upstream package, if
the affected code wasn't touched, you can just carry your patch
forward.
i should have noted that i knew about that approach -- i guess i was
just curious why there wasn't an "rpmbuild" option that supported
short-circuiting starting at the build step and continuing from there,
which would be emphatically quick and dirty.

ok, i'll just use the above technique. thanks.

rday
--
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://crashcourse.ca
========================================================================
Nigel Metheringham
2007-10-16 18:16:08 UTC
Permalink
Post by Robert P. J. Day
i should have noted that i knew about that approach -- i guess i was
just curious why there wasn't an "rpmbuild" option that supported
short-circuiting starting at the build step and continuing from there,
which would be emphatically quick and dirty.
The whole idea of rpm is to package reproducible scripted builds from
pristine sources. Fiddling with the build part way through breaks that.

Nigel
--
[ Nigel Metheringham ***@InTechnology.co.uk ]
[ - Comments in this message are my own and not ITO opinion/policy - ]
Robert P. J. Day
2007-10-16 16:30:07 UTC
Permalink
Post by Matthew Miller
Post by Robert P. J. Day
what's the canonical way to build a modified binary rpm from the
original source rpm? i can download the source rpm, install it under
$ rpmbuild -bp <spec file>
to run the prep stage.
at that point, i can mess with the source, but it's not clear what
command to invoke to have the build pick up at that point and finish
off the build to create the (now modified) binary rpm.
Mess with the source, generate a patch, and then add it to the spec
file. Add a short string and number to the end of the release tag
(so "Release: 1" becomes "Release 1.rday.1" or similar), and then do
rpmbuild -ba on that.
just to clarify that there isn't something i'm missing, let me
summarize the steps.

first, i can grab the source rpm and "install" it with rpm. that
gives me (under my rpm work directory):

1) the spec file
2) the gzipped tarball
3) all the patch files

now, i can't start building any patches until i untar the tarball.
i can't do that with "rpmbuild -bp" since that not only unzips the
tarball, but it applies all the patches. whoops, that's gone too
far.

so i'm reduced to untarring the tarball manually, creating my patch,
adding it to the patch dir with the rest, mod'ding the spec file, and
finally running "rpmbuild -bb" on the spec file. is that about right?

rday
--
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://crashcourse.ca
========================================================================
Stanley, Jon
2007-10-16 15:28:20 UTC
Permalink
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Well, you're halfway there. Do your rpmbuild -bp, patch that however you want. Generate a patchfile, put that in your SOURCES dir. and modify the spec file to use that patch file.

Then rpmbuild-ba <your modified spec>

- -----Original Message-----
From: rpm-list-***@redhat.com [mailto:rpm-list-***@redhat.com] On Behalf Of Robert P. J. Day
Sent: Tuesday, October 16, 2007 11:21 AM
To: rpm list
Subject: how to build a patched binary rpm from a source rpm?


what's the canonical way to build a modified binary rpm from the
original source rpm? i can download the source rpm, install it under
my own "rpms/" directory, then run:

$ rpmbuild -bp <spec file>

to run the prep stage.

at that point, i can mess with the source, but it's not clear what
command to invoke to have the build pick up at that point and finish
off the build to create the (now modified) binary rpm.

i would have thought this would involve "--short-circuit" in some
way, but that doesn't seem possible.

help?

rday

- --
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://crashcourse.ca
========================================================================

_______________________________________________
Rpm-list mailing list
Rpm-***@redhat.com
https://www.redhat.com/mailman/listinfo/rpm-list

-----BEGIN PGP SIGNATURE-----
Version: 9.6.2 (Build 2014)

wsFVAwUBRxTYlHJE2wkjIctBAQJ/9g/9F7nwuEG25cLxYHzvBsKtJ2ZnxhaBXi+4
d0TulXnUkg0aoGQh7+UWbjP3VprMhssab6WOSrjB/SAPrKWCfdldRKlIKsXdrQ4J
6Soy7kznrT5y9WSQ8QAu0gqTPndPtV+ygM3mh6nLDoM6chWe43y44oOw4r1g0JYw
t4xJkCIi9aXFc16j4NY+t6of5qWVfU2VzRNB2CXgk57E/C9BoD62oIGXDwmhIZZX
fSNnBvTgwbJIf4Qv7MTtWt5Jml/9Z2O9jNnJuUtYqSBTsof7tnVG0Z6GL8v9pq6y
y8EiMEpVnNngOTxosUpON5vMCcrQ6BxFzeJ9B5mt5hW0O4KP9nd/sXQIxthNLLJV
H8xFW9C8ZaPDAPpMqM300nZQVNYOV8WKukV0IDSC+tzF8BUncRgGk0XlztubnqVz
ZbYNUE4oBU/lSTibAlP9AvRsm/NTaUz8qMXTX8OlW7s6OodRVqh0oFOOlV0J216W
WsNrYk6dXT3Tm+OMJlV2ToBaM9myCMQw4p4pPa8SyoXBV7VPaOeCztXcxNCS2T2k
MxBgYu9kDW9d/zxzXd13Wz0EIlIinwo5F6OtHqr/DqkJdaJGDleVFwWmaHqYEF3Z
5I0V8M5yYvbp4KbPAtiUSeJAaaUoLZEdxEMOaXuAOFqjqHBB0C24Ai9e6LaqADpX
Lxm1ZkNd/RA=
=zEab
-----END PGP SIGNATURE-----



This message contains information which may be confidential and/or privileged. Unless you are the intended recipient (or authorized to receive for the intended recipient), you may not read, use, copy or disclose to anyone the message or any information contained in the message. If you have received the message in error, please advise the sender by reply e-mail and delete the message and any attachment(s) thereto without retaining any copies.
Robert P. J. Day
2007-10-16 16:33:04 UTC
Permalink
Post by Stanley, Jon
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Well, you're halfway there. Do your rpmbuild -bp, patch that
however you want. Generate a patchfile, put that in your SOURCES
dir. and modify the spec file to use that patch file.
Then rpmbuild-ba <your modified spec>
sorry, i summarized the steps before i read this almost identical
summary. ok, i'm good.

and i noticed that post about mezzanine, and stupidly deleted it. but
i found the web site, thanks.

rday
--
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://crashcourse.ca
========================================================================
Michael Jennings
2007-10-16 16:22:41 UTC
Permalink
On Tuesday, 16 October 2007, at 11:21:16 (-0400),
Post by Robert P. J. Day
what's the canonical way to build a modified binary rpm from the
original source rpm? i can download the source rpm, install it under
$ rpmbuild -bp <spec file>
to run the prep stage.
at that point, i can mess with the source, but it's not clear what
command to invoke to have the build pick up at that point and finish
off the build to create the (now modified) binary rpm.
i would have thought this would involve "--short-circuit" in some
way, but that doesn't seem possible.
What you're looking for is Mezzanine:

http://beta.kainx.org/articles/6

The basic procedure is something like this:

1. mzimport -L foo.src.rpm
2. cd foo
3. mzprep
4. <Make changes to source tree found under work/>
5. mzpatch -n foo-change_description.patch
6. <Add patch to spec file>
7. mzbuild

Michael
--
Michael Jennings (a.k.a. KainX) http://www.kainx.org/ <***@kainx.org>
Linux Server/Cluster Admin, LBL.gov Author, Eterm (www.eterm.org)
-----------------------------------------------------------------------
"There are two ways to slide easily through life: to believe
everything, or to doubt everything; both ways save us from
thinking." -- Polish Linguist Alfred Korzybski
Wyse, Chris
2007-10-17 17:29:53 UTC
Permalink
Hi,

Is there a way to prevent the rpmbuild of the source rpm from performing
the installation? My install section is executed during rpmbuild - I
really only want the installation done when I install the binary rpm.
Am I missing something or doing something wrong (or both)?


Chris Wyse
Senior Member of Technical Staff
Embedded Technologies
860-978-0849 cell/office
413-778-9101 fax
http://www.windriver.com
Jos Vos
2007-10-17 17:39:53 UTC
Permalink
Post by Wyse, Chris
Is there a way to prevent the rpmbuild of the source rpm from performing
the installation? My install section is executed during rpmbuild - I
really only want the installation done when I install the binary rpm.
Am I missing something or doing something wrong (or both)?
Both :-).

%instal is for installing in the temporary buildroot (BuildRoot: ...)
and the contents of that directory are used to collect the files for
the binary rpm (as listed in %files).
--
-- Jos Vos <***@xos.nl>
-- X/OS Experts in Open Systems BV | Phone: +31 20 6938364
-- Amsterdam, The Netherlands | Fax: +31 20 6948204
Bob Proulx
2007-10-17 17:41:36 UTC
Permalink
Post by Wyse, Chris
Is there a way to prevent the rpmbuild of the source rpm from performing
the installation? My install section is executed during rpmbuild - I
really only want the installation done when I install the binary rpm.
Am I missing something or doing something wrong (or both)?
Hmm... Never install directly into the root of the filesystem. That
would be bad. The best way to prevent this from happening
accidentally is to never rpmbuild as root. If you are not root then
you won't have permission to splat files into the root filesystem.

Make sure the rpm spec file is setting BuildRoot: to an image area.
A typical setting might be:

BuildRoot: %{_tmpdir}/%{name}-%{version}-build

Then rpmbuild will %install normally but the installation will go into
the image area. When using the above the path would typically be
something like /var/tmp/<package>-<version>-build/* enabling the
package to be built to a non-root user.

Summary: Never rpmbuild as root.

Bob
Leland Ray
2007-10-17 20:20:10 UTC
Permalink
Post by Wyse, Chris
Is there a way to prevent the rpmbuild of the source
rpm from
Post by Wyse, Chris
performing the installation? My install section is
executed during
Post by Wyse, Chris
rpmbuild - I really only want the installation done
when I install the binary rpm.
Post by Wyse, Chris
Am I missing something or doing something wrong (or
both)?

There is a terminology problem here.

The %install scriptlet is the logic required to copy
the files into a layout for a future binary
installation, not to install the component.

Typically, the logic is the same as the logic required
to install into the filesystem after a build, like
doing a make install. So the way most people implement
the %install scriptlet is to make install into a false
root, which rpm calls BuildRoot. The BuildRoot would
be set as a make variable from the command line.

After %install, rpm packages the files according to
the %files section.

Think of %install as "prepare file layout for
packaging".


__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

Loading...