From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6547633542169362432 X-Received: by 2002:adf:a285:: with SMTP id s5-v6mr1660517wra.8.1524489736983; Mon, 23 Apr 2018 06:22:16 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 10.28.245.12 with SMTP id t12ls1887795wmh.2.gmail; Mon, 23 Apr 2018 06:22:16 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/hykbY1uxrijKVBouoohA1m6HRFiXvH2siMla0IWAZxHc5XfTMpfK4zm6fx7C5SPBPx3pQ X-Received: by 10.28.202.15 with SMTP id a15mr738718wmg.18.1524489736178; Mon, 23 Apr 2018 06:22:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524489736; cv=none; d=google.com; s=arc-20160816; b=NS9iF2m1j+ipJDueq4dASZg/9VSngwhu5/6C62eAcj1xQL/vq1grjLDGavuArSWS3c Qw0wzkvKTLYDWp85+nevm4+jdZi2Vrv+KUTbkIJK30Cc5NBCwEnQ5dOe9AXN7f0UhpJe L6XNvJpx75vLlE6CYHhSS4Ueiipj2XQ0mXXC2+lmU/GlghyGrmeF0eC9ID6Y9DeokWrM u/CkQTKXbiOUt33yLVF93zRsCJTKiVIXdJfrIfQhP7kfDcdnDjfS7yIiLM7NcUDJjauB YJBxDm+umBWZSqE4dG4mtDPxfEWJmGf1YzM/7AtJQLVeNClmtfEnyLCAflk4d4z7Dywu hsAg== 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=+5pYP9B/BBPYnVWpvBu3OCqwqj2Ig5AMeq2Tp6uD43I=; b=fe8LCaJRhMnMLkP2JYfYRgp+t5zl682rVjjOckIMoxKupibzKtGrTstOoQfjh0icTu BNvjdMtU8JsbTmxjQNK5uYVU6+IfCLup8fJAUSielXr/wbF8VNa4rHByiGd5IolZ6LZi Gs352c7lCmwk5HErcG2P2nsR3Wf8CvM8KTrIt1J0OxpgdYjFGZXoQj+tDyejFWnyMMpi ZbqD/FnI1Cd5zZlBjWxbpBlHKAQHA2TFnBOH59QtbS+fe9DHHFy5HubQSOxOFLr2LyFI KhdWsZT/Ep9TW889wMcuKLdyIMnlIA5JtmdKmSeh2+KwVJqge6ks9a1B8kNLm4Whf/Zz Jq0g== 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 u1-v6si513074wri.3.2018.04.23.06.22.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Apr 2018 06:22:16 -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 w3NDLr5g012434 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 23 Apr 2018 15:22:03 +0200 From: Alexander Smirnov To: isar-users@googlegroups.com Cc: Alexander Smirnov Subject: [RFC][PATCH 2/3] classes/dsc: Basic Debian .dsc backend implementation Date: Mon, 23 Apr 2018 16:21:45 +0300 Message-Id: <20180423132146.14743-3-asmirnov@ilbers.de> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20180423132146.14743-1-asmirnov@ilbers.de> References: <20180423132146.14743-1-asmirnov@ilbers.de> X-TUID: 2bFUjWWt1Pxe This patch introduces class to work with Debian .dsc files. The main goal is to simplify re-building and customization of original Debian packages. To rebuild package from the upstream the following recipe template could be used: DSC_URI = "http://ftp.de.debian.org/...dsc;md5sum=..." inherit debian-dsc All the remaining information bitbake will derive automatically. This is only first implementation, so there are still several open issues like: - Chose correct upstream package version depending on Debian distro - quilt-3.0 source format support - Cross-recipe dependencies recognition Signed-off-by: Alexander Smirnov --- meta/classes/debian-dsc.bbclass | 112 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 meta/classes/debian-dsc.bbclass diff --git a/meta/classes/debian-dsc.bbclass b/meta/classes/debian-dsc.bbclass new file mode 100644 index 0000000..4159e3a --- /dev/null +++ b/meta/classes/debian-dsc.bbclass @@ -0,0 +1,112 @@ +# Debian .dsc backend +# +# This software is a part of ISAR. +# Copyright (c) ilbers GmbH, 2018 +# +# SPDX-License-Identifier: MIT + +# List of non-standard variables added to package workspace +# +# Set by user: +# * DSC_URI - uri link to .dsc file in upstream apt +# +# Generated automatically: +# * DEBIAN_URI - uri link to Debian patch in upstream apt + +python __anonymous() { + # Fetch .dsc package file + dsc_uri = (d.getVar("DSC_URI", True) or "").split() + if len(dsc_uri) == 0: + return + + try: + fetcher = bb.fetch2.Fetch(dsc_uri, d) + fetcher.download() + except bb.fetch2.BBFetchException as e: + raise bb.build.FuncFailed(e) + + # Open .dsc file from downloads + dl_dir = d.getVar("DL_DIR", True) + dsc_file = (dsc_uri[0].split(";")[0]).split("/")[-1] + filepath = dl_dir + "/" + dsc_file + + pv = "" + src_uri = "" + + # Parse .dsc file to get package details + with open(filepath, "r") as file: + line = file.readline() + + while line: + # Get package version and export PV + if line.startswith("Version:") and not pv: + pv = line.split(": ")[-1].rstrip() + d.setVar("PV", pv) + + # Get package and Debian patch arcives names + if line.startswith("Files:") and not src_uri: + line = file.readline() + src = line.split(" ")[-1].rstrip() + src_uri = (dsc_uri[0].rsplit("/", 1))[0] + "/" + src + src_uri = src_uri + ";md5sum=" + line.split(" ")[1].rstrip() + d.setVar("SRC_URI", src_uri) + + line = file.readline() + debian = line.split(" ")[-1].rstrip() + debian_uri = (dsc_uri[0].rsplit("/", 1))[0] + "/" + debian + debian_uri = debian_uri + ";md5sum=" + line.split(" ")[1].rstrip() + d.setVar("DEBIAN_URI", debian_uri) + + line = file.readline() + + file.close() + + # Set correct path to unpacked sources + pv_orig = (src.split("_")[-1]).split(".orig")[0] + pn = d.getVar("PN", True) + d.setVar("S", pn + "-" + pv_orig) +} + +python do_fetch_append() { + debian_uri = (d.getVar("DEBIAN_URI", True) or "").split() + if len(debian_uri) == 0: + return + + try: + fetcher = bb.fetch2.Fetch(debian_uri, d) + fetcher.download() + except bb.fetch2.BBFetchException as e: + raise bb.build.FuncFailed(e) +} + +python do_unpack_append() { + import subprocess + + s = d.getVar("S", True) + workdir = d.getVar("WORKDIR", True) + debian_uri = (d.getVar("DEBIAN_URI", True) or "").split() + + try: + fetcher = bb.fetch2.Fetch(debian_uri, d) + fetcher.unpack(workdir + "/" + s) + except bb.fetch2.BBFetchException as e: + raise bb.build.FuncFailed(e) +} + +# NOTE: this is workaround to serve quilt-3.0 package format support. +# To build such package, the original tarball should be placed +# in "../" folder. In general, this should be handled by Isar +# core build classes, but for now this class in the only one user +# for quilt-3.0, so for the first implementation let"s keep it here. +# Open issues: +# - How to identify if package has quilt-3.0 source format? +# - How to avoid copying of tarballs from downloads to working dir? +do_build_prepend() { + dl_dir="${@ d.getVar('DL_DIR', True)}" + workdir="${@ d.getVar('WORKDIR', True)}" + file="${@ ((d.getVar('SRC_URI', True)).split(";")[0]).split("/")[-1]}" + + install -m 644 $dl_dir/$file $workdir +} + +inherit dpkg -- 2.9.5