forked from redhat-imaging/imagefactory
-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
82 lines (72 loc) · 3.17 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# Copyright 2011 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from distutils.core import setup
from distutils.command.sdist import sdist as _sdist
import os
import os.path
import subprocess
import time
VERSION = '1.1.3'
RELEASE = '1'
class sdist(_sdist):
""" custom sdist command, to prep imagefactory.spec file """
def run(self):
global VERSION
global RELEASE
# Create a development release string for later use
git_head = subprocess.Popen("git log -1 --pretty=format:%h",
shell=True,
stdout=subprocess.PIPE).communicate()[0].strip()
date = time.strftime("%Y%m%d%H%M%S", time.gmtime())
git_release = "%sgit%s" % (date, git_head)
# Expand macros in imagefactory.spec.in
spec_in = open('imagefactory.spec.in', 'r')
spec = open('imagefactory.spec', 'w')
for line in spec_in.xreadlines():
if "@VERSION@" in line:
line = line.replace("@VERSION@", VERSION)
elif "@RELEASE@" in line:
# If development release, include date+githash in %{release}
if RELEASE.startswith('0'):
RELEASE += '.' + git_release
line = line.replace("@RELEASE@", RELEASE)
spec.write(line)
spec_in.close()
spec.close()
# Create Version.py to allow internal version repording via the API
version_out = open("imgfac/Version.py", 'w')
version_out.write('VERSION = "%s-%s"\n' % (VERSION, RELEASE))
version_out.close()
# Run parent constructor
_sdist.run(self)
datafiles=[('share/man/man1', ['documentation/man/imagefactory.1', 'documentation/man/imagefactoryd.1']),
('share/man/man5', ['documentation/man/imagefactory.conf.5']),
('share/man/man7', ['documentation/man/imagefactory.rest.7']),
('/etc/imagefactory', ['imagefactory.conf']),
('/etc/pki/imagefactory', ['cert-ec2.pem']),
('/etc/sysconfig', ['conf/sysconfig/imagefactoryd']),
('/etc/logrotate.d', ['conf/logrotate.d/imagefactoryd']),
('/etc/rc.d/init.d', ['scripts/imagefactoryd'])]
setup(name='imagefactory',
version=VERSION,
description='Image Factory system image generation tool',
author='Ian McLeod',
author_email='[email protected]',
license='Apache License, Version 2.0',
url='http://www.aeolusproject.org/imagefactory.html',
packages=['imgfac', 'imgfac.rest', 'imgfac.picklingtools'],
scripts=['imagefactory', 'imagefactoryd'],
data_files = datafiles,
cmdclass = {'sdist': sdist}
)