From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6473366578589073408 X-Received: by 10.223.182.18 with SMTP id f18mr2510305wre.9.1507198109706; Thu, 05 Oct 2017 03:08:29 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 10.28.50.138 with SMTP id y132ls3883301wmy.9.gmail; Thu, 05 Oct 2017 03:08:29 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCVIieooKhHJy/eVE0h7jIJ2JTtOIQ4Sud+Pt3NG1vqnCO+hcnFsVPbucFIxLaUSA0sIx45 X-Received: by 10.223.133.244 with SMTP id 49mr2491701wru.22.1507198109453; Thu, 05 Oct 2017 03:08:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507198109; cv=none; d=google.com; s=arc-20160816; b=g7OImNPce1cuijbqW6fVovHHfnEXqpUtsokCCJTcPbkXg0fN+ECCh84NlAb/phmZLv 5VT17eXLCtJfD8vnnwh92QEGUwKigUnmYpmGzAWAZlg/IaDpnmk7GKy7nIRKyLNSr5W9 VDOR8COI/PJ2JojiTuXgp2zeeSq5J7hJC7aPPsHi3k6GV+cz2NeIEl9KG+dpKlwOi/RQ uRgRUVN585cc2ccRbUx1zA+0t1na7W7KwOdQTeRLosuQNMA/pb8X9sH+pKMno0oIdHCp ZN/S1/ISeTKJ2n6zBYn3woZL5cFXdJoeykaN+km7rh014Op53i5tWWCfz2/8QA8nQ4q7 j7jQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=khzQjpjCh3mGCiCpkkcGKB6TcVO5Qd86yG8k0et0Edo=; b=lxiQ6eQCr+ALO/pR7pdNLgc7BzmuXkIqw0stpB/zxmoMfszrUDGzz+V8eVIgXs0q9W 1BXVRb/BG1GYSPu6kBXufu6nl4vqVKKIzHzf9FkP+k0Clw/Sqgq4LgP/PxRYrxJSSXkM IzzRGk+8w1OOuLlUEg+coPAIHV8m6i+BDvBvlT6LHRWjP8JDpuDSABuaWpK3WmRjCn3E jfjGcohrmvDbtxjo+QdV7G14YptHP0aVp7E3aXXLyyR0VerzhaoNV/1QqpcyXQv78OiY eiuWP5SHQVZLle9QYXQNunhYmeSfWl07wGzGdmCglPIH7mBonhvUxpwSLae42WC+CGy9 eAGA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: best guess record for domain of asmirnov@ilbers.de designates 85.214.62.211 as permitted sender) smtp.mailfrom=asmirnov@ilbers.de Return-Path: Received: from aqmola.ilbers.de (aqmola.ilbers.de. [85.214.62.211]) by gmr-mx.google.com with ESMTPS id 196si93772wmk.4.2017.10.05.03.08.29 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Oct 2017 03:08:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of asmirnov@ilbers.de designates 85.214.62.211 as permitted sender) client-ip=85.214.62.211; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: best guess record for domain of asmirnov@ilbers.de designates 85.214.62.211 as permitted sender) smtp.mailfrom=asmirnov@ilbers.de Received: from localhost.localdomain ([188.227.110.165]) (authenticated bits=0) by aqmola.ilbers.de (8.14.4/8.14.4/Debian-4+deb7u1) with ESMTP id v95A8DXZ003858 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 5 Oct 2017 12:08:20 +0200 From: Alexander Smirnov To: isar-users@googlegroups.com Cc: Alexander Smirnov Subject: [PATCH 2/4] apt: Generate Isar reprepro database Date: Thu, 5 Oct 2017 13:08:05 +0300 Message-Id: <20171005100807.3369-3-asmirnov@ilbers.de> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20171005100807.3369-1-asmirnov@ilbers.de> References: <20171005100807.3369-1-asmirnov@ilbers.de> X-TUID: E07PTaoPPW94 Generate reprepro database for Isar apt repository. Signed-off-by: Alexander Smirnov --- 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