apk.installed(): Retuns all packages and versions now
pmb.chroot.apk.installed() used to return only the explicitly installed packages. This is not good enough for the initfs check functions (and especially for the "lazy reproducible builds", from which branch this commit was cherry picked). This commit introduces more noise for the logfile - if this becomes a problem, raise your voice in the issues tracker and we'll do something about it. (This commit also changes minor code styling in other files, I did not run autopep8 last time, because flake8 didn't complain...)
This commit is contained in:
parent
4b903b7232
commit
32ad868cdc
|
@ -17,9 +17,9 @@ You should have received a copy of the GNU General Public License
|
|||
along with pmbootstrap. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
import logging
|
||||
import os
|
||||
import pmb.chroot
|
||||
import pmb.parse.apkindex
|
||||
import pmb.parse.other
|
||||
|
||||
|
||||
def install(args, packages, suffix="native", build=True):
|
||||
|
@ -67,16 +67,23 @@ def upgrade(args, suffix="native", update_index=True):
|
|||
if update_index:
|
||||
pmb.chroot.root(args, ["apk", "update"], suffix)
|
||||
|
||||
# -a: also update previously downgraded (and therefore pinned) packages
|
||||
# -a: also update previously downgraded (and therefore pinned) packages
|
||||
pmb.chroot.root(args, ["apk", "upgrade", "-a"], suffix)
|
||||
|
||||
|
||||
def installed(args, suffix="native"):
|
||||
"""
|
||||
Get all explicitly installed packages
|
||||
Get all installed packages and their versions.
|
||||
:returns: { "hello-world": {"package": "hello-world-1-r2", "pkgrel": "2",
|
||||
"pkgver": "1", "pkgname": "hello-world"}, ...}
|
||||
"""
|
||||
world = args.work + "/chroot_" + suffix + "/etc/apk/world"
|
||||
if not os.path.exists(world):
|
||||
return []
|
||||
with open(world, encoding="utf-8") as handle:
|
||||
return handle.read().splitlines()
|
||||
ret = {}
|
||||
list = pmb.chroot.user(args, ["apk", "info", "-vv"], suffix,
|
||||
return_stdout=True)
|
||||
for line in list.split("\n"):
|
||||
if not line.rstrip():
|
||||
continue
|
||||
package = line.split(" - ")[0]
|
||||
split = pmb.parse.other.package_split(package)
|
||||
ret[split["pkgname"]] = split
|
||||
return ret
|
||||
|
|
|
@ -85,7 +85,8 @@ def install(args, show_flash_msg=True):
|
|||
# List all packages to be installed (including the ones specified by --add)
|
||||
# and upgrade the installed packages/apkindexes
|
||||
logging.info("*** (2/5) CREATE DEVICE ROOTFS (" + args.device + ") ***")
|
||||
install_packages = (pmb.config.install_device_packages + ["device-" + args.device])
|
||||
install_packages = (pmb.config.install_device_packages +
|
||||
["device-" + args.device])
|
||||
suffix = "rootfs_" + args.device
|
||||
pmb.chroot.apk.upgrade(args, suffix)
|
||||
|
||||
|
|
|
@ -80,9 +80,15 @@ def arguments():
|
|||
|
||||
# Action: log
|
||||
log = sub.add_parser("log", help="follow the pmbootstrap logfile")
|
||||
log_distccd = sub.add_parser("log_distccd", help="follow the distccd logfile")
|
||||
log_distccd = sub.add_parser(
|
||||
"log_distccd",
|
||||
help="follow the distccd logfile")
|
||||
for action in [log, log_distccd]:
|
||||
action.add_argument("-n", "--lines", default="30", help="count of initial output lines")
|
||||
action.add_argument(
|
||||
"-n",
|
||||
"--lines",
|
||||
default="30",
|
||||
help="count of initial output lines")
|
||||
|
||||
# Action: zap
|
||||
zap = sub.add_parser("zap", help="safely delete chroot"
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
"""
|
||||
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/>.
|
||||
"""
|
||||
|
||||
|
||||
def package_split(package):
|
||||
"""
|
||||
Split a full package name (as returned by `apk info -vv` and as found as
|
||||
apk file name) into its components.
|
||||
:param package: Example: "heimdall-1.4.2-r1"
|
||||
"""
|
||||
split = package.split("-")
|
||||
pkgrel = split[-1][1:]
|
||||
pkgver = split[-2]
|
||||
version = "-" + pkgver + "-r" + pkgrel
|
||||
pkgname = package[:-1 * len(version)]
|
||||
return {"pkgname": pkgname,
|
||||
"pkgrel": pkgrel,
|
||||
"pkgver": pkgver,
|
||||
"package": package}
|
|
@ -79,10 +79,10 @@ def main():
|
|||
pmb.build.ccache_stats(args, args.arch)
|
||||
elif args.action == "log":
|
||||
pmb.helpers.run.user(args, ["tail", "-f", args.log,
|
||||
"-n", args.lines], log=False)
|
||||
"-n", args.lines], log=False)
|
||||
elif args.action == "log_distccd":
|
||||
pmb.chroot.user(args, ["tail", "-f", "/home/user/distccd.log",
|
||||
"-n", args.lines], log=False)
|
||||
"-n", args.lines], log=False)
|
||||
elif args.action == "zap":
|
||||
pmb.chroot.zap(args)
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue