[elbe-devel] [PATCH 2/8] buildrepo: first version of buildrepo
Manuel Traut
manut at linutronix.de
Fri Oct 19 15:20:31 CEST 2018
On Thu, Sep 27, 2018 at 12:34:15PM +0200, Torben Hohn wrote:
> when the initvm is setup, it is necessary to download the sources,
> used by the binary packages in the initvm. "elbe buildrepo" is
> supposed to build up a debian repo, that contains all the binaries and
> sources used in the initvm.
>
> Later on, this repo will be used to seed the inivm related packages and
> sources in the generated cdroms.
docs/elbe-buildrepo.txt should be also added.
> Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
> ---
> elbepack/commands/buildrepo.py | 141 +++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 141 insertions(+)
> create mode 100644 elbepack/commands/buildrepo.py
>
> diff --git a/elbepack/commands/buildrepo.py b/elbepack/commands/buildrepo.py
I'm not happy with the command name.
I would prefer something like 'fetchinitvmpkgs'
> new file mode 100644
> index 00000000..82ff64ba
> --- /dev/null
> +++ b/elbepack/commands/buildrepo.py
> @@ -0,0 +1,141 @@
> +# ELBE - Debian Based Embedded Rootfilesystem Builder
> +# Copyright (c) 2013-2015 Torben Hohn <torbenh at linutronix.de>
> +# Copyright (c) 2013-2014, 2016-2017 Manuel Traut <manut at linutronix.de>
> +# Copyright (c) 2014 Stefan Gast <stefan.gast at linutronix.de>
> +# Copyright (c) 2015 Matthias Buehler <Matthias.Buehler at de.trumpf.com>
> +#
> +# SPDX-License-Identifier: GPL-3.0-or-later
please start with an up to date header
rest looks sane.
> +from __future__ import print_function
> +
> +import sys
> +from optparse import OptionParser
> +
> +from apt.package import FetchError
> +from apt import Cache
> +
> +from elbepack.elbexml import ElbeXML, ValidationError
> +from elbepack.repomanager import CdromInitRepo, CdromSrcRepo
> +from elbepack.asciidoclog import StdoutLog
> +from elbepack.dump import get_initvm_pkglist
> +from elbepack.aptprogress import ElbeAcquireProgress
> +from elbepack.filesystem import hostfs
> +
> +
> +def run_command(argv):
> + oparser = OptionParser(
> + usage="usage: %prog buildrepo [options] <xmlfile>")
> +
> + oparser.add_option("-b", "--binrepo", dest="binrepo",
> + default="/var/cache/elbe/initvm-bin-repo",
> + help="directory where the bin repo should reside")
> +
> + oparser.add_option("-s", "--srcrepo", dest="srcrepo",
> + default="/var/cache/elbe/initvm-src-repo",
> + help="directory where the src repo should reside")
> +
> + oparser.add_option("--proxy", dest="proxy",
> + help="Override the http proxy")
> +
> + oparser.add_option("--debug", action="store_true", dest="debug",
> + default=False,
> + help="Enable various features to debug the build")
> +
> + oparser.add_option("--skip-validation", action="store_true",
> + dest="skip_validation", default=False,
> + help="Skip xml schema validation")
> +
> + oparser.add_option("--cdrom-mount-path", dest="cdrom",
> + help="path where cdrom is mounted")
> +
> + oparser.add_option("--apt-archive", dest="archive",
> + default="/var/cache/elbe/binaries/main",
> + help="path where binary packages are downloaded to.")
> +
> + oparser.add_option("--src-archive", dest="srcarchive",
> + default="/var/cache/elbe/sources",
> + help="path where src packages are downloaded to.")
> +
> + (opt, args) = oparser.parse_args(argv)
> +
> + if len(args) != 1:
> + print("wrong number of arguments")
> + oparser.print_help()
> + sys.exit(20)
> +
> + try:
> + xml = ElbeXML(args[0], skip_validate=opt.skip_validation)
> + except ValidationError as e:
> + print(str(e))
> + print("xml validation failed. Bailing out")
> + sys.exit(20)
> +
> + log = StdoutLog()
> + mirror = xml.get_initvm_primary_mirror(opt.cdrom)
> + init_codename = xml.get_initvm_codename()
> +
> + # Binary Repo
> + #
> + repo = CdromInitRepo(init_codename, opt.binrepo, log, 0, mirror)
> + hostfs.mkdir_p(opt.archive)
> +
> + pkglist = get_initvm_pkglist()
> + cache = Cache()
> + cache.open()
> + for pkg in pkglist:
> + try:
> + p = cache[pkg.name]
> + pkgver = p.installed
> + deb = pkgver.fetch_binary(opt.archive,
> + ElbeAcquireProgress(cb=None))
> + repo.includedeb(deb, 'main')
> + except ValueError:
> + log.printo("No Package " + pkg.name +
> + "-" + str(pkg.installed_version))
> + except FetchError:
> + log.printo(
> + "Package " +
> + pkg.name +
> + "-" +
> + pkgver.version +
> + " could not be downloaded")
> + except TypeError:
> + log.printo("Package " +
> + pkg.name +
> + "-" +
> + str(pkg.installed_version) +
> + " missing name or version")
> +
> + repo.finalize()
> +
> + # Source Repo
> + #
> + repo = CdromSrcRepo(init_codename, init_codename, opt.srcrepo, log, 0, mirror)
> + hostfs.mkdir_p(opt.srcarchive)
> +
> + for pkg in pkglist:
> + try:
> + p = cache[pkg.name]
> + pkgver = p.installed
> + dsc = pkgver.fetch_source(opt.srcarchive,
> + ElbeAcquireProgress(cb=None),
> + unpack=False)
> + repo.includedsc(dsc, 'main')
> + except ValueError:
> + log.printo("No Package " + pkg.name +
> + "-" + str(pkg.installed_version))
> + except FetchError:
> + log.printo(
> + "Package " +
> + pkg.name +
> + "-" +
> + pkgver.version +
> + " could not be downloaded")
> + except TypeError:
> + log.printo("Package " +
> + pkg.name +
> + "-" +
> + str(pkg.installed_version) +
> + " missing name or version")
> +
> + repo.finalize()
> --
> 2.11.0
>
>
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel
More information about the elbe-devel
mailing list