-
Notifications
You must be signed in to change notification settings - Fork 23
/
make_rpm.py
86 lines (70 loc) · 2.75 KB
/
make_rpm.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
83
84
85
86
# This file is part of the Linux Process Explorer
# See www.sourceforge.net/projects/procexp
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2, or (at your option) any
# later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
'''
This module contains tooling to generate an rpm package.
'''
# pylint: disable-msg-cat=WCREFI
#@PydevCodeAnalysisIgnore
import subprocess
import os
import sys
import shutil
import shutil
pwd = os.getcwd()
#get subversion version number of the repository
svn = subprocess.Popen(["svnversion","."], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
svnversion = svn.communicate()[0]
svnversion = svnversion.strip()
projectname = "process_explorer"
versionprefix = "0.3"
def createFullPath(thepathlist):
fullpath = ""
for p in thepathlist.split(":"):
if p != "":
fullpath = fullpath + "/opt/" + projectname + '-' + versionprefix + '-' + svnversion + "/" + p + ":"
return fullpath
pwd = os.getcwd()
#
#Create RPM 'environment'
#
subprocess.check_call(["/bin/rm", "-rf", "./rpm"])
subprocess.check_call(["/bin/rm", "-rf", "./i386"])
os.mkdir("./rpm")
os.mkdir("./rpm/BUILD")
os.mkdir("./rpm/RPMS")
os.mkdir("./rpm/SOURCES")
os.mkdir("./rpm/SPECS")
os.mkdir("./rpm/SRPMS")
#
# Build the RPM which installs all software on target
#
subprocess.check_call(["rpmbuild",
"-bb",
"--define", "_topdir "+pwd + "/rpm",
"--define", "_svnversion " + svnversion,
"--define", "_projectname " + projectname,
"--define", "_versionprefix " + versionprefix,
"process_explorer.spec"])
# "--define", "_pythonpath " + createFullPath(pythonpath),
subprocess.check_call(["mv", pwd + '/rpm/RPMS/i386/'+projectname + '-' + versionprefix + '-' + svnversion + ".i386.rpm", "."])
#create .tar.gz file for rpmless setup..
subprocess.check_call(["tar", "-C", pwd + "/rpm/BUILD/opt", "-cvzf", projectname + '-' + versionprefix + '-' + svnversion + ".tar.gz", projectname + '-' + versionprefix + '-' + svnversion])
#remove stuff
subprocess.check_call(["/bin/rm", "-rf", "./rpm"])
print "********************************************"
print "RPM file is : " + pwd + '/rpm/RPMS/i386/'+projectname + '-' + versionprefix + '-' + svnversion + ".i386.rpm"
print "********************************************"