From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 0CF2E1387AB for ; Sat, 8 Feb 2014 16:30:54 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id AA6DAE0B01; Sat, 8 Feb 2014 16:30:51 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 474F8E0B01 for ; Sat, 8 Feb 2014 16:30:51 +0000 (UTC) Received: from spoonbill.gentoo.org (spoonbill.gentoo.org [81.93.255.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 737DB33F8E9 for ; Sat, 8 Feb 2014 16:30:50 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by spoonbill.gentoo.org (Postfix) with ESMTP id 321FE18278 for ; Sat, 8 Feb 2014 16:30:49 +0000 (UTC) From: "Ulrich Müller" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Ulrich Müller" Message-ID: <1391877315.9b2496f2a230e8f29feda04e141ccd574858cb24.ulm@gentoo> Subject: [gentoo-commits] proj/qa-scripts:master commit in: / X-VCS-Repository: proj/qa-scripts X-VCS-Files: find-binary-files.sh X-VCS-Directories: / X-VCS-Committer: ulm X-VCS-Committer-Name: Ulrich Müller X-VCS-Revision: 9b2496f2a230e8f29feda04e141ccd574858cb24 X-VCS-Branch: master Date: Sat, 8 Feb 2014 16:30:49 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 19736211-f26d-436d-b04a-bb67eaf155a2 X-Archives-Hash: 69ee1171ec80a0aa71b9b483ce5b97e2 commit: 9b2496f2a230e8f29feda04e141ccd574858cb24 Author: Ulrich Müller gentoo org> AuthorDate: Sat Feb 8 16:35:15 2014 +0000 Commit: Ulrich Müller gentoo org> CommitDate: Sat Feb 8 16:35:15 2014 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/qa-scripts.git;a=commit;h=9b2496f2 New script to find binary files based on file -i magic. Signed-off-by: Ulrich Müller gentoo.org> --- find-binary-files.sh | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/find-binary-files.sh b/find-binary-files.sh new file mode 100755 index 0000000..17bdc0a --- /dev/null +++ b/find-binary-files.sh @@ -0,0 +1,37 @@ +#!/bin/bash +# Copyright 2014 Gentoo Foundation +# Distributed under the terms of the GNU GPL version 2 or later +# Author: Ulrich Müller + +shopt -s extglob + +portdir=$(portageq get_repo_path / gentoo) +cd "${portdir}" || exit 1 + +find . \( -path ./distfiles -o -path ./local -o -path ./metadata \) -prune \ + -o ! -type d -exec file -ih '{}' + \ +| while read line; do + path=${line%:*} + type=${line##*:*( )} + case ${type} in + "application/octet-stream; charset=unknown" \ + | "binary; charset=binary") + # GNU Info files (or patches to them) can contain the following + # control characters that produce false positives: + # - 0x1f, followed by LF or FF + # - 0x7f (DEL), preceded by "Node:" in the same line + # Filter such characters and reiterate + line=$(sed -e 's/\x1f\f\?$//;/Node:/s/\x7f//' "${path}" | file -i -) + type=${line##*:*( )} + ;; + esac + case ${type} in + text/*) ;; # text file + application/*"; charset=us-ascii") ;; + application/*"; charset=utf-8") ;; + "image/svg+xml; charset=us-ascii") ;; # SVG image + "image/x-xpmi; charset=us-ascii") ;; # XPM image + *) echo "${path#./}: ${type}" ;; + esac +done \ +| sort