get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 613859,
    "url": "http://patchwork.ozlabs.org/api/patches/613859/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/buildroot/patch/1461358223-18312-9-git-send-email-s.martin49@gmail.com/",
    "project": {
        "id": 27,
        "url": "http://patchwork.ozlabs.org/api/projects/27/?format=api",
        "name": "Buildroot development",
        "link_name": "buildroot",
        "list_id": "buildroot.buildroot.org",
        "list_email": "buildroot@buildroot.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": "",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<1461358223-18312-9-git-send-email-s.martin49@gmail.com>",
    "list_archive_url": null,
    "date": "2016-04-22T20:50:20",
    "name": "[v9,08/11] support/scripts: add check-host-leaks script + all needed helpers",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": false,
    "hash": "4da30ed377aa976fe6c0c87ff047239e46094b91",
    "submitter": {
        "id": 12868,
        "url": "http://patchwork.ozlabs.org/api/people/12868/?format=api",
        "name": "Samuel Martin",
        "email": "s.martin49@gmail.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/buildroot/patch/1461358223-18312-9-git-send-email-s.martin49@gmail.com/mbox/",
    "series": [],
    "comments": "http://patchwork.ozlabs.org/api/patches/613859/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/613859/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<buildroot-bounces@busybox.net>",
        "X-Original-To": [
            "incoming@patchwork.ozlabs.org",
            "buildroot@lists.busybox.net"
        ],
        "Delivered-To": [
            "patchwork-incoming@bilbo.ozlabs.org",
            "buildroot@osuosl.org"
        ],
        "Received": [
            "from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133])\n\tby ozlabs.org (Postfix) with ESMTP id 3qs77p3DvQz9sCk\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSat, 23 Apr 2016 06:51:18 +1000 (AEST)",
            "from localhost (localhost [127.0.0.1])\n\tby hemlock.osuosl.org (Postfix) with ESMTP id 1D34B966B1;\n\tFri, 22 Apr 2016 20:51:17 +0000 (UTC)",
            "from hemlock.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id vEPKjcJmvGhf; Fri, 22 Apr 2016 20:51:10 +0000 (UTC)",
            "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby hemlock.osuosl.org (Postfix) with ESMTP id BC61D9666C;\n\tFri, 22 Apr 2016 20:50:56 +0000 (UTC)",
            "from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138])\n\tby ash.osuosl.org (Postfix) with ESMTP id 9866D1C1750\n\tfor <buildroot@lists.busybox.net>;\n\tFri, 22 Apr 2016 20:50:48 +0000 (UTC)",
            "from localhost (localhost [127.0.0.1])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id 8B7B291FCC\n\tfor <buildroot@lists.busybox.net>;\n\tFri, 22 Apr 2016 20:50:48 +0000 (UTC)",
            "from whitealder.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id Q3uusEaSv9ld for <buildroot@lists.busybox.net>;\n\tFri, 22 Apr 2016 20:50:47 +0000 (UTC)",
            "from mail-wm0-f67.google.com (mail-wm0-f67.google.com\n\t[74.125.82.67])\n\tby whitealder.osuosl.org (Postfix) with ESMTPS id 567D291FC9\n\tfor <buildroot@buildroot.org>; Fri, 22 Apr 2016 20:50:47 +0000 (UTC)",
            "by mail-wm0-f67.google.com with SMTP id w143so5970522wmw.3\n\tfor <buildroot@buildroot.org>; Fri, 22 Apr 2016 13:50:47 -0700 (PDT)",
            "from bobook.localdomain (ivr94-4-82-229-165-48.fbx.proxad.net.\n\t[82.229.165.48]) by smtp.gmail.com with ESMTPSA id\n\tiv1sm9826507wjb.34.2016.04.22.13.50.43\n\t(version=TLSv1/SSLv3 cipher=OTHER);\n\tFri, 22 Apr 2016 13:50:44 -0700 (PDT)"
        ],
        "Authentication-Results": "ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com header.b=wxCYmi9G;\n\tdkim-atps=neutral",
        "X-Virus-Scanned": [
            "amavisd-new at osuosl.org",
            "amavisd-new at osuosl.org"
        ],
        "X-Greylist": "domain auto-whitelisted by SQLgrey-1.7.6",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=MqPfReZZhw3xsSa1riaedtFoLnXdxfJhKRBLneTNeJs=;\n\tb=wxCYmi9GGMdPun/ncsjcRKy1wkXoyfRJKavL3axBs27wWTNd97gYvpOIfYwDuH1INz\n\tPU2Gt33nzbC5NQ5/Hne4LxmiBlpUJI7lQElpa2hNc4RZ684neTLWrevT3Ij0E8no/HEP\n\tUJDUehzfnxVIFcClJ54WAdlUYPBxw8Z2N6Mzgkx78tKLZOAhoxg7uzcVnmp/jxp/Rkao\n\t4pQoSO/j55MsK/t2tzxQ6hfqD68isoQVGKRmCQLbyklTFA2kuI4PJP/ZKk1UG2mwJcsq\n\to4GbVcTXPWzhlkVp68ibe3ty76qpTdDXRaAJ7777Pm6cKRYEHXvs2JkAGIHpwitl1cC2\n\trgYg==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20130820;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=MqPfReZZhw3xsSa1riaedtFoLnXdxfJhKRBLneTNeJs=;\n\tb=Wr/AlKg/2SmYA6d2MwAG4DEkTgSRfH+ykAnVJCp1k8zO5FnUtbhmH6EwBQfvmimSk8\n\tieegh9cd6e3gaggOyTxY7YLzWet8DKPT9iKVzYKbT1pgDePvXvoS9gvMa9+vLD4sDG38\n\tmVniEQCt0WWNEzfqZ/E1gN3Sn7lFCh4Q87Xieaap+FK73h4qfRKv++zwWTQL4x9SE3Qn\n\t5HWALwiocrj2XCGTO+MGHM8Uhss0sQ42EOEweITDTy81ubAnGncK6yuF8Jal5BW7swck\n\tzxGv3cq+x96hphW+/+unZPVevVmNLKw34BNQeHcHEtUeaQDpo218ZuxvQwFs2cgHV+GX\n\tJm3g==",
        "X-Gm-Message-State": "AOPr4FVAPmgxl3pNuMxv+c5Uj5s/aN40oFaSXnTT9b3H6VaQdf2UVsulbd7WJ8i0dlZUIA==",
        "X-Received": "by 10.28.8.149 with SMTP id 143mr5977992wmi.2.1461358246024;\n\tFri, 22 Apr 2016 13:50:46 -0700 (PDT)",
        "From": "Samuel Martin <s.martin49@gmail.com>",
        "To": "buildroot@buildroot.org",
        "Date": "Fri, 22 Apr 2016 22:50:20 +0200",
        "Message-Id": "<1461358223-18312-9-git-send-email-s.martin49@gmail.com>",
        "X-Mailer": "git-send-email 2.8.0",
        "In-Reply-To": "<1461358223-18312-1-git-send-email-s.martin49@gmail.com>",
        "References": "<1461358223-18312-1-git-send-email-s.martin49@gmail.com>",
        "Subject": "[Buildroot] [PATCH v9 08/11] support/scripts: add check-host-leaks\n\tscript + all needed helpers",
        "X-BeenThere": "buildroot@busybox.net",
        "X-Mailman-Version": "2.1.18-1",
        "Precedence": "list",
        "List-Id": "Discussion and development of buildroot <buildroot.busybox.net>",
        "List-Unsubscribe": "<http://lists.busybox.net/mailman/options/buildroot>,\n\t<mailto:buildroot-request@busybox.net?subject=unsubscribe>",
        "List-Archive": "<http://lists.busybox.net/pipermail/buildroot/>",
        "List-Post": "<mailto:buildroot@busybox.net>",
        "List-Help": "<mailto:buildroot-request@busybox.net?subject=help>",
        "List-Subscribe": "<http://lists.busybox.net/mailman/listinfo/buildroot>,\n\t<mailto:buildroot-request@busybox.net?subject=subscribe>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "buildroot-bounces@busybox.net",
        "Sender": "\"buildroot\" <buildroot-bounces@busybox.net>"
    },
    "content": "Signed-off-by: Samuel Martin <s.martin49@gmail.com>\n\n---\nchanges v8->v9:\n- none\n\nchanges v7->v8:\n- move sdk.check_host_leaks in the check-host-leaks script itself\n  (Arnout)\n- drop leak classification (Arnout)\n- rework readelf.is_elf_{static_library,object} (Arnout)\n- add utils.assert_absolute_canonical_path\n- drop utils.guess_gnu_target_name\n- rework/simplify the check-host-leaks script command line\n\nchanges v6->v7:\n- {filer,is}_elf* functions moved from utils to readelf module\n- update sdk.check_host_leaks\n\nchanges v5->v6:\n- new patch\n---\n support/scripts/check-host-leaks | 126 +++++++++++++++++++++++++++++++++++++++\n support/scripts/shell/readelf.sh |  77 ++++++++++++++++++++++--\n support/scripts/shell/sdk.sh     |   7 +++\n support/scripts/shell/utils.sh   |  14 +++++\n 4 files changed, 218 insertions(+), 6 deletions(-)\n create mode 100755 support/scripts/check-host-leaks",
    "diff": "diff --git a/support/scripts/check-host-leaks b/support/scripts/check-host-leaks\nnew file mode 100755\nindex 0000000..9f363af\n--- /dev/null\n+++ b/support/scripts/check-host-leaks\n@@ -0,0 +1,126 @@\n+#!/usr/bin/env bash\n+\n+# Copyright (C) 2016 Samuel Martin <s.martin49@gmail.com>\n+#\n+# This program is free software; you can redistribute it and/or modify\n+# it under the terms of the GNU General Public License as published by\n+# the Free Software Foundation; either version 2 of the License, or\n+# (at your option) any later version.\n+#\n+# This program is distributed in the hope that it will be useful,\n+# but WITHOUT ANY WARRANTY; without even the implied warranty of\n+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n+# General Public License for more details.\n+#\n+# You should have received a copy of the GNU General Public License\n+# along with this program; if not, write to the Free Software\n+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n+\n+usage() {\n+  local ret=\"${1:-0}\"\n+  cat <<EOF\n+\n+Usage:  ${0##*/} [options] ROOT_DIR LEAK_PATH...\n+\n+Description:\n+\n+        This script scans a tree for host paths leaked into it.\n+        Prints out leaks alongside with the kind of leak.\n+\n+Arguments:\n+\n+        ROOT_DIR        Path to the root of the tree to be scanned\n+\n+        LEAK_PATH       Paths to check for occurence. Several paths can be\n+                        passed.\n+                        A LEAK_PATH must be an absolute canonical path.\n+                        In the Buildroot context, the LEAK_PATH are Buildroot's\n+                        TOPDIR, BASE_DIR, HOST_DIR and STAGING_DIR.\n+\n+Options:\n+\n+        --exclude=PATH\n+                Excludes files from ROOT_DIR starting with PATH. Obviously, the\n+                excluded paths should point to some sub-location of ROOT_DIR.\n+                Can be set more than once.\n+                An excluded path must be an absolute canonical path.\n+\n+\n+EOF\n+  return ${ret}\n+}\n+\n+source \"${0%/*}/shell/source.sh\"\n+\n+source.load_module log\n+source.load_module utils\n+source.load_module sdk\n+\n+main() {\n+    local root_dir\n+    local class_leaks\n+    local excluded=()\n+    local leak_paths=()\n+    while test ${#} -gt 0 ; do\n+        case \"${1}\" in\n+            --exclude=*) excluded+=( \"${1#*=}\" )\n+                ;;\n+            --exclude)   shift ; excluded+=( \"${1}\" )\n+                ;;\n+            -h|--help)\n+                usage\n+                exit 0\n+                ;;\n+            *)  if test -z \"${root_dir}\" ; then root_dir=\"${1}\"\n+                else leak_paths+=( \"${1}\" )\n+                fi\n+                ;;\n+        esac\n+        shift\n+    done\n+\n+    excluded=( $(utils.list_reduce ${excluded[@]}) )\n+    leak_paths=( $(utils.list_reduce ${leak_paths[@]}) )\n+\n+    # sanity checks\n+    if test -z \"${root_dir}\" ; then\n+        log.error \"Not enough argument: no ROOT_DIR given.\\n\" ||\n+            usage ${?} || exit ${?}\n+    fi\n+    if test ${#leak_paths[@]} -lt 1 ; then\n+        log.error \"Not enough argument. No LEAK_PATH given.\\n\" ||\n+            usage ${?} || exit ${?}\n+    fi\n+\n+    local path has_non_abspath\n+    for path in ${leak_paths[@]} ; do\n+        utils.assert_absolute_canonical_path \"${path}\" || has_non_abspath=y\n+    done\n+    if test -n \"${has_non_abspath}\" ; then\n+        log.error \"Some LEAK_PATH are not absolute canonical paths.\\n\" ||\n+            usage ${?} || exit ${?}\n+    fi\n+    has_non_abspath=\n+    for path in ${excluded[@]} ; do\n+        utils.assert_absolute_canonical_path \"${path}\" || has_non_abspath=y\n+    done\n+    if test -n \"${has_non_abspath}\" ; then\n+        log.error \"Some excluded path are not absolute canonical paths.\\n\" ||\n+            usage ${?} || exit ${?}\n+    fi\n+\n+    local re_leaks=\"$(sed -re 's/^/(/ ; s/$/)/ ; s/ +/|/g' <<<\"${leak_paths[*]}\")\"\n+    local re_excl=\"$(sed -re 's/ +/|/g' <<<\"${excluded[*]}\")\"\n+    if test -n \"${re_excl}\" ; then\n+      re_excl=\"\\\\:^(${re_excl}):d\"\n+    fi\n+    pushd \"${root_dir}\" >/dev/null\n+    local f\n+    grep -raEl \"${re_leaks}\" . |\n+        sed -re \"${re_excl} ; s:^\\.:${root_dir}:\" |\n+        while read f ; do\n+            printf \"%s\\n\" \"${f}\"\n+        done | sort\n+    popd >/dev/null\n+}\n+main \"${@}\"\ndiff --git a/support/scripts/shell/readelf.sh b/support/scripts/shell/readelf.sh\nindex 78a1a9f..b23666e 100644\n--- a/support/scripts/shell/readelf.sh\n+++ b/support/scripts/shell/readelf.sh\n@@ -17,18 +17,22 @@\n # Readelf helpers\n #\n # This module defines the following functions:\n+#   readelf._match_elf_regexp\n #   readelf._filter_elf_regexp\n #   readelf.filter_elf\n #   readelf.filter_elf_executable\n #   readelf.filter_elf_shared_object\n #   readelf.is_elf_executable\n #   readelf.is_elf_shared_object\n+#   readelf.is_elf_static_library\n+#   readelf.is_elf_object\n #   readelf.get_rpath\n #   readelf.get_neededs\n #   readelf.needs_rpath\n #   readelf.has_rpath\n #   readelf.list_sections\n #   readelf.has_section\n+#   readelf.string_section\n #\n # This module is sensitive to the following environment variables:\n #   READELF\n@@ -39,12 +43,28 @@ source.declare_module readelf\n # C locale, so we are sure we can reliably parse its output.\n : ${READELF:=readelf}\n \n-# readelf._filter_elf_regexp filter_cmd file...\n+# readelf._match_elf_regexp regexp file\n #\n-# Filters ELF files WRT the given regular extended expression.\n+# Returns 0 if the ELF file matches the ELF type given in extended regular\n+# expression, non-0 otherwise.\n+#\n+# regexp     : extended regular expression\n+# file       : list of files to be filtered\n+#\n+# environment:\n+#   READELF: readelf program path\n+readelf._match_elf_regexp() {\n+    log._trace_func\n+    local regexp=\"${1}\" file=\"${2}\"\n+    LC_ALL=C ${READELF} -h \"${file}\" 2>/dev/null | grep -qE \"${regexp}\"\n+}\n+\n+# readelf._filter_elf_regexp regexp file...\n+#\n+# Filters ELF files WRT the given extended regular expression.\n # This funtion can take one or several files, or read them from stdin.\n #\n-# filter_cmd : filter command (usually based on grep)\n+# regexp     : extended regular expression\n # file       : list of files to be filtered\n #\n # environment:\n@@ -56,9 +76,7 @@ readelf._filter_elf_regexp() {\n     test ${#} -gt 0 && in='printf \"%s\\n\" \"${@}\"' || in='dd 2>/dev/null'\n     eval \"${in}\" |\n         while read file ; do\n-            LC_ALL=C ${READELF} -h \"${file}\" 2>/dev/null |\n-                grep -qE \"${regexp}\" ||\n-                    continue\n+            readelf._match_elf_regexp \"${regexp}\" \"${file}\" || continue\n             printf \"%s\\n\" \"${file}\"\n         done\n }\n@@ -129,6 +147,39 @@ readelf.is_elf_executable() {\n     test \"$(readelf.filter_elf_executable \"${1}\")\" != \"\"\n }\n \n+# readelf.is_elf file\n+#\n+# Returns 0 if $file is an ELF file, non-0 otherwise.\n+#\n+# file : path of file to be tested\n+#\n+# environment:\n+#   READELF: readelf program path\n+readelf.is_elf() {\n+    test \"$(readelf.filter_elf \"${1}\")\" != \"\"\n+}\n+\n+# readelf.is_elf_static_library file\n+#\n+# Return 0 if $file is a Linux static libraries, i.e. an ar-archive\n+# containing *.o files.\n+#\n+# file : path of file to be tested\n+readelf.is_elf_static_library() {\n+    readelf._match_elf_regexp \"Type:\\s+REL\\s\\(Relocatable\\sfile\\)\" \"${@}\" &&\n+        readelf._match_elf_regexp \"^File:\\s+\\S+\\)$\" \"${@}\"\n+}\n+\n+# readelf.is_elf_object file\n+#\n+# Return 0 if $file is an ELF object file, i.e. a *.o (or *.ko) file.\n+#\n+# file : path of file to be tested\n+readelf.is_elf_object() {\n+    readelf._match_elf_regexp \"Type:\\s+REL\\s\\(Relocatable\\sfile\\)\" \"${@}\" &&\n+        ! readelf._match_elf_regexp \"^File:\\s+\\S+\\)$\" \"${@}\"\n+}\n+\n # readelf.get_rpath file\n #\n # Return the unsplitted RPATH/RUNPATH of $file.\n@@ -240,3 +291,17 @@ readelf.has_section() {\n     local file=\"${1}\" section_name=\"${2}\"\n     readelf.list_sections \"${file}\" | grep -q \"^${section_name}$\"\n }\n+\n+# readelf.string_section file section\n+#\n+# Return the given $section of $file.\n+#\n+# file    : ELF file path\n+# section : ELF section name\n+#\n+# environment:\n+#   READELF: readelf program path\n+readelf.string_section() {\n+    local file=\"${1}\" section=\"${2}\"\n+    LC_ALL=C \"${READELF}\" --string-dump \"${section}\" \"${file}\" 2>/dev/null\n+}\ndiff --git a/support/scripts/shell/sdk.sh b/support/scripts/shell/sdk.sh\nindex b2f699c..6cb3bbe 100644\n--- a/support/scripts/shell/sdk.sh\n+++ b/support/scripts/shell/sdk.sh\n@@ -19,9 +19,16 @@\n # This module defines the following functions:\n #   sdk.compute_relative_path\n #   sdk.compute_rpath\n+#   sdk.check_host_leaks\n+#\n+# This module is sensitive to the following environment variables:\n+#   READELF\n \n source.declare_module sdk\n \n+source.load_module utils\n+source.load_module readelf\n+\n # sdk.compute_relative_path basedir path start\n #\n # Computes and prints the relative path between $start and $path within $basedir.\ndiff --git a/support/scripts/shell/utils.sh b/support/scripts/shell/utils.sh\nindex 9e9aaab..eac3158 100644\n--- a/support/scripts/shell/utils.sh\n+++ b/support/scripts/shell/utils.sh\n@@ -19,6 +19,7 @@\n # This module defines the following functions:\n #   utils.list_has\n #   utils.list_reduce\n+#   utils.assert_absolute_canonical_path\n \n source.declare_module utils\n \n@@ -58,3 +59,16 @@ utils.list_reduce() {\n \n     echo ${lout[@]}\n }\n+\n+# utils.assert_absolute_canonical_path path\n+#\n+# Returns 0 if 'path' is the absolute canonical path, returns non-0\n+# otherwise.\n+#\n+# If the test failed, an error message will be issued to stderr.\n+#\n+# path : path to be tested\n+utils.assert_absolute_canonical_path() {\n+    test \"$(readlink -f \"${1}\")\" = \"${1}\" ||\n+        log.error \"%s is not the absolute canonical path.\\n\" \"${1}\" >&2\n+}\n",
    "prefixes": [
        "v9",
        "08/11"
    ]
}