From: Alexander Smirnov <asmirnov@ilbers.de>
To: isar-users@googlegroups.com
Cc: Alexander Smirnov <asmirnov@ilbers.de>
Subject: [PATCH 2/4] apt: Generate Isar reprepro database
Date: Thu, 5 Oct 2017 13:08:05 +0300 [thread overview]
Message-ID: <20171005100807.3369-3-asmirnov@ilbers.de> (raw)
In-Reply-To: <20171005100807.3369-1-asmirnov@ilbers.de>
Generate reprepro database for Isar apt repository.
Signed-off-by: Alexander Smirnov <asmirnov@ilbers.de>
---
meta-isar/conf/layer.conf | 3 +++
meta-isar/conf/local.conf.sample | 4 ++++
meta/classes/image.bbclass | 34 ++++++++++++++++++++++++++++++++++
3 files changed, 41 insertions(+)
diff --git a/meta-isar/conf/layer.conf b/meta-isar/conf/layer.conf
index 0950a34..cd42f06 100644
--- a/meta-isar/conf/layer.conf
+++ b/meta-isar/conf/layer.conf
@@ -22,3 +22,6 @@ DEBDISTRONAME = "isar"
# Path to the Isar apt repository
DEPLOY_DIR_APT ?= "${DEPLOY_DIR}/apt"
+
+# Path to the Isar databases used by `reprepro`
+DEPLOY_DIR_DB ?= "${DEPLOY_DIR}/db"
diff --git a/meta-isar/conf/local.conf.sample b/meta-isar/conf/local.conf.sample
index a456b1b..660958f 100644
--- a/meta-isar/conf/local.conf.sample
+++ b/meta-isar/conf/local.conf.sample
@@ -158,3 +158,7 @@ IMAGE_INSTALL = "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/classes/image.bbclass b/meta/classes/image.bbclass
index 57705a7..47f53a3 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -10,6 +10,31 @@ IMAGE_ROOTFS = "${WORKDIR}/rootfs"
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}"
@@ -21,6 +46,15 @@ do_cache_config() {
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_fetch
--
2.1.4
next prev parent reply other threads:[~2017-10-05 10:08 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-05 10:08 [PATCH 0/4 v5] Isar apt deployment Alexander Smirnov
2017-10-05 10:08 ` [PATCH 1/4] apt: Generate configs for apt Alexander Smirnov
2017-10-05 11:14 ` Claudius Heine
2017-10-05 11:43 ` Alexander Smirnov
2017-10-05 12:01 ` Claudius Heine
2017-10-05 10:08 ` Alexander Smirnov [this message]
2017-10-05 11:43 ` [PATCH 2/4] apt: Generate Isar reprepro database Claudius Heine
2017-10-09 12:04 ` Henning Schild
2017-10-05 10:08 ` [PATCH 3/4] apt: Populate Isar apt Alexander Smirnov
2017-10-05 10:08 ` [PATCH 4/4] apt: Install packages via multistrap Alexander Smirnov
2017-10-19 15:24 ` [PATCH 4/4 v6] " Alexander Smirnov
2017-10-09 12:00 ` [PATCH 0/4 v5] Isar apt deployment Henning Schild
2017-10-12 10:42 ` Claudius Heine
2017-10-18 11:06 ` Alexander Smirnov
2017-10-18 13:44 ` Henning Schild
2017-10-18 17:10 ` Alexander Smirnov
2017-10-18 17:14 ` Alexander Smirnov
2017-10-19 16:16 ` Henning Schild
2017-10-19 19:38 ` Alexander Smirnov
2017-10-19 8:41 ` Henning Schild
2017-10-19 9:54 ` Baurzhan Ismagulov
2017-10-19 13:30 ` Henning Schild
2017-10-19 15:14 ` Alexander Smirnov
2017-11-21 12:43 ` Christian Storm
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=20171005100807.3369-3-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