首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用rpmbuild在带有"/“的目录下创建var文件

问使用rpmbuild在带有"/“的目录下创建var文件
EN

Stack Overflow用户
提问于 2018-02-14 01:10:19
回答 1查看 112关注 0票数 0

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

代码语言:javascript
复制
var.tar.gz -- this is my tar file. it has
var/
var/www/
var/www/html/index.html

我的规范文件

代码语言:javascript
复制
[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

你能帮我在哪里提到我要在根目录下创建的文件吗?

EN

回答 1

Stack Overflow用户

发布于 2018-02-14 22:56:04

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

代码语言:javascript
复制
%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。它映射到在.spec中使用的Source0名称。本例中的内容是一个目录和一个文件:simple-0/index.html。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48772106

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档