From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6662700470316826624 X-Received: by 2002:a1c:9d91:: with SMTP id g139mr81577wme.24.1551431486752; Fri, 01 Mar 2019 01:11:26 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a7b:c0cc:: with SMTP id s12ls400264wmh.14.gmail; Fri, 01 Mar 2019 01:11:26 -0800 (PST) X-Google-Smtp-Source: AHgI3IaAoRd4JW/BgIZ5lM7Nom4bc0WBH1fcjLQc2ofSF5l1u0I0f2WYe9/tvosD+4EVu7UCsBfU X-Received: by 2002:a1c:1f90:: with SMTP id f138mr262661wmf.3.1551431486277; Fri, 01 Mar 2019 01:11:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551431486; cv=none; d=google.com; s=arc-20160816; b=yg1AcTbtLYcCjaC94NSp/WSlpHGvK92PfVVR51hsFW2OAhZ1nkkGIAncCqzTWIxwu3 ze9/KTbz8fyMAElYWg7gW9cJJ+7sStCBXhK9KCV+GehHwE2lw9QoVRHmNb2/RjFwfgTT vxmCaB7jSP84s2+3QdNr9XBjeZe+VRC66Y8/M7R1WHkg4YfkQtWvrWj6hwW60wRmxiia pWA+jAftEGSkO1gSSizYsJ28TfkWj0Fue3zS3IiPUcbLMrOTpjA7w5jysy5J1acx+06S WzjQMB1AKe8UINdqjmPJ7z6ObaZG40FgXDskKsUU9Tr1g9NejuXTaJYj3NzIIrdJmYam HsPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:content-description :mime-version:references:message-id:subject:cc:to:from:date; bh=hjvI7Oe4AW9dpn2jRkr/315uLZxiKxtyKWl9rcrP7nw=; b=BqGZ6YvQ77IqnExZzVjqyPiaaZmTsFtxB+BE8oga86Y/EXIGKFu2im+SBUzazH59/+ IR4Som1WGUPO7pU/IWKG7CTYHBTNkryOLEJWuH7coXxy9VX6YFkyw7rceyrXcETZ+ToP CpH0176SdNNoF3fGTdjMwmyEObt5DoipmvpRDAM0oFlUqfFkAu4coI69xpqVhFN+kNsS F5fEmvKXxEPbuDct/p2y/ibQO3OnvmhYBUlFXTqwnWHBLN40glhoHjK+Bbhy6ukRqd9I 64qSLONqwue3TItVxOjgzoTxcdJlTI2tOoJnXyGeOn+J9AOrv3stJbmyw3TvQ4+0BvSH uOUg== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of andreas.reichel.ext@siemens.com designates 192.35.17.28 as permitted sender) smtp.mailfrom=andreas.reichel.ext@siemens.com Return-Path: Received: from goliath.siemens.de (goliath.siemens.de. [192.35.17.28]) by gmr-mx.google.com with ESMTPS id t22si384403wmj.2.2019.03.01.01.11.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Mar 2019 01:11:26 -0800 (PST) Received-SPF: pass (google.com: domain of andreas.reichel.ext@siemens.com designates 192.35.17.28 as permitted sender) client-ip=192.35.17.28; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of andreas.reichel.ext@siemens.com designates 192.35.17.28 as permitted sender) smtp.mailfrom=andreas.reichel.ext@siemens.com Received: from mail1.sbs.de (mail1.sbs.de [192.129.41.35]) by goliath.siemens.de (8.15.2/8.15.2) with ESMTPS id x219BPRx014157 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 1 Mar 2019 10:11:25 +0100 Received: from iiotirae (golem.ppmd.siemens.net [139.25.69.17]) by mail1.sbs.de (8.15.2/8.15.2) with SMTP id x219BP6g023348; Fri, 1 Mar 2019 10:11:25 +0100 Date: Fri, 1 Mar 2019 10:09:49 +0100 From: Andreas Reichel To: Henning Schild Cc: isar-users@googlegroups.com Subject: Re: [PATCH v2 1/3] Fix and simplify apt keyring generation Message-ID: <20190301090949.GB10350@iiotirae> References: <20190227151856.11594-1-andreas.reichel.ext@siemens.com> <20190227151856.11594-2-andreas.reichel.ext@siemens.com> <20190227171242.5c2c73b4@md1za8fc.ad001.siemens.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Description: message Content-Disposition: inline In-Reply-To: <20190227171242.5c2c73b4@md1za8fc.ad001.siemens.net> User-Agent: Mutt/1.11.3 (2019-02-01) X-TUID: vT8XaAPKynSA On Wed, Feb 27, 2019 at 05:12:42PM +0100, Henning Schild wrote: > Am Wed, 27 Feb 2019 16:18:54 +0100 > schrieb "[ext] Andreas J. Reichel" : > > > From: Andreas Reichel > > > > Different fetcher stored keys in different sub dirs, and we can never > > be sure about where downloaded files go. > > To avoid this without making any assumptions, we ask the fetcher where > > the file will be after it is downloaded. This way we also don't need > > to parse the URL manually. > > > > The code is simplified by removing duplicate code and using apt-key > > instead of manually calling gpg. > > > > Signed-off-by: Andreas Reichel > > --- > > meta/classes/isar-bootstrap-helper.bbclass | 11 ++++++ > > .../isar-bootstrap/isar-bootstrap.inc | 39 > > +++++++++---------- 2 files changed, 29 insertions(+), 21 deletions(-) > > > > diff --git a/meta/classes/isar-bootstrap-helper.bbclass > > b/meta/classes/isar-bootstrap-helper.bbclass index d780b85..b8c41f9 > > 100644 --- a/meta/classes/isar-bootstrap-helper.bbclass > > +++ b/meta/classes/isar-bootstrap-helper.bbclass > > @@ -119,6 +119,16 @@ setup_root_file_system() { > > export LANG=C > > export LANGUAGE=C > > export LC_ALL=C > > + > > + if [ -d ${TMPDIR}/aptkeys ]; then > > + for keyfile in ${TMPDIR}/aptkeys/* > > + do > > + kfn="tmp/$(basename $keyfile)" > > + cp $keyfile "$ROOTFSDIR/$kfn" > > + sudo -E chroot "$ROOTFSDIR" /usr/bin/apt-key add "/$kfn" > > Would probably be a good idea to work in /tmp/ as well and in a subdir. > Try naming your key "root" or "usr" ... > > > + rm "$ROOTFSDIR/$kfn" > > + done > > + fi > > sudo -E chroot "$ROOTFSDIR" /usr/bin/apt-get update \ > > -o Dir::Etc::sourcelist="sources.list.d/isar-apt.list" \ > > -o Dir::Etc::sourceparts="-" \ > > @@ -128,6 +138,7 @@ setup_root_file_system() { > > sudo -E chroot "$ROOTFSDIR" /usr/bin/dpkg --add-architecture > > ${DISTRO_ARCH} sudo -E chroot "$ROOTFSDIR" /usr/bin/apt-get update > > fi > > + sudo -E chroot "$ROOTFSDIR" /usr/bin/apt-key update > > sudo -E chroot "$ROOTFSDIR" \ > > /usr/bin/apt-get ${APT_ARGS} --download-only $PACKAGES \ > > ${IMAGE_TRANSIENT_PACKAGES} > > diff --git a/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc > > b/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc index > > 234d339..2ef3b1e 100644 --- > > a/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc +++ > > b/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc @@ -23,35 > > +23,30 @@ APTSRCS = "${WORKDIR}/apt-sources" APTSRCS_INIT = > > "${WORKDIR}/apt-sources-init" BASEAPTSRCS = > > "${WORKDIR}/base-apt-sources" APTKEYFILES = "" > > -APTKEYRING = "${WORKDIR}/apt-keyring.gpg" > > -DEBOOTSTRAP_KEYRING = "" > > DEPLOY_ISAR_BOOTSTRAP ?= "" > > -DISTRO_BOOTSTRAP_BASE_PACKAGES = "locales" > > +DISTRO_BOOTSTRAP_BASE_PACKAGES = "locales gnupg2 apt-transport-https > > ca-certificates" > > That looks more like leftovers from an experiment. Are you sure that is > needed? This is needed because debootstrap can switch to https by itself if it is unsure about the sources (apt-transport-https, ca-certificates), gnupg2 we need for apt-key. > > > In general i think that patch should be splittet into two or > even more patches. Because it solves at least two problems. > > Henning > > > DISTRO_APT_PREMIRRORS ?= "${@ "http://ftp\.(\S+\.)?debian.org > > file:///${REPO_BASE_DIR} \n" if > > bb.utils.to_boolean(d.getVar('ISAR_USE_CACHED_BASE_REPO')) else "" }" > > inherit base-apt-helper > > python () { > > - from urllib.parse import urlparse > > distro_apt_keys = d.getVar("DISTRO_APT_KEYS", False) > > - wd = d.getVar("WORKDIR", True) > > + aptkeys = [] > > + > > if distro_apt_keys: > > - d.setVar("DEBOOTSTRAP_KEYRING", "--keyring ${APTKEYRING}") > > - for key in distro_apt_keys.split(): > > - url = urlparse(key) > > - filename = ''.join([wd, url.path]) > > - d.appendVar("SRC_URI", " %s" % key) > > - d.appendVar("APTKEYFILES", " %s" % filename) > > + aptkeys += distro_apt_keys.split() > > + > > if bb.utils.to_boolean(d.getVar('ISAR_USE_CACHED_BASE_REPO')): > > own_pub_key = d.getVar("BASE_REPO_KEY", False) > > if own_pub_key: > > - d.setVar("DEBOOTSTRAP_KEYRING", "--keyring > > ${APTKEYRING}") > > - for key in own_pub_key.split(): > > - url = urlparse(key) > > - filename = ''.join([wd, url.path]) > > - d.appendVar("SRC_URI", " %s" % key) > > - d.appendVar("APTKEYFILES", " %s" % filename) > > + aptkeys += own_pub_keys.split() > > + > > + for key in aptkeys: > > + d.appendVar("SRC_URI", " %s" % key) > > + fetcher = bb.fetch2.Fetch([key], d) > > + filename = fetcher.localpath(key) > > + d.appendVar("APTKEYFILES", " %s" % filename) > > } > > > > def aggregate_files(d, file_list, file_out): > > @@ -174,13 +169,17 @@ def get_distro_components_argument(d, is_host): > > else: > > return "" > > > > +APTKEYTMPDIR := "${TMPDIR}/aptkeys" > > + > > +do_generate_keyring[cleandirs] = "${APTKEYTMPDIR}" > > do_generate_keyring[dirs] = "${DL_DIR}" > > do_generate_keyring[vardeps] += "DISTRO_APT_KEYS" > > do_generate_keyring() { > > if [ -n "${@d.getVar("APTKEYFILES", True) or ""}" ]; then > > + chmod 777 "${APTKEYTMPDIR}" > > for keyfile in ${@d.getVar("APTKEYFILES", True)}; do > > - gpg --no-default-keyring --keyring "${APTKEYRING}" \ > > - --no-tty --homedir "${DL_DIR}" --import "$keyfile" > > + cp "$keyfile" "${APTKEYTMPDIR}"/"$(basename "$keyfile")" > > + sudo apt-key add "$keyfile" > > done > > fi > > } > > @@ -222,7 +221,6 @@ isar_bootstrap() { > > if [ ${IS_HOST} ]; then > > ${DEBOOTSTRAP} $debootstrap_args \ > > ${@get_distro_components_argument(d, > > True)} \ > > - ${DEBOOTSTRAP_KEYRING} \ > > "${@get_distro_suite(d, True)}" \ > > "${ROOTFSDIR}" \ > > "${@get_distro_source(d, True)}" > > @@ -231,7 +229,6 @@ isar_bootstrap() { > > "${DEBOOTSTRAP}" $debootstrap_args \ > > --arch="${DISTRO_ARCH}" \ > > ${@get_distro_components_argument(d, > > False)} \ > > - ${DEBOOTSTRAP_KEYRING} \ > > "${@get_distro_suite(d, False)}" \ > > "${ROOTFSDIR}" \ > > "${@get_distro_source(d, False)}" > -- Andreas Reichel Dipl.-Phys. (Univ.) Software Consultant Andreas.Reichel@tngtech.com, +49-174-3180074 TNG Technology Consulting GmbH, Betastr. 13a, 85774 Unterfoehring Geschaeftsfuehrer: Henrik Klagges, Dr. Robert Dahlke, Gerhard Mueller Sitz: Unterfoehring * Amtsgericht Muenchen * HRB 135082