Example #1
0
def installAll(
    installPrefix, binaryDestDir, shareDestDir, docDestDir, binaryBuildPath, targetPlatform, cbios, symlinkForBinary
):
    platformVars = extractMakeVariables(
        "build/platform-%s.mk" % targetPlatform,
        dict.fromkeys(("COMPILE_FLAGS", "LINK_FLAGS", "TARGET_FLAGS", "OPENMSX_TARGET_CPU"), ""),
    )
    binaryFileName = "openmsx" + platformVars.get("EXEEXT", "")

    docNodeVars = extractMakeVariables("doc/node.mk")
    docsToInstall = ["doc/" + fileName for fileName in docNodeVars["INSTALL_DOCS"].split()]

    print "  Executable..."
    installDirs(installPrefix + binaryDestDir)
    installFile(binaryBuildPath, installPrefix + binaryDestDir + "/" + binaryFileName)

    print "  Data files..."
    installDirs(installPrefix + shareDestDir)
    installTree("share", installPrefix + shareDestDir, scanTree("share"))

    print "  Documentation..."
    installDirs(installPrefix + docDestDir)
    for path in docsToInstall:
        installFile(path, installPrefix + docDestDir + "/" + basename(path))
    installDirs(installPrefix + docDestDir + "/manual")
    for fileName in listdir("doc/manual"):
        if splitext(fileName)[1] in (".html", ".css", ".png"):
            installFile("doc/manual/" + fileName, installPrefix + docDestDir + "/manual/" + fileName)

    if cbios:
        print "  C-BIOS..."
        installFile("Contrib/README.cbios", installPrefix + docDestDir + "/cbios.txt")
        installTree("Contrib/cbios", installPrefix + shareDestDir + "/machines", scanTree("Contrib/cbios"))

    if hasattr(os, "symlink"):
        print "  Creating symlinks..."
        for machine, alias in (
            ("Toshiba_HX-10", "msx1"),
            ("Philips_NMS_8250", "msx2"),
            ("Panasonic_FS-A1WSX", "msx2plus"),
            ("Panasonic_FS-A1GT", "turbor"),
        ):
            installSymlink(machine + ".xml", installPrefix + shareDestDir + "/machines/" + alias + ".xml")
        if symlinkForBinary and installPrefix == "":

            def createSymlinkToBinary(linkDir):
                if linkDir != binaryDestDir and isdir(linkDir):
                    try:
                        installSymlink(binaryDestDir + "/" + binaryFileName, linkDir + "/" + binaryFileName)
                    except OSError:
                        return False
                    else:
                        return True
                else:
                    return False

            success = createSymlinkToBinary("/usr/local/bin")
            if not success:
                createSymlinkToBinary(expanduser("~/bin"))
Example #2
0
def main(paths):
    versionedPackageName = getVersionedPackageName()
    distBase = 'derived/dist/'
    distPath = distBase + versionedPackageName + '/'

    if isdir(distPath):
        print 'Removing old distribution files...'
        if islink(distPath):
            # Note: Python 2.6 does this check and it seems like a sensible
            #       precaution; since we support Python 2.5 as well we
            #       explictly perform the check before calling rmtree().
            raise OSError(
                'Refusing to recursively delete symlinked directory "%s"' %
                distPath)
        rmtree(distPath)

    print 'Gathering files for distribution...'

    def gather():
        for path in paths:
            if isdir(path):
                for relpath in scanTree(path):
                    yield joinpath(path, relpath)
            else:
                yield path

    installDirs(distPath)
    installTree('.', distPath, gather())

    print 'Creating tarball...'
    # TODO: Try to generate the tarball directly from the provided file lists,
    #       without creating a copy in the "dist" directory first.
    tar = tarfile.open(distBase + versionedPackageName + '.tar.gz', 'w:gz')
    try:
        tar.add(distPath, versionedPackageName)
    finally:
        tar.close()
