Linux command – yum-builddep

Loading

yum-builddep 這是做什麼的?

有編譯過 src.rpm (RPM Source) 的人都知道,在編譯前要把所有需要的工具先安裝好,編譯的時候才不會出錯,這時候我們可以透過 yum-builddep 這隻工具幫我們做前置作業.

如果找不到 yum-builddep 這一個工具,請先安裝 yum-utils 套件.

[root@cn171 ~]# yum install yum-utils
Dependencies Resolved

================================================================================
 Package                Arch           Version               Repository    Size
================================================================================
Installing:
 yum-utils              noarch         1.1.31-34.el7         base         113 k
Installing for dependencies:
 python-chardet         noarch         2.2.1-1.el7_1         base         227 k
 python-kitchen         noarch         1.1.1-5.el7           base         267 k

Transaction Summary
================================================================================
Install  1 Package (+2 Dependent packages)

因為我是最小安裝,所以你要編譯 kernel 的 source RPM 需要這麼多的 packages .

[root@cn171 ~]# yum-builddep kernel

Dependencies Resolved

================================================================================
 Package                   Arch     Version                     Repository
                                                                           Size
================================================================================
Installing:
 asciidoc                  noarch   8.6.8-5.el7                 base      251 k
 audit-libs-devel          x86_64   2.4.1-5.el7                 base       68 k
 bc                        x86_64   1.06.95-13.el7              base      115 k
 binutils-devel            x86_64   2.23.52.0.1-55.el7          base      808 k
 bison                     x86_64   2.7-4.el7                   base      578 k
 elfutils                  x86_64   0.163-3.el7                 base      268 k
 elfutils-devel            x86_64   0.163-3.el7                 base       84 k
 gcc                       x86_64   4.8.5-4.el7                 base       16 M
 hmaccalc                  x86_64   0.9.13-4.el7                base       26 k
 m4                        x86_64   1.4.16-10.el7               base      256 k
 net-tools                 x86_64   2.0-0.17.20131004git.el7    base      304 k
 newt-devel                x86_64   0.52.15-4.el7               base       51 k
 numactl-devel             x86_64   2.0.9-6.el7_2               updates    23 k
 patch                     x86_64   2.7.1-8.el7                 base      110 k
 pciutils-devel            x86_64   3.2.1-4.el7                 base       34 k
 perl-ExtUtils-Embed       noarch   1.30-286.el7                base       49 k
 python-devel              x86_64   2.7.5-38.el7_2              updates   391 k
 redhat-rpm-config         noarch   9.1.0-68.el7.centos         base       77 k
 rpm-build                 x86_64   4.11.3-17.el7               base      143 k
 xmlto                     x86_64   0.0.25-7.el7                base       50 k
