apt-get install rpm
wget https://releases.pagure.org/virt-viewer/virt-viewer-8.0.tar.gz ./
这个自己看readme或者configure吧。。。。
rpmbuild -bb /home/jr/rpmbuild/[xxx]/virt-viewer.spec
error: File /home/jr/rpmbuild/SOURCES/virt-viewer-8.0.tar.gz: No such file or directory
BUILD BUILDROOT RPMS SOURCES SPECS SRPMS
按照提示把源代码的gz包copy到 SOURCES下面就好
编写spec文件
这里偷懒直接用来解压编译virt-viewer源码里面生成的virt-viewer.spec改一改,
不然的话要写半天,还不一定写了能用。。。。尼玛。。。
Name: virt-viewer
Version: 8.0
Release: 1%{?dist}
Summary: Virtual Machine Viewer
Group: Applications/System
License: GPLv2+
URL: http://virt-manager.org/
Source0: http://virt-manager.org/download/sources/%{name}/%{name}-%{version}.tar.gz
%description
Virtual Machine Viewer provides a graphical console client for connecting
to virtual machines. It uses the GTK-VNC or SPICE-GTK widgets to provide
the display, and libvirt for looking up VNC/SPICE server details.
%prep
%setup -q
%build
#%configure %{spice_arg} %{govirt_arg} --with-buildid=%{release} --disable-update-mimedb
%configure --prefix=/usr --libdir=/usr/lib --without-gtk-vnc --without-ovirt --with-buildid=%{release} --disable-update-mimedb
#%__make %{?_smp_mflags}
%__make -j4
%install
rm -rf $RPM_BUILD_ROOT
%__make install DESTDIR=$RPM_BUILD_ROOT
%find_lang %{name}
%files -f %{name}.lang
%doc README.md COPYING AUTHORS ChangeLog NEWS
%define name remote-viewer
%{_bindir}/%{name}
%{_bindir}/remote-viewer
%{_datadir}/icons/hicolor/*/apps/*
%{_datadir}/icons/hicolor/*/devices/*
%{_datadir}/applications/remote-viewer.desktop
%{_datadir}/appdata/remote-viewer.appdata.xml
%{_datadir}/mime/packages/virt-viewer-mime.xml
%{_mandir}/man1/virt-viewer.1*
%{_mandir}/man1/remote-viewer.1*
%changelog
rpmbuild -bb /home/jr/rpmbuild/[xxx]/virt-viewer.spec
最后有个rpm包生成。
我的arm盒子,uname -m ,显示armv7l
正常来说,我应该跑:
rpmbuild -bb -target armv71 /home/jr/rpmbuild/[xxx]/virt-viewer.spec
但是最终跑出来的包安装不了,提示架构不符,只好不加target参数跑rpmbuild了
关于spec文件何编写,有两篇文章拿来参考不错:
https://blog.csdn.net/czg13548930186/article/details/53144868
https://www.cnblogs.com/michael-xiang/p/10480809.html
1.首先是查找、获取源码包
apt-cache showsrc xxx
查询当前镜像站点中是否有该源码包apt-get source xxx
命令来获取源码包,它会将源码包下载到用户当前目录
该命令执行过程中,会调用dpkg-source命令,根据dsc文件中的信息,将源码包解压到同名目录中
dpkg-source可以通过apt-get install dpkg-dev获得
2.安装依赖包:
apt-get build-dep xxx
命令可以主动获取并安装所有相关的软件包
3.编译源码包:
cd xxx
dpkg-buildpackage
4.使用dpkg -i安装编译出来的deb包
感觉这个用的最方便,
rpmbuild编写spec文件太麻烦,还容易出错,
dpkg-buildpackage一般编译的是完全版本的程序,依赖包超多,删减程序、定制化不便,而且apt source下来的包不一定最新。
checkinstall只需要源码make成功之后跑一下就好。
for Ubuntu/Debian:
apt-get install checkinstall
for CentOS/Fedora:
yum install rpm-build rpmdevtools
ref: https://asic-linux.com.mx/~izto/checkinstall/download.php
wget https://raw.githubusercontent.com/rpmsphere/x86_64/master/c/checkinstall-1.6.2-1.x86_64.rpm
yum install checkinstall-1.6.2-1.x86_64.rpm
./configure … xxx
make -j4
3.调用checkinstall打包:
sudo checkinstall
The package documentation directory ./doc-pak does not exist. Should I create a default set of package docs? [y]:
输入y就对了,然后填入包名再回车。
This package will be built according to these values:
0 - Maintainer: [ xxx ]
1 - Summary: [ xxx ]
2 - Name: [ name ]
3 - Version: [ ]
4 - Release: [ 1 ]
5 - License: [ GPL ]
6 - Group: [ checkinstall ]
7 - Architecture: [ amd64 ]
8 - Source location: [ nameofthesrc ]
9 - Alternate source location: [ ]
10 - Requires: [ ]
11 - Provides: [ command ]
12 - Conflicts: [ ]
13 - Replaces: [ ]
想改哪个就输入哪个数字吧,可以来回改几次,最后来两下回车就ok下一步
Copying files to the temporary directory…OK
Stripping ELF binaries and libraries…OK
Compressing man pages…OK
Building file list…OK
Building Debian package…OK
Installing Debian package…OK
Erasing temporary files…OK
Writing backup package…OK
OKDeleting temp dir…OK
.*********************************************************************
Done. The new package has been installed and saved to
/home/jr/virt-viewer/spice-gtk-0.35/spice-gtk_0.35-1_armhf.deb
You can remove it from your system anytime using:
dpkg -r spice-gtk
.**********************************************************************
看看,是不是超级方便,不用去写半天rpmbuild的spec文件,也方便做功能裁剪、定制化,不像dpkg-buildpackage那么死板笨重。
真是神器啊!
yum -y install ruby rubygems ruby-devel
gem source -l
gem sources -a http://mirrors.aliyun.com/rubygems/
gem sources --remove https://rubygems.org/
gem source -u
gem install fpm
make install DESTDIR=/root/tmpdir
fpm -s dir -t rpm -n spice -v 0.14.1 -C /root/tmpdir