Use temp dir for mounting squashfs image.
This commit is contained in:
parent
60dda7db49
commit
cb2dcf7860
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import tempfile
|
||||||
|
|
||||||
from libcalamares import *
|
from libcalamares import *
|
||||||
from filecopy import FileCopyThread
|
from filecopy import FileCopyThread
|
||||||
@ -54,8 +55,10 @@ class UnsquashOperation:
|
|||||||
|
|
||||||
|
|
||||||
def run( self ):
|
def run( self ):
|
||||||
sourceMountPath = job.configuration[ "sourceMountPath" ]
|
sourceMountPath = tempfile.mkdtemp()
|
||||||
|
try:
|
||||||
for entry in self.unpacklist:
|
for entry in self.unpacklist:
|
||||||
|
try:
|
||||||
unsqfsProcess = subprocess.Popen( [ "unsquashfs", "-l", entry[ "source" ] ], stdout = subprocess.PIPE )
|
unsqfsProcess = subprocess.Popen( [ "unsquashfs", "-l", entry[ "source" ] ], stdout = subprocess.PIPE )
|
||||||
wcProcess = subprocess.Popen( [ "wc", "-l" ], stdin = unsqfsProcess.stdout, stdout = subprocess.PIPE )
|
wcProcess = subprocess.Popen( [ "wc", "-l" ], stdin = unsqfsProcess.stdout, stdout = subprocess.PIPE )
|
||||||
countString = wcProcess.communicate()[ 0 ]
|
countString = wcProcess.communicate()[ 0 ]
|
||||||
@ -71,14 +74,21 @@ class UnsquashOperation:
|
|||||||
self.reportProgress()
|
self.reportProgress()
|
||||||
|
|
||||||
self.unsquashImage( entry )
|
self.unsquashImage( entry )
|
||||||
|
finally:
|
||||||
|
os.rmdir( imgMountDir )
|
||||||
|
finally:
|
||||||
|
os.rmdir( sourceMountPath )
|
||||||
|
|
||||||
def unsquashImage( self, entry ):
|
def unsquashImage( self, entry ):
|
||||||
|
try:
|
||||||
subprocess.check_call( [ "mount", entry[ "source" ], entry[ "sourceDir" ], "-t", "squashfs", "-o", "loop" ] )
|
subprocess.check_call( [ "mount", entry[ "source" ], entry[ "sourceDir" ], "-t", "squashfs", "-o", "loop" ] )
|
||||||
|
|
||||||
t = FileCopyThread( entry[ "sourceDir" ], entry[ "destination" ], self.reportProgress )
|
t = FileCopyThread( entry[ "sourceDir" ], entry[ "destination" ], self.reportProgress )
|
||||||
t.start()
|
t.start()
|
||||||
t.join()
|
t.join()
|
||||||
|
finally:
|
||||||
|
subprocess.check_call( [ "umount", "-l", entry[ "sourceDir" ] ] )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
@ -88,7 +98,6 @@ def run():
|
|||||||
# an ordered list of unpack mappings for sqfs file <-> target dir relative
|
# an ordered list of unpack mappings for sqfs file <-> target dir relative
|
||||||
# to rootMountPoint, e.g.:
|
# to rootMountPoint, e.g.:
|
||||||
# configuration:
|
# configuration:
|
||||||
# sourceMountPath: "/some/path"
|
|
||||||
# unpack:
|
# unpack:
|
||||||
# - source: "/path/to/squashfs/image.sqfs"
|
# - source: "/path/to/squashfs/image.sqfs"
|
||||||
# destination: ""
|
# destination: ""
|
||||||
@ -99,12 +108,6 @@ def run():
|
|||||||
|
|
||||||
unpack = list()
|
unpack = list()
|
||||||
|
|
||||||
sourceTempPath = os.path.abspath( job.configuration[ "sourceMountPath" ] )
|
|
||||||
if not os.path.exists( sourceTempPath ):
|
|
||||||
os.mkdir( sourceTempPath )
|
|
||||||
if not os.path.exists( sourceTempPath ):
|
|
||||||
return "Error: cannot create temporary mount directory for source images"
|
|
||||||
|
|
||||||
for entry in job.configuration[ "unpack" ]:
|
for entry in job.configuration[ "unpack" ]:
|
||||||
source = os.path.abspath( entry[ "source" ] )
|
source = os.path.abspath( entry[ "source" ] )
|
||||||
destination = os.path.abspath( os.path.join( rootMountPoint, entry[ "destination" ] ) )
|
destination = os.path.abspath( os.path.join( rootMountPoint, entry[ "destination" ] ) )
|
||||||
|
Loading…
Reference in New Issue
Block a user