From patchwork Wed Apr 3 11:21:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milo Casagrande X-Patchwork-Id: 15849 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 426AE23E39 for ; Wed, 3 Apr 2013 11:21:17 +0000 (UTC) Received: from mail-gh0-f199.google.com (mail-gh0-f199.google.com [209.85.160.199]) by fiordland.canonical.com (Postfix) with ESMTP id B23F5A1861F for ; Wed, 3 Apr 2013 11:21:16 +0000 (UTC) Received: by mail-gh0-f199.google.com with SMTP id r16sf1934750ghr.10 for ; Wed, 03 Apr 2013 04:21:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-beenthere:x-received:received-spf:x-received :x-forwarded-to:x-forwarded-for:delivered-to:x-received:received-spf :mime-version:x-launchpad-project:x-launchpad-branch :x-launchpad-message-rationale:x-launchpad-branch-revision-number :x-launchpad-notification-type:to:from:subject:message-id:date :reply-to:sender:errors-to:precedence:x-generated-by :x-launchpad-hash:x-gm-message-state:x-original-sender :x-original-authentication-results:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe :content-type; bh=IhFvl+4UDOGv8X+S8LueLetMXsdmwwd/Im99f/U8thU=; b=euUsrv2UQwi7mwGmvsFMsFsoq5xmtgw2KjvPVxrD9viEQ0nW5yiP4rZfeOJpdD1BYZ Wy+6zXGjOLSIDOoH709/7aFW2OSlkbZV1Cqwsm+KKKdQ6A2YrCFnI/V7vr0P01WB2rik W1HU71HRDxJUhb1TuCCzn5gfdpe/zgBwtBTnPXKJMU48BDi1q0L5LmRZYlFeg3E/jDjM PrjiHflhWuYwzmBN3i8LCW/htvBzBPZ2AZHp8wXTMDRuDQpFjobmdPQpOY3odEIEH7hR V8gQY7oQhnvnPZRHQfSuxHI5sbEvZOCct01EapPQe4Aerm5LTvlBx+40J3HY7VU2KQKF P95w== X-Received: by 10.224.172.200 with SMTP id m8mr930498qaz.0.1364988076230; Wed, 03 Apr 2013 04:21:16 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.110.9 with SMTP id hw9ls825323qeb.83.gmail; Wed, 03 Apr 2013 04:21:16 -0700 (PDT) X-Received: by 10.52.16.105 with SMTP id f9mr668905vdd.117.1364988076093; Wed, 03 Apr 2013 04:21:16 -0700 (PDT) Received: from mail-ve0-f169.google.com (mail-ve0-f169.google.com [209.85.128.169]) by mx.google.com with ESMTPS id r12si4559117vcv.12.2013.04.03.04.21.16 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 03 Apr 2013 04:21:16 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.169 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.169; Received: by mail-ve0-f169.google.com with SMTP id d10so1591326vea.28 for ; Wed, 03 Apr 2013 04:21:16 -0700 (PDT) X-Received: by 10.58.224.101 with SMTP id rb5mr862277vec.17.1364988075966; Wed, 03 Apr 2013 04:21:15 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.59.4.204 with SMTP id cg12csp165681ved; Wed, 3 Apr 2013 04:21:15 -0700 (PDT) X-Received: by 10.194.158.161 with SMTP id wv1mr2148672wjb.38.1364988074787; Wed, 03 Apr 2013 04:21:14 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id gq7si2300648wib.62.2013.04.03.04.21.14 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 03 Apr 2013 04:21:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) client-ip=91.189.90.7; Received: from ackee.canonical.com ([91.189.89.26]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1UNLkg-0004qo-77 for ; Wed, 03 Apr 2013 11:21:14 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 26908E04E7 for ; Wed, 3 Apr 2013 11:21:14 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: linaro-image-tools X-Launchpad-Branch: ~linaro-image-tools/linaro-image-tools/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 616 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-image-tools/linaro-image-tools/trunk] Rev 616: Disable automount, and enable it at exit. Message-Id: <20130403112114.15034.96212.launchpad@ackee.canonical.com> Date: Wed, 03 Apr 2013 11:21:14 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: list X-Generated-By: Launchpad (canonical.com); Revision="16546"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 044f45062c30744b794e96efd37319390f09b7fa X-Gm-Message-State: ALoCoQlWPEkBCUK7an851mGWdTvsS8jK+y3u7N6rnkP3NW4Xd5Ed9ux34aj3D0uJoa5EgUWbLfDX X-Original-Sender: noreply@launchpad.net X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.169 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Merge authors: Milo Casagrande (milo) Related merge proposals: https://code.launchpad.net/~milo/linaro-image-tools/disable-automount/+merge/156794 proposed by: Milo Casagrande (milo) ------------------------------------------------------------ revno: 616 [merge] committer: Milo Casagrande branch nick: trunk timestamp: Wed 2013-04-03 13:20:22 +0200 message: Disable automount, and enable it at exit. modified: linaro-android-media-create linaro-media-create linaro_image_tools/utils.py --- lp:linaro-image-tools https://code.launchpad.net/~linaro-image-tools/linaro-image-tools/trunk You are subscribed to branch lp:linaro-image-tools. To unsubscribe from this branch go to https://code.launchpad.net/~linaro-image-tools/linaro-image-tools/trunk/+edit-subscription === modified file 'linaro-android-media-create' --- linaro-android-media-create 2013-01-30 11:28:51 +0000 +++ linaro-android-media-create 2013-04-03 10:05:46 +0000 @@ -44,7 +44,9 @@ additional_android_option_checks, andorid_hwpack_in_boot_tarball, ensure_command, - get_logger + get_logger, + disable_automount, + enable_automount, ) @@ -117,6 +119,10 @@ ensure_required_commands(args) + # Do this by default, disable automount options and re-enable them at exit. + disable_automount() + atexit.register(enable_automount) + media = Media(args.device) if media.is_block_device: if not confirm_device_selection_and_ensure_it_is_ready(args.device): === modified file 'linaro-media-create' --- linaro-media-create 2013-02-25 18:18:09 +0000 +++ linaro-media-create 2013-04-03 10:05:46 +0000 @@ -57,6 +57,9 @@ path_in_tarfile_exists, prep_media_path, get_logger, + UnableToFindPackageProvidingCommand, + disable_automount, + enable_automount, ) # Just define the global variables @@ -136,6 +139,10 @@ logger.error(e.value) sys.exit(1) + # Do this by default, disable automount options and re-enable them at exit. + disable_automount() + atexit.register(enable_automount) + board_config = get_board_config(args.dev) board_config.set_metadata(args.hwpacks, args.bootloader, args.dev) board_config.add_boot_args(args.extra_boot_args) === modified file 'linaro_image_tools/utils.py' --- linaro_image_tools/utils.py 2013-02-25 18:18:09 +0000 +++ linaro_image_tools/utils.py 2013-04-03 10:05:46 +0000 @@ -35,6 +35,10 @@ # The name of the hwpack file found in the boot tarball. HWPACK_NAME = "config" +# dconf keys to disable automount options. +AUTOMOUNT_DCONF_KEY = '/org/gnome/desktop/media-handling/automount' +AUTOMOUNT_OPEN_DCONF_KEYU = '/org/gnome/desktop/media-handling/automount-open' + # try_import was copied from python-testtools 0.9.12 and was originally # licensed under a MIT-style license but relicensed under the GPL in Linaro @@ -406,3 +410,42 @@ logger.addHandler(ch) return logger + + +def disable_automount(): + """Disables the desktop environment automount option. + + This will work only under GNOME with dconf installed. + """ + logger = logging.getLogger(DEFAULT_LOGGER_NAME) + + if has_command('dconf'): + logger.info("Disabling desktop environment automount option.") + try: + cmd_runner.run( + ['dconf', 'write', AUTOMOUNT_DCONF_KEY, 'false'], + stdout=open('/dev/null', 'w')).wait() + cmd_runner.run( + ['dconf', 'write', AUTOMOUNT_OPEN_DCONF_KEYU, 'false'], + stdout=open('/dev/null', 'w')).wait() + except cmd_runner.SubcommandNonZeroReturnValue: + logger.error("Error disabling desktop environemnt automount.") + + +def enable_automount(): + """Re-enables back the desktop environment automount option. + + This will work only under GNOME with dconf installed. It should be run + as an atexit function. + """ + logger = logging.getLogger(DEFAULT_LOGGER_NAME) + if has_command('dconf'): + try: + cmd_runner.run( + ['dconf', 'write', AUTOMOUNT_DCONF_KEY, 'true'], + stdout=open('/dev/null', 'w')).wait() + cmd_runner.run( + ['dconf', 'write', AUTOMOUNT_OPEN_DCONF_KEYU, 'true'], + stdout=open('/dev/null', 'w')).wait() + except cmd_runner.SubcommandNonZeroReturnValue: + logger.error("Error enabling back desktop environemnt automount.")