From: Alexander Smirnov <asmirnov@ilbers.de>
To: Cedric_Hombourger@mentor.com, isar-users@googlegroups.com
Subject: Re: [PATCH 1/5] base: add populate_repo task to include distro packages to the repo
Date: Mon, 5 Feb 2018 13:06:15 +0300 [thread overview]
Message-ID: <5e18edf4-a6b0-c85c-d50e-67a9aaeab0cb@ilbers.de> (raw)
In-Reply-To: <20180204175454.220-2-Cedric_Hombourger@mentor.com>
Hi,
n 02/04/2018 08:54 PM, Cedric_Hombourger@mentor.com wrote:
> From: Cedric Hombourger <Cedric_Hombourger@mentor.com>
>
> A package repository is already created for custom packages (built by
> Isar). Provide a populate_repo task to also include any packages
> included into images built by Isar. This mechanism will add both binary
> and source packages. The augmented repository may be used later for
> reproducible builds (technically, packages pulled for the buildchroots
> we build should also be added; this will be the subject of another
> changeset).
Isar-apt should never be used to mirror upstream repositories. Isar-apt
intended to be an overlay for pure Debian.
Regarding reproducibility, there are already two series discusses in
this list which introduce dedicated base-apt repository for caching
upstream:
https://groups.google.com/d/msg/isar-users/9b0f6LP4X6k/LJ3mLxE1EAAJ
https://groups.google.com/d/msg/isar-users/QQUsVmSaAGk/B6FGnVWhAQAJ
Alex
>
> Signed-off-by: Cedric Hombourger <Cedric_Hombourger@mentor.com>
> ---
> .../recipes-core/images/files/multistrap.conf.in | 6 +-
> meta-isar/recipes-core/images/isar-image-base.bb | 78 ++++++++++++++++++++++
> 2 files changed, 81 insertions(+), 3 deletions(-)
>
> diff --git a/meta-isar/recipes-core/images/files/multistrap.conf.in b/meta-isar/recipes-core/images/files/multistrap.conf.in
> index 432b6af..8e4e276 100644
> --- a/meta-isar/recipes-core/images/files/multistrap.conf.in
> +++ b/meta-isar/recipes-core/images/files/multistrap.conf.in
> @@ -16,19 +16,19 @@ source=##DISTRO_APT_SOURCE##
> suite=##DISTRO_SUITE##
> components=##DISTRO_COMPONENTS##
> packages=##IMAGE_PREINSTALL##
> -omitdebsrc=true
> +omitdebsrc=false
>
> [updates]
> source=##DISTRO_APT_SOURCE##
> suite=##DISTRO_SUITE##-updates
> components=##DISTRO_COMPONENTS##
> -omitdebsrc=true
> +omitdebsrc=false
>
> [security]
> source=##DISTRO_APT_SOURCE_SEC##
> suite=##DISTRO_SUITE##/updates
> components=##DISTRO_COMPONENTS##
> -omitdebsrc=true
> +omitdebsrc=false
>
> [Isar]
> packages=##IMAGE_INSTALL##
> diff --git a/meta-isar/recipes-core/images/isar-image-base.bb b/meta-isar/recipes-core/images/isar-image-base.bb
> index dea2cdb..6ce3d6d 100644
> --- a/meta-isar/recipes-core/images/isar-image-base.bb
> +++ b/meta-isar/recipes-core/images/isar-image-base.bb
> @@ -52,6 +52,79 @@ do_rootfs_populate_dev() {
> _mknod_cdev 666 ptmx 5 2
> }
>
> +do_populate_repo() {
> +
> + APT_CACHEDIR=${IMAGE_ROOTFS}/var/cache/apt # Home of the apt cache (for the target image)
> + APT_DEBDIR=${APT_CACHEDIR}/archives # Downloaded packages can be found there
> + APT_SRCDIR=${WORKDIR}/apt-sources # Put source packages outside of the rootfs
> +
> + sudo mkdir -p ${APT_SRCDIR}
> +
> + apt_status_file=$(mktemp)
> + for p in ${DEPLOY_DIR_DEB}/${PN}/*.deb; do
> + # Only process packages that were NOT built by Isar (already added to the repo)
> + deb=$(basename ${p})
> + if [ ! -f ${DEPLOY_DIR_DEB}/${deb} ]; then
> + # Extract package name
> + pkg=$(dpkg-deb -I ${p}|grep -e '^ Package:'|sed -e 's,^ Package: ,,g')
> +
> + # Extract package section and priority so we can tell rerepro where to place this package
> + sect=$(dpkg-deb -I ${p}|grep -e '^ Section:'|sed -e 's,^ Section: ,,g')
> + prio=$(dpkg-deb -I ${p}|grep -e '^ Priority:'|sed -e 's,^ Priority: ,,g')
> +
> + # Determine name of the source package (same as the binary package if not specified)
> + src=$(dpkg-deb -I ${p}|grep -e '^ Source:'|sed -e 's,^ Source: ,,g'|awk '{ print $1; }')
> + src=${src:-${pkg}}
> +
> + # Add the binary package to the repo
> + call_reprepro -b ${DEPLOY_DIR_APT}/${DISTRO} \
> + --dbdir ${DEPLOY_DIR_DB}/${DISTRO} \
> + -C main -S ${sect} -P ${prio} \
> + includedeb ${DEBDISTRONAME} ${p}
> +
> + # Get source package and add it to the repo
> + # Notes:
> + # - multistrap --source-dir is failing to fetch sources hence this manual process
> + # (the culprit appears to be the following apt-get option: APT::Default-Release='*')
> + # - the apt-get command-line was copied from multistrap and tweaked for sources
> + # (a separate/temporary apt status file is used to avoid polluting the existing one
> + # with source transactions)
> + # - as we assume sources were already fetched if the directory exists, quietly
> + # attempt to delete it first; if sources are indeed there, it will fetch. If
> + # they aren't, the directory will be deleted and we will have another go at it
> + rmdir ${APT_SRCDIR}/${src} 2>/dev/null || true
> + if [ ! -d "${APT_SRCDIR}/${src}" ]; then
> + sudo mkdir -p ${APT_SRCDIR}/${src}
> + cd ${APT_SRCDIR}/${src}
> + bbnote "fetching source package '${src}' (binary: ${pkg})"
> + sudo -E apt-get \
> + -o Dir::Etc::TrustedParts=${IMAGE_ROOTFS}/etc/apt/trusted.gpg.d \
> + -o Dir::Etc::Trusted=${IMAGE_ROOTFS}/etc/apt/trusted.gpg \
> + -o Apt::Get::AllowUnauthenticated=true \
> + -o Apt::Get::Download-Only=true \
> + -o Apt::Install-Recommends=false \
> + -o Dir=${IMAGE_ROOTFS} \
> + -o Dir::Etc=${IMAGE_ROOTFS}/etc/apt/ \
> + -o Dir::Etc::Parts=${IMAGE_ROOTFS}/etc/apt/apt.conf.d/ \
> + -o Dir::Etc::PreferencesParts=${IMAGE_ROOTFS}/etc/apt/preferences.d/ \
> + -o Dir::State=${IMAGE_ROOTFS}/var/lib/apt/ \
> + -o Dir::State::Status=${apt_status_file} \
> + -o Dir::Cache=${IMAGE_ROOTFS}/var/cache/apt/ -y source ${src}
> + call_reprepro -b ${DEPLOY_DIR_APT}/${DISTRO} \
> + --dbdir ${DEPLOY_DIR_DB}/${DISTRO} \
> + -C main -S ${sect} -P ${prio} \
> + includedsc ${DEBDISTRONAME} \
> + ${APT_SRCDIR}/${src}/*.dsc
> + else
> + bbnote "already fetched source package '${src}' (binary: ${pkg})"
> + fi
> + fi
> + done
> + rm -f ${apt_status_file}
> +}
> +
> +addtask populate_repo
> +
> do_rootfs() {
> E="${@ bb.utils.export_proxies(d)}"
>
> @@ -94,6 +167,11 @@ do_rootfs() {
> # because of proxy settings
> sudo -E multistrap -a ${DISTRO_ARCH} -d "${IMAGE_ROOTFS}" -f "${WORKDIR}/multistrap.conf"
>
> + # Copy packages before they vanish when the root file-systems get configured
> + # (apt purge is being run)
> + install -m 755 -d ${DEPLOY_DIR_DEB}/${PN}
> + sudo cp -l ${IMAGE_ROOTFS}/var/cache/apt/archives/*.deb ${DEPLOY_DIR_DEB}/${PN}/
> +
> # Configure root filesystem
> sudo chroot ${IMAGE_ROOTFS} /${DISTRO_CONFIG_SCRIPT} ${MACHINE_SERIAL} ${BAUDRATE_TTY} \
> ${ROOTFS_DEV}
>
--
With best regards,
Alexander Smirnov
ilbers GmbH
Baierbrunner Str. 28c
D-81379 Munich
+49 (89) 122 67 24-0
http://ilbers.de/
Commercial register Munich, HRB 214197
General manager: Baurzhan Ismagulov
next prev parent reply other threads:[~2018-02-05 10:06 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-04 17:54 [PATCH 0/5] support creation of a full repo for offline/reproducible builds Cedric_Hombourger
2018-02-04 17:54 ` [PATCH 1/5] base: add populate_repo task to include distro packages to the repo Cedric_Hombourger
2018-02-05 10:06 ` Alexander Smirnov [this message]
2018-02-04 17:54 ` [PATCH 2/5] meta: move reprepro handling code to its own class Cedric_Hombourger
2018-02-04 17:54 ` [PATCH 3/5] buildchroot: use reprepro to populate the full repo Cedric_Hombourger
2018-02-04 17:54 ` [PATCH 4/5] reprepro: create the -updates distribution Cedric_Hombourger
2018-02-04 17:56 ` [PATCH 5/5] multistrap: make the security feed optional Cedric_Hombourger
2018-02-05 7:18 ` [PATCH 0/5] support creation of a full repo for offline/reproducible builds Jan Kiszka
2018-02-05 9:11 ` Benedikt Niedermayr
2018-02-05 10:26 ` Alexander Smirnov
2018-02-05 10:31 ` Jan Kiszka
2018-02-05 11:22 ` Benedikt Niedermayr
2018-02-05 10:08 ` Benedikt Niedermayr
2018-02-05 10:16 ` chombourger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5e18edf4-a6b0-c85c-d50e-67a9aaeab0cb@ilbers.de \
--to=asmirnov@ilbers.de \
--cc=Cedric_Hombourger@mentor.com \
--cc=isar-users@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox