[elbe-devel] [PATCH v2 19/28] Nuke ASCIIDocLog from BuildEnv
dion at linutronix.de
dion at linutronix.de
Fri Jun 21 19:40:11 CEST 2019
From: Olivier Dion <dion at linutronix.de>
Remove 'ASCIIDocLog' from 'BuildEnv' constructor, thus changing all
calls to it and changing the internal of the class to reflect the
change.
Signed-off-by: Olivier Dion <dion at linutronix.de>
---
elbepack/cdroms.py | 5 +-
elbepack/commands/fetch_initvm_pkgs.py | 4 +-
elbepack/commands/toolchainextract.py | 8 +-
elbepack/elbeproject.py | 20 ++---
elbepack/finetuning.py | 3 +-
elbepack/pkgarchive.py | 53 +++++-------
elbepack/repomanager.py | 86 ++++++++-----------
elbepack/rfs.py | 151 ++++++++++++++++-----------------
elbepack/updatepkg.py | 2 +-
9 files changed, 144 insertions(+), 188 deletions(-)
diff --git a/elbepack/cdroms.py b/elbepack/cdroms.py
index e16dcd2d..6f6d80a8 100644
--- a/elbepack/cdroms.py
+++ b/elbepack/cdroms.py
@@ -45,7 +45,6 @@ def mk_source_cdrom(
repo = CdromSrcRepo(codename, init_codename,
os.path.join(target, "srcrepo"),
- log,
cdrom_size,
mirror)
@@ -144,10 +143,10 @@ def mk_binary_cdrom(
log.printo(' generated with --skip-build-bin')
log.do('mkdir -p "%s"' % repo_path)
- repo = CdromInitRepo(init_codename, repo_path, log, cdrom_size, mirror)
+ repo = CdromInitRepo(init_codename, repo_path, cdrom_size, mirror)
target_repo = CdromBinRepo(arch, codename, None,
- target_repo_path, log, cdrom_size, mirror)
+ target_repo_path, cdrom_size, mirror)
if xml is not None:
cache = get_rpcaptcache(rfs, arch)
diff --git a/elbepack/commands/fetch_initvm_pkgs.py b/elbepack/commands/fetch_initvm_pkgs.py
index 554c838e..95f6a5be 100644
--- a/elbepack/commands/fetch_initvm_pkgs.py
+++ b/elbepack/commands/fetch_initvm_pkgs.py
@@ -91,7 +91,7 @@ def run_command(argv):
# Binary Repo
#
- repo = CdromInitRepo(init_codename, opt.binrepo, log, 0, mirror)
+ repo = CdromInitRepo(init_codename, opt.binrepo, 0, mirror)
hostfs.mkdir_p(opt.archive)
@@ -119,7 +119,7 @@ def run_command(argv):
# Source Repo
#
- repo = CdromSrcRepo(init_codename, init_codename, opt.srcrepo, log, 0, mirror)
+ repo = CdromSrcRepo(init_codename, init_codename, opt.srcrepo, 0, mirror)
hostfs.mkdir_p(opt.srcarchive)
# a cdrom build does not have sources
diff --git a/elbepack/commands/toolchainextract.py b/elbepack/commands/toolchainextract.py
index 2f7693cb..d8298e9b 100644
--- a/elbepack/commands/toolchainextract.py
+++ b/elbepack/commands/toolchainextract.py
@@ -70,11 +70,9 @@ def run_command(argv):
with elbe_logging(opt.output):
- repo = ToolchainRepo(
- defaults["arch"],
- opt.codename,
- opt.output,
- StdoutLog())
+ repo = ToolchainRepo(defaults["arch"],
+ opt.codename,
+ opt.output)
for p in pkgs:
repo.includedeb(os.path.join(tmpdir, p))
diff --git a/elbepack/elbeproject.py b/elbepack/elbeproject.py
index 6911a9c9..046bcbf5 100644
--- a/elbepack/elbeproject.py
+++ b/elbepack/elbeproject.py
@@ -189,13 +189,14 @@ class ElbeProject (object):
self.log = StdoutLog()
self.repo = ProjectRepo(self.arch, self.codename,
- os.path.join(self.builddir, "repo"), self.log)
+ os.path.join(self.builddir, "repo"))
# Create BuildEnv instance, if the chroot directory exists and
# has an etc/elbe_version
if os.path.exists(self.chrootpath):
- self.buildenv = BuildEnv(
- self.xml, self.log, self.chrootpath, clean=False)
+ self.buildenv = BuildEnv(self.xml,
+ self.chrootpath,
+ clean=False)
else:
self.buildenv = None
@@ -250,7 +251,6 @@ class ElbeProject (object):
self.sysrootpath))
self.sysrootenv = BuildEnv(self.xml,
- self.log,
self.sysrootpath,
clean=True)
# Import keyring
@@ -312,7 +312,6 @@ class ElbeProject (object):
hostsysrootpath))
self.host_sysrootenv = BuildEnv(self.xml,
- self.log,
hostsysrootpath,
clean=True,
arch="amd64")
@@ -437,10 +436,10 @@ class ElbeProject (object):
sysrootstr = ""
if os.path.exists(self.sysrootpath):
sysrootstr = "(including sysroot packages)"
- env = BuildEnv(self.xml, self.log, self.sysrootpath,
+ env = BuildEnv(self.xml, self.sysrootpath,
build_sources=build_sources, clean=False)
else:
- env = BuildEnv(self.xml, self.log, self.chrootpath,
+ env = BuildEnv(self.xml, self.chrootpath,
build_sources=build_sources, clean=False)
# ensure the /etc/apt/sources.list is created according to
@@ -520,7 +519,7 @@ class ElbeProject (object):
# so it gets rebuilt properly.
if not self.has_full_buildenv():
self.log.do('mkdir -p "%s"' % self.chrootpath)
- self.buildenv = BuildEnv(self.xml, self.log, self.chrootpath,
+ self.buildenv = BuildEnv(self.xml, self.chrootpath,
build_sources=build_sources, clean=True)
skip_pkglist = False
@@ -861,8 +860,9 @@ class ElbeProject (object):
# Create a new BuildEnv instance, if we have a build directory
if self.has_full_buildenv():
- self.buildenv = BuildEnv(
- self.xml, self.log, self.chrootpath, clean=False)
+ self.buildenv = BuildEnv(self.xml,
+ self.chrootpath,
+ clean=False)
# Create TargetFs instance, if the target directory exists.
# We use the old content of the directory if no rebuild is done, so
diff --git a/elbepack/finetuning.py b/elbepack/finetuning.py
index 426097aa..5da50b1f 100644
--- a/elbepack/finetuning.py
+++ b/elbepack/finetuning.py
@@ -539,8 +539,7 @@ class UpdatedAction(FinetuningAction):
" missing name or version")
r = UpdateRepo(target.xml,
- target.path + '/var/cache/elbe/repos/base',
- log)
+ target.path + '/var/cache/elbe/repos/base')
for d in buildenv.rfs.glob('tmp/pkgs/*.deb'):
r.includedeb(d, 'main')
diff --git a/elbepack/pkgarchive.py b/elbepack/pkgarchive.py
index 14e6bd46..e335b8e2 100644
--- a/elbepack/pkgarchive.py
+++ b/elbepack/pkgarchive.py
@@ -5,6 +5,7 @@
# SPDX-License-Identifier: GPL-3.0-or-later
import errno
+import logging
from os import path, remove
from shutil import rmtree, copytree, move
from apt.package import FetchError
@@ -12,7 +13,7 @@ from elbepack.repomanager import RepoBase, RepoAttributes
class ArchiveRepo(RepoBase):
- def __init__(self, xml, pathname, log, origin, description, components,
+ def __init__(self, xml, pathname, origin, description, components,
maxsize=None):
# pylint: disable=too-many-arguments
@@ -24,7 +25,6 @@ class ArchiveRepo(RepoBase):
RepoBase.__init__(self,
pathname,
- log,
None,
repo_attrs,
description,
@@ -45,7 +45,7 @@ def gen_binpkg_archive(ep, repodir):
try:
# Repository containing all packages currently installed
- repo = ArchiveRepo(ep.xml, repopath, ep.log, "Elbe",
+ repo = ArchiveRepo(ep.xml, repopath, "Elbe",
"Elbe package archive", ["main"])
c = ep.get_rpcaptcache()
@@ -59,34 +59,21 @@ def gen_binpkg_archive(ep, repodir):
if not path.isfile(abs_path):
# Package file does not exist, download it and adjust path name
- ep.log.printo(
- "Package file " +
- filename +
- " not found in var/cache/apt/archives, downloading it")
+ logging.warning('Package file "%s" not found in var/cache/apt/archives, downloading it' % filename)
abs_path = ep.buildenv.rfs.fname(rel_path)
+ pkg_id = "%s-%s" % (pkg.name, pkg.installed_version)
try:
abs_path = c.download_binary(pkg.name,
'/var/cache/elbe/pkgarchive',
pkg.installed_version)
except ValueError:
- ep.log.printo("No Package " + pkg.name + "-" +
- pkg.installed_version)
+ logging.error('No package "%s"' % pkg_id)
raise
except FetchError:
- ep.log.printo(
- "Package " +
- pkg.name +
- "-" +
- pkg.installed_version +
- " could not be downloaded")
+ logging.error('Package "%s" could not be downloaded' % pkd_id)
raise
except TypeError:
- ep.log.printo(
- "Package " +
- pkg.name +
- "-" +
- pkg.installed_version +
- " missing name or version")
+ logging.error('Package "%s" missing name or version' % pkd_id)
raise
# Add package to repository
@@ -116,12 +103,12 @@ def checkout_binpkg_archive(ep, repodir):
try:
# Copy the package archive into the buildenv,
# so the RPCAptCache can access it
- ep.log.printo("Copying package archive into build environment")
+ logging.info("Copying package archive into build environment")
copytree(repopath, pkgarchive)
# Move original etc/apt/sources.list and etc/apt/sources.list.d out
# of the way
- ep.log.printo("Moving original APT configuration out of the way")
+ logging.info("Moving original APT configuration out of the way")
if path.isfile(sources_list):
move(sources_list, sources_list_backup)
if path.isdir(sources_list_d):
@@ -129,7 +116,7 @@ def checkout_binpkg_archive(ep, repodir):
# Now create our own, with the package archive being the only
# source
- ep.log.printo("Creating new /etc/apt/sources.list")
+ logging.info("Creating new /etc/apt/sources.list")
deb = "deb file:///var/cache/elbe/pkgarchive "
deb += ep.xml.text("/project/suite")
deb += " main"
@@ -138,14 +125,14 @@ def checkout_binpkg_archive(ep, repodir):
# We need to update the APT cache to apply the changed package
# source
- ep.log.printo("Updating APT cache to use package archive")
+ logging.info("Updating APT cache to use package archive")
ep.drop_rpcaptcache()
c = ep.get_rpcaptcache()
c.update()
# Iterate over all packages, and mark them for installation or
# deletion, using the same logic as in commands/updated.py
- ep.log.printo("Calculating packages to install/remove")
+ logging.info("Calculating packages to install/remove")
fpl = ep.xml.node("fullpkgs")
pkgs = c.get_pkglist('all')
@@ -154,24 +141,24 @@ def checkout_binpkg_archive(ep, repodir):
for fpi in fpl:
if p.name == fpi.et.text:
version = fpi.et.get('version')
- ep.log.printo("Install " + p.name + "-" + version)
+ logging.info('Install "%s-%s"' % (p.name, version))
c.mark_install(p.name, version,
from_user=not fpi.et.get('auto'),
nodeps=True)
marked = True
if not marked:
- ep.log.printo("Delete " + p.name + "-" + version)
+ logging.info('Delete "%s-%s"' % (p.name, version))
c.mark_delete(p.name)
# Now commit the changes
- ep.log.printo("Commiting package changes")
+ logging.info("Commiting package changes")
c.commit()
finally:
# If we changed the package sources, move back the backup
if path.isdir(sources_list_d_backup) or \
path.isfile(sources_list_backup):
- ep.log.printo("Moving back original APT configuration")
+ logging.info("Moving back original APT configuration")
update_needed = True
else:
update_needed = False
@@ -186,13 +173,11 @@ def checkout_binpkg_archive(ep, repodir):
# Remove the package archive from the buildenv
if path.isdir(pkgarchive):
- ep.log.printo(
- "Removing package archive from build environment")
+ logging.info("Removing package archive from build environment")
rmtree(pkgarchive)
# Update APT cache, if we modified the package sources
if update_needed:
- ep.log.printo(
- "Updating APT cache to use original package sources")
+ logging.info("Updating APT cache to use original package sources")
ep.drop_rpcaptcache()
ep.get_rpcaptcache().update()
diff --git a/elbepack/repomanager.py b/elbepack/repomanager.py
index 1969c8f9..862b4f77 100644
--- a/elbepack/repomanager.py
+++ b/elbepack/repomanager.py
@@ -9,6 +9,7 @@
import os
import shutil
+import logging
from debian.deb822 import Deb822
@@ -16,7 +17,7 @@ from elbepack.debianreleases import codename2suite
from elbepack.filesystem import Filesystem
from elbepack.pkgutils import get_dsc_size
from elbepack.egpg import generate_elbe_internal_key, export_key, unlock_key
-from elbepack.shellhelper import CommandError
+from elbepack.shellhelper import CommandError, do
class RepoAttributes(object):
@@ -56,7 +57,6 @@ class RepoBase(object):
def __init__(
self,
path,
- log,
init_attr,
repo_attr,
origin,
@@ -68,7 +68,6 @@ class RepoBase(object):
self.vol_path = path
self.volume_count = 0
- self.log = log
self.init_attr = init_attr
self.repo_attr = repo_attr
@@ -164,28 +163,22 @@ class RepoBase(object):
shutil.copyfile(keyring, self.fs.fname("/elbe-keyring.gpg"))
if need_update:
- self.log.do(
- 'reprepro --export=force --basedir "' +
- self.fs.path +
- '" update',
- env_add={'GNUPGHOME': "/var/cache/elbe/gnupg"})
+ cmd = 'reprepro --export=force --basedir "%s" update' % self.fs.path
+ do(cmd,
+ env_add={'GNUPGHOME': "/var/cache/elbe/gnupg"})
else:
for att in self.attrs:
- self.log.do(
- 'reprepro --basedir "' +
- self.fs.path +
- '" export ' +
- att.codename,
+ cmd = 'reprepro --basedir "%s" export %s' % (self.fs.path,
+ att.codename)
+ do(cmd,
env_add={'GNUPGHOME': "/var/cache/elbe/gnupg"})
def finalize(self):
for att in self.attrs:
- self.log.do(
- 'reprepro --basedir "' +
- self.fs.path +
- '" export ' +
- att.codename,
- env_add={'GNUPGHOME': '/var/cache/elbe/gnupg'})
+ cmd = 'reprepro --basedir "%s" export %s' % (self.fs.path,
+ att.codename)
+ do(cmd,
+ env_add={'GNUPGHOME': '/var/cache/elbe/gnupg'})
def _includedeb(self, path, codename, component):
if self.maxsize:
@@ -193,15 +186,12 @@ class RepoBase(object):
if new_size > self.maxsize:
self.new_repo_volume()
- self.log.do(
- 'reprepro --keepunreferencedfiles --export=never --basedir "' +
- self.fs.path +
- '" -C ' +
- component +
- ' includedeb ' +
- codename +
- ' ' +
- path)
+ cmd = ('reprepro --keepunreferencedfiles --export=never '
+ '--basedir "%s" -C %s includedeb %s %s' % (self.fs.path,
+ component,
+ codename,
+ path))
+ do(cmd)
def includedeb(self, path, component="main", pkgname=None, force=False):
# pkgname needs only to be specified if force is enabled
@@ -223,14 +213,14 @@ class RepoBase(object):
self._includedeb(path, self.init_attr.codename, component)
def _include(self, path, codename, component):
- self.log.do('reprepro --ignore=wrongdistribution '
+ do('reprepro --ignore=wrongdistribution '
'--ignore=surprisingbinary --keepunreferencedfiles '
- '--export=never --basedir "' + self.fs.path + '" -C ' +
- component + ' -P normal -S misc include ' + codename +
- ' ' + path)
+ '--export=never --basedir "' + self.fs.path + '" -C ' +
+ component + ' -P normal -S misc include ' + codename +
+ ' ' + path)
def _removedeb(self, pkgname, codename):
- self.log.do(
+ do(
"reprepro --basedir %s remove %s %s" %
(self.fs.path, codename, pkgname),
env_add={'GNUPGHOME': '/var/cache/elbe/gnupg'})
@@ -239,7 +229,7 @@ class RepoBase(object):
self._removedeb(pkgname, self.repo_attr.codename)
def _removesrc(self, srcname, codename):
- self.log.do(
+ do(
"reprepro --basedir %s removesrc %s %s" %
(self.fs.path, codename, srcname),
env_add={'GNUPGHOME': '/var/cache/elbe/gnupg'})
@@ -269,7 +259,7 @@ class RepoBase(object):
if self.maxsize and (self.fs.disk_usage("") > self.maxsize):
self.new_repo_volume()
- self.log.do(
+ do(
'reprepro --keepunreferencedfiles --export=never --basedir "' +
self.fs.path +
'" -C ' +
@@ -292,9 +282,8 @@ class RepoBase(object):
#
# copy the dsc into the cdrom root,
# when reprepro fails to insert it.
- self.log.printo('Unable to verify dsc "%s":' % path)
- self.log.printo('unsupported signature algorithm')
- self.log.do('cp -av "%s" "%s"' % (path, self.fs.path))
+ logging.error('Unable to verify dsc "%s": unsupported signature algorithm' % path)
+ do('cp -av "%s" "%s"' % (path, self.fs.path))
elif force:
# Including dsc did not work.
# Maybe we have the same Version with a
@@ -321,7 +310,7 @@ class RepoBase(object):
files = []
if self.volume_count == 0:
new_path = '"' + self.fs.path + '"'
- self.log.do(
+ do(
"genisoimage -o %s -J -joliet-long -R %s" %
(fname, new_path))
files.append(fname)
@@ -329,7 +318,7 @@ class RepoBase(object):
for i in range(self.volume_count + 1):
volfs = self.get_volume_fs(i)
newname = fname + ("%02d" % i)
- self.log.do(
+ do(
"genisoimage -o %s -J -joliet-long -R %s" %
(newname, volfs.path))
files.append(newname)
@@ -338,7 +327,7 @@ class RepoBase(object):
class UpdateRepo(RepoBase):
- def __init__(self, xml, path, log):
+ def __init__(self, xml, path):
self.xml = xml
arch = xml.text("project/arch", key="arch")
@@ -348,7 +337,6 @@ class UpdateRepo(RepoBase):
RepoBase.__init__(self,
path,
- log,
None,
repo_attrs,
"Update",
@@ -356,7 +344,7 @@ class UpdateRepo(RepoBase):
class CdromInitRepo(RepoBase):
- def __init__(self, init_codename, path, log, maxsize,
+ def __init__(self, init_codename, path, maxsize,
mirror='http://ftp.de.debian.org/debian'):
# pylint: disable=too-many-arguments
@@ -367,7 +355,6 @@ class CdromInitRepo(RepoBase):
RepoBase.__init__(self,
path,
- log,
None,
init_attrs,
"Elbe",
@@ -382,7 +369,6 @@ class CdromBinRepo(RepoBase):
codename,
init_codename,
path,
- log,
maxsize,
mirror='http://ftp.debian.org/debian'):
@@ -398,7 +384,6 @@ class CdromBinRepo(RepoBase):
RepoBase.__init__(self,
path,
- log,
init_attrs,
repo_attrs,
"Elbe",
@@ -407,7 +392,7 @@ class CdromBinRepo(RepoBase):
class CdromSrcRepo(RepoBase):
- def __init__(self, codename, init_codename, path, log, maxsize,
+ def __init__(self, codename, init_codename, path, maxsize,
mirror='http://ftp.debian.org/debian'):
# pylint: disable=too-many-arguments
@@ -427,7 +412,6 @@ class CdromSrcRepo(RepoBase):
RepoBase.__init__(self,
path,
- log,
init_attrs,
repo_attrs,
"Elbe",
@@ -436,11 +420,10 @@ class CdromSrcRepo(RepoBase):
class ToolchainRepo(RepoBase):
- def __init__(self, arch, codename, path, log):
+ def __init__(self, arch, codename, path):
repo_attrs = RepoAttributes(codename, arch, "main")
RepoBase.__init__(self,
path,
- log,
None,
repo_attrs,
"toolchain",
@@ -448,11 +431,10 @@ class ToolchainRepo(RepoBase):
class ProjectRepo(RepoBase):
- def __init__(self, arch, codename, path, log):
+ def __init__(self, arch, codename, path):
repo_attrs = RepoAttributes(codename, arch + ' source', "main")
RepoBase.__init__(self,
path,
- log,
None,
repo_attrs,
"Local",
diff --git a/elbepack/rfs.py b/elbepack/rfs.py
index 8476d01b..3d35e29c 100644
--- a/elbepack/rfs.py
+++ b/elbepack/rfs.py
@@ -10,11 +10,12 @@
import os
import urlparse
import urllib2
+import logging
from elbepack.efilesystem import BuildImgFs
from elbepack.templates import (write_pack_template, get_preseed,
preseed_to_text)
-from elbepack.shellhelper import CommandError
+from elbepack.shellhelper import CommandError, do, chroot, get_command_out
class DebootstrapException (Exception):
@@ -23,12 +24,11 @@ class DebootstrapException (Exception):
class BuildEnv (object):
- def __init__(self, xml, log, path, build_sources=False, clean=False, arch="default"):
+ def __init__(self, xml, path, build_sources=False, clean=False, arch="default"):
# pylint: disable=too-many-arguments
self.xml = xml
- self.log = log
self.path = path
self.rpcaptcache = None
self.arch = arch
@@ -59,57 +59,56 @@ class BuildEnv (object):
def cdrom_umount(self):
if self.xml.prj.has("mirror/cdrom"):
cdrompath = self.rfs.fname("cdrom")
- self.log.do('umount "%s"' % cdrompath)
- self.log.do("rm -f %s/etc/apt/trusted.gpg.d/elbe-cdrepo.gpg" %
- self.path)
- self.log.do("rm -f %s/etc/apt/trusted.gpg.d/elbe-cdtargetrepo.gpg" %
- self.path)
+ do('umount "%s"' % cdrompath)
+ do("rm -f %s/etc/apt/trusted.gpg.d/elbe-cdrepo.gpg" %
+ self.path)
+ do("rm -f %s/etc/apt/trusted.gpg.d/elbe-cdtargetrepo.gpg" %
+ self.path)
def cdrom_mount(self):
if self.xml.has("project/mirror/cdrom"):
cdrompath = self.rfs.fname("cdrom")
- self.log.do('mkdir -p "%s"' % cdrompath)
- self.log.do('mount -o loop "%s" "%s"'
- % (self.xml.text("project/mirror/cdrom"), cdrompath))
+ do('mkdir -p "%s"' % cdrompath)
+ do('mount -o loop "%s" "%s"' %
+ (self.xml.text("project/mirror/cdrom"), cdrompath))
def __enter__(self):
if os.path.exists(self.path + '/../repo/pool'):
- self.log.do("mv %s/../repo %s" % (self.path, self.path))
- self.log.do('echo "deb copy:///repo %s main" > '
- '%s/etc/apt/sources.list.d/local.list' % (
- self.xml.text("project/suite"), self.path))
- self.log.do('echo "deb-src copy:///repo %s main" >> '
- '%s/etc/apt/sources.list.d/local.list' % (
- self.xml.text("project/suite"), self.path))
+ do("mv %s/../repo %s" % (self.path, self.path))
+ do('echo "deb copy:///repo %s main" > '
+ '%s/etc/apt/sources.list.d/local.list' %
+ (self.xml.text("project/suite"), self.path))
+ do('echo "deb-src copy:///repo %s main" >> '
+ '%s/etc/apt/sources.list.d/local.list' %
+ (self.xml.text("project/suite"), self.path))
self.cdrom_mount()
self.rfs.__enter__()
if self.xml.has("project/mirror/cdrom"):
- self.log.chroot(self.rfs.path,
- 'apt-key '
- '--keyring /etc/apt/trusted.gpg.d/elbe-cdrepo.gpg '
- 'add /cdrom/repo.pub')
- self.log.chroot(self.rfs.path,
- 'apt-key '
- '--keyring /etc/apt/trusted.gpg.d/elbe-cdtargetrepo.gpg '
- 'add /cdrom/targetrepo/repo.pub')
+ chroot(self.rfs.path,
+ 'apt-key '
+ '--keyring /etc/apt/trusted.gpg.d/elbe-cdrepo.gpg '
+ 'add /cdrom/repo.pub')
+ chroot(self.rfs.path,
+ 'apt-key '
+ '--keyring /etc/apt/trusted.gpg.d/elbe-cdtargetrepo.gpg '
+ 'add /cdrom/targetrepo/repo.pub')
if os.path.exists(os.path.join(self.rfs.path, 'repo/pool')):
- self.log.chroot(self.rfs.path,
- 'apt-key '
- '--keyring /etc/apt/trusted.gpg.d/elbe-localrepo.gpg '
- 'add /repo/repo.pub')
+ chroot(self.rfs.path,
+ 'apt-key '
+ '--keyring /etc/apt/trusted.gpg.d/elbe-localrepo.gpg '
+ 'add /repo/repo.pub')
return self
def __exit__(self, typ, value, traceback):
self.rfs.__exit__(typ, value, traceback)
self.cdrom_umount()
if os.path.exists(self.path + '/repo'):
- self.log.do("mv %s/repo %s/../" % (self.path, self.path))
- self.log.do("rm %s/etc/apt/sources.list.d/local.list" % self.path)
- self.log.do("rm %s/etc/apt/trusted.gpg.d/elbe-localrepo.gpg" %
- self.path)
+ do("mv %s/repo %s/../" % (self.path, self.path))
+ do("rm %s/etc/apt/sources.list.d/local.list" % self.path)
+ do("rm %s/etc/apt/trusted.gpg.d/elbe-localrepo.gpg" % self.path)
def debootstrap(self, arch="default"):
@@ -139,13 +138,12 @@ class BuildEnv (object):
os.environ["DEBIAN_FRONTEND"] = "noninteractive"
os.environ["DEBONF_NONINTERACTIVE_SEEN"] = "true"
- self.log.h2("debootstrap log")
+ logging.info("Debootstrap log")
if arch == "default":
arch = self.xml.text("project/buildimage/arch", key="arch")
- host_arch = self.log.get_command_out(
- "dpkg --print-architecture").strip()
+ host_arch = get_command_out("dpkg --print-architecture").strip()
includepkgs = None
strapcmd = 'debootstrap '
@@ -175,7 +173,7 @@ class BuildEnv (object):
try:
self.cdrom_mount()
- self.log.do(cmd)
+ do(cmd)
except CommandError:
cleanup = True
raise DebootstrapException()
@@ -195,29 +193,29 @@ class BuildEnv (object):
self.rfs.fname("cdrom"))
else:
keyring = ''
+
cmd = '%s --foreign --arch=%s %s "%s" "%s" "%s"' % (
strapcmd, arch, keyring, suite, self.rfs.path, primary_mirror)
try:
self.cdrom_mount()
- self.log.do(cmd)
+ do(cmd)
ui = "/usr/share/elbe/qemu-elbe/" + self.xml.defs["userinterpr"]
if not os.path.exists(ui):
ui = "/usr/bin/" + self.xml.defs["userinterpr"]
- self.log.do('cp %s %s' % (ui, self.rfs.fname("usr/bin")))
+ do('cp %s %s' % (ui, self.rfs.fname("usr/bin")))
if self.xml.has("project/noauth"):
- self.log.chroot(
- self.rfs.path,
- '/debootstrap/debootstrap --no-check-gpg --second-stage')
+ chroot(self.rfs.path,
+ '/debootstrap/debootstrap --no-check-gpg --second-stage')
else:
- self.log.chroot(self.rfs.path,
- '/debootstrap/debootstrap --second-stage')
+ chroot(self.rfs.path,
+ '/debootstrap/debootstrap --second-stage')
- self.log.chroot(self.rfs.path, 'dpkg --configure -a')
+ chroot(self.rfs.path, 'dpkg --configure -a')
except CommandError:
cleanup = True
@@ -238,10 +236,10 @@ class BuildEnv (object):
def add_key(self, key):
cmd = 'echo "%s" > %s' % (key, self.rfs.fname("tmp/key.pub"))
clean = 'rm -f %s' % self.rfs.fname("tmp/key.pub")
- self.log.do(cmd)
+ do(cmd)
with self.rfs:
- self.log.chroot(self.rfs.path, 'apt-key add /tmp/key.pub')
- self.log.do(clean)
+ chroot(self.rfs.path, 'apt-key add /tmp/key.pub')
+ do(clean)
def import_keys(self):
if self.xml.has('project/mirror/url-list'):
@@ -270,7 +268,7 @@ class BuildEnv (object):
preseed_txt = preseed_to_text(preseed)
self.rfs.write_file("var/cache/elbe/preseed.txt", 0o644, preseed_txt)
with self.rfs:
- self.log.chroot(
+ chroot(
self.rfs.path, 'debconf-set-selections < %s' %
self.rfs.fname("var/cache/elbe/preseed.txt"))
@@ -313,7 +311,7 @@ class BuildEnv (object):
def seed_etc(self):
passwd = self.xml.text("target/passwd")
- self.log.chroot(
+ chroot(
self.rfs.path, """/bin/sh -c 'echo "%s\\n%s\\n" | passwd'""" %
(passwd, passwd))
@@ -322,39 +320,34 @@ class BuildEnv (object):
if self.xml.has("target/domain"):
fqdn = ("%s.%s" % (hostname, self.xml.text("target/domain")))
- self.log.chroot(
- self.rfs.path,
- """/bin/sh -c 'echo "127.0.1.1 %s %s elbe-daemon" >> """
- """/etc/hosts'""" % (fqdn,hostname))
+ chroot(self.rfs.path,
+ """/bin/sh -c 'echo "127.0.1.1 %s %s elbe-daemon" >> """
+ """/etc/hosts'""" % (fqdn,hostname))
- self.log.chroot(
- self.rfs.path,
- """/bin/sh -c 'echo "%s" > /etc/hostname'""" % hostname)
+ chroot(self.rfs.path,
+ """/bin/sh -c 'echo "%s" > /etc/hostname'""" % hostname)
- self.log.chroot(
- self.rfs.path,
- """/bin/sh -c 'echo "%s" > """
- """/etc/mailname'""" % (fqdn))
+ chroot(self.rfs.path,
+ """/bin/sh -c 'echo "%s" > """
+ """/etc/mailname'""" % (fqdn))
if self.xml.has("target/console"):
serial_con, serial_baud = self.xml.text(
"target/console").split(',')
if serial_baud:
- self.log.chroot(
- self.rfs.path,
- """/bin/sh -c '[ -f /etc/inittab ] && """
- """echo "T0:23:respawn:/sbin/getty -L %s %s vt100" >> """
- """/etc/inittab'""" % (serial_con, serial_baud),
- allow_fail=True)
-
- self.log.chroot(
- self.rfs.path,
- """/bin/sh -c """
- """'[ -f /lib/systemd/system/serial-getty at .service ] && """
- """ln -s /lib/systemd/system/serial-getty at .service """
- """/etc/systemd/system/getty.target.wants/"""
- """serial-getty@%s.service'""" % serial_con,
- allow_fail=True)
+ chroot(self.rfs.path,
+ """/bin/sh -c '[ -f /etc/inittab ] && """
+ """echo "T0:23:respawn:/sbin/getty -L %s %s vt100" >> """
+ """/etc/inittab'""" % (serial_con, serial_baud),
+ allow_fail=True)
+
+ chroot(self.rfs.path,
+ """/bin/sh -c """
+ """'[ -f /lib/systemd/system/serial-getty at .service ] && """
+ """ln -s /lib/systemd/system/serial-getty at .service """
+ """/etc/systemd/system/getty.target.wants/"""
+ """serial-getty@%s.service'""" % serial_con,
+ allow_fail=True)
else:
- self.log.printo("parsing console tag failed, needs to be of "
- "'/dev/ttyS0,115200' format.")
+ logging.error("parsing console tag failed, needs to be of "
+ "'/dev/ttyS0,115200' format.")
diff --git a/elbepack/updatepkg.py b/elbepack/updatepkg.py
index b41cffe0..8c14aa23 100644
--- a/elbepack/updatepkg.py
+++ b/elbepack/updatepkg.py
@@ -114,7 +114,7 @@ def gen_update_pkg(project, xml_filename, upd_filename,
if xml_filename:
repodir = os.path.join(update, "repo")
- repo = UpdateRepo(xml, repodir, project.log)
+ repo = UpdateRepo(xml, repodir)
for fname in fnamelist:
path = os.path.join(
--
2.11.0
More information about the elbe-devel
mailing list