Post-upload tweaks to support RC builds.
This commit is contained in:
parent
a28832b029
commit
3c0683185f
@ -6,19 +6,30 @@ from subprocess import call
|
|||||||
suffix = '.dmg'
|
suffix = '.dmg'
|
||||||
if sys.argv[1] == 'windows':
|
if sys.argv[1] == 'windows':
|
||||||
suffix = '.exe'
|
suffix = '.exe'
|
||||||
|
if sys.argv[1] == 'linux':
|
||||||
|
suffix = '.tar.bz2'
|
||||||
|
|
||||||
|
isReleaseCandidate = False
|
||||||
|
if len(sys.argv) > 2 and sys.argv[2] == 'release':
|
||||||
|
isReleaseCandidate = True
|
||||||
|
|
||||||
allSuffix = '*' + suffix
|
allSuffix = '*' + suffix
|
||||||
|
|
||||||
print "Wildcard pattern is:" + allSuffix
|
print "Wildcard pattern is:" + allSuffix
|
||||||
|
pattern = r'\w+-(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)([\w-]*)' + suffix
|
||||||
pattern = r'FlightGear-(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)-([\w-]+)' + suffix
|
|
||||||
publicNightlyRoot = "/var/www/html/builds/nightly"
|
|
||||||
incomingDir = "/home/jenkins/nightly-incoming"
|
|
||||||
sourceForgePath = "/home/frs/project/f/fl/flightgear/unstable/"
|
|
||||||
sourceForgeUserHost = "jmturner@frs.sourceforge.net"
|
sourceForgeUserHost = "jmturner@frs.sourceforge.net"
|
||||||
sftpCommandFile = "sftp-commands"
|
sftpCommandFile = "sftp-commands"
|
||||||
|
|
||||||
os.chdir(publicNightlyRoot)
|
if isReleaseCandidate:
|
||||||
|
publicRoot = "/var/www/html/builds/rc"
|
||||||
|
incomingDir = "/home/jenkins/incoming"
|
||||||
|
sourceForgePath = "/home/frs/project/f/fl/flightgear/release-candidate/"
|
||||||
|
else:
|
||||||
|
publicRoot = "/var/www/html/builds/nightly"
|
||||||
|
incomingDir = "/home/jenkins/nightly-incoming"
|
||||||
|
sourceForgePath = "/home/frs/project/f/fl/flightgear/unstable/"
|
||||||
|
|
||||||
|
os.chdir(publicRoot)
|
||||||
|
|
||||||
def findFileVersion(dir):
|
def findFileVersion(dir):
|
||||||
for file in os.listdir(dir):
|
for file in os.listdir(dir):
|
||||||
@ -26,14 +37,14 @@ def findFileVersion(dir):
|
|||||||
m = re.match(pattern, file)
|
m = re.match(pattern, file)
|
||||||
if (m is not None):
|
if (m is not None):
|
||||||
return (m.group('major'), m.group('minor'), m.group('patch'))
|
return (m.group('major'), m.group('minor'), m.group('patch'))
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
incomingVer = findFileVersion(incomingDir)
|
incomingVer = findFileVersion(incomingDir)
|
||||||
if incomingVer is None:
|
if incomingVer is None:
|
||||||
print "No incoming files found matching " + allSuffix
|
print "No incoming files found matching " + allSuffix
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
existingVer = findFileVersion('.')
|
existingVer = findFileVersion('.')
|
||||||
|
|
||||||
# if files in dest location mis-match the version, archive them
|
# if files in dest location mis-match the version, archive them
|
||||||
@ -42,11 +53,12 @@ existingVer = findFileVersion('.')
|
|||||||
versionChange = (existingVer != incomingVer)
|
versionChange = (existingVer != incomingVer)
|
||||||
|
|
||||||
oldFiles = []
|
oldFiles = []
|
||||||
|
incomingFiles = []
|
||||||
newFiles = []
|
newFiles = []
|
||||||
|
|
||||||
if versionChange:
|
if versionChange:
|
||||||
print "Version number changing"
|
print "Version number changing"
|
||||||
|
|
||||||
for file in os.listdir('.'):
|
for file in os.listdir('.'):
|
||||||
if fnmatch.fnmatch(file, allSuffix):
|
if fnmatch.fnmatch(file, allSuffix):
|
||||||
if not os.path.islink(file):
|
if not os.path.islink(file):
|
||||||
@ -55,22 +67,33 @@ if versionChange:
|
|||||||
|
|
||||||
for file in os.listdir(incomingDir):
|
for file in os.listdir(incomingDir):
|
||||||
if fnmatch.fnmatch(file, allSuffix):
|
if fnmatch.fnmatch(file, allSuffix):
|
||||||
newFiles.append(file)
|
incomingFiles.append(file)
|
||||||
|
|
||||||
# copy and symlink
|
# copy and symlink
|
||||||
for file in newFiles:
|
for file in incomingFiles:
|
||||||
# move it to the public location
|
# move it to the public location
|
||||||
srcFile = os.path.join(incomingDir, file)
|
srcFile = os.path.join(incomingDir, file)
|
||||||
os.rename(srcFile, file)
|
|
||||||
|
outFile = file
|
||||||
# symlink for stable web URL
|
# insert -rc before suffix
|
||||||
m = re.match(r'FlightGear-\d+\.\d+\.\d+-([\w-]+)' + suffix, file)
|
if isReleaseCandidate:
|
||||||
latestName = 'FlightGear-latest-' + m.group(1) + suffix
|
m = re.match(r'(\w+-\d+\.\d+\.\d+[\w-]*)' + suffix, file)
|
||||||
|
outFile = m.group(1) + '-rc' + suffix
|
||||||
if os.path.exists(latestName):
|
print "RC out name is " + outFile
|
||||||
os.remove(latestName)
|
|
||||||
os.symlink(file, latestName)
|
os.rename(srcFile, outFile)
|
||||||
|
newFiles.append(outFile)
|
||||||
|
|
||||||
|
if not isReleaseCandidate:
|
||||||
|
# symlink for stable web URL
|
||||||
|
m = re.match(r'(\w+)-\d+\.\d+\.\d+-([\w-]+)' + suffix, file)
|
||||||
|
latestName = m.group(1) + '-latest-' + m.group(2) + suffix
|
||||||
|
|
||||||
|
if os.path.exists(latestName):
|
||||||
|
os.remove(latestName)
|
||||||
|
os.symlink(file, latestName)
|
||||||
|
|
||||||
|
|
||||||
# remove files from SF
|
# remove files from SF
|
||||||
if len(oldFiles) > 0:
|
if len(oldFiles) > 0:
|
||||||
f = open(sftpCommandFile, 'w')
|
f = open(sftpCommandFile, 'w')
|
||||||
@ -80,13 +103,11 @@ if len(oldFiles) > 0:
|
|||||||
f.write("rm " + file + '\n')
|
f.write("rm " + file + '\n')
|
||||||
f.write("bye\n")
|
f.write("bye\n")
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
call(["sftp", "-b", sftpCommandFile, sourceForgeUserHost])
|
call(["sftp", "-b", sftpCommandFile, sourceForgeUserHost])
|
||||||
os.remove(sftpCommandFile)
|
os.remove(sftpCommandFile)
|
||||||
|
|
||||||
# upload to SourceForge
|
# upload to SourceForge
|
||||||
for file in newFiles:
|
for file in newFiles:
|
||||||
print "Uploading " + file + " to SourceForge"
|
print "Uploading " + file + " to SourceForge"
|
||||||
call(["scp", file, sourceForgeUserHost + ":" + sourceForgePath + file])
|
call(["scp", file, sourceForgeUserHost + ":" + sourceForgePath + file])
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user