首页 > 解决方案 > Spec rpm: how to enter in build directory without using tar files?

问题描述

I want to build a project from git, and create the rpm,this is the spec,is incomplete, but the most interesting part is first one. I need to enter in build dir created by git,but fail This is the part of spec. file

%define build_timestamp %(date +"%Y%m%d")
#
Summary:        My git project
Name:           gitproject
Release:        1
Version:        %{build_timestamp}
License:        GPLv2+
Group:          Unspecified
URL:            https://mygitserver.com/myname/myproject
#-----------------------------------------------------
Requires:       openssl
BuildRequires:  compat-openssl10-devel
BuildRoot:      %{_tmppath}/%{name}-%{version}-buildroot
#-----------------------------------------------------
AutoReqProv: no

%description
Git personal project, is in testing

%prep
git clone  https://mygitserver.com/myname  %{name}
cd %{name}

The problem is..instead of enter in %{name} enter in BUILD..which of course contain a lot of dirs..but not the makefile.

+ umask 022
+ cd /home/user/rpmbuild/BUILD
+ make -j2
make: *** No targets specified and no makefile found.  Stop.

How can I enter %{name}?

标签: rpmbuild

解决方案


我不会跳过 tgz 部分,但让我们git为您完成工作。我解决这个问题的方法:在你的规范文件中使用Source和:%setup -q

Source:         %{name}-%{version}.tgz

%prep
%setup -q

现在您可以使用 git 为您创建这个 tgz 文件:

git archive --format=tgz --prefix=gitproject-1.2.3-1 <hash or tag> > /home/user/rpmbuild/SOURCES/gitproject-1.2.3.tgz

请注意,前缀 ang 文件名需要与您的规范文件中%name-%version.tgzSource标记匹配。当然,您可以更改这些命名约定。

PS:我已经围绕这个写了一个完整的方便脚本;但是使用这些命令,您应该可以完成大部分工作。


推荐阅读