def _save_db(self): """ Save DB to disk. """ with open(self._db_path, 'w') as f: util.yaml_dump(self._db, f)
def init(env_dir, name, toolset_name=None): """ Initialize the environment in the given directory. """ # Bail out with an error if the environment already exists if Environment.env_exists(env_dir): raise Exception('Environment already exists in: %s' % env_dir) # Create the empty db file (this triggers database file creation) pdb = InstallDatabase(env_dir) # Make sure we have a valid ld.so symlink linux.update_ld_so_symlink(env_dir) # Lookup our toolset and translate to dict toolset = build.Toolset.lookup_by_name(toolset_name) # Create our settings dict and write it disk settings = { 'name' : name, 'toolset' : toolset.to_dict(), } # For path to our settings files, and save it settings_path = os.path.join(env_dir, Environment.SETTINGS_PATH) with open(settings_path, 'w') as f: util.yaml_dump(settings, f)
def init(env_dir, name, toolset_name=None): """ Initialize the environment in the given directory. """ # Bail out with an error if the environment already exists if Environment.env_exists(env_dir): raise Exception('Environment already exists in: %s' % env_dir) # Create the empty db file (this triggers database file creation) pdb = InstallDatabase(env_dir) # Make sure we have a valid ld.so symlink linux.update_ld_so_symlink(env_dir) # Lookup our toolset and translate to dict toolset = build.Toolset.lookup_by_name(toolset_name) # Create our settings dict and write it disk settings = { 'name': name, 'toolset': toolset.to_dict(), } # For path to our settings files, and save it settings_path = os.path.join(env_dir, Environment.SETTINGS_PATH) with open(settings_path, 'w') as f: util.yaml_dump(settings, f)
def _create_package(self, install_dir, storage_dir, info): """ Creates a package from the given package info. The path to that archive is returned. """ # Tar up the files file_tar = os.path.join(self._work_dir, 'files.tar.gz') with tarfile.open(file_tar, "w:gz") as tar: for entry_name in info['files']: full_path = os.path.join(install_dir, entry_name) tar.add(full_path, arcname=entry_name) # Create our metadata file meta_file = os.path.join(self._work_dir, 'xpkg.yml') with open(meta_file, 'w') as f: util.yaml_dump(info, f) # Create our package package_name = self._get_package_name(info) package_tar = os.path.join(self._work_dir, package_name) with tarfile.open(package_tar, "w") as tar: tar.add(meta_file, arcname=os.path.basename(meta_file)) tar.add(file_tar, arcname=os.path.basename(file_tar)) # Move to the desired location dest_path = os.path.join(storage_dir, package_name) if os.path.exists(dest_path): os.remove(dest_path) shutil.move(package_tar, storage_dir) return dest_path