使用" /"创建var文件;用rpmbuild

时间:2018-02-13 17:10:19

标签: linux rpm

我是rpmbuild的新手,谷歌搜索并复制一个spec文件参数并成功创建rpm当我运行它时rpm没有创建

var.tar.gz -- this is my tar file. it has
var/
var/www/
var/www/html/index.html

我的规范文件

[root@kaka1 SPECS]# vi var.spec 

Name:           var
Version:        1
Release:        0
Summary:        Xiph Streaming media server that supports multiple formats.
Group:          Applications/Multimedia
License:        GPL
URL:            http################
Source:         var-1.0.tar.gz
Prefix:         %{_prefix}
Packager:       Sukama
BuildRoot:      %{_tmppath}/%{name}-root

%description
easily and supports open standards for commuincation and interaction.

%prep
rm -rf /root/rpmbuild/BUILD/*

%setup -n var


gzip -dc /root/rpmbuild/SOURCES/var-1.0.tar.gz| tar -xvvf  -
if [ $? -ne 0 ]; then
  exit $?
fi

你能帮助我在哪里可以提到我的文件在root下创建?

1 个答案:

答案 0 :(得分:1)

首先,不要使用varusr之类的名称作为包名,使用与包可能代表的内容更相关的名称。这是一个简单的spec文件,应该将index.html安装到/var/www目录中。

%define debug_package %{nil}
Summary: Simple SPEC
Name: simple
Version: 0
Release: 1
License: NONE # Use your suitable license
Group: NONE
URL: NONE
Source0: %{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root

## Following lines are commented out, but that's the way to go 
#BuildRequires: httpd  # This needs https RPM during your build
#Requires: httpd  # This would require httpd to be installed for this RPM 

%description

%prep
%setup -q  # This untars the source

%build  # currently empty

%install  # This moves into the source directory "simple-0" (see below)
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/var/www
install -m 0644 index.html %{buildroot}/var/www/index.html

%clean
rm -rf $RPM_BUILD_ROOT

%post


%files
%defattr(-,root,root,-)
%doc
/var/www/index.html  # Your packages owns the file, but not the directories


%changelog
* Web Feb 14 2018 <user@localhost> - 0.0
- Initial build.

对于上面的.spec文件,需要一个名为simple-0.tar.gz的tarball。这会映射到Source0内使用的.spec名称。这种情况下的内容是目录和文件:simple-0/index.html