Change-Id: If9fe5f025398a644afe4b6c5e9901ab0c5abe03b
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/2896
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Alexey Makhalov <amakhalov@vmware.com>
| ... | ... |
@@ -4,20 +4,20 @@ import sys |
| 4 | 4 |
|
| 5 | 5 |
def cleanUpChroot(chrootPath): |
| 6 | 6 |
returnVal,listmountpoints=findmountpoints(chrootPath) |
| 7 |
- |
|
| 7 |
+ |
|
| 8 | 8 |
if not returnVal: |
| 9 | 9 |
return False |
| 10 |
- |
|
| 10 |
+ |
|
| 11 | 11 |
sortmountpoints(listmountpoints, chrootPath) |
| 12 |
- |
|
| 12 |
+ |
|
| 13 | 13 |
print listmountpoints |
| 14 |
- |
|
| 14 |
+ |
|
| 15 | 15 |
if not unmountmountpoints(listmountpoints): |
| 16 | 16 |
return False |
| 17 |
- |
|
| 17 |
+ |
|
| 18 | 18 |
if not removeAllFilesFromChroot(chrootPath): |
| 19 | 19 |
return False |
| 20 |
- |
|
| 20 |
+ |
|
| 21 | 21 |
return True |
| 22 | 22 |
|
| 23 | 23 |
def removeAllFilesFromChroot(chrootPath): |
| ... | ... |
@@ -28,7 +28,7 @@ def removeAllFilesFromChroot(chrootPath): |
| 28 | 28 |
print "Unable to remove files from chroot "+chrootPath |
| 29 | 29 |
return False |
| 30 | 30 |
return True |
| 31 |
- |
|
| 31 |
+ |
|
| 32 | 32 |
def unmountmountpoints(listmountpoints): |
| 33 | 33 |
if listmountpoints is None: |
| 34 | 34 |
return True |
| ... | ... |
@@ -45,7 +45,7 @@ def unmountmountpoints(listmountpoints): |
| 45 | 45 |
print "Unable to unmount all mounts. Unable to clean up the chroot" |
| 46 | 46 |
return False |
| 47 | 47 |
return True |
| 48 |
- |
|
| 48 |
+ |
|
| 49 | 49 |
def findmountpoints(chrootPath): |
| 50 | 50 |
cmd="mount | grep "+chrootPath+" | cut -d' ' -s -f3" |
| 51 | 51 |
process = subprocess.Popen("%s" %cmd,shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
|
| ... | ... |
@@ -71,9 +71,10 @@ def sortmountpoints(listmountpoints,chrootPath): |
| 71 | 71 |
def main(): |
| 72 | 72 |
if len(sys.argv) < 2: |
| 73 | 73 |
print "Usage: ./clean-up-chroot.py <chrootpath>" |
| 74 |
- return False |
|
| 75 |
- return cleanUpChroot(sys.argv[1]) |
|
| 74 |
+ sys.exit(1) |
|
| 75 |
+ if not cleanUpChroot(sys.argv[1]): |
|
| 76 |
+ sys.exit(1) |
|
| 77 |
+ sys.exit(0) |
|
| 76 | 78 |
|
| 77 | 79 |
if __name__=="__main__": |
| 78 | 80 |
main() |
| 79 |
- |