Skip to content

Instantly share code, notes, and snippets.

@jfinstrom
Created November 24, 2012 17:42
Show Gist options
  • Save jfinstrom/4140646 to your computer and use it in GitHub Desktop.
Save jfinstrom/4140646 to your computer and use it in GitHub Desktop.
spec File generator
class specfile:
def __init__(self):
self.package = ''
self.version = ''
self.release = '1'
self.files = []
self.configs = []
self.license = 'GPL'
self.packager = 'RPM Generator <rpm@generator>'
self.vendor = 'none'
self.description = ''
self.buildroot = ''
self.group = 'generic/generic'
self.prep = []
self.post = []
def add_post_line(self,line):
self.post.append(line)
def add_prep_line(self, line):
self.prep.append(line)
def add_files(self, path):
self.files.append(path)
def add_configs(self,path):
self.configs.append(path)
def make_spec(self):
slines = []
#make RPMbuild not poop it self because it cant find a file
slines.append('%define _unpackaged_files_terminate_build 0')
slines.append('%define _missing_doc_files_terminate_build 0')
#Header
slines.append('Name: %s' % self.package)
slines.append('Summary: %s' % self.description)
slines.append('Version: %s' % self.version)
slines.append('Release: %s' % self.release)
slines.append('License: %s' % self.license)
slines.append('Vendor: %s' % self.vendor)
slines.append('Packager: %s' % self.packager)
slines.append('Group: %s' % self.group)
slines.append('BuildRoot: %s' % self.buildroot )
slines.append('Provides: %{name} = %{version}')
slines.append('%description')
slines.append(self.description)
if len(self.prep) > 0:
slines.append('%prep')
for line in self.prep:
slines.append(line)
if len(self.post) > 0:
slines.append('%post')
for line in self.post:
slines.append(line)
if len(self.files) > 0:
slines.append('%files')
for line in self.files:
slines.append(line)
if len(self.configs) > 0:
slines.append('%config')
for line in self.configs:
slines.append(line)
return slines
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment