grml cleaned up, testing

This commit is contained in:
brent s. 2021-01-21 11:34:06 -05:00
parent 7c8f25ea03
commit 0e8d460565
Signed by: bts
GPG Key ID: 8C004C2F93481F6B
6 changed files with 300 additions and 25 deletions

View File

@ -13,6 +13,9 @@ class BaseUpdater(object):
_tpl_dir = os.path.join(os.path.dirname(os.path.abspath(os.path.expanduser(__file__))), 'tpl')
_tpl_file = None
_date_fmt = '%a, %d %b %Y %H:%M:%S %z'
_tpl_vars = {}
arch = None
variant = None

def __init__(self,
dest_dir,
@ -49,6 +52,19 @@ class BaseUpdater(object):
self.dest_iso = os.path.join(self.dest_dir, self.dest_file)
self.dest_ver = os.path.join(self.dest_dir, self.ver_file)

def _init_tplvars(self):
self.getUUID()
self._tpl_vars['iso_path'] = os.path.abspath(
os.path.expanduser(
os.path.join(self.grub_iso_dir,
self.dest_file))).lstrip('/')
self._tpl_vars['disk_uuid'] = self.boot_uuid
self._tpl_vars['version'] = self.new_ver
self._tpl_vars['arch'] = self.arch
self._tpl_vars['ver_str'] = str(self.new_ver).replace('.', '')
self._tpl_vars['variant'] = self.variant
return(None)

def main(self):
if self.getRunning():
return(None)
@ -61,6 +77,7 @@ class BaseUpdater(object):
self.do_update = True
self.download()
if self.do_grub:
self._init_tplvars()
self.grub()
self.touchVer()
self.unlock()
@ -133,17 +150,12 @@ class BaseUpdater(object):
return(None)

def grub(self):
self.getUUID()
import jinja2
loader = jinja2.FileSystemLoader(searchpath = self._tpl_dir)
tplenv = jinja2.Environment(loader = loader)
tpl = tplenv.get_template(self._tpl_file)
with open(self.grub_cfg, 'w') as fh:
fh.write(tpl.render(iso_path = os.path.abspath(
os.path.expanduser(
os.path.join(self.grub_iso_dir,
self.dest_file))).lstrip('/'),
disk_uuid = self.boot_uuid))
fh.write(tpl.render(**self._tpl_vars))
os.chmod(self.grub_cfg, 0o0755)
cmd = subprocess.run(['grub-mkconfig',
'-o', '{0}/grub/grub.cfg'.format(self.boot_dir)],

View File

@ -30,7 +30,7 @@ class Updater(_base.BaseUpdater):
_allowed_hashes = ('md5', 'sha1')
_allowed_arches = ('x86_64', )
_datever_fmt = '%Y.%m.%d'
_arch = 'x86_64' # Arch Linux proper only offers x86_64.
arch = 'x86_64' # Arch Linux proper only offers x86_64.
_iso_dir = 'iso/latest'
_iso_fname = 'archlinux-{ver}-{arch}.iso'
_iso_file = os.path.join(_iso_dir, _iso_fname)
@ -130,7 +130,7 @@ class Updater(_base.BaseUpdater):
self.new_hash = self.old_hash
self.new_ver = self.old_ver
self.new_date = self.old_date
# if ver_info.get('arch') != self._arch:
# if ver_info.get('arch') != self.arch:
# self.do_update = True
# self.force_update = True
try:
@ -186,7 +186,7 @@ class Updater(_base.BaseUpdater):
self.rel_notes_url = notes
datever = self.new_ver.strftime(self._datever_fmt)
self.iso_url = os.path.join(self.mirror_base,
self._iso_file.lstrip('/')).format(ver = datever, arch = self._arch)
self._iso_file.lstrip('/')).format(ver = datever, arch = self.arch)
hash_url = os.path.join(self.mirror_base,
self._iso_dir,
'{0}sums.txt'.format(self.hash_type))

View File

@ -80,12 +80,14 @@ class Updater(_base.BaseUpdater):
self.do_update = True
self.force_update = True
self.old_ver = 0.00
self.variant = 'full'
return(None)
with open(self.dest_ver, 'rb') as fh:
ver_info = json.load(fh)
self.old_date = datetime.datetime.strptime(ver_info['date'], self._date_fmt)
self.old_ver = ver_info['ver']
self.old_hash = ver_info.get(self.hash_type, self._def_hash)
self.variant = ver_info.get('variant', self.variant)
self.new_hash = self.old_hash
self.new_ver = self.old_ver
self.new_date = self.old_date
@ -122,6 +124,8 @@ class Updater(_base.BaseUpdater):
ver_info = fname_r.groupdict()
if ver_info['arch'] != self.arch:
continue
if ver_info['variant'] != self.variant:
continue
new_ver = float(ver_info.get('version', self.old_ver))
iso_url = os.path.join(self.dl_base, link['href'].replace(self.dl_base, ''))
hash_url = '{0}.{1}'.format(iso_url, self.hash_type)
@ -145,6 +149,7 @@ class Updater(_base.BaseUpdater):
d = {'date': self.new_date.strftime(self._date_fmt),
'arch': self.arch,
'ver': self.new_ver,
'variant': self.variant,
self.hash_type: self.new_hash}
j = json.dumps(d, indent = 4)
with open(self.dest_ver, 'w') as fh:

View File

@ -19,8 +19,14 @@ submenu 'Arch Install ISO' {
set isofile='{{ iso_path }}'
set imgdevpath="/dev/disk/by-uuid/{{ disk_uuid }}"
loopback loop (${root})/${isofile}
linux (loop)/arch/boot/x86_64/vmlinuz-linux archisobasedir=arch img_dev=$imgdevpath img_loop=${isofile} earlymodules=loop
initrd (loop)/arch/boot/intel-ucode.img (loop)/arch/boot/amd-ucode.img (loop)/arch/boot/x86_64/initramfs-linux.img
linux (loop)/arch/boot/x86_64/vmlinuz-linux \
archisobasedir=arch \
img_dev=$imgdevpath \
img_loop=${isofile} \
earlymodules=loop
initrd (loop)/arch/boot/intel-ucode.img \
(loop)/arch/boot/amd-ucode.img \
(loop)/arch/boot/x86_64/initramfs-linux.img
}

menuentry 'Accessibility mode' {
@ -34,8 +40,15 @@ submenu 'Arch Install ISO' {
set isofile='{{ iso_path }}'
set imgdevpath="/dev/disk/by-uuid/{{ disk_uuid }}"
loopback loop (${root})/${isofile}
linux (loop)/arch/boot/x86_64/vmlinuz-linux archisobasedir=arch img_dev=$imgdevpath img_loop=${isofile} earlymodules=loop accessibility=on
initrd (loop)/arch/boot/intel-ucode.img (loop)/arch/boot/amd-ucode.img (loop)/arch/boot/x86_64/initramfs-linux.img
linux (loop)/arch/boot/x86_64/vmlinuz-linux \
archisobasedir=arch \
img_dev=$imgdevpath \
img_loop=${isofile} \
earlymodules=loop \
accessibility=on
initrd (loop)/arch/boot/intel-ucode.img \
(loop)/arch/boot/amd-ucode.img \
(loop)/arch/boot/x86_64/initramfs-linux.img
}

}

View File

@ -0,0 +1,204 @@
#!/bin/sh
# TODO: other entries
# Copy this file to /etc/grub.d/40_custom_grml with mode 0755 and run grub-mkconfig -o /boot/grub/grub.cfg
exec tail -n +3 $0
# GRML
# Project: https://grml.org/
# Details:
# https://grml.org/docs/
# http://grml.org/cheatcodes/
submenu 'GRML' {

# Does this work?
load_video
insmod gzio
insmod part_gpt
insmod part_msdos
insmod ext2
insmod loopback
set gfxpayload=keep
search --no-floppy --fs-uuid {{ disk_uuid }} --set=root
set isofile='{{ iso_path }}'
set variant={{ variant }}
set ver={{ ver_str }}
set arch={{ arch }}
set bootid=grml${arch}${variant}${ver}
set imgdevpath="/dev/disk/by-uuid/{{ disk_uuid }}"

menuentry 'Default options' {
loopback loop (${root})/${isofile}
linux (loop)/boot/grml${arch}${variant}/vmlinuz \
apm=power-off \
boot=live \
live-media-path=/live/grml${arch}-${variant}/ \
bootid=${bootid} \
findiso=${isofile} \
nomce \
net.ifnames=0
initrd (loop)/boot/grml64small/initrd.img
}

menuentry 'Predictable network interface names' {
loopback loop (${root})/${isofile}
linux (loop)/boot/grml${arch}${variant}/vmlinuz \
apm=power-off \
boot=live \
live-media-path=/live/grml${arch}-${variant}/ \
bootid=${bootid} \
findiso=${isofile} \
nomce
initrd (loop)/boot/grml64small/initrd.img
}

menuentry 'Enable persistency' {
loopback loop (${root})/${isofile}
linux (loop)/boot/grml${arch}${variant}/vmlinuz \
apm=power-off \
boot=live \
live-media-path=/live/grml${arch}-${variant}/ \
bootid=${bootid} \
findiso=${isofile} \
nomce \
net.ifnames=0 \
persistence
initrd (loop)/boot/grml64small/initrd.img
}

menuentry 'Run from RAM' {
loopback loop (${root})/${isofile}
linux (loop)/boot/grml${arch}${variant}/vmlinuz \
apm=power-off \
boot=live \
live-media-path=/live/grml${arch}-${variant}/ \
bootid=${bootid} \
findiso=${isofile} \
nomce \
net.ifnames=0 \
toram=grml64-full.squashfs
initrd (loop)/boot/grml64small/initrd.img
}

menuentry 'Copy entire ISO to RAM' {
loopback loop (${root})/${isofile}
linux (loop)/boot/grml${arch}${variant}/vmlinuz \
apm=power-off \
boot=live \
live-media-path=/live/grml${arch}-${variant}/ \
bootid=${bootid} \
findiso=${isofile} \
nomce \
net.ifnames=0 \
toram
initrd (loop)/boot/grml64small/initrd.img
}

menuentry 'Start X' {
loopback loop (${root})/${isofile}
linux (loop)/boot/grml${arch}${variant}/vmlinuz \
apm=power-off \
boot=live \
live-media-path=/live/grml${arch}-${variant}/ \
bootid=${bootid} \
findiso=${isofile} \
nomce \
net.ifnames=0 \
startx
initrd (loop)/boot/grml64small/initrd.img
}

menuentry 'No framebuffer' {
loopback loop (${root})/${isofile}
linux (loop)/boot/grml${arch}${variant}/vmlinuz \
apm=power-off \
boot=live \
live-media-path=/live/grml${arch}-${variant}/ \
bootid=${bootid} \
findiso=${isofile} \
nomce \
net.ifnames=0 \
video=ofonly \
radeon.modeset=0 \
i915.modeset=0 \
nouveau.modeset=0 \
cirrus.modeset=0 \
mgag200.modeset=0 \
nomodeset
initrd (loop)/boot/grml64small/initrd.img
}

menuentry 'No kernel modeset' {
loopback loop (${root})/${isofile}
linux (loop)/boot/grml${arch}${variant}/vmlinuz \
apm=power-off \
boot=live \
live-media-path=/live/grml${arch}-${variant}/ \
bootid=${bootid} \
findiso=${isofile} \
nomce \
net.ifnames=0 \
radeon.modeset=0 \
i915.modeset=0 \
nouveau.modeset=0 \
cirrus.modeset=0 \
mgag200.modeset=0 \
nomodeset
initrd (loop)/boot/grml64small/initrd.img
}

menuentry 'Forensic mode' {
loopback loop (${root})/${isofile}
linux (loop)/boot/grml${arch}${variant}/vmlinuz \
apm=power-off \
boot=live \
live-media-path=/live/grml${arch}-${variant}/ \
bootid=${bootid} \
findiso=${isofile} \
nomce \
net.ifnames=0 \
read-only \
nofstab \
noraid \
nodmraid \
nolvm \
noautoconfig \
noswap \
raid=noautodetect
initrd (loop)/boot/grml64small/initrd.img
}

menuentry 'Debug mode' {
loopback loop (${root})/${isofile}
linux (loop)/boot/grml${arch}${variant}/vmlinuz \
apm=power-off \
boot=live \
live-media-path=/live/grml${arch}-${variant}/ \
bootid=${bootid} \
findiso=${isofile} \
nomce \
net.ifnames=0 \
initcall \
verbose \
debug=vc \
systemd.log_level=debug \
systemd.log_target=kmsg \
log_buf_len=1M
initrd (loop)/boot/grml64small/initrd.img
}

menuentry 'Serial mode' {
loopback loop (${root})/${isofile}
linux (loop)/boot/grml${arch}${variant}/vmlinuz \
apm=power-off \
boot=live \
live-media-path=/live/grml${arch}-${variant}/ \
bootid=${bootid} \
findiso=${isofile} \
nomce \
net.ifnames=0 \
video=vesafb:off \
console=tty1 \
console=ttyS0,9600n8
initrd (loop)/boot/grml64small/initrd.img
}

}

View File

@ -19,8 +19,14 @@ submenu 'System Rescue CD' {
set isofile='{{ iso_path }}'
set imgdevpath="/dev/disk/by-uuid/{{ disk_uuid }}"
loopback loop (${root})/${isofile}
linux (loop)/sysresccd/boot/x86_64/vmlinuz archisobasedir=sysresccd img_dev=${imgdevpath} img_loop=${isofile} earlymodules=loop
initrd (loop)/sysresccd/boot/intel_ucode.img (loop)/sysresccd/boot/amd_ucode.img (loop)/sysresccd/boot/x86_64/sysresccd.img
linux (loop)/sysresccd/boot/x86_64/vmlinuz \
archisobasedir=sysresccd \
img_dev=${imgdevpath} \
img_loop=${isofile} \
earlymodules=loop
initrd (loop)/sysresccd/boot/intel_ucode.img \
(loop)/sysresccd/boot/amd_ucode.img \
(loop)/sysresccd/boot/x86_64/sysresccd.img
}

menuentry 'Run from RAM' {
@ -34,8 +40,15 @@ submenu 'System Rescue CD' {
set isofile='{{ iso_path }}'
set imgdevpath="/dev/disk/by-uuid/{{ disk_uuid }}"
loopback loop (${root})/${isofile}
linux (loop)/sysresccd/boot/x86_64/vmlinuz archisobasedir=sysresccd img_dev=${imgdevpath} img_loop=${isofile} earlymodules=loop copytoram
initrd (loop)/sysresccd/boot/intel_ucode.img (loop)/sysresccd/boot/amd_ucode.img (loop)/sysresccd/boot/x86_64/sysresccd.img
linux (loop)/sysresccd/boot/x86_64/vmlinuz \
archisobasedir=sysresccd \
img_dev=${imgdevpath} \
img_loop=${isofile} \
earlymodules=loop \
copytoram
initrd (loop)/sysresccd/boot/intel_ucode.img \
(loop)/sysresccd/boot/amd_ucode.img \
(loop)/sysresccd/boot/x86_64/sysresccd.img
}

menuentry 'Confirm/verify checksum' {
@ -49,8 +62,15 @@ submenu 'System Rescue CD' {
set isofile='{{ iso_path }}'
set imgdevpath="/dev/disk/by-uuid/{{ disk_uuid }}"
loopback loop (${root})/${isofile}
linux (loop)/sysresccd/boot/x86_64/vmlinuz archisobasedir=sysresccd img_dev=${imgdevpath} img_loop=${isofile} earlymodules=loop checksum
initrd (loop)/sysresccd/boot/intel_ucode.img (loop)/sysresccd/boot/amd_ucode.img (loop)/sysresccd/boot/x86_64/sysresccd.img
linux (loop)/sysresccd/boot/x86_64/vmlinuz \
archisobasedir=sysresccd \
img_dev=${imgdevpath} \
img_loop=${isofile} \
earlymodules=loop \
checksum
initrd (loop)/sysresccd/boot/intel_ucode.img \
(loop)/sysresccd/boot/amd_ucode.img \
(loop)/sysresccd/boot/x86_64/sysresccd.img
}

menuentry 'Use basic display drivers' {
@ -64,8 +84,15 @@ submenu 'System Rescue CD' {
set isofile='{{ iso_path }}'
set imgdevpath="/dev/disk/by-uuid/{{ disk_uuid }}"
loopback loop (${root})/${isofile}
linux (loop)/sysresccd/boot/x86_64/vmlinuz archisobasedir=sysresccd img_dev=${imgdevpath} img_loop=${isofile} earlymodules=loop nomodeset
initrd (loop)/sysresccd/boot/intel_ucode.img (loop)/sysresccd/boot/amd_ucode.img (loop)/sysresccd/boot/x86_64/sysresccd.img
linux (loop)/sysresccd/boot/x86_64/vmlinuz \
archisobasedir=sysresccd \
img_dev=${imgdevpath} \
img_loop=${isofile} \
earlymodules=loop \
nomodeset
initrd (loop)/sysresccd/boot/intel_ucode.img \
(loop)/sysresccd/boot/amd_ucode.img \
(loop)/sysresccd/boot/x86_64/sysresccd.img
}

menuentry 'Find and boot a locally installed Linux' {
@ -79,8 +106,15 @@ submenu 'System Rescue CD' {
set isofile='{{ iso_path }}'
set imgdevpath="/dev/disk/by-uuid/{{ disk_uuid }}"
loopback loop (${root})/${isofile}
linux (loop)/sysresccd/boot/x86_64/vmlinuz archisobasedir=sysresccd img_dev=${imgdevpath} img_loop=${isofile} earlymodules=loop findroot
initrd (loop)/sysresccd/boot/intel_ucode.img (loop)/sysresccd/boot/amd_ucode.img (loop)/sysresccd/boot/x86_64/sysresccd.img
linux (loop)/sysresccd/boot/x86_64/vmlinuz \
archisobasedir=sysresccd \
img_dev=${imgdevpath} \
img_loop=${isofile} \
earlymodules=loop \
findroot
initrd (loop)/sysresccd/boot/intel_ucode.img \
(loop)/sysresccd/boot/amd_ucode.img \
(loop)/sysresccd/boot/x86_64/sysresccd.img
}

menuentry 'Stop during boot before the root filesystem is mounted' {
@ -94,8 +128,15 @@ submenu 'System Rescue CD' {
set isofile='{{ iso_path }}'
set imgdevpath="/dev/disk/by-uuid/{{ disk_uuid }}"
loopback loop (${root})/${isofile}
linux (loop)/sysresccd/boot/x86_64/vmlinuz archisobasedir=sysresccd img_dev=${imgdevpath} img_loop=${isofile} earlymodules=loop break
initrd (loop)/sysresccd/boot/intel_ucode.img (loop)/sysresccd/boot/amd_ucode.img (loop)/sysresccd/boot/x86_64/sysresccd.img
linux (loop)/sysresccd/boot/x86_64/vmlinuz \
archisobasedir=sysresccd \
img_dev=${imgdevpath} \
img_loop=${isofile} \
earlymodules=loop \
break
initrd (loop)/sysresccd/boot/intel_ucode.img \
(loop)/sysresccd/boot/amd_ucode.img \
(loop)/sysresccd/boot/x86_64/sysresccd.img
}

}