Cool tip: vi and spec file templates

This is a really cool tip I stumbled onto while working with some of the packages on my team.  A couple months back I was editing a spec file and accidentally mistyped the name of the spec file.  Much to my surprise most of the file was completely missing.  After several :q! I finally realized that vi has a skeleton spec file that gets generated when edit a *.spec file that doesn’t exist yet.

So, for example if you typed:

 vi mypackage.spec

you would get:

#
# This file and all modifications and additions to the pristine
# package are under the same license as the package itself.
#

# norootforbuild

Name:           mypackage
Version:
Release:
Summary:
Group:
License:
Url:
PreReq:
Provides:
BuildRequires:
Source:
Patch:
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
AutoReqProv:    on

%description

Authors:
--------
    Name Surname

%prep
%setup

%build
%configure
make %{?jobs:-j%jobs}

%install
%makeinstall

%clean
rm -rf $RPM_BUILD_ROOT

%post
%postun

%files
%defattr(-,root,root)
%doc ChangeLog README COPYING

%changelog
* Wed Jan 13 2010 sshaw at stshaw.site

3 comments

  1. […] 今天早上在 Decriptor’s Blog 看到的一個技巧分享,以往再編輯 RPM SPEC 檔案時始終十分頭痛裏面的格式,現在當你再 SUSE Linux中透過 vi  XXX.spec 時,便會自動提供一個完整的 SPEC 格式讓你使用,十分方便與實用的技巧 ^^ […]

Leave a Reply

Your email address will not be published. Required fields are marked *