From patchwork Thu Apr 7 14:09:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Lagerwall X-Patchwork-Id: 8773391 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D4F679FBEA for ; Thu, 7 Apr 2016 14:22:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 146AA20251 for ; Thu, 7 Apr 2016 14:22:17 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3D5712024F for ; Thu, 7 Apr 2016 14:22:16 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aoAmh-0008Di-Br; Thu, 07 Apr 2016 14:19:47 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aoAmg-0008Dc-3I for xen-devel@lists.xen.org; Thu, 07 Apr 2016 14:19:46 +0000 Received: from [85.158.137.68] by server-8.bemta-3.messagelabs.com id C3/90-04050-18C66075; Thu, 07 Apr 2016 14:19:45 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrOLMWRWlGSWpSXmKPExsXitHSDvW5DDlu 4wYRZZhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8aHm69YCk5xV1ycUtjA2MPRxcjJISHgL7G2 byE7iM0mYCBx69J3ZhBbREBWYnXXHKA4BwezQLnE3LVOIGFhAXOJubePsYLYLAIqEgt+72ACs XkFPCRe/F7EDDFSTuLc+i8sILaQgJrE2+VnWCBqBCVOznwCZjMLSEgcfPECqp5b4vbpqcwTGH lmISmbhaRsASPTKkaN4tSistQiXUMzvaSizPSMktzEzBxdQwNjvdzU4uLE9NScxKRiveT83E2 MwABhAIIdjKu2ex5ilORgUhLl/ZnGFi7El5SfUpmRWJwRX1Sak1p8iFGGg0NJgpcrGygnWJSa nlqRlpkDDFWYtAQHj5IIrx9Imre4IDG3ODMdInWKUVFKnLceJCEAksgozYNrg8XHJUZZKWFeR qBDhHgKUotyM0tQ5V8xinMwKgnzyoNM4cnMK4Gb/gpoMRPQ4gv8YItLEhFSUg2M8Xe+Oz4Ii3 ofy35+akxk7wXuSfcutPg8K57krLja+Jh8Wlud+wVHzcWsS3x6/85Z2qZidedWfZy44cMaAeu MGr/r7tbXyk9dW+GjHXxoxRn3pL0CyyZ1nNmbvyv+NK9f7ZrZotNesKQrvJY3rY3MUD9nYbFG ecqny+ur2941v75wJjub9Va+EktxRqKhFnNRcSIAkq94L4oCAAA= X-Env-Sender: prvs=898cf5a10=ross.lagerwall@citrix.com X-Msg-Ref: server-3.tower-31.messagelabs.com!1460038782!33509591!1 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 8.28; banners=-,-,- X-VirusChecked: Checked Received: (qmail 30425 invoked from network); 7 Apr 2016 14:19:44 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-3.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 7 Apr 2016 14:19:44 -0000 X-IronPort-AV: E=Sophos;i="5.24,449,1454976000"; d="scan'208";a="352200570" From: Ross Lagerwall To: Date: Thu, 7 Apr 2016 15:09:40 +0100 Message-ID: <1460038181-4463-1-git-send-email-ross.lagerwall@citrix.com> X-Mailer: git-send-email 2.4.3 MIME-Version: 1.0 X-DLP: MIA2 Cc: Wei Liu , Ian Jackson , Ross Lagerwall Subject: [Xen-devel] [PATCH 1/2] pygrub: Ignore GRUB2 if statements X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP SLES 12's default GRUB config has the following code before any entries: if [ -n "$extra_cmdline" ]; then submenu "Bootable snapshot #$snapshot_num" { menuentry "If OK, run 'snapper rollback' and reboot." { true; } } fi This prevents pygrub from booting using the default entry. Since I'm not aware of any distro GRUB config which puts useful entries within conditionals, ignore them. Signed-off-by: Ross Lagerwall --- tools/pygrub/src/GrubConf.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/pygrub/src/GrubConf.py b/tools/pygrub/src/GrubConf.py index dc810d5..cf9aa8b 100644 --- a/tools/pygrub/src/GrubConf.py +++ b/tools/pygrub/src/GrubConf.py @@ -373,6 +373,7 @@ class Grub2ConfigFile(_GrubConfigFile): lines = buf.split("\n") in_function = False + in_if = False img = None title = "" menu_level=0 @@ -389,9 +390,14 @@ class Grub2ConfigFile(_GrubConfigFile): if l.startswith('function'): in_function = True continue - if in_function: + elif l.startswith('if'): + in_if = True + continue + if in_function or in_if: if l.startswith('}'): in_function = False + elif l.startswith('fi'): + in_if = False continue # new image