diff options
author | Ahmad Sharif <asharif@chromium.org> | 2012-10-09 17:48:09 -0700 |
---|---|---|
committer | Ahmad Sharif <asharif@chromium.org> | 2012-10-09 17:48:09 -0700 |
commit | f395c26437cbdabc2960447fba89b226f4409e82 (patch) | |
tree | c67df25ac39b2c2b3d6d9aa847391edebbb0c478 /image_chromeos.py | |
parent | a171f8d10c0507127de54c60076f1f59feef3629 (diff) | |
download | toolchain-utils-f395c26437cbdabc2960447fba89b226f4409e82.tar.gz |
Synced repos to: 63271
Diffstat (limited to 'image_chromeos.py')
-rwxr-xr-x | image_chromeos.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/image_chromeos.py b/image_chromeos.py index f1497fb9..380a94f7 100755 --- a/image_chromeos.py +++ b/image_chromeos.py @@ -9,10 +9,12 @@ This script images a remote ChromeOS device with a specific image." __author__ = "asharif@google.com (Ahmad Sharif)" +import fcntl import filecmp import glob import optparse import os +import re import shutil import sys import tempfile @@ -22,15 +24,25 @@ from utils import misc from utils.file_utils import FileUtils checksum_file = "/usr/local/osimage_checksum_file" - +lock_file = "/tmp/lock_image_chromeos" def Usage(parser, message): print "ERROR: " + message parser.print_help() sys.exit(0) + def Main(argv): """Build ChromeOS.""" + #Get lock for the host + f = open(lock_file, "w+a") + try: + fcntl.lockf(f, fcntl.LOCK_EX|fcntl.LOCK_NB) + except IOError: + f.close() + print ("You can not run two instances of image_chromes at the same time." + "\nTry again. Exiting ....") + exit(0) # Common initializations cmd_executer = command_executer.GetCommandExecuter() l = logger.GetLogger() @@ -150,6 +162,8 @@ def Main(argv): else: l.LogOutput("Checksums match. Skipping reimage") + fcntl.lockf(f, fcntl.LOCK_UN) + f.close() return retval @@ -219,7 +233,8 @@ def IsImageModdedForTest(chromeos_root, image): stateful_mp = tempfile.mkdtemp() MountImage(chromeos_root, image, rootfs_mp, stateful_mp) lsb_release_file = os.path.join(rootfs_mp, "etc/lsb-release") - is_test_image = "Test Build" in open(lsb_release_file).read() + lsb_release_contents = open(lsb_release_file).read() + is_test_image = re.search("test", lsb_release_contents, re.IGNORECASE) MountImage(chromeos_root, image, rootfs_mp, stateful_mp, unmount=True) return is_test_image |