Merge branch 'misuth_g_test' into 'master'
GUEZE-Port rprmbuild repo to gitlab See merge request projects-domain-live/rpmbuild!1
This commit is contained in:
commit
6a1166ce64
2 files changed
+14
-74
No files matched your search
-24
@@ -58,30 +58,6 @@ def system( cmdstring, file = None ):
|
||||
ret = p.stdout.read().strip()
|
||||
return ret
|
||||
|
||||
def getSvn_Release( svn_dir ):
|
||||
try:
|
||||
old_lang = os.environ['LANG']
|
||||
except:
|
||||
old_lang = None
|
||||
os.putenv("LANG", "en_US")
|
||||
cmd = "svn info %s | grep \"Last Changed Rev\"" % svn_dir
|
||||
rel = system( cmd ).split(':')[1].strip()
|
||||
if old_lang:
|
||||
os.putenv("LANG", old_lang)
|
||||
return rel
|
||||
|
||||
def getSvn_Date( svn_dir ):
|
||||
try:
|
||||
old_lang = os.environ['LANG']
|
||||
except:
|
||||
old_lang = None
|
||||
os.putenv("LANG", "en_US")
|
||||
cmd = "svn info %s | grep \"Last Changed Date\"" % svn_dir
|
||||
rel = system( cmd ).split()[3].strip()
|
||||
if old_lang:
|
||||
os.putenv("LANG", old_lang)
|
||||
return rel
|
||||
|
||||
def getOS_Name():
|
||||
if os.path.exists('/etc/SuSE-release'):
|
||||
f = open('/etc/SuSE-release', 'r')
|
||||
|
||||
+14
-50
@@ -32,8 +32,7 @@ class build(object):
|
||||
self.version_min = 1
|
||||
self.version_rev = 0
|
||||
self.cmake_version_prefix = "TDS"
|
||||
self.source_dir_rel = "TDS-Source"
|
||||
self.svn_fullpath = None
|
||||
self.source_dir_rel = "tds"
|
||||
|
||||
self.buildtype = os.getenv( "CMAKE_BUILD_TYPE" )
|
||||
if self.buildtype == None or self.buildtype == "":
|
||||
@@ -55,29 +54,12 @@ class build(object):
|
||||
print(" Using extfw dir: %s" % self.extfw_dir)
|
||||
print(" Using buildtype: %s" % self.buildtype)
|
||||
print(" Project name: %s" % self.project_name)
|
||||
print(" SVN Path: %s" % self.svn_fullpath)
|
||||
print(" Version: %s.%s-%s" % ( self.version_maj, self.version_min, self.version_rev ))
|
||||
print(" Jenkins build number: %s" % os.getenv( "BUILD_NUMBER" ))
|
||||
print(" GitLab-CI build number: %s" % os.getenv( "BUILD_NUMBER" ))
|
||||
print(" Date: %s" % self.version_date)
|
||||
print("")
|
||||
time.sleep(2)
|
||||
|
||||
# does a svn export, returns True when it's a checkout or False when it's an update
|
||||
def svn_export( self, svn_path, dest_dir, svn_revision = "HEAD", svn_user = None, svn_passwd = None ):
|
||||
|
||||
removeDirectory( dest_dir )
|
||||
|
||||
info( "--------------------------------" )
|
||||
info( "Exporting %s to %s" % ( svn_path, dest_dir ) )
|
||||
info( "--------------------------------" )
|
||||
|
||||
command = "svn export -r %s %s %s" % ( svn_revision, svn_path, dest_dir )
|
||||
if svn_user:
|
||||
command += "--username %s " % svn_user
|
||||
if svn_passwd:
|
||||
command += "--password %s " % svn_passwd
|
||||
os.system( command ) and die( "while svn export. cmd: %s" % command )
|
||||
|
||||
def version_str( self ):
|
||||
return "%s.%s" % ( self.version_maj, self.version_min )
|
||||
|
||||
@@ -107,7 +89,7 @@ class build(object):
|
||||
return specname
|
||||
die( 'Unable to find a valid spec file in %s' % specdir )
|
||||
|
||||
def copy_spec( self, svn_fullpath, dest_dir, spec_fullpath ):
|
||||
def copy_spec( self, dest_dir, spec_fullpath ):
|
||||
# copy spec to build
|
||||
f = open( spec_fullpath, 'r' )
|
||||
content = f.read()
|
||||
@@ -145,7 +127,7 @@ class build(object):
|
||||
content = content.replace( "@OS_SYSTEM@", getOS_Name() )
|
||||
content = content.replace( "@PACKAGER@", getpass.getuser() )
|
||||
content = content.replace( "@VERSION@", self.version_str() )
|
||||
content = content.replace( "@RELEASE@", self.version_rev )
|
||||
content = content.replace( "@RELEASE@", str(self.version_rev) )
|
||||
content = content.replace( "@SOURCE_DIR_REL@", self.source_dir_rel )
|
||||
content = content.replace( "@SOURCES@", self.xzfilename() )
|
||||
content = content.replace( "@APPLICATION@", self.repository )
|
||||
@@ -154,6 +136,7 @@ class build(object):
|
||||
if not os.path.exists( dest_dir ):
|
||||
os.makedirs( dest_dir )
|
||||
f = open( os.path.join( dest_dir, os.path.split( spec_fullpath )[1] ), 'w' )
|
||||
|
||||
f.write( content )
|
||||
f.close()
|
||||
|
||||
@@ -213,15 +196,14 @@ def main():
|
||||
b = build()
|
||||
|
||||
try:
|
||||
opts, args = getopt.getopt(sys.argv[1:], "b:c:f:o:p:r:v:s:",
|
||||
["base_dir=", "cmake_build_flags=", "cmake_version_prefix=", "filelist=", "output_dir=", "project_name=", "repository", "version=", "svn_path="])
|
||||
opts, args = getopt.getopt(sys.argv[1:], "b:c:f:o:p:r:v:",
|
||||
["base_dir=", "cmake_build_flags=", "cmake_version_prefix=", "filelist=", "output_dir=", "project_name=", "repository=", "version="])
|
||||
except getopt.GetoptError as err:
|
||||
print >> sys.stderr, err
|
||||
usage()
|
||||
sys.exit(2)
|
||||
|
||||
rpm_filelist = None
|
||||
svn_path = "trunk"
|
||||
b.repository = "TDS"
|
||||
for o, a in opts:
|
||||
if o == "--cmake_build_flags":
|
||||
@@ -246,46 +228,28 @@ def main():
|
||||
b.version_min = version[1]
|
||||
except:
|
||||
die( "Invalid version format (maj.min): %s" % a )
|
||||
if o in ("-s", "--svn_path"):
|
||||
svn_path = a
|
||||
|
||||
b.source_dir_rel = b.repository + "-source"
|
||||
|
||||
svn_destdir = os.path.join( "/tmp", b.source_dir_rel )
|
||||
|
||||
svn_server = "192.168.133.21"
|
||||
if svn_path.startswith('svn://'):
|
||||
b.svn_fullpath = svn_path
|
||||
else:
|
||||
b.svn_fullpath = "svn://%s/%s/%s/" % ( svn_server, b.repository, svn_path )
|
||||
|
||||
# b.check_rpm("ctc_EXTFW_%s" % os_str)
|
||||
|
||||
b.version_rev = getSvn_Release( b.svn_fullpath )
|
||||
b.version_date = getSvn_Date( b.svn_fullpath )
|
||||
b.version_date = os.getenv( "VERSION_DATE" )
|
||||
b.init()
|
||||
b.printOptions()
|
||||
|
||||
rpmbase_dir = os.path.join( os.getenv( "HOME" ), 'rpmbuild' )
|
||||
rpmbase_dir = '/shd/CTC/TOOLS/rpmbuild'
|
||||
project_base_dir = '/builds/projects-domain-live/tds'
|
||||
|
||||
specdir = os.path.join( rpmbase_dir, "SPECS" )
|
||||
if not os.path.exists(specdir):
|
||||
os.makedirs(specdir)
|
||||
|
||||
b.svn_export( b.svn_fullpath, svn_destdir )
|
||||
b.clean_lts_cc_conf(svn_destdir + '/Lts/Projects')
|
||||
specname = b.specname( os.path.join( svn_destdir, "specs" ) )
|
||||
b.copy_spec( b.svn_fullpath,
|
||||
specdir,
|
||||
os.path.join( svn_destdir, "specs", specname ) )
|
||||
b.clean_lts_cc_conf(os.path.join(project_base_dir, 'Lts', 'Projects'))
|
||||
specname = b.specname(os.path.join(project_base_dir, 'specs'))
|
||||
b.copy_spec( specdir, os.path.join(project_base_dir, "specs", specname ))
|
||||
|
||||
full_version = "%s.%s-%s" % ( b.version_maj, b.version_min, b.version_rev )
|
||||
b.printOptions()
|
||||
|
||||
b.pack_sources( svn_destdir, os.path.join( rpmbase_dir, "SOURCES" ) )
|
||||
removeDirectory( svn_destdir )
|
||||
b.pack_sources( project_base_dir, os.path.join( rpmbase_dir, "SOURCES" ) )
|
||||
exec_rpmbuild( specdir, specname )
|
||||
|
||||
# move rpms to FOO-1.2-345
|
||||
dstdir = os.path.join( b.output_dir, "%s-%s-%s" % ( b.project_name, b.repository, full_version ) )
|
||||
filter = re.compile( "^.*%s\..*\.rpm$" % full_version )
|
||||
|
||||
Reference in new issue
Block a user