Example #3
0
def installAll(
	installPrefix, binaryDestDir, shareDestDir, docDestDir,
	binaryBuildPath, targetPlatform, cbios, symlinkForBinary
	):
	platformVars = extractMakeVariables(
		'build/platform-%s.mk' % targetPlatform,
		dict.fromkeys(
			('COMPILE_FLAGS', 'LINK_FLAGS', 'TARGET_FLAGS',
			 'OPENMSX_TARGET_CPU'),
			''
			)
		)
	binaryFileName = 'openmsx' + platformVars.get('EXEEXT', '')

	docNodeVars = extractMakeVariables('doc/node.mk')
	docsToInstall = [
		'doc/' + fileName for fileName in docNodeVars['INSTALL_DOCS'].split()
		]

	print '  Executable...'
	installDirs(installPrefix + binaryDestDir)
	installFile(
		binaryBuildPath,
		installPrefix + binaryDestDir + '/' + binaryFileName
		)

	print '  Data files...'
	installDirs(installPrefix + shareDestDir)
	installTree('share', installPrefix + shareDestDir, scanTree('share'))

	print '  Documentation...'
	installDirs(installPrefix + docDestDir)
	for path in docsToInstall:
		installFile(path, installPrefix + docDestDir + '/' + basename(path))
	installDirs(installPrefix + docDestDir + '/manual')
	for fileName in listdir('doc/manual'):
		if splitext(fileName)[1] in ('.html', '.css', '.png'):
			installFile(
				'doc/manual/' + fileName,
				installPrefix + docDestDir + '/manual/' + fileName
				)

	if cbios:
		print '  C-BIOS...'
		installFile(
			'Contrib/README.cbios', installPrefix + docDestDir + '/cbios.txt'
			)
		installTree(
			'Contrib/cbios', installPrefix + shareDestDir + '/machines',
			scanTree('Contrib/cbios')
			)
		installDirs(installPrefix + shareDestDir + '/systemroms/cbios-old')
		installTree(
			'Contrib/cbios-old',
			installPrefix + shareDestDir + '/systemroms/cbios-old',
			scanTree('Contrib/cbios-old')
			)

	if hasattr(os, 'symlink'):
		print '  Creating symlinks...'
		for machine, alias in (
			('National_CF-3300', 'msx1'),
			('Toshiba_HX-10', 'msx1_eu'),
			('Sony_HB-F900', 'msx2'),
			('Philips_NMS_8250', 'msx2_eu'),
			('Panasonic_FS-A1WSX', 'msx2plus'),
			('Panasonic_FS-A1GT', 'turbor'),
			):
			installSymlink(
				machine + ".xml",
				installPrefix + shareDestDir + '/machines/' + alias + ".xml"
				)
		if symlinkForBinary and installPrefix == '':
			def createSymlinkToBinary(linkDir):
				if linkDir != binaryDestDir and isdir(linkDir):
					try:
						installSymlink(
							binaryDestDir + '/' + binaryFileName,
							linkDir + '/' + binaryFileName
							)
					except OSError:
						return False
					else:
						return True
				else:
					return False
			success = createSymlinkToBinary('/usr/local/bin')
			if not success:
				createSymlinkToBinary(expanduser('~/bin'))
