274 lines
No EOL
12 KiB
Python
274 lines
No EOL
12 KiB
Python
import os
|
|
import shutil
|
|
from abc import ABCMeta, abstractmethod
|
|
import sys
|
|
|
|
class CommonLibrary:
|
|
# Release Folder Release description
|
|
releaseDetails = {
|
|
"atlaslayout": ("atlas-layout", "Atlas Layout", ),
|
|
"atlassdk": ("atlas-sdk", "Atlas SDK", ),
|
|
"inksysui": ("ink-system-ui", "Ink System UI", ),
|
|
"atlasreleasenotes": ("atlas-ui-release-notes", "Atlas UI Release notes", ),
|
|
"atlasmcstools": ("atlas-layout", "Atlas MCS Tools Modules", ), # The MCS tools are stored in the atlas-layout releases git repo.
|
|
}
|
|
|
|
workspace = os.getenv("WORKSPACE", "").strip()
|
|
print("Workspace folder is: ", workspace)
|
|
if not workspace:
|
|
print("Workspace folder incorrect")
|
|
sys.exit(1)
|
|
|
|
softwareRelease = os.getenv("SOFTWARE_RELEASE", "").strip()
|
|
print("Software release to publish is:", softwareRelease)
|
|
if not softwareRelease:
|
|
print("No software release has not been specified")
|
|
sys.exit(1)
|
|
|
|
customer = os.getenv("CUSTOMER", "").strip()
|
|
print("Customer to publish to is:", customer)
|
|
if not customer:
|
|
print("No customer has not been specified")
|
|
sys.exit(1)
|
|
|
|
includeAtlas = os.getenv("INCLUDE_ATLAS", "false").strip().lower()
|
|
print("Include Atlas Layout in release:", includeAtlas)
|
|
if not includeAtlas:
|
|
print("No Atlas Layout include parameter has not been specified")
|
|
sys.exit(1)
|
|
|
|
includeInkSystemUI = os.getenv("INCLUDE_INK_SYSTEM_UI", "false").strip().lower()
|
|
print("Include Ink System UI in release:", includeInkSystemUI)
|
|
if not includeInkSystemUI:
|
|
print("No Ink System UI include parameter has not been specified")
|
|
sys.exit(1)
|
|
|
|
includeAtlasSDK = os.getenv("INCLUDE_ATLAS_SDK_TOOLS", "false").strip().lower()
|
|
print("Include Atlas SDK in release:", includeAtlasSDK)
|
|
if not includeAtlasSDK:
|
|
print("No Atlas SDK include parameter has not been specified")
|
|
sys.exit(1)
|
|
|
|
includeMCS = os.getenv("INCLUDE_ATLAS_MCS_TOOLS", "false").strip().lower()
|
|
print("Include Atlas MCS Tools modules in release:", includeMCS)
|
|
if not includeMCS:
|
|
print("No Atlas MCS Tools include parameter has not been specified")
|
|
sys.exit(1)
|
|
|
|
ftpCustomerRootDir = os.getenv("FTP_CUSTOMER_ROOT", "").strip()
|
|
print("FTP root directory:", ftpCustomerRootDir)
|
|
if not ftpCustomerRootDir:
|
|
print("No FTP root directory parameter has not been specified")
|
|
sys.exit(1)
|
|
|
|
ftpClientExe = os.getenv("FTP_CLIENT_LOCATION", "").strip()
|
|
print("FTP client executable:", ftpClientExe)
|
|
if not ftpClientExe:
|
|
print("FTP client executable parameter has not been specified")
|
|
sys.exit(1)
|
|
|
|
ftpURL = os.getenv("FTP_URL", "").strip()
|
|
print("FTP URL:", ftpURL)
|
|
if not ftpURL:
|
|
print("FTP URL parameter has not been specified")
|
|
sys.exit(1)
|
|
|
|
ftpUser = os.getenv("FTP_USER", "").strip()
|
|
print("FTP User:", ftpUser)
|
|
if not ftpUser:
|
|
print("FTP User parameter has not been specified")
|
|
sys.exit(1)
|
|
|
|
ftpPassword = os.getenv("FTP_PASSWORD", "").strip()
|
|
print("FTP Password: ********")
|
|
if not ftpPassword:
|
|
print("FTP Password parameter has not been specified")
|
|
sys.exit(1)
|
|
|
|
def readVersionNumber(versionString):
|
|
versionList = versionString.split(sep='.')
|
|
items = len(versionList)
|
|
if items < 3 or items > 4:
|
|
raise VersionError(versionString)
|
|
major = versionList[0]
|
|
middle = versionList[1]
|
|
minor = versionList[2]
|
|
return (major, middle, minor)
|
|
|
|
def removeReadonly(func, path, _):
|
|
"Clear the readonly bit and reattempt the removal"
|
|
os.chmod(path, stat.S_IWRITE)
|
|
func(path)
|
|
|
|
buildRootDir = os.path.join(workspace, "build")
|
|
def prepareBuildDirectory(transferScriptFile, softwareRelease):
|
|
# Make sure the build directories are cleaned away
|
|
buildRootDir = CommonLibrary.buildRootDir
|
|
if os.path.isdir(buildRootDir):
|
|
shutil.rmtree(buildRootDir, onerror=CommonLibrary.removeReadonly)
|
|
|
|
releaseFolder = "Atlas UI " + softwareRelease
|
|
buildRoot = os.path.join(buildRootDir, releaseFolder)
|
|
os.makedirs(buildRoot)
|
|
|
|
print("option batch continue", file = transferScriptFile)
|
|
print('mkdir "', releaseFolder, '"', file = transferScriptFile, sep='')
|
|
print("option batch abort", file = transferScriptFile)
|
|
print('synchronize remote "', buildRoot, '" "', releaseFolder, '"', file = transferScriptFile, sep='')
|
|
return buildRoot
|
|
|
|
def checkReleaseFolders():
|
|
for _, v in sorted(CommonLibrary.releaseDetails.items()):
|
|
(folder, description) = v
|
|
fullFolderPath = os.path.join(CommonLibrary.workspace, folder)
|
|
if os.path.isdir(fullFolderPath):
|
|
print("Release of", description, "is at folder:", fullFolderPath)
|
|
else:
|
|
print("Could not find folder:", fullFolderPath, " for release of:", description)
|
|
raise ReleaseFolderIssue
|
|
|
|
|
|
def listdir(rootdir):
|
|
for root, directories, filenames in os.walk(rootdir):
|
|
for directory in sorted(directories):
|
|
print(os.path.join(root, directory))
|
|
for filename in sorted(filenames):
|
|
print(os.path.join(root, filename))
|
|
|
|
transferScript = os.path.join(workspace, "transfer.txt")
|
|
|
|
class VersionError(Exception):
|
|
def __init__(self, versionString):
|
|
self._versionString = versionString
|
|
|
|
def __repr__(self):
|
|
return self._versionString
|
|
|
|
class ReleaseFolderIssue(Exception):
|
|
def __init__(self):
|
|
pass
|
|
|
|
class Copier:
|
|
__metaclass__ = ABCMeta
|
|
|
|
def __init__(self, component):
|
|
(self.releaseFolderPath, self.releaseDesc) = CommonLibrary.releaseDetails[component]
|
|
|
|
@abstractmethod
|
|
def transfer(self): pass
|
|
|
|
def description(self):
|
|
return self.releaseDesc
|
|
|
|
def makeDirectories(self, dirs):
|
|
print("Making directories:", dirs)
|
|
os.makedirs(dirs, exist_ok = True)
|
|
|
|
def copyFile(self, src, dest):
|
|
print("Copying from:", src, "to:", dest)
|
|
shutil.copyfile(src, dest)
|
|
|
|
class AtlasLayoutCopierPost2_0_14(Copier):
|
|
def __init__(self):
|
|
Copier.__init__(self, "atlaslayout")
|
|
|
|
def transfer(self, buildRoot, softwareRelease):
|
|
# Do a copy if required
|
|
if CommonLibrary.includeAtlas == "true":
|
|
# Source
|
|
srcRelPath = os.path.join(CommonLibrary.workspace, self.releaseFolderPath)
|
|
|
|
releaseInstaller = os.path.join(srcRelPath, "x64", "GIS Atlas 2", "DiskImages", "DISK1", "GIS Atlas Layout.exe")
|
|
|
|
# Destination
|
|
atlasLayoutBuildRoot = os.path.join(buildRoot, "GIS Atlas Layout Installer")
|
|
self.makeDirectories(atlasLayoutBuildRoot)
|
|
destName = os.path.join(atlasLayoutBuildRoot, "GIS Inkjet OS " + softwareRelease + " Atlas Installer.exe")
|
|
self.copyFile(releaseInstaller, destName)
|
|
|
|
|
|
class AtlasSDKCopier(Copier):
|
|
def __init__(self):
|
|
Copier.__init__(self, "atlassdk")
|
|
|
|
def transfer(self, buildRoot, softwareRelease):
|
|
# Do a copy if required
|
|
if CommonLibrary.includeAtlasSDK == "true":
|
|
# Source
|
|
srcRelPath = os.path.join(CommonLibrary.workspace, self.releaseFolderPath)
|
|
releaseInstaller = os.path.join(srcRelPath, "x64", "GIS Atlas SDK", "DiskImages", "DISK1", "GIS Atlas SDK.exe")
|
|
|
|
# Destination
|
|
atlasSDKBuildRoot = os.path.join(buildRoot, "GIS Atlas Tools SDK Installer")
|
|
self.makeDirectories(atlasSDKBuildRoot)
|
|
destName = os.path.join(atlasSDKBuildRoot, "GIS Atlas Tools SDK " + softwareRelease + " Installer.exe")
|
|
self.copyFile(releaseInstaller, destName)
|
|
|
|
class InkSystemUICopierPost2_0_19(Copier):
|
|
def __init__(self):
|
|
Copier.__init__(self, "inksysui")
|
|
|
|
def transfer(self, buildRoot, softwareRelease):
|
|
# Do a copy if required
|
|
if CommonLibrary.includeInkSystemUI == "true":
|
|
# Source
|
|
srcRelPath = os.path.join(CommonLibrary.workspace, self.releaseFolderPath)
|
|
releaseInstaller = os.path.join(srcRelPath, "x64", "GIS Ink System Configuration UI", "DiskImages", "DISK1", "GIS Atlas Ink System Configuration UI.exe")
|
|
|
|
# Destination
|
|
inkSystemConfigurationUIBuildRoot = os.path.join(buildRoot, "GIS Ink System UI Installer", "Configuration UI")
|
|
self.makeDirectories(inkSystemConfigurationUIBuildRoot)
|
|
destName = os.path.join(inkSystemConfigurationUIBuildRoot, "GIS Atlas Ink System Configuration UI " + softwareRelease + " Installer.exe")
|
|
self.copyFile(releaseInstaller, destName)
|
|
|
|
# Source
|
|
releaseInstaller = os.path.join(srcRelPath, "x64", "GIS Ink System Operator UI", "DiskImages", "DISK1", "GIS Atlas Ink System Operator UI.exe")
|
|
|
|
# Destination
|
|
inkSystemOperatorUIBuildRoot = os.path.join(buildRoot, "GIS Ink System UI Installer", "Operator UI")
|
|
self.makeDirectories(inkSystemOperatorUIBuildRoot)
|
|
destName = os.path.join(inkSystemOperatorUIBuildRoot, "GIS Atlas Ink System Operator UI " + softwareRelease + " Installer.exe")
|
|
self.copyFile(releaseInstaller, destName)
|
|
|
|
# Source
|
|
releaseInstaller = os.path.join(srcRelPath, "x64", "GIS Ink System Tool Modules", "DiskImages", "DISK1", "GIS Atlas Ink System Tool Modules.exe")
|
|
|
|
# Destination
|
|
inkSystemOperatorUIModuleBuildRoot = os.path.join(buildRoot, "GIS Ink System UI Installer", "Operator UI Module")
|
|
self.makeDirectories(inkSystemOperatorUIModuleBuildRoot)
|
|
destName = os.path.join(inkSystemOperatorUIModuleBuildRoot, "GIS Atlas Ink System Operator UI Module " + softwareRelease + " Installer.exe")
|
|
self.copyFile(releaseInstaller, destName)
|
|
|
|
class McsToolsCopierPost2_0_28(Copier):
|
|
def __init__(self):
|
|
Copier.__init__(self, "atlasmcstools")
|
|
|
|
def transfer(self, buildRoot, softwareRelease):
|
|
# Do a copy if required
|
|
if CommonLibrary.includeMCS == "true":
|
|
# Source
|
|
srcRelPath = os.path.join(CommonLibrary.workspace, self.releaseFolderPath)
|
|
releaseInstaller = os.path.join(srcRelPath, "x64", "GIS MCS Tool Modules", "DiskImages", "DISK1", "GIS Atlas MCS Tool Modules.exe")
|
|
|
|
# Destination
|
|
mcsToolsBuildRoot = os.path.join(buildRoot, "GIS Atlas MCS Tool Modues Installer")
|
|
self.makeDirectories(mcsToolsBuildRoot)
|
|
destName = os.path.join(mcsToolsBuildRoot, "GIS MCS Tool Modules " + softwareRelease + " Installer.exe")
|
|
self.copyFile(releaseInstaller, destName)
|
|
|
|
class AtlasUIReleaseNotesCopier(Copier):
|
|
def __init__(self):
|
|
Copier.__init__(self, "atlasreleasenotes")
|
|
|
|
def transfer(self, buildRoot, softwareRelease):
|
|
# Unconditionally copy release notes
|
|
|
|
# Source
|
|
srcRelPath = os.path.join(CommonLibrary.workspace, self.releaseFolderPath)
|
|
releaseInstaller = os.path.join(srcRelPath, "Release Notes.txt")
|
|
|
|
# Destination
|
|
releaseNotesBuildRoot = buildRoot
|
|
self.makeDirectories(releaseNotesBuildRoot)
|
|
destName = os.path.join(releaseNotesBuildRoot, "Release Notes.txt")
|
|
self.copyFile(releaseInstaller, destName) |