def main(): # Test arguments and find full pathnames. if not validate_args(sys.argv): usage() return # Reaching this point means all arguments are valid, so set the variables and # get full pathnames when necessary. trunk_location = os.path.realpath(sys.argv[1]) output_dir = os.path.realpath(sys.argv[2]) # Begin creating demokit print "Creating a demokit. This may take a moment or two." # Create temporary directories for the demokit files and archive temp_demokit_dir = tempfile.mkdtemp() temp_archive_dir = tempfile.mkdtemp() # Prepare all files to go into demokit prepare_files(trunk_location,temp_demokit_dir) # Clean the temporary directory of unnecessary files clean_folder.clean_folder(trunk_location + os.sep + "dist/demokit_files.fi", temp_demokit_dir) # Create archive package_demokit(temp_demokit_dir, temp_archive_dir) # Move the demokit tarball to the specified output directory for tarball in os.listdir(temp_archive_dir): shutil.copy2(temp_archive_dir + os.sep + tarball, output_dir) # Remove the temporary directories shutil.rmtree(temp_demokit_dir) shutil.rmtree(temp_archive_dir) print "Demokit created: " + output_dir + os.sep + BASE_DEMOKIT_DIR + ".tgz"
def prepare_gen_files(trunk_location, temp_install_dir, include_tests, pubkey, privkey, finalfiles): """ <Purpose> Prepare the general non-installer-specific files (needed for all installers) and deposit them into the temporary folder designated to hold the files that will be present in the base installer(s), including the metainfo file. <Arguments> trunk_location: The path to the trunk of the repository, used to find all the requisite files that appear in the installer. pubkey: The path to a public key that will be used to generate the metainfo file. privkey: The path to a private key that will be used to generate the metainfo file. temp_install_dir: The temporary directory where the general files to be included in the installer will be placed. include_tests: Boolean variable specifying whether or not to include tests in installer. finalfiles: Boolean variable specifying whether or not to prepare the final files after the metafile has been written <Exceptions> IOError on bad file paths. <Side Effects> All general non-installer-specific files placed into the specified temporary installation directory. <Returns> List of all the files in the temporary installation directory, which will be added to the installer tarball. """ # Run preparetest to generate and place all the general installation files # in the temporary installation directory. # To run /trunk/preparetest.py, we must be in that directory (probably a bug # in preparetest.py?) original_dir = os.getcwd() preparetest_dir = trunk_location + os.sep + "dist" os.chdir(preparetest_dir) if include_tests: p = subprocess.Popen([sys.executable, preparetest_dir + os.sep + "preparetest.py", "-t", temp_install_dir]) p.wait() else: p = subprocess.Popen([sys.executable, preparetest_dir + os.sep + "preparetest.py", temp_install_dir]) p.wait() os.chdir(original_dir) # Copy the benchmarking scripts to the installer directory shutil.copy2(trunk_location + "/resource/benchmark_resources.py", temp_install_dir) shutil.copy2(trunk_location + "/resource/Mac_BSD_resources.py", temp_install_dir) shutil.copy2(trunk_location + "/resource/create_installer_state.py", temp_install_dir) shutil.copy2(trunk_location + "/resource/measuredisk.py", temp_install_dir) shutil.copy2(trunk_location + "/resource/vessel.restrictions", temp_install_dir) shutil.copy2(trunk_location + "/resource/Linux_resources.py", temp_install_dir) shutil.copy2(trunk_location + "/resource/measure_random.py", temp_install_dir) shutil.copy2(trunk_location + "/resource/Win_WinCE_resources.py", temp_install_dir) # Copy the universal installer and uninstaller to the program directory. shutil.copy2(trunk_location + "/dist/seattleinstaller.py", temp_install_dir) shutil.copy2(trunk_location + "/dist/seattleuninstaller.py", temp_install_dir) # Copy the script that stops all running seattle processes. shutil.copy2(trunk_location + "/dist/stop_all_seattle_processes.py", temp_install_dir) # Copy the script that will update old crontab entries on Linux and Darwin # systems to the new 2009 seattle crontab entry. This must remain in the # installer indefinitely (or at least for a while) in the event that a user # installed seattle with the previous, old crontab entry, then lost permission # to modify his crontab. In the event that he regains permission to modify # his crontab, the previously installed crontab entry must be updated. shutil.copy2(trunk_location + "/dist/update_crontab_entry.py", temp_install_dir) # Clean the folder of unnecessary files before generating metafile. clean_folder.clean_folder(trunk_location + "/dist/initial_files.fi", temp_install_dir) # To run writemetainfo.py, we must be in that directory (probably a bug in # writemetainfo.py?) os.chdir(temp_install_dir) # Generate the metainfo file. p = subprocess.Popen([sys.executable, temp_install_dir + os.sep + "writemetainfo.py", privkey, pubkey, "-n"]) p.wait() os.chdir(original_dir) # If specified, copy remaining files that should not be included in the # metafile into the temporary installation directory. if finalfiles: # Copy the static files to the program directory. shutil.copy2(trunk_location + "/dist/nodeman.cfg", temp_install_dir) shutil.copy2(trunk_location + "/dist/resources.offcut", temp_install_dir) # Run clean_folder a final time to ensure the final directory contains all # the necessary files now that the last files have been added. clean_folder.clean_folder(trunk_location + "/dist/final_files.fi", temp_install_dir) return os.listdir(temp_install_dir)
def prepare_gen_files(trunk_location, temp_install_dir, include_tests, pubkey, privkey, finalfiles): """ <Purpose> Prepare the general non-installer-specific files (needed for all installers) and deposit them into the temporary folder designated to hold the files that will be present in the base installer(s), including the metainfo file. <Arguments> trunk_location: The path to the trunk of the repository, used to find all the requisite files that appear in the installer. pubkey: The path to a public key that will be used to generate the metainfo file. privkey: The path to a private key that will be used to generate the metainfo file. temp_install_dir: The temporary directory where the general files to be included in the installer will be placed. include_tests: Boolean variable specifying whether or not to include tests in installer. finalfiles: Boolean variable specifying whether or not to prepare the final files after the metafile has been written <Exceptions> IOError on bad file paths. <Side Effects> All general non-installer-specific files placed into the specified temporary installation directory. <Returns> List of all the files in the temporary installation directory, which will be added to the installer tarball. """ # Run preparetest to generate and place all the general installation files # in the temporary installation directory. # To run /trunk/preparetest.py, we must be in that directory (probably a bug # in preparetest.py?) original_dir = os.getcwd() os.chdir(trunk_location) if include_tests: p = subprocess.Popen([ "python", trunk_location + os.sep + "preparetest.py", "-t", temp_install_dir ]) p.wait() else: p = subprocess.Popen([ "python", trunk_location + os.sep + "preparetest.py", temp_install_dir ]) p.wait() os.chdir(original_dir) # Copy Anthony Honstain's benchmarking scripts to the installer. shutil.copy2(trunk_location + "/resource/benchmark_resources.py", temp_install_dir) shutil.copy2(trunk_location + "/resource/Mac_BSD_resources.py", temp_install_dir) shutil.copy2(trunk_location + "/resource/create_installer_state.py", temp_install_dir) shutil.copy2(trunk_location + "/resource/measuredisk.py", temp_install_dir) shutil.copy2(trunk_location + "/resource/vessel.restrictions", temp_install_dir) shutil.copy2(trunk_location + "/resource/Linux_resources.py", temp_install_dir) shutil.copy2(trunk_location + "/resource/measure_random.py", temp_install_dir) shutil.copy2(trunk_location + "/resource/Win_WinCE_resources.py", temp_install_dir) # Copy the universal installer and uninstaller to the program directory. shutil.copy2(trunk_location + "/dist/seattleinstaller.py", temp_install_dir) shutil.copy2(trunk_location + "/dist/seattleuninstaller.py", temp_install_dir) # Copy the script that stops all running seattle processes. shutil.copy2(trunk_location + "/dist/stop_all_seattle_processes.py", temp_install_dir) # Copy the script that will update old crontab entries on Linux and Darwin # systems to the new 2009 seattle crontab entry. This must remain in the # installer indefinitely (or at least for a while) in the event that a user # installed seattle with the previous, old crontab entry, then lost permission # to modify his crontab. In the event that he regains permission to modify # his crontab, the previously installed crontab entry must be updated. shutil.copy2(trunk_location \ + "/dist/update_crontab_entry.py", temp_install_dir) # Clean the folder of unnecessary files before generating metafile. clean_folder.clean_folder(trunk_location + "/dist/initial_files.fi", temp_install_dir) # To run writemetainfo.py, we must be in that directory (probably a bug in # writemetainfo.py?) os.chdir(temp_install_dir) # Generate the metainfo file. p = subprocess.Popen([ "python", temp_install_dir + os.sep + "writemetainfo.py", privkey, pubkey, "-n" ]) p.wait() os.chdir(original_dir) # If specified, copy remaining files that should not be included in the # metafile into the temporary installation directory. if finalfiles: # Copy the static files to the program directory. shutil.copy2(trunk_location + "/dist/nodeman.cfg", temp_install_dir) shutil.copy2(trunk_location + "/dist/resources.offcut", temp_install_dir) # Run clean_folder a final time to ensure the final directory contains all # the necessary files now that the last files have been added. clean_folder.clean_folder(trunk_location + "/dist/final_files.fi", temp_install_dir) return os.listdir(temp_install_dir)