@@ -221,6 +221,10 @@ ISAR_CROSS_COMPILE ?= "0"
# does not access the network
#BB_NO_NETWORK ?= "1"
+#
+# Uncomment to use previously built isar_apt repo if package version hasn't changed
+#ISAR_APT_REUSE ?= "1"
+
# Set root password to 'root'
# Password was encrypted using following command:
# mkpasswd -m sha512crypt -R 10000
@@ -9,6 +9,7 @@ inherit debianize
inherit terminal
inherit repository
inherit deb-dl-dir
+inherit isar-apt-cache
DEPENDS ?= ""
new file mode 100644
@@ -0,0 +1,69 @@
+# This software is a part of ISAR.
+# Copyright (C) 2017-2019 Siemens AG
+# Copyright (C) 2019 ilbers GmbH
+#
+# SPDX-License-Identifier: MIT
+
+iac_check_package_in_repo() {
+ DISTS_ISAR="${REPO_ISAR_DIR}/${DISTRO}/dists/${DEBDISTRONAME}"
+ PACKAGES="${DISTS_ISAR}/main/binary-${PACKAGE_ARCH}/Packages"
+
+ if [ ! -f "${PACKAGES}" ]; then
+ return 1
+ fi
+
+ if ! grep -q "^\(Package\|Source\): ${PN}$" "${PACKAGES}"; then
+ return 2
+ fi
+
+ local repo_version=$(sed -n -e '/^\(Package\|Source\): ${PN}$/,/Version/p' ${PACKAGES} | grep '^Version' | sed -e 's/.* //' | head -n1)
+ local new_version=$(head -n1 ${S}/debian/changelog | sed -e 's/.* (\(.*\)) .*/\1/' | head -n1)
+
+ if [ "${repo_version}" != "${new_version}" ]; then
+ return 3
+ fi
+
+ bbnote "Package ${PN}-${PV} is already in isar-apt repo, reuse it"
+ return 0
+}
+
+iac_check_need_rebuild() {
+ if [ "${ISAR_APT_REUSE}" != "1" ]; then
+ return 1
+ fi
+
+ iac_check_package_in_repo
+}
+
+def iac_check_task_early_exit(d):
+ try:
+ bb.build.exec_func("iac_check_need_rebuild", d)
+ return True
+ except:
+ return False
+
+
+do_apt_fetch_prepend() {
+ iac_check_need_rebuild && return
+}
+
+do_apt_unpack_prepend() {
+ iac_check_need_rebuild && return
+}
+
+do_prepare_build_prepend() {
+ iac_check_need_rebuild && return
+}
+
+do_deploy_deb_prepend() {
+ iac_check_need_rebuild && return
+}
+
+do_install_builddeps_prepend() {
+ iac_check_need_rebuild && return
+}
+
+python do_dpkg_build_prepend() {
+ if iac_check_task_early_exit(d):
+ return 0
+}
The idea of reusing isar-apt repo at second build is to early exit from build-related tasks if the package with the same version already exists in current isar-apt repo. Also, redefining default values of REPO_ISAR_DIR and REPO_ISAR_DB_DIR maybe useful to share isar-apt between different builds and not to keep it under ${TMPDIR}: REPO_ISAR_DIR = "/path/to/isar-apt/${DISTRO}-${DISTRO_ARCH}/apt" REPO_ISAR_DB_DIR = "/path/to/isar-apt/${DISTRO}-${DISTRO_ARCH}/db" The variable ISAR_APT_REUSE in local.conf controls the behvaiour: 0: Don't use isar-apt cache, always rebuilt packages (default) 1: Use local isar-apt cache, rebuilt packages only if needed Signed-off-by: Uladzimir Bely <ubely@ilbers.de> --- meta-isar/conf/local.conf.sample | 4 ++ meta/classes/dpkg-base.bbclass | 1 + meta/classes/isar-apt-cache.bbclass | 69 +++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 meta/classes/isar-apt-cache.bbclass