Show a patch.

GET /api/patches/3143/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 3143,
    "url": "https://patchwork.libcamera.org/api/patches/3143/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/3143/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20200317173145.18226-4-kgupta@es.iitr.ac.in>",
    "date": "2020-03-17T17:31:44",
    "name": "[libcamera-devel,3/4] libcamera: ipa_proxy: search for proxy in build tree",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "b80ff03e562bbe942e66e94905765838da7d3588",
    "submitter": {
        "id": 39,
        "url": "https://patchwork.libcamera.org/api/people/39/?format=api",
        "name": "Kaaira Gupta",
        "email": "kgupta@es.iitr.ac.in"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/3143/mbox/",
    "series": [
        {
            "id": 727,
            "url": "https://patchwork.libcamera.org/api/series/727/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=727",
            "date": "2020-03-17T17:31:41",
            "name": "libcamera: determine IPA_PROXY_PATH at runtime",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/727/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/3143/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/3143/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<kgupta@es.iitr.ac.in>",
        "Received": [
            "from mail-pf1-x430.google.com (mail-pf1-x430.google.com\n\t[IPv6:2607:f8b0:4864:20::430])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 442B962923\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 17 Mar 2020 18:32:35 +0100 (CET)",
            "by mail-pf1-x430.google.com with SMTP id b72so12311996pfb.11\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 17 Mar 2020 10:32:35 -0700 (PDT)",
            "from kaaira-HP-Pavilion-Notebook ([103.113.213.153])\n\tby smtp.gmail.com with ESMTPSA id v1sm52049pjy.35.2020.03.17.10.32.32\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 17 Mar 2020 10:32:33 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=es-iitr-ac-in.20150623.gappssmtp.com; s=20150623;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=KrtPCqHQs+csT3TD5XmQcU1mNeju6IYSHxiln/8Vwk4=;\n\tb=TdJqvbXM27ujr7k1ASvreKqZOX9AzLts1tC+kqO4ZyCPc+4nXRUieMaGCTb77Vlmtd\n\txhneuenxLyj5oq6aVU3LI9WIXbrZC0donelQs04S2c6g8islZGNW5sSXAHqQ6R6A34Ge\n\thOhBfvDlT9GV0MqMrGjAmDHJiarg9g1kilmSQehugpipnpD9LXFgrxxLBrV/OKXnid10\n\t9rRpizF3z8pg25kfuS2b+6M0DFIZnImewPWWTg3+dYdO++mGaaX2EbPPHv9aEwbGyOII\n\tEh9kV3xBfvR42pwuc+LRYOdxy53E+hrMLWEOfGM0k/KE+WZufhIKBP3RX4mr8/3UqrlV\n\tTz/w==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=KrtPCqHQs+csT3TD5XmQcU1mNeju6IYSHxiln/8Vwk4=;\n\tb=ZhxN57t4f0/1qQzstmaKbZG2y0TrAeJOLnFbAKItcPceOCEaI9wLKd1dl/qWGsdCOa\n\tjwg0HVfA/4S4BUr316pAvtj0SXwU/9tY+bCdlsQuJIHP91IC0cZcLG1fMJXnpiRTuAmc\n\tVmB3bvVWuTMOwcvVU4YdSMvgzCfjGZHERugiZLHoVL9QQ28DstnAzJ8R6oTRjsx7BkR8\n\t2kRCJUCTrsvOLEEi6zr43iAC1aYXU7c45aH5FRgPv7wvMI0NG+mudim4zMiStu6pc3Rj\n\tpdlaM7pGDNvMAoKUM8yQa+EWFbOel/fk6WzCg/D2ZW2WfcK/UM8G3eYoN0cFSA66/pjH\n\t3qEg==",
        "X-Gm-Message-State": "ANhLgQ3hwYMI3z/eszrSOMIwqfCTjYtPITQiF2vu71OLUXMigkB7Os0l\n\tqx8DPi1pdlZVMse9PRl/tqqCnw==",
        "X-Google-Smtp-Source": "ADFU+vtatYKgzKXA9N9n1e9rVBE+LWqO3viayzgUZHX0P/kHU6PwWxcX0lyINDwok+SJjun/AC5dag==",
        "X-Received": "by 2002:a63:4cc:: with SMTP id 195mr290250pge.93.1584466353853; \n\tTue, 17 Mar 2020 10:32:33 -0700 (PDT)",
        "From": "Kaaira Gupta <kgupta@es.iitr.ac.in>",
        "To": "libcamera-devel@lists.libcamera.org, kieran.bingham@ideasonboard.com,\n\tHelen Koike <helen.koike@collabora.com>,\n\tVaishali Thakkar <vthakkar@vaishalithakkar.in>",
        "Cc": "Kaaira Gupta <kgupta@es.iitr.ac.in>",
        "Date": "Tue, 17 Mar 2020 23:01:44 +0530",
        "Message-Id": "<20200317173145.18226-4-kgupta@es.iitr.ac.in>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20200317173145.18226-1-kgupta@es.iitr.ac.in>",
        "References": "<20200317173145.18226-1-kgupta@es.iitr.ac.in>",
        "Subject": "[libcamera-devel] [PATCH LIBCAMERA 3/4] libcamera: ipa_proxy:\n\tsearch for proxy in build tree",
        "X-BeenThere": "libcamera-devel@lists.libcamera.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "<libcamera-devel.lists.libcamera.org>",
        "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>",
        "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>",
        "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>",
        "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>",
        "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>",
        "X-List-Received-Date": "Tue, 17 Mar 2020 17:32:35 -0000"
    },
    "content": "When libcamera is build and tested before installing, it will\nbe unable to locate the path to proxy files,or previously\ninstalled files in the system path may be incorrect to load.\n\nHence, when libcamera is not installed and running from a build\ntree, identify the location of that tree by finding the path of\nactive libcamera.so, and from that point add the relative path to\nthe proxy file.\n\nSigned-off-by: Kaaira Gupta <kgupta@es.iitr.ac.in>\n---\n src/libcamera/ipa_proxy.cpp | 54 +++++++++++++++++++++++++++++++++----\n 1 file changed, 49 insertions(+), 5 deletions(-)",
    "diff": "diff --git a/src/libcamera/ipa_proxy.cpp b/src/libcamera/ipa_proxy.cpp\nindex 363d034..d7c32a1 100644\n--- a/src/libcamera/ipa_proxy.cpp\n+++ b/src/libcamera/ipa_proxy.cpp\n@@ -9,7 +9,9 @@\n \n #include <string.h>\n #include <unistd.h>\n-\n+#include <dlfcn.h>\n+#include <elf.h>\n+#include <link.h>\n #include \"log.h\"\n #include \"utils.h\"\n \n@@ -20,6 +22,35 @@\n  * \\brief IPA Proxy\n  */\n \n+static bool isLibcameraInstalled()\n+{\n+\t/* musl doesn't declare _DYNAMIC in link.h, declare it manually. */\n+\textern ElfW(Dyn) _DYNAMIC[];\n+\n+\t/*\n+\t * DT_RUNPATH (DT_RPATH when the linker uses old dtags) is removed on\n+\t * install.\n+\t */\n+\tfor (const ElfW(Dyn) *dyn = _DYNAMIC; dyn->d_tag != DT_NULL; ++dyn) {\n+\t\tif (dyn->d_tag == DT_RUNPATH || dyn->d_tag == DT_RPATH)\n+\t\t\treturn false;\n+\t}\n+\n+\treturn true;\n+}\n+\n+static std::string libcameraPath()\n+{\n+\tDl_info info;\n+\n+\t/* Look up our own symbol. */\n+\tint ret = dladdr(reinterpret_cast<void *>(libcameraPath), &info);\n+\tif (ret == 0)\n+\t\treturn nullptr;\n+\n+\treturn info.dli_fname;\n+}\n+\n namespace libcamera {\n \n LOG_DEFINE_CATEGORY(IPAProxy)\n@@ -89,10 +120,23 @@ std::string IPAProxy::resolvePath(const std::string &file) const\n \t\t}\n \t}\n \n-\t/*Try finding the exec target from the install directory.*/\n-        std::string proxyPath = std::string(IPA_PROXY_DIR) + proxyFile;\n-        if (!access(proxyPath.c_str(), X_OK))\n-                return proxyPath;\n+\t/*\n+\t *When libcamera is used before it is installed, load proxies from the\n+\t *same build directory as the libcamera directory itself. This requires\n+\t *identifying the path of the libcamera.so, and referencing a relative\n+\t *path for the proxies from that point.\n+\t */\n+\tif (!isLibcameraInstalled()){\n+\t\tstd::string ipaProxyDir = utils::dirname(libcameraPath()) + \"/../../proxy\";\n+\n+\t\tLOG(IPAProxy, Info)\n+\t\t\t<< \"libcamera is not installed. Adding '\"\n+\t\t\t<< ipaProxyDir << \"' to the Proxy search path\";\n+\n+\t\tstd::string proxyPath = ipaProxyDir + proxyFile;\n+\t\tif (!access(proxyPath.c_str(), X_OK))\n+\t\t\treturn proxyPath;\n+\t}\n \n \treturn std::string();\n }\n",
    "prefixes": [
        "libcamera-devel",
        "3/4"
    ]
}