Example #4
0
def installAll(
	installPrefix, binaryDestDir, shareDestDir, docDestDir,
	binaryBuildPath, targetPlatform, cbios, symlinkForBinary
	):
	platformVars = extractMakeVariables(
		'build/platform-%s.mk' % targetPlatform,
		dict.fromkeys(
			('COMPILE_FLAGS', 'LINK_FLAGS', 'TARGET_FLAGS',
			 'OPENMSX_TARGET_CPU'),
			''
			)
		)
	binaryFileName = 'openmsx' + platformVars.get('EXEEXT', '')

	docNodeVars = extractMakeVariables('doc/node.mk')
	docsToInstall = [
		'doc/' + fileName for fileName in docNodeVars['INSTALL_DOCS'].split()
		]

	print('  Executable...')
	installDirs(installPrefix + binaryDestDir)
	installFile(
		binaryBuildPath,
		installPrefix + binaryDestDir + '/' + binaryFileName
		)

	print('  Data files...')
	installDirs(installPrefix + shareDestDir)
	installTree('share', installPrefix + shareDestDir, scanTree('share'))

	print('  Documentation...')
	installDirs(installPrefix + docDestDir)
	for path in docsToInstall:
		installFile(path, installPrefix + docDestDir + '/' + basename(path))
	installDirs(installPrefix + docDestDir + '/manual')
	for fileName in listdir('doc/manual'):
		if splitext(fileName)[1] in ('.html', '.css', '.png'):
			installFile(
				'doc/manual/' + fileName,
				installPrefix + docDestDir + '/manual/' + fileName
				)

	if platform.system() == 'Linux':
		if 'XDG_DATA_HOME' in os.environ:
			desktopShareDestDir = os.environ['XDG_DATA_HOME']
		elif os.geteuid() == 0:
			desktopShareDestDir = '/usr/share'
		else:
			desktopShareDestDir = os.path.expanduser('~/.local/share')
		if isdir(desktopShareDestDir):
			print('  Desktop icons...')
			for i in ['16', '32', '48', '64', '128', '256']:
				Path(desktopShareDestDir + '/icons/hicolor/' + i + 'x' + i + '/apps').mkdir(parents=True, exist_ok=True)
				installFile(
					'share/icons/openMSX-logo-' + i + '.png', desktopShareDestDir + '/icons/hicolor/' + i + 'x' + i + '/apps/openmsx.png'
				)

			print('  Desktop file...')
			Path(desktopShareDestDir + '/applications').mkdir(parents=True, exist_ok=True)
			installFile(
				'Contrib/linux/org.openmsx.openMSX.desktop', desktopShareDestDir + '/applications/org.openmsx.openMSX.desktop'
				)
			print('  Metainfo file...')
			Path(desktopShareDestDir + '/metainfo').mkdir(parents=True, exist_ok=True)
			installFile(
				'Contrib/linux/org.openmsx.openMSX.metainfo.xml', desktopShareDestDir + '/metainfo/org.openmsx.openMSX.metainfo.xml'
				)
		else:
			print('  Failed to install icon, desktop and metainfo files. ' + desktopShareDestDir + ' does not exist.')

	if cbios:
		print('  C-BIOS...')
		installFile(
			'Contrib/README.cbios', installPrefix + docDestDir + '/cbios.txt'
			)
		installTree(
			'Contrib/cbios', installPrefix + shareDestDir + '/machines',
			scanTree('Contrib/cbios')
			)
		installDirs(installPrefix + shareDestDir + '/systemroms/cbios-old')
		installTree(
			'Contrib/cbios-old',
			installPrefix + shareDestDir + '/systemroms/cbios-old',
			scanTree('Contrib/cbios-old')
			)

	if hasattr(os, 'symlink') and os.name != 'nt':
		print('  Creating symlinks...')
		for machine, alias in (
			('National_CF-3300', 'msx1'),
			('Toshiba_HX-10', 'msx1_eu'),
			('Sony_HB-F900', 'msx2'),
			('Philips_NMS_8250', 'msx2_eu'),
			('Panasonic_FS-A1WSX', 'msx2plus'),
			('Panasonic_FS-A1GT', 'turbor'),
			):
			installSymlink(
				machine + ".xml",
				installPrefix + shareDestDir + '/machines/' + alias + ".xml"
				)
		if symlinkForBinary and installPrefix == '':
			def createSymlinkToBinary(linkDir):
				if linkDir != binaryDestDir and isdir(linkDir):
					try:
						installSymlink(
							binaryDestDir + '/' + binaryFileName,
							linkDir + '/' + binaryFileName
							)
					except OSError:
						return False
					else:
						return True
				else:
					return False
			success = createSymlinkToBinary('/usr/local/bin')
			if not success:
				createSymlinkToBinary(expanduser('~/bin'))