def test__sync_file_truncate_persistent(self): fs = FileSystem(path=self.rootpath()) file = File(lines=['line']) fs.rootdirectory().add(name='file', entry=file) fs.sync() fs = scan_filesystem(path=self.rootpath()) file = fs.rootdirectory().find(['file']) file.truncate() fs.sync() fs = scan_filesystem(path=self.rootpath()) file = fs.rootdirectory().find(['file']) self.failUnless(file.lines() == []) pass
def output(self): super(AutomakeBackendOutputBuilder, self).output() # 'make maintainer-clean' should remove the files we generate self.makefile_am().add_maintainercleanfiles('Makefile.am') self.makefile_am().add_maintainercleanfiles('Makefile.in') # dump file_installer's knowledge into Makefile.am self.file_installer().output(makefile_am=self.__makefile_am) # distribute the package configuration file, but only if it is # part of the physical package structure. if self.parentbuilder() is self.package().rootbuilder(): confix2_pkg = self.package().rootdirectory().get(const.CONFIX2_PKG) if not confix2_pkg.is_overlayed(): self.makefile_am().add_extra_dist(const.CONFIX2_PKG) pass pass self.configure_ac().set_packagename(self.package().name()) self.configure_ac().set_packageversion(self.package().version()) # we require autoconf 2.52 because it has (possibly among # others) AC_HELP_STRING(), and can go into subsubdirs from # the toplevel. self.configure_ac().set_minimum_autoconf_version('2.52') # we never pass AC_DEFINE'd macros on the commandline. rather, # we put everything in config.h. self.configure_ac().add_ac_config_headers('config.h') # our minimum required automake version is 1.9 self.makefile_am().add_automake_options('1.9') # enable dist'ing in the following formats self.makefile_am().add_automake_options('dist-bzip2') self.makefile_am().add_automake_options('dist-zip') # the ubiquitous readonly-prefixes: add the configure option # and stuff. self.configure_ac().add_paragraph( paragraph=readonly_prefixes.commandline_option_paragraph, order=Configure_ac.OPTIONS) # register subdirectories with our toplevel Makefile.am. if self.parentbuilder() is self.package().rootbuilder(): for dirnode in self.package().topo_directories(): assert isinstance(dirnode, DirectoryBuilder) relpath = dirnode.directory().relpath( self.package().rootdirectory()) if len(relpath): dirstr = '/'.join(relpath) self.makefile_am().add_subdir(dirstr) self.configure_ac().add_ac_config_files( '/'.join(relpath + ['Makefile'])) else: dirstr = '.' self.makefile_am().add_subdir(dirstr) self.configure_ac().add_ac_config_files('Makefile') pass pass pass # piggy-back the repo install on automake. if self.parentbuilder() is self.package().rootbuilder(): self.makefile_am().define_install_directory( symbolicname='confixrepo', dirname=repo_automake.dir_for_automake()) self.makefile_am().add_to_install_directory( symbolicname='confixrepo', family='DATA', files=[self.package().repofilename()]) self.makefile_am().add_extra_dist( name=self.package().repofilename()) pass # AC_CONFIG_SRCDIR (for paranoia and sanity checks): we need # one unique file in the tree, as a meaningful argument to # AC_CONFIG_SRCDIR. if True: goodfile = notsogoodfile = None for b in self.package().iter_builders(): if not isinstance(b, FileBuilder): continue if b.file().is_overlayed(): # we won't put files from an overlay into the # package since automake and friends won't be able # to find them. continue if isinstance(b.file(), File) and b.file().state() == FileState.VIRTUAL: # also, there may be "virtual" files around (but # only if the file's a "real" file) which we # cannot put into a package. (boy, this sucks!) continue if b.file().name() not in [ const.CONFIX2_PKG, const.CONFIX2_DIR ]: goodfile = b.file() break notsogoodfile = b.file() pass if goodfile: unique_file = goodfile elif notsogoodfile: unique_file = notsogoodfile else: raise Error('Not even one file handled by any submodule of ' 'package ' + self.package().name() + "; " "probably the current working directory " "(" + os.getcwd() + ") is not " "the package root directory?") self.configure_ac().set_unique_file_in_srcdir('/'.join( unique_file.relpath(self.package().rootdirectory()))) pass # add Confix2.dir to the distribution package - but only if it # is part of the physical package structure confix2_dir_file = self.parentbuilder().directory().find( [const.CONFIX2_DIR]) if confix2_dir_file is not None and not confix2_dir_file.is_overlayed( ): self.__makefile_am.add_extra_dist(const.CONFIX2_DIR) pass # finally: if I am in the toplevel directory, write # configure.ac and acinclude.m4 if self.parentbuilder() is self.package().rootbuilder(): configure_ac_file = self.package().rootdirectory().find( ['configure.ac']) if configure_ac_file is None: configure_ac_file = self.package().rootdirectory().add( name='configure.ac', entry=File()) else: configure_ac_file.truncate() pass configure_ac_file.add_lines(self.configure_ac().lines()) acinclude_m4_file = self.package().rootdirectory().find( ['acinclude.m4']) if acinclude_m4_file is None: acinclude_m4_file = self.package().rootdirectory().add( name='acinclude.m4', entry=File()) else: acinclude_m4_file.truncate() pass acinclude_m4_file.add_lines(self.__acinclude_m4.lines()) pass # finally: write Makefile.am if True: mf_am = self.parentbuilder().directory().find(['Makefile.am']) if mf_am is None: mf_am = File() self.parentbuilder().directory().add(name='Makefile.am', entry=mf_am) else: mf_am.truncate() pass mf_am.add_lines(self.__makefile_am.lines()) pass pass