From: Alexander Smirnov <asmirnov@ilbers.de>
To: isar-users@googlegroups.com
Cc: Alexander Smirnov <asmirnov@ilbers.de>
Subject: [PATCH 1/4] isar-apt: Introduce separate recipe
Date: Thu, 1 Feb 2018 14:29:41 +0300 [thread overview]
Message-ID: <20180201112944.7877-2-asmirnov@ilbers.de> (raw)
In-Reply-To: <20180201112944.7877-1-asmirnov@ilbers.de>
Motivation: in current implementation whole isar-apt logic are done as
a part of image class. This actually not the optimal way due to the
various issues like:
- isar-apt should be singletone in current tree despite on amount of images
to be built.
- isar-apt API could be possible extended, for example by adding do_export().
- *-image is not the mandatory target to build. User may build just
example-hello, but isar-apt should handle this.
So there should be separate recipe which is responsibe for isar-apt management.
Also isar-apt should be a static part of core Isar like buildchroot.
This patch drops isar-apt from image class, and introduces isar-apt recipe.
Signed-off-by: Alexander Smirnov <asmirnov@ilbers.de>
---
meta-isar/conf/local.conf.sample | 4 --
.../recipes-core/images/files/distributions.in | 3 -
meta/classes/dpkg-base.bbclass | 12 +++-
meta/classes/image.bbclass | 67 +---------------------
.../isar-apt/files/distributions.in | 3 +
meta/recipes-devtools/isar-apt/isar-apt.bb | 29 ++++++++++
6 files changed, 43 insertions(+), 75 deletions(-)
delete mode 100644 meta-isar/recipes-core/images/files/distributions.in
create mode 100644 meta/recipes-devtools/isar-apt/files/distributions.in
create mode 100644 meta/recipes-devtools/isar-apt/isar-apt.bb
diff --git a/meta-isar/conf/local.conf.sample b/meta-isar/conf/local.conf.sample
index 33d988e..2ae43e7 100644
--- a/meta-isar/conf/local.conf.sample
+++ b/meta-isar/conf/local.conf.sample
@@ -158,7 +158,3 @@ IMAGE_INSTALL = "example-hello example-raw"
#
# Default parallel jobs for bitbake:
BB_NUMBER_THREADS = "4"
-
-#
-# Number of attempts to try to get reprepro lock for access to apt cache
-REPREPRO_LOCK_ATTEMPTS = "16"
diff --git a/meta-isar/recipes-core/images/files/distributions.in b/meta-isar/recipes-core/images/files/distributions.in
deleted file mode 100644
index cd214c6..0000000
--- a/meta-isar/recipes-core/images/files/distributions.in
+++ /dev/null
@@ -1,3 +0,0 @@
-Codename: {DISTRO_NAME}
-Architectures: i386 armhf amd64 source
-Components: main
diff --git a/meta/classes/dpkg-base.bbclass b/meta/classes/dpkg-base.bbclass
index 4941f9b..026028f 100644
--- a/meta/classes/dpkg-base.bbclass
+++ b/meta/classes/dpkg-base.bbclass
@@ -31,11 +31,17 @@ do_build() {
_do_build_cleanup
}
-# Install package to dedicated deploy directory
+# Install package to Isar-apt
do_deploy_deb() {
- install -m 644 ${WORKDIR}/*.deb ${DEPLOY_DIR_DEB}/
+ reprepro -b ${DEPLOY_DIR_APT}/${DISTRO} \
+ --dbdir ${DEPLOY_DIR_DB}/${DISTRO} \
+ -C main \
+ includedeb ${DEBDISTRONAME} \
+ ${WORKDIR}/*.deb
}
addtask deploy_deb after do_build
do_deploy_deb[dirs] = "${DEPLOY_DIR_DEB}"
-do_deploy_deb[stamp-extra-info] = "${MACHINE}"
+do_deploy_deb[stamp-extra-info] = "${DISTRO}-${MACHINE}"
+do_deploy_deb[lockfiles] = "${DEPLOY_DIR_APT}/isar.lock"
+do_deploy_deb[depends] = "isar-apt:do_cache_config"
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index e2cb01b..cbd74b3 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -17,70 +17,6 @@ KERNEL_IMAGE ?= "${@get_image_name(d, 'vmlinuz')}"
INITRD_IMAGE ?= "${@get_image_name(d, 'initrd.img')}"
inherit ${IMAGE_TYPE}
-call_reprepro() {
- for i in $(seq 1 ${REPREPRO_LOCK_ATTEMPTS}); do
- # According to `sh` manual page, shell exit statuses fall between
- # 0-255. The EEXIST error code is (-17), so casting to usigned 8-bit
- # integer results value (239).
- eexist=$(python -c 'import errno; print(256-errno.EEXIST)')
- retval="0"
- reprepro $* || retval="$?"
-
- # If reprepro has failed to get database lock, it returns EEXIST code.
- # In this case we continue trying to get lock until max amount of
- # attempts is reached.
- if [ $retval -eq $eexist ]; then
- bbwarn "Failed to get reprepro lock, trying again..."
- sleep 5
- else
- break
- fi
- done
-
- if [ $retval -ne 0 ]; then
- bbfatal "reprepro failed"
- fi
-}
-
-CACHE_CONF_DIR = "${DEPLOY_DIR_APT}/${DISTRO}/conf"
-do_cache_config[dirs] = "${CACHE_CONF_DIR}"
-do_cache_config[stamp-extra-info] = "${DISTRO}"
-
-# Generate reprepro config for current distro if it doesn't exist. Once it's
-# generated, this task should do nothing.
-do_cache_config() {
- if [ ! -e "${CACHE_CONF_DIR}/distributions" ]; then
- sed -e "s#{DISTRO_NAME}#"${DEBDISTRONAME}"#g" \
- ${FILESDIR}/distributions.in > ${CACHE_CONF_DIR}/distributions
- fi
-
- path_cache="${DEPLOY_DIR_APT}/${DISTRO}"
- path_databases="${DEPLOY_DIR_DB}/${DISTRO}"
-
- if [ ! -d "${path_databases}" ]; then
- call_reprepro -b ${path_cache} \
- --dbdir ${path_databases} \
- export ${DEBDISTRONAME}
- fi
-}
-
-addtask cache_config before do_populate
-
-do_populate[stamp-extra-info] = "${DISTRO}-${MACHINE}"
-
-# Populate Isar apt repository by newly built packages
-do_populate() {
- if [ -n "${IMAGE_INSTALL}" ]; then
- call_reprepro -b ${DEPLOY_DIR_APT}/${DISTRO} \
- --dbdir ${DEPLOY_DIR_DB}/${DISTRO} \
- -C main \
- includedeb ${DEBDISTRONAME} \
- ${DEPLOY_DIR_DEB}/*.deb
- fi
-}
-
-addtask populate before do_build after do_unpack
-do_populate[deptask] = "do_deploy_deb"
do_rootfs[stamp-extra-info] = "${MACHINE}-${DISTRO}"
@@ -88,7 +24,8 @@ do_rootfs() {
die "No root filesystem function defined, please implement in your recipe"
}
-addtask rootfs before do_build after do_populate
+addtask rootfs before do_build after do_unpack
+do_rootfs[deptask] = "do_deploy_deb"
do_copy_boot_files() {
KERNEL_IMAGE=${@get_image_name(d, 'vmlinuz')}
diff --git a/meta/recipes-devtools/isar-apt/files/distributions.in b/meta/recipes-devtools/isar-apt/files/distributions.in
new file mode 100644
index 0000000..cd214c6
--- /dev/null
+++ b/meta/recipes-devtools/isar-apt/files/distributions.in
@@ -0,0 +1,3 @@
+Codename: {DISTRO_NAME}
+Architectures: i386 armhf amd64 source
+Components: main
diff --git a/meta/recipes-devtools/isar-apt/isar-apt.bb b/meta/recipes-devtools/isar-apt/isar-apt.bb
new file mode 100644
index 0000000..9c31d12
--- /dev/null
+++ b/meta/recipes-devtools/isar-apt/isar-apt.bb
@@ -0,0 +1,29 @@
+# This software is a part of ISAR.
+# Copyright (C) 2015-2017 ilbers GmbH
+
+SRC_URI = "file://distributions.in"
+
+CACHE_CONF_DIR = "${DEPLOY_DIR_APT}/${DISTRO}/conf"
+do_cache_config[dirs] = "${CACHE_CONF_DIR}"
+do_cache_config[stamp-extra-info] = "${DISTRO}"
+do_cache_config[lockfiles] = "${DEPLOY_DIR_APT}/isar.lock"
+
+# Generate reprepro config for current distro if it doesn't exist. Once it's
+# generated, this task should do nothing.
+do_cache_config() {
+ if [ ! -e "${CACHE_CONF_DIR}/distributions" ]; then
+ sed -e "s#{DISTRO_NAME}#"${DEBDISTRONAME}"#g" \
+ ${WORKDIR}/distributions.in > ${CACHE_CONF_DIR}/distributions
+ fi
+
+ path_cache="${DEPLOY_DIR_APT}/${DISTRO}"
+ path_databases="${DEPLOY_DIR_DB}/${DISTRO}"
+
+ if [ ! -d "${path_databases}" ]; then
+ reprepro -b ${path_cache} \
+ --dbdir ${path_databases} \
+ export ${DEBDISTRONAME}
+ fi
+}
+
+addtask cache_config after do_unpack before do_build
--
2.1.4
next prev parent reply other threads:[~2018-02-01 11:30 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-01 11:29 [PATCH 0/4] Rework isar-apt Alexander Smirnov
2018-02-01 11:29 ` Alexander Smirnov [this message]
2018-02-01 11:29 ` [PATCH 2/4] buildchroot: Enable isar-apt Alexander Smirnov
2018-02-04 12:06 ` Jan Kiszka
2018-02-01 11:29 ` [PATCH 3/4] build.sh: Update apt sources Alexander Smirnov
2018-02-01 11:40 ` Jan Kiszka
2018-02-01 11:48 ` Alexander Smirnov
2018-02-01 13:13 ` Jan Kiszka
2018-02-01 13:43 ` Alexander Smirnov
2018-02-01 14:28 ` Jan Kiszka
2018-02-01 11:29 ` [PATCH 4/4] build.sh: Force 'yes' for apt Alexander Smirnov
2018-02-01 11:41 ` Jan Kiszka
2018-02-01 12:27 ` Alexander Smirnov
2018-02-01 16:14 ` [PATCH 0/4] Rework isar-apt Jan Kiszka
2018-02-01 16:22 ` Alexander Smirnov
2018-02-01 16:25 ` Jan Kiszka
2018-02-01 16:54 ` Alexander Smirnov
2018-02-01 17:03 ` Jan Kiszka
2018-02-01 20:32 ` Alexander Smirnov
2018-02-01 18:37 ` Claudius Heine
2018-02-01 19:37 ` Alexander Smirnov
2018-02-01 20:09 ` Claudius Heine
2018-02-01 20:13 ` Claudius Heine
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=20180201112944.7877-2-asmirnov@ilbers.de \
--to=asmirnov@ilbers.de \
--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