def dist(appname='', version=''):
	'''makes a tarball for redistributing the sources'''
	# return return (distdirname, tarballname)
	import tarfile

	if not appname: appname = Utils.g_module.APPNAME
	if not version: version = Utils.g_module.VERSION

	tmp_folder = appname + '-' + version
	if g_gz in ['gz', 'bz2']:
		arch_name = tmp_folder + '.tar.' + g_gz
	else:
		arch_name = tmp_folder + '.' + 'zip'

	# remove the previous dir
	try:
		shutil.rmtree(tmp_folder)
	except (OSError, __HOLE__):
		pass

	# remove the previous archive
	try:
		os.remove(arch_name)
	except (OSError, IOError):
		pass

	# copy the files into the temporary folder
	blddir = getattr(Utils.g_module, BLDDIR, None)
	if not blddir:
		blddir = getattr(Utils.g_module, 'out', None)
	copytree('.', tmp_folder, blddir)

	# undocumented hook for additional cleanup
	dist_hook = getattr(Utils.g_module, 'dist_hook', None)
	if dist_hook:
		back = os.getcwd()
		os.chdir(tmp_folder)
		try:
			dist_hook()
		finally:
			# go back to the root directory
			os.chdir(back)

	if g_gz in ['gz', 'bz2']:
		tar = tarfile.open(arch_name, 'w:' + g_gz)
		tar.add(tmp_folder)
		tar.close()
	else:
		Utils.zip_folder(tmp_folder, arch_name, tmp_folder)

	try: from hashlib import sha1 as sha
	except ImportError: from sha import sha
	try:
		digest = " (sha=%r)" % sha(Utils.readf(arch_name)).hexdigest()
	except:
		digest = ''

	info('New archive created: %s%s' % (arch_name, digest))

	if os.path.exists(tmp_folder): shutil.rmtree(tmp_folder)
	return arch_name

# FIXME waf 1.6 a unique ctx parameter, and remove the optional appname and version
dataset/ETHPy150Open appcelerator-archive/poc-nodejs-desktop/Resources/nodejs/builds/linux/node/lib/node/wafadmin/Scripting.py/dist