Create git repo from svn
This commit is contained in:
commit
84d3102f18
12 files changed
+2231
No files matched your search
@@ -0,0 +1 @@
|
||||
.svn/
|
||||
@@ -0,0 +1,35 @@
|
||||
# $Id: ctc_TDS_license.spec.in 1061 2014-07-24 13:37:25Z ehrlicher $
|
||||
# $HeadURL: svn://192.168.133.21/admin/rpmbuild/ctc_TDS_license.spec.in $
|
||||
#
|
||||
#
|
||||
Summary: CTC Software License for @PROJECT@ @VERSION@
|
||||
Name: ctc_@PROJECT@_software_license
|
||||
Version: @VERSION@
|
||||
Release: @RELEASE@
|
||||
License: proprietary
|
||||
Group: Applications/Communications
|
||||
Prefix: /shd/CTC/WS
|
||||
%if 0%{?suse_version} < 1120
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
%endif
|
||||
Vendor: Rheinmetall Defence Electronis GmbH
|
||||
URL: http://www.rheinmetall-defence.com
|
||||
Packager: ctc
|
||||
AutoReqProv: no
|
||||
|
||||
%description
|
||||
CTC TDS Software License for @PROJECT@, runtime until @RUNTIME@
|
||||
|
||||
%changelog
|
||||
#* date +"%a %b %d %Y" text
|
||||
* Wed Mar 19 2014 CE
|
||||
- initial
|
||||
|
||||
%if 0%{?suse_version} < 1120
|
||||
%clean
|
||||
%{__rm} -rf '%{buildroot}'
|
||||
%endif
|
||||
|
||||
%files
|
||||
%defattr(-,ctc,ctc)
|
||||
/shd/CTC/WS/.license.dat
|
||||
@@ -0,0 +1,35 @@
|
||||
# $Id: ctc_WMS_license.spec.in 1061 2014-07-24 13:37:25Z ehrlicher $
|
||||
# $HeadURL: svn://192.168.133.21/admin/rpmbuild/ctc_WMS_license.spec.in $
|
||||
#
|
||||
#
|
||||
Summary: CTC Software License for @PROJECT@ @VERSION@
|
||||
Name: ctc_@PROJECT@_software_license
|
||||
Version: @VERSION@
|
||||
Release: @RELEASE@
|
||||
License: proprietary
|
||||
Group: Applications/Communications
|
||||
Prefix: /shd/CTC/WH
|
||||
%if 0%{?suse_version} < 1120
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
%endif
|
||||
Vendor: Rheinmetall Defence Electronis GmbH
|
||||
URL: http://www.rheinmetall-defence.com
|
||||
Packager: ctc
|
||||
AutoReqProv: no
|
||||
|
||||
%description
|
||||
CTC WMS Software License for @PROJECT@, runtime until @RUNTIME@
|
||||
|
||||
%changelog
|
||||
#* date +"%a %b %d %Y" text
|
||||
* Wed Mar 19 2014 CE
|
||||
- initial
|
||||
|
||||
%if 0%{?suse_version} < 1120
|
||||
%clean
|
||||
%{__rm} -rf '%{buildroot}'
|
||||
%endif
|
||||
|
||||
%files
|
||||
%defattr(-,ctc,ctc)
|
||||
/shd/CTC/WH/.license.dat
|
||||
Executable
+230
@@ -0,0 +1,230 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# $Id: helpers.py 1370 2022-07-05 11:08:18Z wille_m $
|
||||
# $HeadURL: svn://192.168.133.21/admin/rpmbuild/helpers.py $
|
||||
# $Author: wille_m $
|
||||
# Created by Christian Ehrlicher, SLSE, 20013-02-19
|
||||
#
|
||||
|
||||
import getpass
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import stat
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
# helper functions
|
||||
def verbose():
|
||||
verb = os.getenv( "EMERGE_VERBOSE" )
|
||||
if ( not verb == None and verb.isdigit() and int(verb) > 0 ):
|
||||
return int( verb )
|
||||
else:
|
||||
return 0
|
||||
|
||||
def debug( message ):
|
||||
if verbose() > 1:
|
||||
print("debug: %s" % message)
|
||||
return True
|
||||
|
||||
def info( message ):
|
||||
if verbose() > 0:
|
||||
print("info: %s" % message)
|
||||
return True
|
||||
|
||||
def warning( message ):
|
||||
print("warning: %s" % message)
|
||||
return True
|
||||
|
||||
def error( message ):
|
||||
die( message )
|
||||
|
||||
def die( message ):
|
||||
print >> sys.stderr, "emerge fatal error: %s" % message
|
||||
sys.exit( 1 )
|
||||
|
||||
def system( cmdstring, file = None ):
|
||||
debug( "Executing '%s'" % cmdstring )
|
||||
out = subprocess.PIPE
|
||||
if file != None:
|
||||
out = file
|
||||
p = subprocess.Popen( cmdstring, shell=True, stdout=out, stderr=sys.stderr )
|
||||
ret = p.wait()
|
||||
if ( ret != 0 ):
|
||||
die( "Error executing %s (%s)" % (cmdstring, ret) )
|
||||
ret = ""
|
||||
if 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')
|
||||
rx = re.compile('^VERSION = (.*)$')
|
||||
for line in f.readlines():
|
||||
m = rx.match(line)
|
||||
if not m:
|
||||
line = re.sub('\s', '', line)
|
||||
line = re.sub('\([xX]86[-_]64\)', '', line)
|
||||
line = line.replace('SUSE', '')
|
||||
line = line.replace('LinuxEnterpriseServer', 'SLE')
|
||||
line = line.replace('LinuxEnterpriseDesktop', 'SLE')
|
||||
return line.strip()
|
||||
return "unknown"
|
||||
else:
|
||||
f = open('/etc/os-release', 'r')
|
||||
rx = re.compile('^PRETTY_NAME="(.*)"$')
|
||||
for line in f.readlines():
|
||||
m = rx.match(line)
|
||||
if m:
|
||||
return m.group(1).replace(' ','_')
|
||||
return "unknown"
|
||||
|
||||
def removeDirectory( dest_dir ):
|
||||
info( "--------------------------------" )
|
||||
info( "Removing %s" % ( dest_dir ) )
|
||||
info( "--------------------------------" )
|
||||
if ( os.path.exists( dest_dir ) and os.path.isdir( dest_dir ) ):
|
||||
for root, dirs, files in os.walk( dest_dir, topdown=False):
|
||||
for name in files:
|
||||
try:
|
||||
os.remove( os.path.join(root, name) )
|
||||
except:
|
||||
die( "couldn't delete file %s\n ( %s )" % ( name, os.path.join( root, name ) ) )
|
||||
for name in dirs:
|
||||
try:
|
||||
if ( os.path.islink(os.path.join(root, name)) ):
|
||||
os.remove( os.path.join(root, name) )
|
||||
else:
|
||||
os.rmdir( os.path.join(root, name) )
|
||||
except:
|
||||
die( "couldn't delete directory %s\n( %s )" % ( name, os.path.join( root, name ) ) )
|
||||
os.rmdir( dest_dir )
|
||||
|
||||
|
||||
def copySrcDirToDestDir( srcdir, dstdir, perm = None, with_subdirs = True ):
|
||||
info( "--------------------------------" )
|
||||
info( "Copying %s to %s" % ( srcdir, dstdir ) )
|
||||
info( "--------------------------------" )
|
||||
|
||||
while srcdir[-1] == '/':
|
||||
srcdir = srcdir[:-1]
|
||||
if with_subdirs:
|
||||
for root, dirs, files in os.walk( srcdir ):
|
||||
tmpdir = root.replace( srcdir, dstdir )
|
||||
debug( "dstdir = '%s'" % tmpdir )
|
||||
if ( not os.path.exists( tmpdir ) ):
|
||||
debug( "Creating dir '%s'" % tmpdir )
|
||||
os.makedirs( tmpdir )
|
||||
if perm:
|
||||
os.chmod( tmpdir, perm | stat.S_IREAD | stat.S_IRGRP | stat.S_IROTH )
|
||||
for file in files:
|
||||
if os.path.isfile( tmpdir ) and os.path.exists( tmpdir ):
|
||||
os.remove( tmpdir )
|
||||
shutil.copy( os.path.join( root, file ), tmpdir )
|
||||
if perm:
|
||||
f = os.path.join( tmpdir, file )
|
||||
add_perm = 0
|
||||
if os.path.isdir( f ):
|
||||
add_perm = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH
|
||||
else:
|
||||
mode = os.stat( f ).st_mode
|
||||
if (stat.S_IXUSR & mode) == stat.S_IXUSR:
|
||||
add_perm = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH
|
||||
os.chmod( f, perm | add_perm )
|
||||
else:
|
||||
for f in os.listdir( srcdir ):
|
||||
if os.path.isdir( f ):
|
||||
continue
|
||||
shutil.copy( os.path.join( srcdir, f ),
|
||||
os.path.join( dstdir, f ) )
|
||||
|
||||
def moveFilesToDir( srcdir, dstdir, rx_filter = None, with_subdirs = True ):
|
||||
info( "--------------------------------" )
|
||||
info( "Moving files from %s to %s" % ( srcdir, dstdir ) )
|
||||
info( "--------------------------------" )
|
||||
|
||||
moved_files = []
|
||||
if not os.path.exists( dstdir ):
|
||||
os.makedirs( dstdir )
|
||||
if with_subdirs:
|
||||
for root, dirs, files in os.walk( srcdir ):
|
||||
for file in files:
|
||||
if rx_filter and not rx_filter.match( file ):
|
||||
continue
|
||||
src = os.path.join( root, file )
|
||||
dst = os.path.join( dstdir, file )
|
||||
debug( "Move %s to %s" % ( src, dst ) )
|
||||
if os.path.exists( dst ):
|
||||
os.remove( dst )
|
||||
moved_files.append( dst )
|
||||
shutil.move( src, dstdir )
|
||||
else:
|
||||
for f in os.listdir( srcdir ):
|
||||
if os.path.isdir( f ):
|
||||
continue
|
||||
if rx_filter and not rx_filter.match( f ):
|
||||
continue
|
||||
src = os.path.join( srcdir, file )
|
||||
dst = os.path.join( dstdir, file )
|
||||
debug( "Move %s to %s" % ( src, dst ) )
|
||||
moved_files.append( dst )
|
||||
shutil.move( src, dstdir )
|
||||
return moved_files
|
||||
|
||||
def adjustPermissions( srcdir ):
|
||||
info( "--------------------------------" )
|
||||
info( "Adjusting permissions in %s" % srcdir )
|
||||
info( "--------------------------------" )
|
||||
|
||||
stat_file = stat.S_IREAD | stat.S_IWRITE | stat.S_IRUSR | stat.S_IROTH
|
||||
stat_executable = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH
|
||||
stat_dir = stat_file | stat_executable
|
||||
while srcdir[-1] == '/':
|
||||
srcdir = srcdir[:-1]
|
||||
for root, dirs, files in os.walk( srcdir ):
|
||||
os.chmod( root, )
|
||||
for file in files:
|
||||
f = os.path.join( root, file )
|
||||
perm = 0
|
||||
if os.path.isdir( f ):
|
||||
perm = stat_dir
|
||||
else:
|
||||
perm = stat_file
|
||||
mode = os.stat( f ).st_mode
|
||||
if (stat.S_IXUSR & mode) == stat.S_IXUSR:
|
||||
perm |= stat_executable
|
||||
os.chmod( f, perm )
|
||||
|
||||
def exec_rpmbuild( spec_dir, spec_filename, buildroot = None ):
|
||||
spec = os.path.join( spec_dir, spec_filename )
|
||||
cmd = "rpmbuild -ba %s" % spec
|
||||
if buildroot:
|
||||
cmd += " --buildroot=%s" % buildroot
|
||||
system( cmd, sys.stdout ) and die( "during rpmbuild. cmd: %s" % command )
|
||||
|
||||
Executable
+56
@@ -0,0 +1,56 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $Id: make_license_rpm.sh 1100 2014-08-04 08:26:12Z ehrlicher $
|
||||
# $HeadURL: svn://192.168.133.21/admin/rpmbuild/make_license_rpm.sh $
|
||||
#
|
||||
if [ $# -ne 6 ] ; then
|
||||
echo "Invalid param count: $0 <generate_license_executable> <product (WMS|TDS)> <project (ratc_mulino)> <version> <release> <expire date>"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
GEN_LIC_EXECUTABLE=$1
|
||||
PRODUCT=$2
|
||||
PROJECT=$3
|
||||
VERSION=$4
|
||||
RELEASE=$5
|
||||
EXPIRE_DATE=$6
|
||||
|
||||
if [ "x$PRODUCT" != "xWMS" ] && [ "x$PRODUCT" != "xTDS" ] ; then
|
||||
echo "Invalid product '$PRODUCT";
|
||||
exit -2
|
||||
fi
|
||||
RPM_BUILDROOT=`mktemp -d`
|
||||
|
||||
LIC_FILE_DIR=${RPM_BUILDROOT}"/shd/CTC/WH"
|
||||
if [ "$PRODUCT" == "TDS" ] ; then
|
||||
LIC_FILE_DIR=${RPM_BUILDROOT}"/shd/CTC/WS"
|
||||
fi
|
||||
mkdir -p ${LIC_FILE_DIR}
|
||||
LIC_FILE_TEMP=${LIC_FILE_DIR}"/.license.dat"
|
||||
|
||||
echo $LIC_FILE_DIR
|
||||
echo $LIC_FILE_TEMP
|
||||
|
||||
# generate license file
|
||||
${GEN_LIC_EXECUTABLE} ${PRODUCT} ${VERSION} ${EXPIRE_DATE} ${LIC_FILE_TEMP}
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error executing ${GEN_LIC_EXECUTBLE} - aborting"
|
||||
exit -2
|
||||
fi
|
||||
|
||||
# generating spec file
|
||||
COMPLETE_PROJECT="${PROJECT}-${PRODUCT}"
|
||||
SPEC_FILE="${COMPLETE_PROJECT}_software_license.spec"
|
||||
SPEC_FILE_IN="ctc_${PRODUCT}_license.spec.in"
|
||||
echo "Generating $SPEC_FILE"
|
||||
cat $SPEC_FILE_IN | sed "s/@PROJECT@/${COMPLETE_PROJECT}/g" | sed "s/@VERSION@/${VERSION}/g" | sed "s/@RUNTIME@/${EXPIRE_DATE}/g" | sed "s/@RELEASE@/${RELEASE}/g" > ${SPEC_FILE}
|
||||
|
||||
# executing RPM
|
||||
echo "Creating RPM"
|
||||
rpmbuild -bb --target=noarch $SPEC_FILE --buildroot=${RPM_BUILDROOT}
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error executing rpmbuild - aborting"
|
||||
exit -3
|
||||
fi
|
||||
|
||||
#rm -r ${LIC_FILE_DIR}
|
||||
Executable
+307
@@ -0,0 +1,307 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# $Id: make_rpm.py 1382 2023-10-09 04:11:49Z fritsche_h $
|
||||
# $HeadURL: svn://192.168.133.21/admin/rpmbuild/make_rpm.py $
|
||||
# $Author: fritsche_h $
|
||||
# Created by Christian Ehrlicher, SLSE, 20013-02-19
|
||||
#
|
||||
|
||||
import datetime
|
||||
import getopt
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
import ConfigParser
|
||||
import fnmatch
|
||||
|
||||
# helper functions
|
||||
loc = os.path.dirname( sys.argv[0] )
|
||||
loc = os.path.abspath( loc )
|
||||
exec(compile(open('helpers.py').read(), 'helpers.py', 'exec'))
|
||||
|
||||
class build(object):
|
||||
def __init__( self ):
|
||||
self.project_name = 'ctc'
|
||||
self.base_dir = os.getcwd()
|
||||
self.cmake_build_flags = None
|
||||
self.output_dir = "/shd/CTC/TOOLS/TDS-rpmbuild/"
|
||||
self.version_maj = 1
|
||||
self.version_min = 1
|
||||
self.version_rev = 0
|
||||
self.cmake_version_prefix = "TDS"
|
||||
self.source_dir_rel = "TDS-Source"
|
||||
self.svn_fullpath = None
|
||||
|
||||
self.buildtype = os.getenv( "CMAKE_BUILD_TYPE" )
|
||||
if self.buildtype == None or self.buildtype == "":
|
||||
self.buildtype = 'RelWithDebInfo'
|
||||
|
||||
self.cmake_generator = 'Unix Makefiles'
|
||||
|
||||
def init( self ):
|
||||
self.extfw_dir = "%s/EXTFW-inst/opt/EXTFW" % self.base_dir
|
||||
if not os.path.exists( self.extfw_dir ):
|
||||
self.extfw_dir = '/opt/EXTFW'
|
||||
os.environ["EXTFW"] = self.extfw_dir
|
||||
os.environ["CMAKE_PREFIX_PATH"] = self.extfw_dir
|
||||
|
||||
def printOptions( self ):
|
||||
print("Config options")
|
||||
print("**************")
|
||||
print(" Using base dir: %s" % self.base_dir)
|
||||
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(" 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 )
|
||||
|
||||
def xzfilename( self ):
|
||||
return self.project_name + '_' + self.repository + '_' + getOS_Name() + '-' + self.version_str() + '.tar.xz'
|
||||
|
||||
def specname( self, specdir ):
|
||||
specname = 'ctc_%s_%s.spec' % ( self.repository, self.project_name )
|
||||
debug( "specname: %s" % os.path.join( specdir, specname ) )
|
||||
if os.path.exists( os.path.join( specdir, specname ) ):
|
||||
return specname
|
||||
specname = 'ctc_%s.spec' % ( self.repository )
|
||||
debug( "specname: %s" % os.path.join( specdir, specname ) )
|
||||
if os.path.exists( os.path.join( specdir, specname ) ):
|
||||
return specname
|
||||
specname = 'lts.spec'
|
||||
debug( "specname: %s" % os.path.join( specdir, specname ) )
|
||||
if os.path.exists( os.path.join( specdir, specname ) ):
|
||||
return specname
|
||||
specname = 'ctc.spec'
|
||||
debug( "specname: %s" % os.path.join( specdir, specname ) )
|
||||
if os.path.exists( os.path.join( specdir, specname ) ):
|
||||
return specname
|
||||
specname = '%s.spec' % self.project_name
|
||||
debug( "specname: %s" % os.path.join( specdir, specname ) )
|
||||
if os.path.exists( os.path.join( specdir, specname ) ):
|
||||
return specname
|
||||
die( 'Unable to find a valid spec file in %s' % specdir )
|
||||
|
||||
def copy_spec( self, svn_fullpath, dest_dir, spec_fullpath ):
|
||||
# copy spec to build
|
||||
f = open( spec_fullpath, 'r' )
|
||||
content = f.read()
|
||||
f.close()
|
||||
|
||||
# Jenkins Build Tag (wird von Jenkins gesetzt wenn darüber gebaut wird)
|
||||
jenkins_build_tag = os.getenv( "BUILD_TAG" )
|
||||
if jenkins_build_tag == None or len(jenkins_build_tag) == 0:
|
||||
jenkins_build_tag = 'Not build with jenkins job'
|
||||
|
||||
# Versionsinformationen übergeben
|
||||
cmake_flags = ""
|
||||
cmake_flags += '-D%s_VERSION_MAJOR:STRING="%s" ' % (self.cmake_version_prefix, self.version_maj)
|
||||
cmake_flags += '-D%s_VERSION_MINOR:STRING="%s" ' % (self.cmake_version_prefix, self.version_min)
|
||||
cmake_flags += '-D%s_VERSION_REV:STRING="%s" ' % (self.cmake_version_prefix, self.version_rev)
|
||||
cmake_flags += '-D%s_VERSION_PATCH:STRING="%s" ' % (self.cmake_version_prefix, self.version_rev)
|
||||
cmake_flags += '-D%s_VERSION_DATE:STRING="%s" ' % (self.cmake_version_prefix, self.version_date)
|
||||
cmake_flags += '-D_pname:STRING="%s" ' % (self.project_name)
|
||||
|
||||
jenkins_build_number = os.getenv( "BUILD_NUMBER" )
|
||||
if jenkins_build_number != None:
|
||||
cmake_flags += '-DJENKINS_BUILD_NUMBER:STRING="%s" '% (jenkins_build_number)
|
||||
|
||||
if self.cmake_build_flags:
|
||||
cmake_flags += ' %s ' % self.cmake_build_flags
|
||||
|
||||
# und den Buildtype
|
||||
cmake_flags += '-DCMAKE_BUILD_TYPE="%s" ' % self.buildtype
|
||||
|
||||
filename = 'project.%s.cfg' % self.project_name
|
||||
cmake_flags += '-DTDS_PROJECT_CONFIG_FILE=%s ' % filename
|
||||
|
||||
content = content.replace( "@PROJECT@", self.project_name )
|
||||
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( "@SOURCE_DIR_REL@", self.source_dir_rel )
|
||||
content = content.replace( "@SOURCES@", self.xzfilename() )
|
||||
content = content.replace( "@APPLICATION@", self.repository )
|
||||
content = content.replace( "@CMAKE_FLAGS@ ", cmake_flags )
|
||||
content = content.replace( "@JENKINS_BUILD_TAG@", jenkins_build_tag )
|
||||
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()
|
||||
|
||||
def clean_lts_cc_conf(self, folder):
|
||||
config_files = []
|
||||
for root, dirs, files in os.walk(folder):
|
||||
for name in files:
|
||||
if fnmatch.fnmatch(name, 'lts-cc*conf'):
|
||||
config_files.append(os.path.join(root, name))
|
||||
|
||||
for config_file in config_files:
|
||||
config = ConfigParser.RawConfigParser()
|
||||
config.optionxform = str
|
||||
config.read(config_file)
|
||||
|
||||
for section in config.sections():
|
||||
if len(config.items(section)) == 0:
|
||||
config.remove_section(section)
|
||||
|
||||
with open(config_file, 'w') as file:
|
||||
config.write(file)
|
||||
|
||||
def pack_sources( self, src_dir, dest_dir ):
|
||||
xzfilename = self.xzfilename()
|
||||
xzfilename = os.path.join( dest_dir, xzfilename )
|
||||
|
||||
info( "--------------------------------" )
|
||||
info( "Packing sources in %s to %s" % ( src_dir, xzfilename ) )
|
||||
info( "--------------------------------" )
|
||||
|
||||
removeDirectory( xzfilename ) # falls es ein directory ist
|
||||
if os.path.exists( xzfilename ): # falls es eine datei ist
|
||||
os.remove( xzfilename )
|
||||
if not os.path.exists( dest_dir ):
|
||||
os.makedirs( dest_dir )
|
||||
|
||||
os.chdir( os.path.split( src_dir )[0] )
|
||||
cmd = "tar cJf %s %s" % ( xzfilename, os.path.split( src_dir )[1] )
|
||||
system( cmd, sys.stdout ) and die( "while packing. cmd: %s" % command )
|
||||
|
||||
# svn export ${svn} ${base}
|
||||
|
||||
# fixup_rde_header ${base} "c"
|
||||
# fixup_rde_header ${base} "h"
|
||||
# fixup_rde_header ${base} "cpp"
|
||||
# fixup_rde_header ${base} "hpp"
|
||||
# fixup_rde_header ${base} "txt"
|
||||
# fixup_rde_header ${base} "py"
|
||||
|
||||
# cp ${base}/specs/ctc.spec /usr/src/packages/SPECS/
|
||||
|
||||
|
||||
def usage():
|
||||
print >> sys.stdout, "Usage: %s [-b <base_dir> ] -f <filelist> -o <output_dir> -r <repository> -v <version> -s <svn_path>" % sys.argv[0]
|
||||
|
||||
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="])
|
||||
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":
|
||||
b.cmake_build_flags = a
|
||||
print("build flags: ", b.cmake_build_flags)
|
||||
if o in ("-b", "--base_dir"):
|
||||
b.base_dir = a
|
||||
if o in ("-f", "--filelist"):
|
||||
rpm_filelist = a
|
||||
if o in ("-o", "--output_dir"):
|
||||
b.output_dir = a
|
||||
if o in ("-c", "--cmake_version_prefix"):
|
||||
b.cmake_version_prefix = a
|
||||
if o in ("-p", "--project_name"):
|
||||
b.project_name = a
|
||||
if o in ("-r", "--repository"):
|
||||
b.repository = a
|
||||
if o in ("-v", "--version"):
|
||||
version = a.split('.')
|
||||
try:
|
||||
b.version_maj = version[0]
|
||||
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 = "slssvn"
|
||||
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.init()
|
||||
b.printOptions()
|
||||
|
||||
rpmbase_dir = os.path.join( os.getenv( "HOME" ), 'rpmbuild' )
|
||||
|
||||
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 ) )
|
||||
|
||||
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 )
|
||||
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 )
|
||||
moved_files = moveFilesToDir( rpmbase_dir,
|
||||
dstdir,
|
||||
filter,
|
||||
True
|
||||
)
|
||||
|
||||
if rpm_filelist != None:
|
||||
try:
|
||||
f = open( rpm_filelist, 'w' )
|
||||
for m in moved_files:
|
||||
f.write( '%s\n' % m )
|
||||
f.close()
|
||||
except:
|
||||
die( 'Error creating fileslist %s' % rpm_filelist )
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Executable
+305
@@ -0,0 +1,305 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# $Id: make_rpm15.2.py 1382 2023-10-09 04:11:49Z fritsche_h $
|
||||
# $HeadURL: svn://192.168.133.21/admin/rpmbuild/make_rpm15.2.py $
|
||||
# $Author: fritsche_h $
|
||||
# Created by Christian Ehrlicher, SLSE, 20013-02-19
|
||||
#
|
||||
|
||||
import datetime
|
||||
import getopt
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
import ConfigParser
|
||||
import fnmatch
|
||||
|
||||
# helper functions
|
||||
loc = os.path.dirname( sys.argv[0] )
|
||||
loc = os.path.abspath( loc )
|
||||
exec(compile(open('helpers.py').read(), 'helpers.py', 'exec'))
|
||||
|
||||
class build(object):
|
||||
def __init__( self ):
|
||||
self.project_name = 'ctc'
|
||||
self.base_dir = os.getcwd()
|
||||
self.cmake_build_flags = None
|
||||
self.output_dir = "/shd/CTC/TOOLS/TDS-rpmbuild/"
|
||||
self.version_maj = 1
|
||||
self.version_min = 1
|
||||
self.version_rev = 0
|
||||
self.cmake_version_prefix = "TDS"
|
||||
self.source_dir_rel = "TDS-Source"
|
||||
self.svn_fullpath = None
|
||||
|
||||
self.buildtype = os.getenv( "CMAKE_BUILD_TYPE" )
|
||||
if self.buildtype == None or self.buildtype == "":
|
||||
self.buildtype = 'RelWithDebInfo'
|
||||
|
||||
self.cmake_generator = 'Unix Makefiles'
|
||||
|
||||
def init( self ):
|
||||
self.extfw_dir = "%s/EXTFW-inst/opt/EXTFW" % self.base_dir
|
||||
if not os.path.exists( self.extfw_dir ):
|
||||
self.extfw_dir = '/opt/EXTFW'
|
||||
os.environ["EXTFW"] = self.extfw_dir
|
||||
os.environ["CMAKE_PREFIX_PATH"] = self.extfw_dir
|
||||
|
||||
def printOptions( self ):
|
||||
print("Config options")
|
||||
print("**************")
|
||||
print(" Using base dir: %s" % self.base_dir)
|
||||
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(" 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 )
|
||||
|
||||
def xzfilename( self ):
|
||||
return self.project_name + '_' + self.repository + '_' + getOS_Name() + '-' + self.version_str() + '.tar.xz'
|
||||
|
||||
def specname( self, specdir ):
|
||||
specname = 'ctc_%s_%s.spec' % ( self.repository, self.project_name )
|
||||
debug( "specname: %s" % os.path.join( specdir, specname ) )
|
||||
if os.path.exists( os.path.join( specdir, specname ) ):
|
||||
return specname
|
||||
specname = 'ctc_%s.spec' % ( self.repository )
|
||||
debug( "specname: %s" % os.path.join( specdir, specname ) )
|
||||
if os.path.exists( os.path.join( specdir, specname ) ):
|
||||
return specname
|
||||
specname = 'lts15.2.spec'
|
||||
debug( "specname: %s" % os.path.join( specdir, specname ) )
|
||||
if os.path.exists( os.path.join( specdir, specname ) ):
|
||||
return specname
|
||||
specname = 'ctc.spec'
|
||||
debug( "specname: %s" % os.path.join( specdir, specname ) )
|
||||
if os.path.exists( os.path.join( specdir, specname ) ):
|
||||
return specname
|
||||
specname = '%s.spec' % self.project_name
|
||||
debug( "specname: %s" % os.path.join( specdir, specname ) )
|
||||
if os.path.exists( os.path.join( specdir, specname ) ):
|
||||
return specname
|
||||
die( 'Unable to find a valid spec file in %s' % specdir )
|
||||
|
||||
def copy_spec( self, svn_fullpath, dest_dir, spec_fullpath ):
|
||||
# copy spec to build
|
||||
f = open( spec_fullpath, 'r' )
|
||||
content = f.read()
|
||||
f.close()
|
||||
|
||||
# Jenkins Build Tag (wird von Jenkins gesetzt wenn darüber gebaut wird)
|
||||
jenkins_build_tag = os.getenv( "BUILD_TAG" )
|
||||
if jenkins_build_tag == None or len(jenkins_build_tag) == 0:
|
||||
jenkins_build_tag = 'Not build with jenkins job'
|
||||
|
||||
# Versionsinformationen übergeben
|
||||
cmake_flags = ""
|
||||
cmake_flags += '-D%s_VERSION_MAJOR:STRING="%s" ' % (self.cmake_version_prefix, self.version_maj)
|
||||
cmake_flags += '-D%s_VERSION_MINOR:STRING="%s" ' % (self.cmake_version_prefix, self.version_min)
|
||||
cmake_flags += '-D%s_VERSION_REV:STRING="%s" ' % (self.cmake_version_prefix, self.version_rev)
|
||||
cmake_flags += '-D%s_VERSION_PATCH:STRING="%s" ' % (self.cmake_version_prefix, self.version_rev)
|
||||
cmake_flags += '-D%s_VERSION_DATE:STRING="%s" ' % (self.cmake_version_prefix, self.version_date)
|
||||
jenkins_build_number = os.getenv( "BUILD_NUMBER" )
|
||||
if jenkins_build_number != None:
|
||||
cmake_flags += '-DJENKINS_BUILD_NUMBER:STRING="%s" '% (jenkins_build_number)
|
||||
|
||||
if self.cmake_build_flags:
|
||||
cmake_flags += ' %s ' % self.cmake_build_flags
|
||||
|
||||
# und den Buildtype
|
||||
cmake_flags += '-DCMAKE_BUILD_TYPE="%s" ' % self.buildtype
|
||||
|
||||
filename = 'project.%s.cfg' % self.project_name
|
||||
cmake_flags += '-DTDS_PROJECT_CONFIG_FILE=%s ' % filename
|
||||
|
||||
content = content.replace( "@PROJECT@", self.project_name )
|
||||
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( "@SOURCE_DIR_REL@", self.source_dir_rel )
|
||||
content = content.replace( "@SOURCES@", self.xzfilename() )
|
||||
content = content.replace( "@APPLICATION@", self.repository )
|
||||
content = content.replace( "@CMAKE_FLAGS@ ", cmake_flags )
|
||||
content = content.replace( "@JENKINS_BUILD_TAG@", jenkins_build_tag )
|
||||
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()
|
||||
|
||||
def clean_lts_cc_conf(self, folder):
|
||||
config_files = []
|
||||
for root, dirs, files in os.walk(folder):
|
||||
for name in files:
|
||||
if fnmatch.fnmatch(name, 'lts-cc*conf'):
|
||||
config_files.append(os.path.join(root, name))
|
||||
|
||||
for config_file in config_files:
|
||||
config = ConfigParser.RawConfigParser()
|
||||
config.optionxform = str
|
||||
config.read(config_file)
|
||||
|
||||
for section in config.sections():
|
||||
if len(config.items(section)) == 0:
|
||||
config.remove_section(section)
|
||||
|
||||
with open(config_file, 'w') as file:
|
||||
config.write(file)
|
||||
|
||||
def pack_sources( self, src_dir, dest_dir ):
|
||||
xzfilename = self.xzfilename()
|
||||
xzfilename = os.path.join( dest_dir, xzfilename )
|
||||
|
||||
info( "--------------------------------" )
|
||||
info( "Packing sources in %s to %s" % ( src_dir, xzfilename ) )
|
||||
info( "--------------------------------" )
|
||||
|
||||
removeDirectory( xzfilename ) # falls es ein directory ist
|
||||
if os.path.exists( xzfilename ): # falls es eine datei ist
|
||||
os.remove( xzfilename )
|
||||
if not os.path.exists( dest_dir ):
|
||||
os.makedirs( dest_dir )
|
||||
|
||||
os.chdir( os.path.split( src_dir )[0] )
|
||||
cmd = "tar cJf %s %s" % ( xzfilename, os.path.split( src_dir )[1] )
|
||||
system( cmd, sys.stdout ) and die( "while packing. cmd: %s" % command )
|
||||
|
||||
# svn export ${svn} ${base}
|
||||
|
||||
# fixup_rde_header ${base} "c"
|
||||
# fixup_rde_header ${base} "h"
|
||||
# fixup_rde_header ${base} "cpp"
|
||||
# fixup_rde_header ${base} "hpp"
|
||||
# fixup_rde_header ${base} "txt"
|
||||
# fixup_rde_header ${base} "py"
|
||||
|
||||
# cp ${base}/specs/ctc.spec /usr/src/packages/SPECS/
|
||||
|
||||
|
||||
def usage():
|
||||
print >> sys.stdout, "Usage: %s [-b <base_dir> ] -f <filelist> -o <output_dir> -r <repository> -v <version> -s <svn_path>" % sys.argv[0]
|
||||
|
||||
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="])
|
||||
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":
|
||||
b.cmake_build_flags = a
|
||||
print("build flags: ", b.cmake_build_flags)
|
||||
if o in ("-b", "--base_dir"):
|
||||
b.base_dir = a
|
||||
if o in ("-f", "--filelist"):
|
||||
rpm_filelist = a
|
||||
if o in ("-o", "--output_dir"):
|
||||
b.output_dir = a
|
||||
if o in ("-c", "--cmake_version_prefix"):
|
||||
b.cmake_version_prefix = a
|
||||
if o in ("-p", "--project_name"):
|
||||
b.project_name = a
|
||||
if o in ("-r", "--repository"):
|
||||
b.repository = a
|
||||
if o in ("-v", "--version"):
|
||||
version = a.split('.')
|
||||
try:
|
||||
b.version_maj = version[0]
|
||||
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 = "slssvn"
|
||||
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.init()
|
||||
b.printOptions()
|
||||
|
||||
rpmbase_dir = os.path.join( os.getenv( "HOME" ), 'rpmbuild' )
|
||||
|
||||
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 ) )
|
||||
|
||||
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 )
|
||||
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 )
|
||||
moved_files = moveFilesToDir( rpmbase_dir,
|
||||
dstdir,
|
||||
filter,
|
||||
True
|
||||
)
|
||||
|
||||
if rpm_filelist != None:
|
||||
try:
|
||||
f = open( rpm_filelist, 'w' )
|
||||
for m in moved_files:
|
||||
f.write( '%s\n' % m )
|
||||
f.close()
|
||||
except:
|
||||
die( 'Error creating fileslist %s' % rpm_filelist )
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Executable
+308
@@ -0,0 +1,308 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# $Id: make_rpm15.4.py 1382 2023-10-09 04:11:49Z fritsche_h $
|
||||
# $HeadURL: svn://192.168.133.21/admin/rpmbuild/make_rpm15.4.py $
|
||||
# $Author: fritsche_h $
|
||||
# Created by Christian Ehrlicher, SLSE, 20013-02-19
|
||||
#
|
||||
|
||||
import datetime
|
||||
import getopt
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
import ConfigParser
|
||||
import fnmatch
|
||||
|
||||
# helper functions
|
||||
loc = os.path.dirname( sys.argv[0] )
|
||||
loc = os.path.abspath( loc )
|
||||
exec(compile(open('helpers.py').read(), 'helpers.py', 'exec'))
|
||||
|
||||
class build(object):
|
||||
def __init__( self ):
|
||||
self.project_name = 'ctc'
|
||||
self.base_dir = os.getcwd()
|
||||
self.cmake_build_flags = None
|
||||
self.output_dir = "/shd/CTC/TOOLS/TDS-rpmbuild/"
|
||||
self.version_maj = 1
|
||||
self.version_min = 1
|
||||
self.version_rev = 0
|
||||
self.cmake_version_prefix = "TDS"
|
||||
self.source_dir_rel = "TDS-Source"
|
||||
self.svn_fullpath = None
|
||||
|
||||
self.buildtype = os.getenv( "CMAKE_BUILD_TYPE" )
|
||||
if self.buildtype == None or self.buildtype == "":
|
||||
self.buildtype = 'RelWithDebInfo'
|
||||
|
||||
self.cmake_generator = 'Unix Makefiles'
|
||||
|
||||
def init( self ):
|
||||
self.extfw_dir = "%s/EXTFW-inst/opt/EXTFW" % self.base_dir
|
||||
if not os.path.exists( self.extfw_dir ):
|
||||
self.extfw_dir = '/opt/EXTFW'
|
||||
os.environ["EXTFW"] = self.extfw_dir
|
||||
os.environ["CMAKE_PREFIX_PATH"] = self.extfw_dir
|
||||
|
||||
def printOptions( self ):
|
||||
print("Config options")
|
||||
print("**************")
|
||||
print(" Using base dir: %s" % self.base_dir)
|
||||
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(" 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 )
|
||||
|
||||
def xzfilename( self ):
|
||||
return self.project_name + '_' + self.repository + '_' + getOS_Name() + '-' + self.version_str() + '.tar.xz'
|
||||
|
||||
def specname( self, specdir ):
|
||||
specname = 'ctc_%s_%s.spec' % ( self.repository, self.project_name )
|
||||
debug( "specname: %s" % os.path.join( specdir, specname ) )
|
||||
if os.path.exists( os.path.join( specdir, specname ) ):
|
||||
return specname
|
||||
specname = 'ctc_%s.spec' % ( self.repository )
|
||||
debug( "specname: %s" % os.path.join( specdir, specname ) )
|
||||
if os.path.exists( os.path.join( specdir, specname ) ):
|
||||
return specname
|
||||
specname = 'lts15.4.spec'
|
||||
debug( "specname: %s" % os.path.join( specdir, specname ) )
|
||||
if os.path.exists( os.path.join( specdir, specname ) ):
|
||||
return specname
|
||||
specname = 'ctc.spec'
|
||||
debug( "specname: %s" % os.path.join( specdir, specname ) )
|
||||
if os.path.exists( os.path.join( specdir, specname ) ):
|
||||
return specname
|
||||
specname = '%s.spec' % self.project_name
|
||||
debug( "specname: %s" % os.path.join( specdir, specname ) )
|
||||
if os.path.exists( os.path.join( specdir, specname ) ):
|
||||
return specname
|
||||
die( 'Unable to find a valid spec file in %s' % specdir )
|
||||
|
||||
def copy_spec( self, svn_fullpath, dest_dir, spec_fullpath ):
|
||||
# copy spec to build
|
||||
f = open( spec_fullpath, 'r' )
|
||||
content = f.read()
|
||||
f.close()
|
||||
|
||||
# Jenkins Build Tag (wird von Jenkins gesetzt wenn darüber gebaut wird)
|
||||
jenkins_build_tag = os.getenv( "BUILD_TAG" )
|
||||
if jenkins_build_tag == None or len(jenkins_build_tag) == 0:
|
||||
jenkins_build_tag = 'Not build with jenkins job'
|
||||
|
||||
# Versionsinformationen übergeben
|
||||
cmake_flags = ""
|
||||
cmake_flags += '-D%s_VERSION_MAJOR:STRING="%s" ' % (self.cmake_version_prefix, self.version_maj)
|
||||
cmake_flags += '-D%s_VERSION_MINOR:STRING="%s" ' % (self.cmake_version_prefix, self.version_min)
|
||||
cmake_flags += '-D%s_VERSION_REV:STRING="%s" ' % (self.cmake_version_prefix, self.version_rev)
|
||||
cmake_flags += '-D%s_VERSION_PATCH:STRING="%s" ' % (self.cmake_version_prefix, self.version_rev)
|
||||
cmake_flags += '-D%s_VERSION_DATE:STRING="%s" ' % (self.cmake_version_prefix, self.version_date)
|
||||
cmake_flags += '-D_pname:STRING="%s" ' % (self.project_name)
|
||||
|
||||
|
||||
jenkins_build_number = os.getenv( "BUILD_NUMBER" )
|
||||
if jenkins_build_number != None:
|
||||
cmake_flags += '-DJENKINS_BUILD_NUMBER:STRING="%s" '% (jenkins_build_number)
|
||||
|
||||
if self.cmake_build_flags:
|
||||
cmake_flags += ' %s ' % self.cmake_build_flags
|
||||
|
||||
# und den Buildtype
|
||||
cmake_flags += '-DCMAKE_BUILD_TYPE="%s" ' % self.buildtype
|
||||
|
||||
filename = 'project.%s.cfg' % self.project_name
|
||||
cmake_flags += '-DTDS_PROJECT_CONFIG_FILE=%s ' % filename
|
||||
|
||||
content = content.replace( "@PROJECT@", self.project_name )
|
||||
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( "@SOURCE_DIR_REL@", self.source_dir_rel )
|
||||
content = content.replace( "@SOURCES@", self.xzfilename() )
|
||||
content = content.replace( "@APPLICATION@", self.repository )
|
||||
content = content.replace( "@CMAKE_FLAGS@ ", cmake_flags )
|
||||
content = content.replace( "@JENKINS_BUILD_TAG@", jenkins_build_tag )
|
||||
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()
|
||||
|
||||
def clean_lts_cc_conf(self, folder):
|
||||
config_files = []
|
||||
for root, dirs, files in os.walk(folder):
|
||||
for name in files:
|
||||
if fnmatch.fnmatch(name, 'lts-cc*conf'):
|
||||
config_files.append(os.path.join(root, name))
|
||||
|
||||
for config_file in config_files:
|
||||
config = ConfigParser.RawConfigParser()
|
||||
config.optionxform = str
|
||||
config.read(config_file)
|
||||
|
||||
for section in config.sections():
|
||||
if len(config.items(section)) == 0:
|
||||
config.remove_section(section)
|
||||
|
||||
with open(config_file, 'w') as file:
|
||||
config.write(file)
|
||||
|
||||
def pack_sources( self, src_dir, dest_dir ):
|
||||
xzfilename = self.xzfilename()
|
||||
xzfilename = os.path.join( dest_dir, xzfilename )
|
||||
|
||||
info( "--------------------------------" )
|
||||
info( "Packing sources in %s to %s" % ( src_dir, xzfilename ) )
|
||||
info( "--------------------------------" )
|
||||
|
||||
removeDirectory( xzfilename ) # falls es ein directory ist
|
||||
if os.path.exists( xzfilename ): # falls es eine datei ist
|
||||
os.remove( xzfilename )
|
||||
if not os.path.exists( dest_dir ):
|
||||
os.makedirs( dest_dir )
|
||||
|
||||
os.chdir( os.path.split( src_dir )[0] )
|
||||
cmd = "tar cJf %s %s" % ( xzfilename, os.path.split( src_dir )[1] )
|
||||
system( cmd, sys.stdout ) and die( "while packing. cmd: %s" % command )
|
||||
|
||||
# svn export ${svn} ${base}
|
||||
|
||||
# fixup_rde_header ${base} "c"
|
||||
# fixup_rde_header ${base} "h"
|
||||
# fixup_rde_header ${base} "cpp"
|
||||
# fixup_rde_header ${base} "hpp"
|
||||
# fixup_rde_header ${base} "txt"
|
||||
# fixup_rde_header ${base} "py"
|
||||
|
||||
# cp ${base}/specs/ctc.spec /usr/src/packages/SPECS/
|
||||
|
||||
|
||||
def usage():
|
||||
print >> sys.stdout, "Usage: %s [-b <base_dir> ] -f <filelist> -o <output_dir> -r <repository> -v <version> -s <svn_path>" % sys.argv[0]
|
||||
|
||||
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="])
|
||||
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":
|
||||
b.cmake_build_flags = a
|
||||
print("build flags: ", b.cmake_build_flags)
|
||||
if o in ("-b", "--base_dir"):
|
||||
b.base_dir = a
|
||||
if o in ("-f", "--filelist"):
|
||||
rpm_filelist = a
|
||||
if o in ("-o", "--output_dir"):
|
||||
b.output_dir = a
|
||||
if o in ("-c", "--cmake_version_prefix"):
|
||||
b.cmake_version_prefix = a
|
||||
if o in ("-p", "--project_name"):
|
||||
b.project_name = a
|
||||
if o in ("-r", "--repository"):
|
||||
b.repository = a
|
||||
if o in ("-v", "--version"):
|
||||
version = a.split('.')
|
||||
try:
|
||||
b.version_maj = version[0]
|
||||
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 = "slssvn"
|
||||
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.init()
|
||||
b.printOptions()
|
||||
|
||||
rpmbase_dir = os.path.join( os.getenv( "HOME" ), 'rpmbuild' )
|
||||
|
||||
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 ) )
|
||||
|
||||
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 )
|
||||
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 )
|
||||
moved_files = moveFilesToDir( rpmbase_dir,
|
||||
dstdir,
|
||||
filter,
|
||||
True
|
||||
)
|
||||
|
||||
if rpm_filelist != None:
|
||||
try:
|
||||
f = open( rpm_filelist, 'w' )
|
||||
for m in moved_files:
|
||||
f.write( '%s\n' % m )
|
||||
f.close()
|
||||
except:
|
||||
die( 'Error creating fileslist %s' % rpm_filelist )
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Executable
+354
@@ -0,0 +1,354 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# $Id: make_rpmSVOnly.py 1382 2023-10-09 04:11:49Z fritsche_h $
|
||||
# $HeadURL: svn://slssvn/admin/rpmbuild/make_rpmSVOnly.py $
|
||||
# $Author: fritsche_h $
|
||||
# Created by Christian Ehrlicher, SLSE, 20013-02-19
|
||||
#
|
||||
|
||||
import datetime
|
||||
import getopt
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
import ConfigParser
|
||||
import fnmatch
|
||||
|
||||
# helper functions
|
||||
loc = os.path.dirname( sys.argv[0] )
|
||||
loc = os.path.abspath( loc )
|
||||
exec(compile(open('helpers.py').read(), 'helpers.py', 'exec'))
|
||||
|
||||
class build(object):
|
||||
def __init__( self ):
|
||||
self.project_name = 'ctc'
|
||||
self.base_dir = os.getcwd()
|
||||
self.cmake_build_flags = None
|
||||
self.output_dir = "/shd/CTC/TOOLS/TDS-rpmbuild/"
|
||||
self.version_maj = 1
|
||||
self.version_min = 1
|
||||
self.version_rev = 0
|
||||
self.cmake_version_prefix = "TDS"
|
||||
self.source_dir_rel = "TDS-Source"
|
||||
self.svn_fullpath = None
|
||||
self.build_hla_rpm = "false"
|
||||
self.build_sv_rpm = "true"
|
||||
self.build_lic_rpm = "false"
|
||||
self.build_ws_rpm = "false"
|
||||
self.build_bld_rpm = "false"
|
||||
self.build_aar_rpm = "false"
|
||||
|
||||
|
||||
self.buildtype = os.getenv( "CMAKE_BUILD_TYPE" )
|
||||
if self.buildtype == None or self.buildtype == "":
|
||||
self.buildtype = 'RelWithDebInfo'
|
||||
|
||||
self.cmake_generator = 'Unix Makefiles'
|
||||
|
||||
def init( self ):
|
||||
self.extfw_dir = "%s/EXTFW-inst/opt/EXTFW" % self.base_dir
|
||||
if not os.path.exists( self.extfw_dir ):
|
||||
self.extfw_dir = '/opt/EXTFW'
|
||||
os.environ["EXTFW"] = self.extfw_dir
|
||||
os.environ["CMAKE_PREFIX_PATH"] = self.extfw_dir
|
||||
|
||||
def printOptions( self ):
|
||||
print("Config options")
|
||||
print("**************")
|
||||
print(" Using base dir: %s" % self.base_dir)
|
||||
print(" Using extfw dir: %s" % self.extfw_dir)
|
||||
print(" Using buildtype: %s" % self.buildtype)
|
||||
print(" Project name: %s" % self.project_name)
|
||||
print(" Build HLA RPM: %s" % self.build_hla_rpm)
|
||||
print(" Build SV RPM: %s" % self.build_sv_rpm)
|
||||
print(" Build Licence RPM: %s" % self.build_lic_rpm)
|
||||
print(" Build WS RPM: %s" % self.build_ws_rpm)
|
||||
print(" Build Building RPM: %s" % self.build_bld_rpm)
|
||||
print(" Build AAR RPM: %s" % self.build_aar_rpm)
|
||||
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(" 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 )
|
||||
|
||||
def xzfilename( self ):
|
||||
return self.project_name + '_' + self.repository + '_' + getOS_Name() + '-' + self.version_str() + '.tar.xz'
|
||||
|
||||
def specname( self, specdir ):
|
||||
specname = 'ctc_%s_%s.spec' % ( self.repository, self.project_name )
|
||||
debug( "specname: %s" % os.path.join( specdir, specname ) )
|
||||
if os.path.exists( os.path.join( specdir, specname ) ):
|
||||
return specname
|
||||
specname = 'ctc_%s.spec' % ( self.repository )
|
||||
debug( "specname: %s" % os.path.join( specdir, specname ) )
|
||||
if os.path.exists( os.path.join( specdir, specname ) ):
|
||||
return specname
|
||||
specname = 'ltsHLAOnly.spec'
|
||||
debug( "specname: %s" % os.path.join( specdir, specname ) )
|
||||
if os.path.exists( os.path.join( specdir, specname ) ):
|
||||
return specname
|
||||
specname = 'ltsSVOnly.spec'
|
||||
debug( "specname: %s" % os.path.join( specdir, specname ) )
|
||||
if os.path.exists( os.path.join( specdir, specname ) ):
|
||||
return specname
|
||||
specname = 'ctc.spec'
|
||||
debug( "specname: %s" % os.path.join( specdir, specname ) )
|
||||
if os.path.exists( os.path.join( specdir, specname ) ):
|
||||
return specname
|
||||
specname = '%s.spec' % self.project_name
|
||||
debug( "specname: %s" % os.path.join( specdir, specname ) )
|
||||
if os.path.exists( os.path.join( specdir, specname ) ):
|
||||
return specname
|
||||
die( 'Unable to find a valid spec file in %s' % specdir )
|
||||
|
||||
def copy_spec( self, svn_fullpath, dest_dir, spec_fullpath ):
|
||||
# copy spec to build
|
||||
f = open( spec_fullpath, 'r' )
|
||||
content = f.read()
|
||||
f.close()
|
||||
|
||||
# Jenkins Build Tag (wird von Jenkins gesetzt wenn darüber gebaut wird)
|
||||
jenkins_build_tag = os.getenv( "BUILD_TAG" )
|
||||
if jenkins_build_tag == None or len(jenkins_build_tag) == 0:
|
||||
jenkins_build_tag = 'Not build with jenkins job'
|
||||
|
||||
# Versionsinformationen übergeben
|
||||
cmake_flags = ""
|
||||
cmake_flags += '-D%s_VERSION_MAJOR:STRING="%s" ' % (self.cmake_version_prefix, self.version_maj)
|
||||
cmake_flags += '-D%s_VERSION_MINOR:STRING="%s" ' % (self.cmake_version_prefix, self.version_min)
|
||||
cmake_flags += '-D%s_VERSION_REV:STRING="%s" ' % (self.cmake_version_prefix, self.version_rev)
|
||||
cmake_flags += '-D%s_VERSION_PATCH:STRING="%s" ' % (self.cmake_version_prefix, self.version_rev)
|
||||
cmake_flags += '-D%s_VERSION_DATE:STRING="%s" ' % (self.cmake_version_prefix, self.version_date)
|
||||
cmake_flags += '-D_pname:STRING="%s" ' % (self.project_name)
|
||||
|
||||
jenkins_build_number = os.getenv( "BUILD_NUMBER" )
|
||||
if jenkins_build_number != None:
|
||||
cmake_flags += '-DJENKINS_BUILD_NUMBER:STRING="%s" '% (jenkins_build_number)
|
||||
|
||||
if self.cmake_build_flags:
|
||||
cmake_flags += ' %s ' % self.cmake_build_flags
|
||||
|
||||
# und den Buildtype
|
||||
cmake_flags += '-DCMAKE_BUILD_TYPE="%s" ' % self.buildtype
|
||||
|
||||
filename = 'project.%s.cfg' % self.project_name
|
||||
cmake_flags += '-DTDS_PROJECT_CONFIG_FILE=%s ' % filename
|
||||
|
||||
## auto add BuildFlags depending on the modules
|
||||
if self.build_sv_rpm == "true":
|
||||
cmake_flags += '-DBUILD_SV=ON '
|
||||
if self.build_ws_rpm == "true":
|
||||
cmake_flags += '-DBUILD_SV=WS '
|
||||
if self.build_hla_rpm == "true":
|
||||
cmake_flags += '-DBUILD_HLA=ON -DBUILD_SVC_HLA=ON '
|
||||
if self.build_aar_rpm == "true":
|
||||
cmake_flags += '-DBUILD_AAR=ON '
|
||||
|
||||
content = content.replace( "@PROJECT@", self.project_name )
|
||||
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( "@SOURCE_DIR_REL@", self.source_dir_rel )
|
||||
content = content.replace( "@SOURCES@", self.xzfilename() )
|
||||
content = content.replace( "@APPLICATION@", self.repository )
|
||||
content = content.replace( "@CMAKE_FLAGS@ ", cmake_flags )
|
||||
content = content.replace( "@JENKINS_BUILD_TAG@", jenkins_build_tag )
|
||||
content = content.replace( "@BUILDSVNRPM@", self.build_sv_rpm )
|
||||
content = content.replace( "@BUILDRPMHLA@", self.build_hla_rpm )
|
||||
content = content.replace( "@BUILDRPMLIC@", self.build_lic_rpm )
|
||||
# content = content.replace( "@BUILDRPMWS@", self.build_ws_rpm )
|
||||
# content = content.replace( "@BUILDRPMBLD@", self.build_bld_rpm )
|
||||
# content = content.replace( "@BUILDRPMAAR@", self.build_aar_rpm )
|
||||
|
||||
|
||||
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()
|
||||
|
||||
def clean_lts_cc_conf(self, folder):
|
||||
config_files = []
|
||||
for root, dirs, files in os.walk(folder):
|
||||
for name in files:
|
||||
if fnmatch.fnmatch(name, 'lts-cc*conf'):
|
||||
config_files.append(os.path.join(root, name))
|
||||
|
||||
for config_file in config_files:
|
||||
config = ConfigParser.RawConfigParser()
|
||||
config.optionxform = str
|
||||
config.read(config_file)
|
||||
|
||||
for section in config.sections():
|
||||
if len(config.items(section)) == 0:
|
||||
config.remove_section(section)
|
||||
|
||||
with open(config_file, 'w') as file:
|
||||
config.write(file)
|
||||
|
||||
def pack_sources( self, src_dir, dest_dir ):
|
||||
xzfilename = self.xzfilename()
|
||||
xzfilename = os.path.join( dest_dir, xzfilename )
|
||||
|
||||
info( "--------------------------------" )
|
||||
info( "Packing sources in %s to %s" % ( src_dir, xzfilename ) )
|
||||
info( "--------------------------------" )
|
||||
|
||||
removeDirectory( xzfilename ) # falls es ein directory ist
|
||||
if os.path.exists( xzfilename ): # falls es eine datei ist
|
||||
os.remove( xzfilename )
|
||||
if not os.path.exists( dest_dir ):
|
||||
os.makedirs( dest_dir )
|
||||
|
||||
os.chdir( os.path.split( src_dir )[0] )
|
||||
cmd = "tar cJf %s %s" % ( xzfilename, os.path.split( src_dir )[1] )
|
||||
system( cmd, sys.stdout ) and die( "while packing. cmd: %s" % command )
|
||||
|
||||
# svn export ${svn} ${base}
|
||||
|
||||
# fixup_rde_header ${base} "c"
|
||||
# fixup_rde_header ${base} "h"
|
||||
# fixup_rde_header ${base} "cpp"
|
||||
# fixup_rde_header ${base} "hpp"
|
||||
# fixup_rde_header ${base} "txt"
|
||||
# fixup_rde_header ${base} "py"
|
||||
|
||||
# cp ${base}/specs/ctc.spec /usr/src/packages/SPECS/
|
||||
|
||||
|
||||
def usage():
|
||||
print >> sys.stdout, "Usage: %s [-b <base_dir> ] -f <filelist> -o <output_dir> -r <repository> -v <version> -s <svn_path>" % sys.argv[0]
|
||||
|
||||
def main():
|
||||
b = build()
|
||||
|
||||
try:
|
||||
opts, args = getopt.getopt(sys.argv[1:], "a:b:w:d:w:t:l:c:h:f:o:p:r:v:s:",
|
||||
["base_dir=", "build_aar_rpm=", "build_hla_rpm=", "build_ws_rpm=", "build_sv_rpm=", "build_lic_rpm=", "build_bld_rpm=", "cmake_build_flags=", "cmake_version_prefix=", "filelist=", "output_dir=", "project_name=","build_only_hla=", "repository", "version=", "svn_path="])
|
||||
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":
|
||||
b.cmake_build_flags = a
|
||||
print("build flags: ", b.cmake_build_flags)
|
||||
if o in ("-b", "--base_dir"):
|
||||
b.base_dir = a
|
||||
if o in ("-f", "--filelist"):
|
||||
rpm_filelist = a
|
||||
if o in ("-o", "--output_dir"):
|
||||
b.output_dir = a
|
||||
if o in ("-c", "--cmake_version_prefix"):
|
||||
b.cmake_version_prefix = a
|
||||
if o in ("-p", "--project_name"):
|
||||
b.project_name = a
|
||||
if o in ("-h", "--build_hla_rpm"):
|
||||
b.build_hla_rpm = a
|
||||
if o in ("-w", "--build_ws_rpm"):
|
||||
b.build_ws_rpm = a
|
||||
if o in ("-t", "--build_sv_rpm"):
|
||||
b.build_sv_rpm = a
|
||||
if o in ("-l", "--build_lic_rpm"):
|
||||
b.build_lic_rpm = a
|
||||
if o in ("-d", "--build_bld_rpm"):
|
||||
b.build_bld_rpm = a
|
||||
if o in ("-a", "--build_aar_rpm"):
|
||||
b.build_aar_rpm = a
|
||||
if o in ("-r", "--repository"):
|
||||
b.repository = a
|
||||
if o in ("-v", "--version"):
|
||||
version = a.split('.')
|
||||
try:
|
||||
b.version_maj = version[0]
|
||||
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 = "slssvn"
|
||||
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.init()
|
||||
b.printOptions()
|
||||
|
||||
rpmbase_dir = os.path.join( os.getenv( "HOME" ), 'rpmbuild' )
|
||||
|
||||
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 ) )
|
||||
|
||||
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 )
|
||||
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 )
|
||||
moved_files = moveFilesToDir( rpmbase_dir,
|
||||
dstdir,
|
||||
filter,
|
||||
True
|
||||
)
|
||||
|
||||
if rpm_filelist != None:
|
||||
try:
|
||||
f = open( rpm_filelist, 'w' )
|
||||
for m in moved_files:
|
||||
f.write( '%s\n' % m )
|
||||
f.close()
|
||||
except:
|
||||
die( 'Error creating fileslist %s' % rpm_filelist )
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Executable
+307
@@ -0,0 +1,307 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# $Id: make_rpmSVOnly.py 1382 2023-10-09 04:11:49Z fritsche_h $
|
||||
# $HeadURL: svn://192.168.133.21/admin/rpmbuild/make_rpmSVOnly.py $
|
||||
# $Author: fritsche_h $
|
||||
# Created by Christian Ehrlicher, SLSE, 20013-02-19
|
||||
#
|
||||
|
||||
import datetime
|
||||
import getopt
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
import ConfigParser
|
||||
import fnmatch
|
||||
|
||||
# helper functions
|
||||
loc = os.path.dirname( sys.argv[0] )
|
||||
loc = os.path.abspath( loc )
|
||||
exec(compile(open('helpers.py').read(), 'helpers.py', 'exec'))
|
||||
|
||||
class build(object):
|
||||
def __init__( self ):
|
||||
self.project_name = 'ctc'
|
||||
self.base_dir = os.getcwd()
|
||||
self.cmake_build_flags = None
|
||||
self.output_dir = "/shd/CTC/TOOLS/TDS-rpmbuild/"
|
||||
self.version_maj = 1
|
||||
self.version_min = 1
|
||||
self.version_rev = 0
|
||||
self.cmake_version_prefix = "TDS"
|
||||
self.source_dir_rel = "TDS-Source"
|
||||
self.svn_fullpath = None
|
||||
|
||||
self.buildtype = os.getenv( "CMAKE_BUILD_TYPE" )
|
||||
if self.buildtype == None or self.buildtype == "":
|
||||
self.buildtype = 'RelWithDebInfo'
|
||||
|
||||
self.cmake_generator = 'Unix Makefiles'
|
||||
|
||||
def init( self ):
|
||||
self.extfw_dir = "%s/EXTFW-inst/opt/EXTFW" % self.base_dir
|
||||
if not os.path.exists( self.extfw_dir ):
|
||||
self.extfw_dir = '/opt/EXTFW'
|
||||
os.environ["EXTFW"] = self.extfw_dir
|
||||
os.environ["CMAKE_PREFIX_PATH"] = self.extfw_dir
|
||||
|
||||
def printOptions( self ):
|
||||
print("Config options")
|
||||
print("**************")
|
||||
print(" Using base dir: %s" % self.base_dir)
|
||||
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(" 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 )
|
||||
|
||||
def xzfilename( self ):
|
||||
return self.project_name + '_' + self.repository + '_' + getOS_Name() + '-' + self.version_str() + '.tar.xz'
|
||||
|
||||
def specname( self, specdir ):
|
||||
specname = 'ctc_%s_%s.spec' % ( self.repository, self.project_name )
|
||||
debug( "specname: %s" % os.path.join( specdir, specname ) )
|
||||
if os.path.exists( os.path.join( specdir, specname ) ):
|
||||
return specname
|
||||
specname = 'ctc_%s.spec' % ( self.repository )
|
||||
debug( "specname: %s" % os.path.join( specdir, specname ) )
|
||||
if os.path.exists( os.path.join( specdir, specname ) ):
|
||||
return specname
|
||||
specname = 'ltsSVOnly.spec'
|
||||
debug( "specname: %s" % os.path.join( specdir, specname ) )
|
||||
if os.path.exists( os.path.join( specdir, specname ) ):
|
||||
return specname
|
||||
specname = 'ctc.spec'
|
||||
debug( "specname: %s" % os.path.join( specdir, specname ) )
|
||||
if os.path.exists( os.path.join( specdir, specname ) ):
|
||||
return specname
|
||||
specname = '%s.spec' % self.project_name
|
||||
debug( "specname: %s" % os.path.join( specdir, specname ) )
|
||||
if os.path.exists( os.path.join( specdir, specname ) ):
|
||||
return specname
|
||||
die( 'Unable to find a valid spec file in %s' % specdir )
|
||||
|
||||
def copy_spec( self, svn_fullpath, dest_dir, spec_fullpath ):
|
||||
# copy spec to build
|
||||
f = open( spec_fullpath, 'r' )
|
||||
content = f.read()
|
||||
f.close()
|
||||
|
||||
# Jenkins Build Tag (wird von Jenkins gesetzt wenn darüber gebaut wird)
|
||||
jenkins_build_tag = os.getenv( "BUILD_TAG" )
|
||||
if jenkins_build_tag == None or len(jenkins_build_tag) == 0:
|
||||
jenkins_build_tag = 'Not build with jenkins job'
|
||||
|
||||
# Versionsinformationen übergeben
|
||||
cmake_flags = ""
|
||||
cmake_flags += '-D%s_VERSION_MAJOR:STRING="%s" ' % (self.cmake_version_prefix, self.version_maj)
|
||||
cmake_flags += '-D%s_VERSION_MINOR:STRING="%s" ' % (self.cmake_version_prefix, self.version_min)
|
||||
cmake_flags += '-D%s_VERSION_REV:STRING="%s" ' % (self.cmake_version_prefix, self.version_rev)
|
||||
cmake_flags += '-D%s_VERSION_PATCH:STRING="%s" ' % (self.cmake_version_prefix, self.version_rev)
|
||||
cmake_flags += '-D%s_VERSION_DATE:STRING="%s" ' % (self.cmake_version_prefix, self.version_date)
|
||||
cmake_flags += '-D_pname:STRING="%s" ' % (self.project_name)
|
||||
|
||||
jenkins_build_number = os.getenv( "BUILD_NUMBER" )
|
||||
if jenkins_build_number != None:
|
||||
cmake_flags += '-DJENKINS_BUILD_NUMBER:STRING="%s" '% (jenkins_build_number)
|
||||
|
||||
if self.cmake_build_flags:
|
||||
cmake_flags += ' %s ' % self.cmake_build_flags
|
||||
|
||||
# und den Buildtype
|
||||
cmake_flags += '-DCMAKE_BUILD_TYPE="%s" ' % self.buildtype
|
||||
|
||||
filename = 'project.%s.cfg' % self.project_name
|
||||
cmake_flags += '-DTDS_PROJECT_CONFIG_FILE=%s ' % filename
|
||||
|
||||
content = content.replace( "@PROJECT@", self.project_name )
|
||||
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( "@SOURCE_DIR_REL@", self.source_dir_rel )
|
||||
content = content.replace( "@SOURCES@", self.xzfilename() )
|
||||
content = content.replace( "@APPLICATION@", self.repository )
|
||||
content = content.replace( "@CMAKE_FLAGS@ ", cmake_flags )
|
||||
content = content.replace( "@JENKINS_BUILD_TAG@", jenkins_build_tag )
|
||||
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()
|
||||
|
||||
def clean_lts_cc_conf(self, folder):
|
||||
config_files = []
|
||||
for root, dirs, files in os.walk(folder):
|
||||
for name in files:
|
||||
if fnmatch.fnmatch(name, 'lts-cc*conf'):
|
||||
config_files.append(os.path.join(root, name))
|
||||
|
||||
for config_file in config_files:
|
||||
config = ConfigParser.RawConfigParser()
|
||||
config.optionxform = str
|
||||
config.read(config_file)
|
||||
|
||||
for section in config.sections():
|
||||
if len(config.items(section)) == 0:
|
||||
config.remove_section(section)
|
||||
|
||||
with open(config_file, 'w') as file:
|
||||
config.write(file)
|
||||
|
||||
def pack_sources( self, src_dir, dest_dir ):
|
||||
xzfilename = self.xzfilename()
|
||||
xzfilename = os.path.join( dest_dir, xzfilename )
|
||||
|
||||
info( "--------------------------------" )
|
||||
info( "Packing sources in %s to %s" % ( src_dir, xzfilename ) )
|
||||
info( "--------------------------------" )
|
||||
|
||||
removeDirectory( xzfilename ) # falls es ein directory ist
|
||||
if os.path.exists( xzfilename ): # falls es eine datei ist
|
||||
os.remove( xzfilename )
|
||||
if not os.path.exists( dest_dir ):
|
||||
os.makedirs( dest_dir )
|
||||
|
||||
os.chdir( os.path.split( src_dir )[0] )
|
||||
cmd = "tar cJf %s %s" % ( xzfilename, os.path.split( src_dir )[1] )
|
||||
system( cmd, sys.stdout ) and die( "while packing. cmd: %s" % command )
|
||||
|
||||
# svn export ${svn} ${base}
|
||||
|
||||
# fixup_rde_header ${base} "c"
|
||||
# fixup_rde_header ${base} "h"
|
||||
# fixup_rde_header ${base} "cpp"
|
||||
# fixup_rde_header ${base} "hpp"
|
||||
# fixup_rde_header ${base} "txt"
|
||||
# fixup_rde_header ${base} "py"
|
||||
|
||||
# cp ${base}/specs/ctc.spec /usr/src/packages/SPECS/
|
||||
|
||||
|
||||
def usage():
|
||||
print >> sys.stdout, "Usage: %s [-b <base_dir> ] -f <filelist> -o <output_dir> -r <repository> -v <version> -s <svn_path>" % sys.argv[0]
|
||||
|
||||
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="])
|
||||
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":
|
||||
b.cmake_build_flags = a
|
||||
print("build flags: ", b.cmake_build_flags)
|
||||
if o in ("-b", "--base_dir"):
|
||||
b.base_dir = a
|
||||
if o in ("-f", "--filelist"):
|
||||
rpm_filelist = a
|
||||
if o in ("-o", "--output_dir"):
|
||||
b.output_dir = a
|
||||
if o in ("-c", "--cmake_version_prefix"):
|
||||
b.cmake_version_prefix = a
|
||||
if o in ("-p", "--project_name"):
|
||||
b.project_name = a
|
||||
if o in ("-r", "--repository"):
|
||||
b.repository = a
|
||||
if o in ("-v", "--version"):
|
||||
version = a.split('.')
|
||||
try:
|
||||
b.version_maj = version[0]
|
||||
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 = "slssvn"
|
||||
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.init()
|
||||
b.printOptions()
|
||||
|
||||
rpmbase_dir = os.path.join( os.getenv( "HOME" ), 'rpmbuild' )
|
||||
|
||||
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 ) )
|
||||
|
||||
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 )
|
||||
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 )
|
||||
moved_files = moveFilesToDir( rpmbase_dir,
|
||||
dstdir,
|
||||
filter,
|
||||
True
|
||||
)
|
||||
|
||||
if rpm_filelist != None:
|
||||
try:
|
||||
f = open( rpm_filelist, 'w' )
|
||||
for m in moved_files:
|
||||
f.write( '%s\n' % m )
|
||||
f.close()
|
||||
except:
|
||||
die( 'Error creating fileslist %s' % rpm_filelist )
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Executable
+159
@@ -0,0 +1,159 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# $Id: make_rpm_extfw.py 1344 2017-11-16 14:55:23Z ehrlicher $
|
||||
# $HeadURL: svn://192.168.133.21/admin/rpmbuild/make_rpm_extfw.py $
|
||||
# $Author: ehrlicher $
|
||||
# Created by Christian Ehrlicher, SLSE, 20013-12-06
|
||||
#
|
||||
|
||||
import platform
|
||||
import getopt
|
||||
import os
|
||||
import sys
|
||||
|
||||
# helper functions
|
||||
loc = os.path.dirname( sys.argv[0] )
|
||||
loc = os.path.abspath( loc )
|
||||
execfile(os.path.join( loc, 'helpers.py') )
|
||||
|
||||
def copy_spec( src_filepath, dest_path, version_str, version_rev, project ):
|
||||
# copy spec to build
|
||||
f = open( src_filepath, 'r' )
|
||||
content = f.read()
|
||||
f.close()
|
||||
|
||||
# Jenkins Build Tag (wird von Jenkins gesetzt wenn darüber gebaut wird)
|
||||
jenkins_build_tag = os.getenv( "BUILD_TAG" )
|
||||
if jenkins_build_tag == None or len(jenkins_build_tag) == 0:
|
||||
jenkins_build_tag = 'Not build with jenkins job'
|
||||
|
||||
content = content.replace( "@OS_SYSTEM@", getOS_Name() )
|
||||
content = content.replace( "@PACKAGER@", getpass.getuser() )
|
||||
content = content.replace( "@VERSION@", version_str )
|
||||
content = content.replace( "@RELEASE@", version_rev )
|
||||
content = content.replace( "@PROJECT@", project )
|
||||
content = content.replace( "@JENKINS_BUILD_TAG@", jenkins_build_tag )
|
||||
|
||||
f = open( os.path.join( dest_path, os.path.split( src_filepath )[1] ), 'w' )
|
||||
f.write( content )
|
||||
f.close()
|
||||
|
||||
def usage():
|
||||
print >> sys.stdout, "Usage: %s [-e <extfw_src_dir(s)> ] -s <spec_file_loc> -o rpm_output_directory" % sys.argv[0]
|
||||
|
||||
def main():
|
||||
|
||||
try:
|
||||
opts, args = getopt.getopt(sys.argv[1:], "e:f:o:p:r:s:v:",
|
||||
["extfw=", "filelist=", "output_dir=", "project_name=", "repository=", "spec=", "version="])
|
||||
except getopt.GetoptError, err:
|
||||
print >> sys.stderr, err
|
||||
usage()
|
||||
sys.exit(2)
|
||||
|
||||
project_name = 'ctc'
|
||||
repository = 'TDS'
|
||||
output_dir = None
|
||||
rpm_filelist = None
|
||||
extfw_src_dirs = ('/opt/EXTFW').split()
|
||||
spec_file = None
|
||||
version_maj = 1
|
||||
version_min = 0
|
||||
version_rev = 0
|
||||
for o, a in opts:
|
||||
if o in ("-e", "--extfw"):
|
||||
extfw_src_dirs = a.split()
|
||||
if o in ("-f", "--filelist"):
|
||||
rpm_filelist = a
|
||||
if o in ("-o", "--output_dir"):
|
||||
output_dir = a
|
||||
if o in ("-p", "--project_name"):
|
||||
project_name = a
|
||||
if o in ("-rp", "--repository"):
|
||||
repository = a
|
||||
if o in ("-s", "--spec"):
|
||||
spec_file = a
|
||||
if o in ("-v", "--version"):
|
||||
version = a.split('.')
|
||||
try:
|
||||
version_maj = version[0]
|
||||
version_min = version[1]
|
||||
except:
|
||||
die( "Invalid version format (maj.min): %s" % a )
|
||||
|
||||
if not spec_file or not os.path.isfile( spec_file ):
|
||||
usage()
|
||||
die("Spec file location not defined or spec file not found (%s)" % spec_file)
|
||||
|
||||
for src_path in extfw_src_dirs:
|
||||
if not os.path.exists(src_path):
|
||||
usage()
|
||||
die("Source location %s not accessible" % src_path)
|
||||
|
||||
if output_dir == None:
|
||||
usage()
|
||||
die("Output directory not given" )
|
||||
|
||||
# Annahme: spec-File liegt in TDS-source/spec, wir wollen TDS-Source
|
||||
rpmbase_dir = "/usr/src/packages/"
|
||||
try:
|
||||
ver=platform.dist()[1].split('.')[0]
|
||||
if int(ver) >= 12:
|
||||
rpmbase_dir = os.path.join( os.getenv( "HOME" ), 'rpmbuild' )
|
||||
except:
|
||||
print "Could not determine platform - assuming /usr/src/packages as rpmbuild base dir"
|
||||
sys.exit(1)
|
||||
print "Using rpmbuild base dir %s" % rpmbase_dir
|
||||
spec_file = os.path.abspath( spec_file )
|
||||
extfw_path = os.path.join( os.path.dirname( os.path.dirname( spec_file ) ), 'EXTFW' )
|
||||
if not os.path.exists(extfw_path):
|
||||
die("EXTFW svn path %s does not exist" % extfw_path )
|
||||
|
||||
extfw_builddir_base = os.path.join( '/tmp', 'TDS-rpmbuild' )
|
||||
removeDirectory( extfw_builddir_base )
|
||||
for src_path in extfw_src_dirs:
|
||||
while src_path[-1] == '/':
|
||||
src_path = src_path[:-1]
|
||||
tail = src_path.split('/')[-1]
|
||||
|
||||
extfw_builddir_extfw = os.path.join( extfw_builddir_base, 'opt', tail )
|
||||
os.makedirs( extfw_builddir_extfw )
|
||||
copySrcDirToDestDir( src_path, extfw_builddir_extfw, 0644, True )
|
||||
try:
|
||||
os.remove( os.path.join(extfw_builddir_extfw, 'lib64') )
|
||||
except:
|
||||
debug( 'Could not remove lib64 symlink' )
|
||||
|
||||
specdir = os.path.join(rpmbase_dir, "SPECS")
|
||||
version_str = "%s.%s" % ( version_maj, version_min )
|
||||
version_rev = getSvn_Release( extfw_path )
|
||||
version_date = getSvn_Date( extfw_path )
|
||||
full_version = "%s.%s-%s" % ( version_maj, version_min, version_rev )
|
||||
print "Spec-File: %s" % ( spec_file )
|
||||
print "Version: %s" % ( full_version )
|
||||
print "Date: %s" % ( version_date )
|
||||
copy_spec( spec_file, specdir, version_str, version_rev, project_name )
|
||||
exec_rpmbuild( specdir, os.path.split( spec_file )[1], extfw_builddir_base )
|
||||
removeDirectory( extfw_builddir_base )
|
||||
|
||||
# move rpms to FOO-1.2-345
|
||||
dstdir = os.path.join( output_dir, "%s-%s-%s" % ( project_name, repository, full_version ) )
|
||||
filter = re.compile( "^.*%s\..*\.rpm$" % full_version )
|
||||
moved_files = moveFilesToDir( rpmbase_dir,
|
||||
dstdir,
|
||||
filter,
|
||||
True )
|
||||
|
||||
if rpm_filelist != None:
|
||||
try:
|
||||
f = open( rpm_filelist, 'w' )
|
||||
for m in moved_files:
|
||||
f.write( '%s\n' % m )
|
||||
f.close()
|
||||
except:
|
||||
die( 'Error creating fileslist %s' % rpm_filelist )
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Executable
+134
@@ -0,0 +1,134 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# $Id: make_tag.py 1221 2016-05-26 11:00:07Z ehrlicher $
|
||||
# $HeadURL: svn://192.168.133.21/admin/rpmbuild/make_tag.py $
|
||||
# $Author: ehrlicher $
|
||||
# Created by Christian Ehrlicher, SLSE, 20013-02-19
|
||||
#
|
||||
|
||||
import datetime
|
||||
import getopt
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
# helper functions
|
||||
def verbose():
|
||||
verb = os.getenv( "EMERGE_VERBOSE" )
|
||||
if ( not verb == None and verb.isdigit() and int(verb) > 0 ):
|
||||
return int( verb )
|
||||
else:
|
||||
return 0
|
||||
|
||||
def debug( message ):
|
||||
if verbose() > 0:
|
||||
print "emerge debug:", message
|
||||
return True
|
||||
|
||||
def die( message ):
|
||||
print >> sys.stderr, "emerge fatal error: %s" % message
|
||||
sys.exit( 1 )
|
||||
|
||||
def system( cmdstring, file = None ):
|
||||
debug( "Executing '%s'" % cmdstring )
|
||||
out = subprocess.PIPE
|
||||
if file != None:
|
||||
out = file
|
||||
p = subprocess.Popen( cmdstring, shell=True, stdout=out, stderr=sys.stderr )
|
||||
ret = p.wait()
|
||||
if ( ret != 0 ):
|
||||
die( "Error executing %s (%s)" % (cmdstring, ret) )
|
||||
ret = ""
|
||||
if 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 usage():
|
||||
print >> sys.stdout, "Usage: %s [-r repository] [-s source] -p <project_name> -v <version>" % sys.argv[0]
|
||||
print >> sys.stdout, " e.g.: %s -r TDS -s ctc -p tes_uae_ctc -v 4.3" % sys.argv[0]
|
||||
print >> sys.stdout, " e.g.: %s -r AVS -s trunk -p tes_uae_ctc -v 4.3" % sys.argv[0]
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
svn_server = "slssvn"
|
||||
|
||||
try:
|
||||
ip = socket.gethostbyname(socket.gethostname())
|
||||
if ip.startswith('172.'):
|
||||
svn_server = "ECCORAS01"
|
||||
except:
|
||||
print >> sys.stdout, "Using %s as svn server" % svn_server
|
||||
|
||||
try:
|
||||
opts, args = getopt.getopt(sys.argv[1:], "p:r:s:v:",
|
||||
["project_name=", "source=", "repository=", "version=",])
|
||||
except getopt.GetoptError, err:
|
||||
print >> sys.stderr, err
|
||||
usage()
|
||||
sys.exit(2)
|
||||
|
||||
version = None
|
||||
project_name = None
|
||||
svn_repo = "TDS"
|
||||
svn_src = None
|
||||
for o, a in opts:
|
||||
if o in ("-p", "--project_name"):
|
||||
project_name = a
|
||||
if o in ("-r", "--repository"):
|
||||
svn_repo = a
|
||||
if o in ("-s", "--source"):
|
||||
svn_src = a
|
||||
if o in ("-v", "--version"):
|
||||
version = a.split('.')
|
||||
try:
|
||||
version_maj = version[0]
|
||||
version_min = version[1]
|
||||
version = "%s.%s" % ( version_maj, version_min )
|
||||
except:
|
||||
die( "Invalid version format (maj.min): %s" % a )
|
||||
|
||||
if not version or not project_name:
|
||||
usage()
|
||||
die("Version or project name not defined")
|
||||
|
||||
if not svn_src:
|
||||
svn_src = project_name[project_name.rfind('_') + 1:]
|
||||
project = project_name[:project_name.rfind('_'):]
|
||||
subproject_src = svn_src
|
||||
subproject_dst = project_name[project_name.rfind('_') + 1:]
|
||||
|
||||
svn_branch = "svn://%s/%s/branches/%s/stable/%s" % ( svn_server, svn_repo, project, subproject_src )
|
||||
full_version = "%s-%s" % ( version, getSvn_Release( svn_branch ) )
|
||||
svn_tag = "svn://%s/%s/tags/%s/%s/%s_%s-%s" % ( svn_server, svn_repo, project, subproject_dst, project, subproject_dst, full_version )
|
||||
|
||||
print "Project: %s" % project
|
||||
print "SubProject SRC: %s" % subproject_src
|
||||
print "SubProject DST: %s" % subproject_dst
|
||||
print "SVN Path: %s" % svn_branch
|
||||
print "SVN Tag: %s" % svn_tag
|
||||
|
||||
filename = "svn-commit-msg-branch-%s" % project_name
|
||||
f = open( filename, 'w' )
|
||||
f.write( "Tagged TES UAE %s rev %s on %s\n" % ( project_name.upper(), full_version, datetime.date.today().isoformat() ) )
|
||||
f.close()
|
||||
|
||||
system("svn cp %s %s -F %s" % ( svn_branch, svn_tag, filename ) )
|
||||
|
||||
os.remove( filename )
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in new issue
Block a user