def fix_fstab(root_dir, fstype): # /etc/fstab format # <file system> <dir> # <type> <options> <dump> <pass> lines = [ '# Generated on %s' % (util.time_rfc2822()), '%s%14s%14s%14s%14s%6s' % ('LABEL=root', '/', fstype, 'defaults', '0', '0') ] contents = "\n".join(lines) print("Writing a new fstab:") print(contents) util.write_file(util.abs_join(root_dir, 'etc', 'fstab'), "%s\n" % (contents))
def download(self): (cache_pth, exists_there) = self._check_cache() if exists_there: return cache_pth print("Downloading from: %s" % (util.quote(self.where_from))) util.ensure_dirs([os.path.dirname(cache_pth)]) print("To: %s" % (util.quote(cache_pth))) util.download_url(self.where_from, cache_pth) try: meta_js = { 'cached_on': util.time_rfc2822(), 'from': self.where_from, 'root_file': self.root_file, } util.write_file("%s.json" % (cache_pth), "%s\n" % (json.dumps(meta_js, indent=4))) return self._adjust_real_root(cache_pth) except: util.del_file(cache_pth) raise