【问题标题】:create var files under with "/" with rpmbuild使用 rpmbuild 在“/”下创建 var 文件
【发布时间】:2018-02-13 17:10:18
【问题描述】:

我是 rpmbuild 的新手,谷歌搜索并复制了一个规范文件参数,并在我运行它时成功创建了 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

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

【问题讨论】:

  • 你为什么要写信给/var/www/?您是否正在创建自己的 apache 之类的包?此目录应归apache rpm 所有。澄清你想在这里做什么?
  • 您好,我想仅通过 rpm 在多个主机上部署 /var/www/ 下的一些 index.html 文件。如果目录不存在想用 rpm 创建那些目录和文件
  • @iamauser 该目录确实应该归apache所有,但它的内容可能属于其他包。
  • @glglgl 是的,这就是我在回答中的设计方式。

标签: linux rpm


【解决方案1】:

首先,不要使用像varusr 这样的名称作为包名,使用与包可能代表的内容更相关的名称。这是一个简单的规范文件,应该将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 的压缩包。这映射到在.spec 中使用的Source0 名称。在这种情况下,内容将是一个目录和一个文件:simple-0/index.html

【讨论】:

    猜你喜欢
    • 2021-02-04
    • 2011-07-13
    • 2012-04-12
    • 2019-10-31
    • 2020-04-04
    • 2018-05-11
    • 2013-08-29
    • 2018-08-06
    • 2015-10-05
    相关资源
    最近更新 更多