get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 138434,
    "url": "http://patches.dpdk.org/api/patches/138434/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20240315141441.259594-2-rjarry@redhat.com/",
    "project": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<20240315141441.259594-2-rjarry@redhat.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20240315141441.259594-2-rjarry@redhat.com",
    "date": "2024-03-15T14:14:42",
    "name": "devtools: download scripts from linux if not found",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "e8d141fcf4c79953e3197897abb3665aa04e171a",
    "submitter": {
        "id": 2850,
        "url": "http://patches.dpdk.org/api/people/2850/?format=api",
        "name": "Robin Jarry",
        "email": "rjarry@redhat.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20240315141441.259594-2-rjarry@redhat.com/mbox/",
    "series": [
        {
            "id": 31535,
            "url": "http://patches.dpdk.org/api/series/31535/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=31535",
            "date": "2024-03-15T14:14:42",
            "name": "devtools: download scripts from linux if not found",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/31535/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/138434/comments/",
    "check": "warning",
    "checks": "http://patches.dpdk.org/api/patches/138434/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id CC96543CBA;\n\tFri, 15 Mar 2024 15:15:13 +0100 (CET)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 49B2642ED0;\n\tFri, 15 Mar 2024 15:15:13 +0100 (CET)",
            "from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.129.124])\n by mails.dpdk.org (Postfix) with ESMTP id 211FB42E6B\n for <dev@dpdk.org>; Fri, 15 Mar 2024 15:15:11 +0100 (CET)",
            "from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com\n [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n us-mta-687-auiT8PFpN1e5VUZAyy6kWQ-1; Fri, 15 Mar 2024 10:15:08 -0400",
            "from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com\n [10.11.54.2])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D18C58007A2\n for <dev@dpdk.org>; Fri, 15 Mar 2024 14:15:07 +0000 (UTC)",
            "from ringo.redhat.com (unknown [10.39.208.23])\n by smtp.corp.redhat.com (Postfix) with ESMTP id 34E2C40C6DB3;\n Fri, 15 Mar 2024 14:15:07 +0000 (UTC)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1710512110;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding;\n bh=6u1tcOLcEOk7+/h0S8x7bFt8a3V4jhCerqWqq0ekuSE=;\n b=fd4/a979lpz2jPEjvGt9dfo5Wa5HhQB7ygrZCCTOIPoOrYm53Q8a3i+8MH/UCZhtGb2Y2X\n /uU3xK7lJKc5QOfHtJgpkBM4g5EunSNUXx1oYxLwNesml6fYTjeaDS3g0Nnm6XZTiMJs7p\n ETsty+fXiqt34Srvv5W6fpUyH3pOd+c=",
        "X-MC-Unique": "auiT8PFpN1e5VUZAyy6kWQ-1",
        "From": "Robin Jarry <rjarry@redhat.com>",
        "To": "dev@dpdk.org",
        "Subject": "[PATCH] devtools: download scripts from linux if not found",
        "Date": "Fri, 15 Mar 2024 15:14:42 +0100",
        "Message-ID": "<20240315141441.259594-2-rjarry@redhat.com>",
        "MIME-Version": "1.0",
        "X-Scanned-By": "MIMEDefang 3.4.1 on 10.11.54.2",
        "X-Mimecast-Spam-Score": "0",
        "X-Mimecast-Originator": "redhat.com",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain; charset=\"US-ASCII\"; x-default=true",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org"
    },
    "content": "Both checkpatches.sh and get-maintainer.sh require scripts that come\nfrom the linux sources. And they require DPDK_*_PATH variables to be set\nto point at these scripts locally. For new contributors this can be\ntedious since they will have to clone the whole linux sources just to\nhave simple perl scripts.\n\nUpdate checkpatches.sh and get-maintainer.sh to have them download the\nupstream scripts if they are not found locally. Store the downloaded\nscripts in the .git/ folder so that they are found for future runs.\n\nIf either DPDK_CHECKPATCH_PATH or DPDK_GETMAINTAINER_PATH are set, they\nwill be used in priority.\n\nSigned-off-by: Robin Jarry <rjarry@redhat.com>\n---\n devtools/checkpatches.sh            |  6 ++++\n devtools/get-maintainer.sh          |  9 ++++++\n devtools/load-devel-config          | 45 +++++++++++++++++++++++++++++\n doc/guides/contributing/patches.rst |  1 +\n 4 files changed, 61 insertions(+)",
    "diff": "diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh\nindex 8f245ebdabc4..bfacd77f398a 100755\n--- a/devtools/checkpatches.sh\n+++ b/devtools/checkpatches.sh\n@@ -43,6 +43,8 @@ print_usage () {\n \tRun Linux kernel checkpatch.pl with DPDK options.\n \tThe environment variable DPDK_CHECKPATCH_PATH can be set, if not we will\n \ttry to find the script in the sources of the currently running kernel.\n+\tIf the script cannot be found, you will be prompted for downloading it\n+\tfrom the upstream linux sources.\n \n \tThe patches to check can be from stdin, files specified on the command line,\n \tlatest git commits limited with -n option, or commits in the git range\n@@ -376,10 +378,14 @@ while getopts hn:qr:v ARG ; do\n done\n shift $(($OPTIND - 1))\n \n+url=\"https://raw.githubusercontent.com/torvalds/linux/master/scripts/checkpatch.pl\"\n+\n if [ ! -f \"$DPDK_CHECKPATCH_PATH\" ] || [ ! -x \"$DPDK_CHECKPATCH_PATH\" ] ; then\n \tdefault_path=\"/lib/modules/$(uname -r)/source/scripts/checkpatch.pl\"\n \tif [ -f \"$default_path\" ] && [ -x \"$default_path\" ] ; then\n \t\tDPDK_CHECKPATCH_PATH=\"$default_path\"\n+\telif download_script DPDK_CHECKPATCH_PATH \"$url\"; then\n+\t\ttrue\n \telse\n \t\tprint_usage >&2\n \t\techo\ndiff --git a/devtools/get-maintainer.sh b/devtools/get-maintainer.sh\nindex bba4d3f68db8..010aef221226 100755\n--- a/devtools/get-maintainer.sh\n+++ b/devtools/get-maintainer.sh\n@@ -18,10 +18,19 @@ print_usage () {\n \tthe get_maintainer.pl script located in Linux kernel sources. Example:\n \tDPDK_GETMAINTAINER_PATH=~/linux/scripts/get_maintainer.pl\n \n+\tIf the script cannot be found, you will be prompted for downloading it\n+\tfrom the upstream linux sources.\n+\n \tAlso refer to devtools/load-devel-config to store your configuration.\n \tEND_OF_HELP\n }\n \n+if [ ! -f \"$DPDK_GETMAINTAINER_PATH\" ] ||\n+   [ ! -x \"$DPDK_GETMAINTAINER_PATH\" ] ; then\n+\tdownload_script DPDK_GETMAINTAINER_PATH \\\n+\t\t\"https://raw.githubusercontent.com/torvalds/linux/master/scripts/get_maintainer.pl\"\n+fi\n+\n # Requires DPDK_GETMAINTAINER_PATH devel config option set\n if [ ! -f \"$DPDK_GETMAINTAINER_PATH\" ] ||\n    [ ! -x \"$DPDK_GETMAINTAINER_PATH\" ] ; then\ndiff --git a/devtools/load-devel-config b/devtools/load-devel-config\nindex 69a0ac623a6e..46baf73fc0b3 100644\n--- a/devtools/load-devel-config\n+++ b/devtools/load-devel-config\n@@ -1,4 +1,5 @@\n # SPDX-License-Identifier: BSD-3-Clause\n+# vim: ft=sh\n \n # This file is intended to be sourced into shell\n \n@@ -14,3 +15,47 @@ test ! -r $(dirname $(readlink -f $0))/../.develconfig ||\n         . $(dirname $(readlink -f $0))/../.develconfig\n \n # The config files must export variables in the shell style\n+\n+# This function is called to download missing scripts by subcommands\n+#\n+# Example:\n+#   download_script DPDK_CHECKPATCH_PATH \\\n+#       https://raw.githubusercontent.com/torvalds/linux/master/scripts/checkpatch.pl\n+download_script() { # <var_name> <url>\n+\tvar_name=$1\n+\turl=$2\n+\n+\tscript_name=$(basename \"$url\")\n+\tgit_dir=$(git rev-parse --git-dir) || return 1\n+\tdl_path=\"$git_dir/$script_name\"\n+\n+\tif [ -f \"$dl_path\" ] && [ -x \"$dl_path\" ]; then\n+\t\teval \"$var_name='$dl_path'\"\n+\t\treturn 0\n+\tfi\n+\n+\tif ! [ -t 0 ]; then\n+\t\t# not in an interactive terminal, abort\n+\t\treturn 1\n+\tfi\n+\tprompt=\"Download $url and set $var_name=$dl_path? [y/n] \"\n+\n+\twhile printf '%s' \"$prompt\" && read y && ! [ \"$y\" = y ]; do\n+\t\tif [ \"$y\" = n ]; then\n+\t\t\treturn 1\n+\t\tfi\n+\tdone\n+\n+\tif which curl >/dev/null 2>&1; then\n+\t\tcurl -Lo \"$dl_path\" \"$url\" || return 1\n+\telif which wget >/dev/null 2>&1; then\n+\t\twget -O \"$dl_path\" \"$url\" || return 1\n+\telse\n+\t\techo \"error: neither curl nor wget are available.\" >&2\n+\t\treturn 1\n+\tfi\n+\tchmod 755 \"$dl_path\" || return 1\n+\n+\teval \"$var_name='$dl_path'\"\n+\treturn 0\n+}\ndiff --git a/doc/guides/contributing/patches.rst b/doc/guides/contributing/patches.rst\nindex e286d9e6d59e..d24327bebb6c 100644\n--- a/doc/guides/contributing/patches.rst\n+++ b/doc/guides/contributing/patches.rst\n@@ -462,6 +462,7 @@ This uses the Linux kernel development tool ``checkpatch.pl`` which  can be obta\n updating the Linux kernel sources.\n \n The path to the original Linux script must be set in the environment variable ``DPDK_CHECKPATCH_PATH``.\n+If this variable is not set, ``checkpatches.sh`` will prompt before downloading it locally.\n \n Spell checking of commonly misspelled words is enabled\n by default if installed in ``/usr/share/codespell/dictionary.txt``.\n",
    "prefixes": []
}