From: Henning Schild <henning.schild@siemens.com>
To: isar-users@googlegroups.com
Cc: Henning Schild <henning.schild@siemens.com>
Subject: [PATCH 01/17] repository: new class to deal with repos
Date: Mon, 28 Oct 2019 18:01:16 +0100 [thread overview]
Message-ID: <20191028170132.28072-2-henning.schild@siemens.com> (raw)
In-Reply-To: <20191028170132.28072-1-henning.schild@siemens.com>
From: Henning Schild <henning.schild@siemens.com>
Factor out all the "reprepro" code into a common class. There are slight
functional changes since the two copies of the code got out of sync.
Signed-off-by: Henning Schild <henning.schild@siemens.com>
---
meta/classes/base-apt-helper.bbclass | 28 ++++----
meta/classes/dpkg-base.bbclass | 24 ++-----
meta/classes/repository.bbclass | 64 +++++++++++++++++++
meta/recipes-devtools/base-apt/base-apt.bb | 31 +++------
.../base-apt/files/distributions.in | 3 -
.../isar-apt/files/distributions.in | 3 -
meta/recipes-devtools/isar-apt/isar-apt.bb | 26 ++------
7 files changed, 97 insertions(+), 82 deletions(-)
create mode 100644 meta/classes/repository.bbclass
delete mode 100644 meta/recipes-devtools/base-apt/files/distributions.in
delete mode 100644 meta/recipes-devtools/isar-apt/files/distributions.in
diff --git a/meta/classes/base-apt-helper.bbclass b/meta/classes/base-apt-helper.bbclass
index d5674c9..567eaea 100644
--- a/meta/classes/base-apt-helper.bbclass
+++ b/meta/classes/base-apt-helper.bbclass
@@ -1,5 +1,10 @@
# This software is a part of ISAR.
# Copyright (C) 2018 ilbers GmbH
+# Copyright (C) 2019 Siemens AG
+#
+# SPDX-License-Identifier: MIT
+
+inherit repository
compare_pkg_md5sums() {
pkg1=$1
@@ -14,10 +19,6 @@ compare_pkg_md5sums() {
populate_base_apt() {
search_dir=$1
- if [ -n "${GNUPGHOME}" ]; then
- export GNUPGHOME="${GNUPGHOME}"
- fi
-
find $search_dir -name '*.deb' | while read package; do
# NOTE: due to packages stored by reprepro are not modified, we can
# use search by filename to check if package is already in repo. In
@@ -40,18 +41,15 @@ populate_base_apt() {
compare_pkg_md5sums "$package" "$base_apt_p" && continue
# md5sum differs, so remove the package from base-apt
- name=$(echo $base_name | cut -d '_' -f 1)
- reprepro -b ${REPO_BASE_DIR}/${BASE_DISTRO} \
- --dbdir ${REPO_BASE_DB_DIR}/${BASE_DISTRO} \
- -C main -A ${DISTRO_ARCH} \
- remove ${BASE_DISTRO_CODENAME} \
- $name
+ repo_del_package "${REPO_BASE_DIR}"/"${BASE_DISTRO}" \
+ "${REPO_BASE_DB_DIR}"/"${BASE_DISTRO}" \
+ "${BASE_DISTRO_CODENAME}" \
+ "${base_apt_p}"
fi
- reprepro -b ${REPO_BASE_DIR}/${BASE_DISTRO} \
- --dbdir ${REPO_BASE_DB_DIR}/${BASE_DISTRO} \
- -C main \
- includedeb ${BASE_DISTRO_CODENAME} \
- $package
+ repo_add_packages "${REPO_BASE_DIR}"/"${BASE_DISTRO}" \
+ "${REPO_BASE_DB_DIR}"/"${BASE_DISTRO}" \
+ "${BASE_DISTRO_CODENAME}" \
+ "${package}"
done
}
diff --git a/meta/classes/dpkg-base.bbclass b/meta/classes/dpkg-base.bbclass
index fae0a2b..3f1e99f 100644
--- a/meta/classes/dpkg-base.bbclass
+++ b/meta/classes/dpkg-base.bbclass
@@ -7,6 +7,7 @@
inherit buildchroot
inherit debianize
inherit terminal
+inherit repository
DEPENDS ?= ""
@@ -114,31 +115,16 @@ repo_clean() {
DEBS=$( find ${S}/.. -maxdepth 1 -name "*.deb" || [ ! -d ${S} ] )
if [ -n "${DEBS}" ]; then
for d in ${DEBS}; do
- p=$( dpkg-deb --show --showformat '${Package}' ${d} )
- a=$( dpkg-deb --show --showformat '${Architecture}' ${d} )
- # removing "all" means no arch
- aarg="-A ${a}"
- [ "${a}" = "all" ] && aarg=""
- reprepro -b ${REPO_ISAR_DIR}/${DISTRO} \
- --dbdir ${REPO_ISAR_DB_DIR}/${DISTRO} \
- -C main ${aarg} \
- remove ${DEBDISTRONAME} \
- ${p}
+ repo_del_package "${REPO_ISAR_DIR}"/"${DISTRO}" \
+ "${REPO_ISAR_DB_DIR}"/"${DISTRO}" "${DEBDISTRONAME}" "${d}"
done
fi
}
-# Install package to Isar-apt
do_deploy_deb() {
- if [ -n "${GNUPGHOME}" ]; then
- export GNUPGHOME="${GNUPGHOME}"
- fi
repo_clean
- reprepro -b ${REPO_ISAR_DIR}/${DISTRO} \
- --dbdir ${REPO_ISAR_DB_DIR}/${DISTRO} \
- -C main \
- includedeb ${DEBDISTRONAME} \
- ${S}/../*.deb
+ repo_add_packages "${REPO_ISAR_DIR}"/"${DISTRO}" \
+ "${REPO_ISAR_DB_DIR}"/"${DISTRO}" "${DEBDISTRONAME}" ${S}/../*.deb
}
addtask deploy_deb after do_dpkg_build before do_build
diff --git a/meta/classes/repository.bbclass b/meta/classes/repository.bbclass
new file mode 100644
index 0000000..afd3aed
--- /dev/null
+++ b/meta/classes/repository.bbclass
@@ -0,0 +1,64 @@
+# This software is a part of ISAR.
+# Copyright (C) 2017-2019 Siemens AG
+# Copyright (C) 2019 ilbers GmbH
+#
+# SPDX-License-Identifier: MIT
+
+repo_create() {
+ dir="$1"
+ dbdir="$2"
+ codename="$3"
+ gpgkey="$4"
+
+ if [ -n "${GNUPGHOME}" ]; then
+ export GNUPGHOME="${GNUPGHOME}"
+ fi
+
+ if [ ! -f "${dir}"/conf/distributions ]; then
+ mkdir -p "${dir}"/conf/
+ cat <<EOF > "${dir}"/conf/distributions
+Codename: ${codename}
+Architectures: i386 armhf arm64 amd64 mipsel source
+Components: main
+EOF
+ if [ -n "${gpgkey}" ] ; then
+ echo "SignWith: yes" >> "${dir}"/conf/distributions
+ fi
+ fi
+ if [ ! -d "${dbdir}" ]; then
+ reprepro -b "${dir}" --dbdir "${dbdir}" export "${codename}"
+ fi
+}
+
+repo_add_packages() {
+ dir="$1"
+ dbdir="$2"
+ codename="$3"
+ shift; shift; shift
+
+ if [ -n "${GNUPGHOME}" ]; then
+ export GNUPGHOME="${GNUPGHOME}"
+ fi
+ reprepro -b "${dir}" --dbdir "${dbdir}" -C main \
+ includedeb "${codename}" \
+ "$@"
+}
+
+repo_del_package() {
+ dir="$1"
+ dbdir="$2"
+ codename="$3"
+ file="$4"
+
+ if [ -n "${GNUPGHOME}" ]; then
+ export GNUPGHOME="${GNUPGHOME}"
+ fi
+ p=$( dpkg-deb --show --showformat '${Package}' "${file}" )
+ a=$( dpkg-deb --show --showformat '${Architecture}' "${file}" )
+ # removing "all" means no arch
+ aarg="-A ${a}"
+ [ "${a}" = "all" ] && aarg=""
+ reprepro -b "${dir}" --dbdir "${dbdir}" -C main ${aarg} \
+ remove "${codename}" \
+ "${p}"
+}
diff --git a/meta/recipes-devtools/base-apt/base-apt.bb b/meta/recipes-devtools/base-apt/base-apt.bb
index 6acd6e7..765bb1b 100644
--- a/meta/recipes-devtools/base-apt/base-apt.bb
+++ b/meta/recipes-devtools/base-apt/base-apt.bb
@@ -1,38 +1,23 @@
# This software is a part of ISAR.
# Copyright (C) 2018 ilbers GmbH
+# Copyright (C) 2019 Siemens AG
+#
+# SPDX-License-Identifier: MIT
-SRC_URI = "file://distributions.in"
+inherit repository
BASE_REPO_KEY ?= ""
-CACHE_CONF_DIR = "${REPO_BASE_DIR}/${BASE_DISTRO}/conf"
-do_cache_config[dirs] = "${CACHE_CONF_DIR}"
do_cache_config[stamp-extra-info] = "${DISTRO}"
do_cache_config[lockfiles] = "${REPO_BASE_DIR}/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#{CODENAME}#"${BASE_DISTRO_CODENAME}"#g" \
- ${WORKDIR}/distributions.in > ${CACHE_CONF_DIR}/distributions
- if [ "${BASE_REPO_KEY}" ] ; then
- # To generate Release.gpg
- echo "SignWith: yes" >> ${CACHE_CONF_DIR}/distributions
- fi
- fi
-
- path_cache="${REPO_BASE_DIR}/${BASE_DISTRO}"
- path_databases="${REPO_BASE_DB_DIR}/${BASE_DISTRO}"
-
- if [ ! -d "${path_databases}" ]; then
- if [ -n "${GNUPGHOME}" ]; then
- export GNUPGHOME="${GNUPGHOME}"
- fi
- reprepro -b ${path_cache} \
- --dbdir ${path_databases} \
- export ${BASE_DISTRO_CODENAME}
- fi
+ repo_create "${REPO_BASE_DIR}"/"${BASE_DISTRO}" \
+ "${REPO_BASE_DB_DIR}"/"${BASE_DISTRO}" \
+ "${BASE_DISTRO_CODENAME}" \
+ "${BASE_REPO_KEY}"
}
addtask cache_config after do_unpack before do_build
diff --git a/meta/recipes-devtools/base-apt/files/distributions.in b/meta/recipes-devtools/base-apt/files/distributions.in
deleted file mode 100644
index fd7de0b..0000000
--- a/meta/recipes-devtools/base-apt/files/distributions.in
+++ /dev/null
@@ -1,3 +0,0 @@
-Codename: {CODENAME}
-Architectures: i386 armhf arm64 amd64 mipsel source
-Components: main
diff --git a/meta/recipes-devtools/isar-apt/files/distributions.in b/meta/recipes-devtools/isar-apt/files/distributions.in
deleted file mode 100644
index a24a700..0000000
--- a/meta/recipes-devtools/isar-apt/files/distributions.in
+++ /dev/null
@@ -1,3 +0,0 @@
-Codename: {DISTRO_NAME}
-Architectures: i386 armhf arm64 amd64 mipsel source
-Components: main
diff --git a/meta/recipes-devtools/isar-apt/isar-apt.bb b/meta/recipes-devtools/isar-apt/isar-apt.bb
index e6f1753..0227c1b 100644
--- a/meta/recipes-devtools/isar-apt/isar-apt.bb
+++ b/meta/recipes-devtools/isar-apt/isar-apt.bb
@@ -1,32 +1,20 @@
# This software is a part of ISAR.
# Copyright (C) 2015-2017 ilbers GmbH
+# Copyright (C) 2019 Siemens AG
+#
+# SPDX-License-Identifier: MIT
-SRC_URI = "file://distributions.in"
+inherit repository
-CACHE_CONF_DIR = "${REPO_ISAR_DIR}/${DISTRO}/conf"
-do_cache_config[dirs] = "${CACHE_CONF_DIR}"
do_cache_config[stamp-extra-info] = "${DISTRO}"
do_cache_config[lockfiles] = "${REPO_ISAR_DIR}/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="${REPO_ISAR_DIR}/${DISTRO}"
- path_databases="${REPO_ISAR_DB_DIR}/${DISTRO}"
-
- if [ ! -d "${path_databases}" ]; then
- if [ -n "${GNUPGHOME}" ]; then
- export GNUPGHOME="${GNUPGHOME}"
- fi
- reprepro -b ${path_cache} \
- --dbdir ${path_databases} \
- export ${DEBDISTRONAME}
- fi
+ repo_create "${REPO_ISAR_DIR}"/"${DISTRO}" \
+ "${REPO_ISAR_DB_DIR}"/"${DISTRO}" \
+ "${DEBDISTRONAME}"
}
addtask cache_config after do_unpack before do_build
--
2.23.0
next prev parent reply other threads:[~2019-10-28 17:01 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-28 17:01 [PATCH 00/17] base-apt rework Henning Schild
2019-10-28 17:01 ` Henning Schild [this message]
2019-11-24 15:29 ` [PATCH 01/17] repository: new class to deal with repos Baurzhan Ismagulov
2019-11-25 12:03 ` Henning Schild
2019-10-28 17:01 ` [PATCH 02/17] dpkg-base: add download caching of apt:// downloads Henning Schild
2019-10-29 12:57 ` chombourger
2019-10-29 16:03 ` Henning Schild
2019-11-08 11:39 ` Henning Schild
2019-11-24 15:30 ` Baurzhan Ismagulov
2019-11-25 10:32 ` Henning Schild
2019-10-28 17:01 ` [PATCH 03/17] base-apt: change the sources.list to also offer deb-src Henning Schild
2019-10-28 17:01 ` [PATCH 04/17] base-apt: add deb-src packages as well Henning Schild
2019-10-30 19:23 ` Henning Schild
2019-10-28 17:01 ` [PATCH 05/17] base-apt: do not skip gpg check when it is signed Henning Schild
2019-11-24 15:35 ` Baurzhan Ismagulov
2019-11-25 10:30 ` Henning Schild
2019-10-28 17:01 ` [PATCH 06/17] ci: conf: add "hello" to the sample config and every build Henning Schild
2019-10-28 17:01 ` [PATCH 07/17] meta: split all apt-get invocations into download and execution Henning Schild
2019-11-24 15:41 ` Baurzhan Ismagulov
2019-11-25 10:20 ` Henning Schild
2019-10-28 17:01 ` [PATCH 08/17] meta: create DL_DIR support for all apt-get downloaded .debs Henning Schild
2019-10-29 12:48 ` chombourger
2019-10-29 16:02 ` Henning Schild
2019-11-06 13:19 ` Henning Schild
2019-11-24 15:57 ` Baurzhan Ismagulov
2019-11-25 10:15 ` Henning Schild
2019-10-28 17:01 ` [PATCH 09/17] meta: import DL_DIR debs before apt-get download steps Henning Schild
2019-10-30 19:21 ` Henning Schild
2019-11-06 13:17 ` Henning Schild
2019-11-24 20:20 ` Baurzhan Ismagulov
2019-11-25 10:13 ` Henning Schild
2019-10-28 17:01 ` [PATCH 10/17] base-apt: populate from DEBDIR as well Henning Schild
2019-10-28 17:01 ` [PATCH 11/17] base-apt: drop the "apt_cache" feature Henning Schild
2019-10-28 17:01 ` [PATCH 12/17] base-apt: do not copy debs directly out of rootfss anymore Henning Schild
2019-10-28 17:01 ` [PATCH 13/17] base-apt: rework base-apt population Henning Schild
2019-10-28 17:01 ` [PATCH 14/17] base-apt: move class "base-apt-helper" into only user Henning Schild
2019-10-28 17:01 ` [PATCH 15/17] CI: include "isar-disable-apt-cache" into all CI images Henning Schild
2019-10-28 17:01 ` [PATCH 16/17] CI: include "cowsay" into default build to test dpkg-gbp Henning Schild
2019-10-28 17:01 ` [PATCH 17/17] CI: set BB_NO_NETWORK for cached rebuild Henning Schild
2019-11-06 16:00 ` [PATCH 00/17] base-apt rework Jan Kiszka
2019-11-24 13:21 ` Baurzhan Ismagulov
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=20191028170132.28072-2-henning.schild@siemens.com \
--to=henning.schild@siemens.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