efibootdude 0.2__py3-none-any.whl → 0.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of efibootdude might be problematic. Click here for more details.

efibootdude/main.py CHANGED
@@ -18,6 +18,7 @@ from types import SimpleNamespace
18
18
  import subprocess
19
19
  import traceback
20
20
  import curses as cs
21
+ import argparse
21
22
  # import xml.etree.ElementTree as ET
22
23
  from efibootdude.PowerWindow import Window, OptionSpinner
23
24
 
@@ -37,7 +38,7 @@ class EfiBootDude:
37
38
  spin.add_key('verbose', 'v - toggle verbose', vals=[False, True])
38
39
 
39
40
  # FIXME: keys
40
- other = 'tudrnmw*zqx'
41
+ other = 'btudrnmw*zqx'
41
42
  other_keys = set(ord(x) for x in other)
42
43
  other_keys.add(cs.KEY_ENTER)
43
44
  other_keys.add(27) # ESCAPE
@@ -89,18 +90,6 @@ class EfiBootDude:
89
90
 
90
91
  def get_part_uuids(self):
91
92
  """ Get all the Partition UUIDS"""
92
- # uuids = {}
93
- # with open('/run/blkid/blkid.tab', encoding='utf8') as fh:
94
- # # sample: <device ... TYPE="vfat"
95
- # # PARTUUID="25d2dea1-9f68-1644-91dd-4836c0b3a30a">/dev/nvme0n1p1</device>
96
- # for xml_line in fh:
97
- # element = ET.fromstring(xml_line)
98
- # if 'PARTUUID' in element.attrib:
99
- # device=element.text.strip()
100
- # name = self.mounts.get(device, device)
101
- # uuids[element.attrib['PARTUUID'].lower()] = name
102
- # return uuids
103
-
104
93
  uuids = {}
105
94
  partuuid_path = '/dev/disk/by-partuuid/'
106
95
 
@@ -111,6 +100,8 @@ class EfiBootDude:
111
100
  if os.path.islink(full_path):
112
101
  device_path = os.path.realpath(full_path)
113
102
  uuids[entry] = device_path
103
+ if device_path in self.mounts:
104
+ uuids[entry] = self.mounts[device_path]
114
105
  return uuids
115
106
 
116
107
  @staticmethod
@@ -118,7 +109,6 @@ class EfiBootDude:
118
109
  """ Find uuid string in a line """
119
110
  # Define the regex pattern for UUID (e.g., 25d2dea1-9f68-1644-91dd-4836c0b3a30a)
120
111
  pattern = r'\b[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}\b'
121
- # Search for the pattern in the line
122
112
  mats = re.findall(pattern, line, re.IGNORECASE)
123
113
  return mats
124
114
 
@@ -127,9 +117,11 @@ class EfiBootDude:
127
117
  # Define the command to run
128
118
  lines = []
129
119
  if self.testfile:
120
+ # if given a "testfile" (which should be just the
121
+ # raw output of 'efibootmgr'), then parse it
130
122
  with open(self.testfile, 'r', encoding='utf-8') as fh:
131
123
  lines = fh.readlines()
132
- else:
124
+ else: # run efibootmgr
133
125
  command = 'efibootmgr'.split()
134
126
  result = subprocess.run(command, stdout=subprocess.PIPE, text=True, check=True)
135
127
  lines = result.stdout.splitlines()
@@ -230,6 +222,17 @@ class EfiBootDude:
230
222
  words = line.split(maxsplit=1)
231
223
  return words[0]
232
224
 
225
+ def reboot(self):
226
+ """ Reboot the machine """
227
+ Window.stop_curses()
228
+ os.system('clear; stty sane; (set -x; sudo reboot now)')
229
+
230
+ # NOTE: probably will not get here...
231
+ os.system(r'/bin/echo -e "\n\n===== Press ENTER for menu ====> \c"; read FOO')
232
+ self.reinit()
233
+ Window._start_curses()
234
+ self.win.pick_pos = self.boot_idx
235
+
233
236
  def write(self):
