Skip to content

Commit

Permalink
Implement debian persistance feature under Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
mbusb committed Apr 3, 2018
1 parent f9df4bd commit 50085ce
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
Binary file added data/tools/cygwin/cyggcc_s-1.dll
Binary file not shown.
Binary file added data/tools/cygwin/cygwin1.dll
Binary file not shown.
Binary file added data/tools/cygwin/e2fsck.exe
Binary file not shown.
Binary file added data/tools/cygwin/resize2fs.exe
Binary file not shown.
20 changes: 17 additions & 3 deletions scripts/persistence.py
Expand Up @@ -101,8 +101,12 @@ def create_persistence_using_resize2fs(persistence_fname, persistence_size):
if platform.system()=='Windows':
_7zip_exe = gen.resource_path(
os.path.join(tools_dir, '7zip', '7z.exe'))
e2fsck_exe = gen.resource_path(os.path.join(tools_dir, 'cygwin', 'e2fsck.exe'))
resize2fs_exe = gen.resource_path(os.path.join(tools_dir, 'cygwin', 'resize2fs.exe'))
else:
_7zip_exe = '7z'
e2fsck_exe = 'e2fsck'
resize2fs_exe = 'resize2fs'

config.status_text = 'Copying persistence file...'
persistence_gz = gen.resource_path(
Expand Down Expand Up @@ -142,11 +146,11 @@ def create_persistence_using_resize2fs(persistence_fname, persistence_size):
bytes_left -= block_size

config.status_text = 'Resizing the persistence file...'
fsck_cmd = ['e2fsck', '-y', '-f', persistence_path]
fsck_cmd = [e2fsck_exe, '-y', '-f', persistence_path]
if subprocess.call(fsck_cmd)==0:
gen.log("Checking the persistence file.")

resize_cmd = ['resize2fs', persistence_path]
resize_cmd = [resize2fs_exe, persistence_path]
if subprocess.call(resize_cmd)==0:
gen.log("Successfully resized the persistence file.")

Expand All @@ -169,12 +173,22 @@ def create_persistence_using_resize2fs(persistence_fname, persistence_size):
}

def detect_missing_tools(distro):
tools_dir = os.path.join('data', 'tools')
if platform.system() == 'Windows':
_7zip_exe = gen.resource_path(
os.path.join(tools_dir, '7zip', '7z.exe'))
e2fsck_exe = gen.resource_path(os.path.join(tools_dir, 'cygwin', 'e2fsck.exe'))
resize2fs_exe = gen.resource_path(os.path.join(tools_dir, 'cygwin', 'resize2fs.exe'))
else:
_7zip_exe = '7z'
e2fsck_exe = 'e2fsck'
resize2fs_exe = 'resize2fs'
if distro not in creator_dict or \
creator_dict[distro][0] is not create_persistence_using_resize2fs:
return None
try:
with open(os.devnull) as devnull:
for tool in ['e2fsck', 'resize2fs']:
for tool in [e2fsck_exe, resize2fs_exe]:
subprocess.Popen([tool], stdout=devnull, stderr=devnull)
except FileNotFoundError: # Windows
return "'%s.exe' is not installed or not available for use." % tool
Expand Down

0 comments on commit 50085ce

Please sign in to comment.