forked from Mirror/pmbootstrap
Close #69: add 'pmbootstrap initfs' and improve initfs workflow
* allows to build/extract/list initramfs, add/del hook * rebuild the initfs whenever running install or trying to flash/boot it * flasher flash/boot: automatically set up a minimal rootfs with kernel and initfs, if it does not exist yet
This commit is contained in:
parent
32ad868cdc
commit
18339d0a14
9 changed files with 253 additions and 8 deletions
67
pmb/chroot/initfs_hooks.py
Normal file
67
pmb/chroot/initfs_hooks.py
Normal file
|
@ -0,0 +1,67 @@
|
|||
"""
|
||||
Copyright 2017 Oliver Smith
|
||||
|
||||
This file is part of pmbootstrap.
|
||||
|
||||
pmbootstrap is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
pmbootstrap is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with pmbootstrap. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
import os
|
||||
import glob
|
||||
import logging
|
||||
|
||||
import pmb.config
|
||||
import pmb.chroot.apk
|
||||
|
||||
|
||||
def list_chroot(args, suffix):
|
||||
ret = []
|
||||
prefix = pmb.config.initfs_hook_prefix
|
||||
for pkgname in pmb.chroot.apk.installed(args, suffix):
|
||||
if pkgname.startswith(prefix):
|
||||
ret.append(pkgname[len(prefix):])
|
||||
return ret
|
||||
|
||||
|
||||
def list_aports(args):
|
||||
ret = []
|
||||
prefix = pmb.config.initfs_hook_prefix
|
||||
for path in glob.glob(args.aports + "/" + prefix + "*"):
|
||||
ret.append(os.path.basename(path)[len(prefix):])
|
||||
return ret
|
||||
|
||||
|
||||
def ls(args, suffix):
|
||||
hooks_chroot = list_chroot(args, suffix)
|
||||
hooks_aports = list_aports(args)
|
||||
|
||||
for hook in hooks_aports:
|
||||
line = "* " + hook
|
||||
if hook in hooks_chroot:
|
||||
line += " (installed)"
|
||||
logging.info(line)
|
||||
|
||||
|
||||
def add(args, hook, suffix):
|
||||
if hook not in list_aports(args):
|
||||
raise RuntimeError("Invalid hook name! Run 'pmbootstrap initfs hook_ls'"
|
||||
" to get a list of all hooks.")
|
||||
prefix = pmb.config.initfs_hook_prefix
|
||||
pmb.chroot.apk.install(args, [prefix + hook], suffix)
|
||||
|
||||
|
||||
def delete(args, hook, suffix):
|
||||
if hook not in list_chroot(args, suffix):
|
||||
raise RuntimeError("There is no such hook installed!")
|
||||
prefix = pmb.config.initfs_hook_prefix
|
||||
pmb.chroot.root(args, ["apk", "del", prefix + hook], suffix)
|
Loading…
Add table
Add a link
Reference in a new issue