234
237
  """ Commit the changes. """
235
238
  if not self.mods.dirty:
@@ -271,8 +274,6 @@ class EfiBootDude:
271
274
  Window._start_curses()
272
275
  self.win.pick_pos = self.boot_idx
273
276
 
274
-
275
-
276
277
  def main_loop(self):
277
278
  """ TBD """
278
279
 
@@ -296,6 +297,7 @@ class EfiBootDude:
296
297
  ' m - modify - modify the value'
297
298
  ' w - write - write the changes',
298
299
  ' ESC - abandon changes and re-read boot state',
300
+ ' b - reboot the machine',
299
301
  ]
300
302
  for line in lines:
301
303
  self.win.put_body(line)
@@ -356,6 +358,7 @@ class EfiBootDude:
356
358
  actions['m'] = 'modify'
357
359
  if self.mods.dirty:
358
360
  actions['w'] = 'write'
361
+ actions['b'] = 'boot'
359
362
 
360
363
  return actions
361
364
 
@@ -395,7 +398,7 @@ class EfiBootDude:
395
398
  return value
396
399
 
397
400
  if key in (ord('q'), ord('x')):
398
-
401
+
399
402
  answer = 'y'
400
403
  if self.mods.dirty:
401
404
  answer = self.win.answer(
@@ -471,7 +474,7 @@ class EfiBootDude:
471
474
  if key == ord('t') and ns.is_boot:
472
475
  seed = ns.label
473
476
  while True:
474
- answer = self.win.answer(prompt='Enter new label or clear to abort',
477
+ answer = self.win.answer(prompt='Type new label or clear to abort',
475
478
  seed=seed, width=80)
476
479
  seed = answer = answer.strip()
477
480
  if not answer:
@@ -485,7 +488,7 @@ class EfiBootDude:
485
488
  if key == 27: # ESC
486
489
  if self.mods.dirty:
487
490
  answer = self.win.answer(
488
- prompt='Enter "y" to clear edits and refresh')
491
+ prompt='Type "y" to clear edits and refresh')
489
492
  if answer.strip().lower().startswith('y'):
490
493
  self.reinit()
491
494
  else:
@@ -496,13 +499,18 @@ class EfiBootDude:
496
499
  self.write()
497
500
  return None
498
501
 
499
- # FIXME: handle more keys
502
+ if key == ord('b'):
503
+ answer = self.win.answer(prompt='Type "reboot" to reboot',
504
+ seed='reboot', width=80)
505
+ if answer.strip().lower().startswith('reboot'):
506
+ self.reboot()
507
+
508
+ # FIXME: handle more keys
500
509
  return None
501
510
 
502
511
 
503
512
  def main():
504
513
  """ The program """
505
- import argparse
506
514
  parser = argparse.ArgumentParser()
507
515
  parser.add_argument('testfile', nargs='?', default=None)
508
516
  opts = parser.parse_args()
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: efibootdude
3
- Version: 0.2
3
+ Version: 0.5
4
4
  Summary: A visual wrapper for efibootmgr
5
- Author-email: Joe Defen <joedef@google.com>
5
+ Author-email: Joe Defen <joedef@duck.com>
6
6
  License: MIT
7
7
  Project-URL: Homepage, https://github.com/joedefen/efibootdude
8
8
  Project-URL: Bug Tracker, https://github.com/joedefen/efibootdude/issues
@@ -41,19 +41,22 @@ After running `efibootdude` and making some changes, you'll see a screen compara
41
41
  ![efibootdude-screenshot](https://github.com/joedefen/efibootdude/blob/main/images/efibootdude-screenshot.png?raw=true).
42
42
 
43
43
  At this point
44
- * The current line starts with `>` and is highlighted.
44
+ * The "current" line starts with `>` and is highlighted.
45
45
  * The top line shows actions for the current line; type the underscored letter
46
- to effect the action.
47
- * Enter `?` for a more complete explanation of the keys, navigation keys, etc.
46
+ to effect its action.
47
+ * Type `?` for a more complete explanation of the keys, navigation keys, etc.
48
48
  * **ALWAYS** view the help at least once if unfamiliar with this tool,
49
49
  it navigation, and/or uncertain of keys not shown on top line.
50
50
  * With this current line, we can:
51
- * Use `u` or `d` to move it up or down in the boot order.
52
- * Use `t` to relabel the boot entry.
53
- * Use `r` to remove it.
51
+ * Type `u` or `d` to move it up or down in the boot order.
52
+ * Type `t` to relabel the boot entry.
53
+ * Type `r` to remove the boot entry.
54
54
  * And so forth.
55
- * Use the `ESC` key to abandon any changes and reload the boot information.
55
+ * The entries with `*` on the left are active boot entries; toggle whether
56
+ active by typing `*` for the corresponding entries.
57
+ * Press `ESC` key to abandon any changes and reload the boot information.
56
58
  * When ready to write the changes to the BIOS, enter `w`.
59
+ * When the changes look good, type `b` to reboot, if you wish.
57
60
  * When writing the changes, `efibootdude` drops out of menu mode so you can
58
61
  verify the underlying commands, error codes, and error messages.
59
62
 
@@ -0,0 +1,9 @@
1
+ efibootdude/PowerWindow.py,sha256=pQGXsAMeuiHn-vtEiVG0rgW1eCslh3ukC-VrPhH_j3k,28587
2
+ efibootdude/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ efibootdude/main.py,sha256=Z9zPAY3GIY_8JE9COr71WrXBOZvJRGCgsfZPGpffyEQ,18789
4
+ efibootdude-0.5.dist-info/LICENSE,sha256=qB9OdnyyF6WYHiEIXVm0rOSdcf8e2ctorrtWs6CC5lU,1062
5
+ efibootdude-0.5.dist-info/METADATA,sha256=0keU5nYypIDiMUlVD94XKkF5k-NcStNTO5ChJTnxUPg,3584
6
+ efibootdude-0.5.dist-info/WHEEL,sha256=mguMlWGMX-VHnMpKOjjQidIo1ssRlCFu4a4mBpz1s2M,91
7
+ efibootdude-0.5.dist-info/entry_points.txt,sha256=3KZ_86ZSy4f-weuSruTlMGaQ96jZUm7mjyITVnjE184,54
8
+ efibootdude-0.5.dist-info/top_level.txt,sha256=BrMsK3JmOrVJUNkHX1dicqWrdjbm4itRtmXJMxte-VU,12
9
+ efibootdude-0.5.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- efibootdude/PowerWindow.py,sha256=pQGXsAMeuiHn-vtEiVG0rgW1eCslh3ukC-VrPhH_j3k,28587
2
- efibootdude/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- efibootdude/main.py,sha256=opKAafTuw9BpwZl-Q99BmMGVarsf_fEgY-aLjbpeZtA,18460
4
- efibootdude-0.2.dist-info/LICENSE,sha256=qB9OdnyyF6WYHiEIXVm0rOSdcf8e2ctorrtWs6CC5lU,1062
5
- efibootdude-0.2.dist-info/METADATA,sha256=HuHORtrDzLH0ItVDm_UbRXsRVRSgBtyBcVEkzODKNCY,3380
6
- efibootdude-0.2.dist-info/WHEEL,sha256=mguMlWGMX-VHnMpKOjjQidIo1ssRlCFu4a4mBpz1s2M,91
7
- efibootdude-0.2.dist-info/entry_points.txt,sha256=3KZ_86ZSy4f-weuSruTlMGaQ96jZUm7mjyITVnjE184,54
8
- efibootdude-0.2.dist-info/top_level.txt,sha256=BrMsK3JmOrVJUNkHX1dicqWrdjbm4itRtmXJMxte-VU,12
9
- efibootdude-0.2.dist-info/RECORD,,