-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make the local archive in /dell/debs/ when using the customized insta…
…llation without the recovery partition. (Closes: #105)
- Loading branch information
1 parent
e72f4bc
commit db47388
Showing
5 changed files
with
94 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import glob | ||
import json | ||
from os.path import basename | ||
import os | ||
import subprocess as cmd | ||
import shutil | ||
|
||
devices = [] | ||
|
||
for name in glob.glob('/sys/block/*'): | ||
name = basename(name) | ||
if name.startswith('sd'): | ||
devices.append(name) | ||
elif name.startswith('md'): | ||
devices.append(name) | ||
elif name.startswith('nvme'): | ||
devices.append(name) | ||
elif name.startswith('pmem'): | ||
devices.append(name) | ||
|
||
root = cmd.check_output("findmnt -M / -o source -v | tail -n1", shell=True) | ||
root = basename(root.decode().strip()) | ||
root_device = '' | ||
|
||
cdrom = cmd.check_output("findmnt -M /cdrom -o source -v | tail -n1", shell=True) | ||
cdrom = basename(cdrom.decode().strip()) | ||
cdrom_device = '' | ||
|
||
disks = json.loads(cmd.check_output("lsblk -fs -J", shell=True).decode()) | ||
disks = disks['blockdevices'] | ||
|
||
for disk in disks: | ||
if disk['name'] == root: | ||
data = json.dumps(disk) | ||
for device in devices: | ||
if device in data: | ||
root_device = device | ||
break | ||
elif disk['name'] == cdrom: | ||
data = json.dumps(disk) | ||
for device in devices: | ||
if device in data: | ||
cdrom_device = device | ||
break | ||
|
||
if root_device == cdrom_device: | ||
exit(0) | ||
|
||
print('No recovery partition is detected.') | ||
|
||
os.makedirs('/dell/debs') | ||
|
||
for folder in ('/cdrom/pool', '/cdrom/debs'): | ||
for deb in glob.glob(f'{folder}/**/*.deb', recursive=True): | ||
shutil.copy(deb, f'/dell/debs') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters