I want to get the source code of an RPM package, with all patches applied. (what the apt source
do)
For example, bash
. Here is something I’ve tried.
Firstly, I download the src RPM package via yumdownloader
:
yumdownloader --source bash
Then, I got a package named bash-4.2.46-35.el7_9.src.rpm
. I used the following command to extract this file:
rpm2cpio bash-4.2.46-35.el7_9.src.rpm | cpio -ivdm
Then, I got the following files:
[root@ce944fc560a2 src]# ls
bash-2.02-security.patch bash-3.2-ssh_source_bash.patch bash-4.2-cve-2014-7169-0.patch bash-4.2-man-ulimit.patch bash-4.3-cve-2016-0634.patch bash-5.0-syslog-history.patch bash42-003 bash42-013 bash42-023 bash42-033 bash42-043
bash-2.03-paths.patch bash-4.0-nobits.patch bash-4.2-cve-2014-7169-1.patch bash-4.2-manpage.patch bash-4.3-cve-2016-7543.patch bash-bashbug.patch bash42-004 bash42-014 bash42-024 bash42-034 bash42-044
bash-2.03-profile.patch bash-4.1-broken_pipe.patch bash-4.2-cve-2014-7169-2.patch bash-4.2-manpage_trap.patch bash-4.3-dircomp-append-slash.patch bash-cve-2016-9401.patch bash42-005 bash42-015 bash42-025 bash42-035 bash42-045
bash-2.05a-interpreter.patch bash-4.1-defer-sigchld-trap.patch bash-4.2-double-alloc.patch bash-4.2-missing-opt-cd.patch bash-4.3-pipefd-leak.patch bash-infotags.patch bash42-006 bash42-016 bash42-026 bash42-036 bash42-046
bash-2.05b-debuginfo.patch bash-4.1-examples.patch bash-4.2-enable-hyphened-fn-export.patch bash-4.2-missing_closes.patch bash-4.3-trapped-signals.patch bash-requires.patch bash42-007 bash42-017 bash42-027 bash42-037 bash42-052
bash-2.05b-manso.patch bash-4.1-trap.patch bash-4.2-env-inject.patch bash-4.2-noecho.patch bash-4.3-wshouldquote.patch bash-setlocale.patch bash42-008 bash42-018 bash42-028 bash42-038 bash42-053
bash-2.05b-pgrp_sync.patch bash-4.2-brace-expand.patch bash-4.2-extglob-man.patch bash-4.2-rc2-logout.patch bash-4.4-bracketed-paste.patch bash-tty-tests.patch bash42-009 bash42-019 bash42-029 bash42-039 dot-bash_logout
bash-2.05b-readline-oom.patch bash-4.2-case-in-command-subst.patch bash-4.2-history-hang.patch bash-4.2-signal.patch bash-4.4-cve-2019-9924.patch bash.spec bash42-010 bash42-020 bash42-030 bash42-040 dot-bash_profile
bash-2.05b-xcc.patch bash-4.2-check-debugger.patch bash-4.2-ifs-in-temp-env.patch bash-4.2-size_type.patch bash-4.4-param-expansion.patch bash42-001 bash42-011 bash42-021 bash42-031 bash42-041 dot-bashrc
bash-3.2-audit.patch bash-4.2-coverity.patch bash-4.2-leak-compound.patch bash-4.2.tar.gz bash-4.4-pipeline-pgrp.patch bash42-002 bash42-012 bash42-022 bash42-032 bash42-042 fix-shopt-lastpipe-mode-crash.patch
There is a tgz file bash-4.2.tar.gz
which is the original bash source code and lots of patch files.
How to patch these files to the original source code? If my steps are wrong, is there a simple way to solve my question?
2
Answers
After reading the Rebuild a Source RPM, I found an approach to solve the problem.
Firstly, use the
yumdownloader
to download a source package:Then, use the
rpmbuild
to rebuild the package without build and dependency check:rpmbuild
will help you deal with all the things. Then the source code is here:$HOME/rpmbuild/BUILD/bash-4.2/
:From the rpmbuild(1) man page
But
-bX
is for building from a .spec file, use-rX
if you have the src.rpm. So the commandshould work. I add the
--verbose
command-line option to see what’s going on, because neither the defaultrpmbuild
output nor its man page give any hint that it puts the patched source in ~/rpmbuild/BUILD/PACKAGENAME .