Cool Tip: vi and spec File Templates

96

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