Installing for dependencies:
 atk                       x86_64   2.14.0-1.el7                base      251 k
 boost-regex               x86_64   1.53.0-25.el7               base      294 k
 bzip2                     x86_64   1.0.6-13.el7                base       52 k
 cairo                     x86_64   1.14.2-1.el7                base      711 k
 centos-indexhtml          noarch   7-9.el7.centos              base       92 k
 cpp                       x86_64   4.8.5-4.el7                 base      5.9 M
 ctags                     x86_64   5.8-13.el7                  base      155 k
 cups-libs                 x86_64   1:1.6.3-22.el7              base      355 k
 docbook-dtds              noarch   1.0-60.el7                  base      226 k
 docbook-style-xsl         noarch   1.78.1-3.el7                base      2.0 M
 dwz                       x86_64   0.11-3.el7                  base       99 k
 elfutils-libelf-devel     x86_64   0.163-3.el7                 base       35 k
 flex                      x86_64   2.5.37-3.el7                base      292 k
 fontconfig                x86_64   2.10.95-7.el7               base      228 k
 fontpackages-filesystem   noarch   1.44-8.el7                  base      9.9 k
 gd                        x86_64   2.0.35-26.el7               base      146 k
 gdb                       x86_64   7.6.1-80.el7                base      2.4 M
 gdbm-devel                x86_64   1.10-8.el7                  base       47 k
 gdk-pixbuf2               x86_64   2.31.6-3.el7                base      559 k
 ghostscript               x86_64   9.07-18.el7                 base      4.3 M
 ghostscript-fonts         noarch   5.50-32.el7                 base      324 k
 glibc-devel               x86_64   2.17-106.el7_2.8            updates   1.0 M
 glibc-headers             x86_64   2.17-106.el7_2.8            updates   663 k
 graphite2                 x86_64   1.3.6-1.el7_2               updates   112 k
 graphviz                  x86_64   2.30.1-19.el7               base      1.3 M
 gtk2                      x86_64   2.24.28-8.el7               base      3.4 M
 harfbuzz                  x86_64   0.9.36-1.el7                base      156 k
 hicolor-icon-theme        noarch   0.12-7.el7                  base       42 k
 jasper-libs               x86_64   1.900.1-29.el7              base      149 k
 jbigkit-libs              x86_64   2.0-11.el7                  base       46 k
 kernel-headers            x86_64   3.10.0-327.28.3.el7         updates   3.2 M
 lcms2                     x86_64   2.6-2.el7                   base      150 k
 libICE                    x86_64   1.0.9-2.el7                 base       65 k
 libSM                     x86_64   1.2.2-2.el7                 base       39 k
 libX11                    x86_64   1.6.3-2.el7                 base      605 k
 libX11-common             noarch   1.6.3-2.el7                 base      162 k
 libXau                    x86_64   1.0.8-2.1.el7               base       29 k
 libXaw                    x86_64   1.0.12-5.el7                base      190 k
 libXcomposite             x86_64   0.4.4-4.1.el7               base       22 k
 libXcursor                x86_64   1.1.14-2.1.el7              base       30 k
 libXdamage                x86_64   1.1.4-4.1.el7               base       20 k
 libXext                   x86_64   1.3.3-3.el7                 base       39 k
 libXfixes                 x86_64   5.0.1-2.1.el7               base       18 k
 libXfont                  x86_64   1.5.1-2.el7                 base      150 k
 libXft                    x86_64   2.3.2-2.el7                 base       58 k
 libXi                     x86_64   1.7.4-2.el7                 base       40 k
 libXinerama               x86_64   1.1.3-2.1.el7               base       14 k
 libXmu                    x86_64   1.1.2-2.el7                 base       71 k
 libXpm                    x86_64   3.5.11-3.el7                base       54 k
 libXrandr                 x86_64   1.4.2-2.el7                 base       26 k
 libXrender                x86_64   0.9.8-2.1.el7               base       25 k
 libXt                     x86_64   1.1.4-6.1.el7               base      173 k
 libXxf86vm                x86_64   1.1.3-2.1.el7               base       17 k
 libdb-devel               x86_64   5.3.21-19.el7               base       38 k
 libfontenc                x86_64   1.1.2-3.el7                 base       30 k
 libicu                    x86_64   50.1.2-15.el7               base      6.9 M
 libjpeg-turbo             x86_64   1.2.90-5.el7                base      134 k
 libmpc                    x86_64   1.0.1-3.el7                 base       51 k
 libpng                    x86_64   2:1.5.13-7.el7_2            updates   213 k
 librsvg2                  x86_64   2.39.0-1.el7                base      123 k
 libthai                   x86_64   0.1.14-9.el7                base      187 k
 libtiff                   x86_64   4.0.3-25.el7_2              updates   169 k
 libtool-ltdl              x86_64   2.4.2-21.el7_2              updates    49 k
 libxcb                    x86_64   1.11-4.el7                  base      189 k
 libxshmfence              x86_64   1.2-1.el7                   base      7.2 k
 libxslt                   x86_64   1.1.28-5.el7                base      242 k
 lynx                      x86_64   2.8.8-0.3.dev15.el7         base      1.4 M
 mesa-libEGL               x86_64   10.6.5-3.20150824.el7       base       74 k
 mesa-libGL                x86_64   10.6.5-3.20150824.el7       base      184 k
 mesa-libgbm               x86_64   10.6.5-3.20150824.el7       base       40 k
 mesa-libglapi             x86_64   10.6.5-3.20150824.el7       base       39 k
 mpfr                      x86_64   3.1.1-4.el7                 base      203 k
 pango                     x86_64   1.36.8-2.el7                base      287 k
 pciutils                  x86_64   3.2.1-4.el7                 base       90 k
 perl-ExtUtils-Install     noarch   1.58-286.el7                base       73 k
 perl-ExtUtils-MakeMaker   noarch   6.68-3.el7                  base      275 k
 perl-ExtUtils-Manifest    noarch   1.61-244.el7                base       31 k
 perl-ExtUtils-ParseXS     noarch   1:3.18-2.el7                base       77 k
 perl-Thread-Queue         noarch   3.02-2.el7                  base       17 k
 perl-devel                x86_64   4:5.16.3-286.el7            base      452 k
 perl-srpm-macros          noarch   1-8.el7                     base      4.6 k
 pixman                    x86_64   0.32.6-3.el7                base      254 k
 poppler-data              noarch   0.4.6-3.el7                 base      2.2 M
 sgml-common               noarch   0.6.3-39.el7                base       55 k
 slang-devel               x86_64   2.2.4-11.el7                base       91 k
 source-highlight          x86_64   3.1.6-6.el7                 base      611 k
 unzip                     x86_64   6.0-15.el7                  base      166 k
 urw-fonts                 noarch   2.4-16.el7                  base      3.0 M
 vim-filesystem            x86_64   2:7.4.160-1.el7             base      9.6 k
 xml-common                noarch   0.6.3-39.el7                base       26 k
 xorg-x11-font-utils       x86_64   1:7.5-20.el7                base       87 k
 zip                       x86_64   3.0-10.el7                  base      260 k
Updating for dependencies:
 glibc                     x86_64   2.17-106.el7_2.8            updates   3.6 M
 glibc-common              x86_64   2.17-106.el7_2.8            updates    11 M
 numactl-libs              x86_64   2.0.9-6.el7_2               updates    29 k
 python                    x86_64   2.7.5-38.el7_2              updates    89 k
 python-libs               x86_64   2.7.5-38.el7_2              updates   5.6 M

Transaction Summary
================================================================================
Install  20 Packages (+92 Dependent packages)
Upgrade              (  5 Dependent packages)

接下來試試編譯 Kernel source RPM .

[root@cn171 ~]# adduser builder
[root@cn171 ~]# rpm -ivh kernel-3.10.0-327.28.3.el7.src.rpm 
Updating / installing...
   1:kernel-3.10.0-327.28.3.el7       ################################# [100%]
[root@cn171 ~]# cd rpmbuild/SPECS/
[root@cn171 SPECS]# rpmbuild -ba kernel.spec 
錯誤:相依性建置失敗:
	pesign >= 0.109-4 被 kernel-3.10.0-327.28.3.el7.x86_64 需要

[root@cn171 SPECS]# yum install pesign
[root@cn171 SPECS]# rpmbuild -ba kernel.spec
......
已寫入:/root/rpmbuild/RPMS/x86_64/kernel-debug-debuginfo-3.10.0-327.28.3.el7.x86_64.rpm
正在執行(%clean):/bin/sh -e /var/tmp/rpm-tmp.N7Uwzk
+ umask 022
+ cd /root/rpmbuild/BUILD
+ cd kernel-3.10.0-327.28.3.el7
+ rm -rf /root/rpmbuild/BUILDROOT/kernel-3.10.0-327.28.3.el7.x86_64
+ exit 0

編譯完成可以在 rpmbuild/RPMS/x86_64/ 看到編譯好的 rpm 檔案.

[root@cn171 rpmbuild]# cd SPECS/
[root@cn171 SPECS]# cd ../RPMS/x86_64/
[root@cn171 x86_64]# 
總計 738712
-rw-r--r-- 1 root root  34656732  9月  2 23:59 kernel-3.10.0-327.28.3.el7.x86_64.rpm
-rw-r--r-- 1 root root  36355620  9月  3 00:04 kernel-debug-3.10.0-327.28.3.el7.x86_64.rpm
-rw-r--r-- 1 root root 299264512  9月  3 00:08 kernel-debug-debuginfo-3.10.0-327.28.3.el7.x86_64.rpm
-rw-r--r-- 1 root root  11581324  9月  3 00:04 kernel-debug-devel-3.10.0-327.28.3.el7.x86_64.rpm
-rw-r--r-- 1 root root 290149444  9月  3 00:04 kernel-debuginfo-3.10.0-327.28.3.el7.x86_64.rpm
-rw-r--r-- 1 root root  46285184  9月  2 23:59 kernel-debuginfo-common-x86_64-3.10.0-327.28.3.el7.x86_64.rpm
-rw-r--r-- 1 root root  11516656  9月  3 00:00 kernel-devel-3.10.0-327.28.3.el7.x86_64.rpm
-rw-r--r-- 1 root root   3353264  9月  2 23:59 kernel-headers-3.10.0-327.28.3.el7.x86_64.rpm
-rw-r--r-- 1 root root   2524692  9月  3 00:00 kernel-tools-3.10.0-327.28.3.el7.x86_64.rpm
-rw-r--r-- 1 root root   2513308  9月  3 00:00 kernel-tools-debuginfo-3.10.0-327.28.3.el7.x86_64.rpm
-rw-r--r-- 1 root root   2443588  9月  3 00:00 kernel-tools-libs-3.10.0-327.28.3.el7.x86_64.rpm
-rw-r--r-- 1 root root   2439892  9月  3 00:00 kernel-tools-libs-devel-3.10.0-327.28.3.el7.x86_64.rpm
-rw-r--r-- 1 root root   3491672  9月  2 23:59 perf-3.10.0-327.28.3.el7.x86_64.rpm
-rw-r--r-- 1 root root   4575076  9月  3 00:00 perf-debuginfo-3.10.0-327.28.3.el7.x86_64.rpm
-rw-r--r-- 1 root root   2523112  9月  3 00:00 python-perf-3.10.0-327.28.3.el7.x86_64.rpm
-rw-r--r-- 1 root root   2737116  9月  3 00:00 python-perf-debuginfo-3.10.0-327.28.3.el7.x86_64.rpm
沒有解決問題,試試搜尋本站其他內容

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料