From patchwork Mon Jul 30 15:51:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Patzlaff, Marcel" X-Patchwork-Id: 951067 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=pilz.de Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41fPGB3ddWz9s1R for ; Tue, 31 Jul 2018 01:52:18 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 8472B88C0A; Mon, 30 Jul 2018 15:52:14 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gGwq8mjRA5sr; Mon, 30 Jul 2018 15:52:12 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 915D188BE3; Mon, 30 Jul 2018 15:52:12 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 9CD811C21CE for ; Mon, 30 Jul 2018 15:52:09 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 99E9D20783 for ; Mon, 30 Jul 2018 15:52:09 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id W3bf0PXw6QUx for ; Mon, 30 Jul 2018 15:52:08 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail1.pilz.de (mail1.pilz.de [212.211.209.113]) by silver.osuosl.org (Postfix) with ESMTPS id E815D20782 for ; Mon, 30 Jul 2018 15:52:07 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.51,422,1526335200"; d="scan'208";a="1844225" Received: from unknown (HELO srv-desm01) ([172.20.2.85]) by mail1.pilz.de with ESMTP; 30 Jul 2018 17:52:03 +0200 Received: from srv-dema02.de.pilz.local ([172.16.206.6]) by srv-desm01 (IBM Domino Release 9.0.1FP8) with ESMTP id 2018073017515496-3962323 ; Mon, 30 Jul 2018 17:51:54 +0200 Received: from mpa-linux.de.pilz.local ([172.16.204.213]) by srv-dema02.de.pilz.local (IBM Domino Release 9.0.1FP8 HF475) with ESMTP id 2018073017520205-10211 ; Mon, 30 Jul 2018 17:52:02 +0200 From: Marcel Patzlaff To: buildroot@buildroot.org Date: Mon, 30 Jul 2018 17:51:51 +0200 Message-Id: <20180730155153.24091-2-m.patzlaff@pilz.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180730155153.24091-1-m.patzlaff@pilz.de> References: <20180730155153.24091-1-m.patzlaff@pilz.de> X-MIMETrack: Itemize by SMTP Server on DEMA02/SRV/Pilz(Release 9.0.1FP8 HF475|July 13, 2017) at 30.07.2018 17:52:02, Serialize by ntm_grab.EXE on DEMA02/SRV/Pilz(Release 9.0.1FP8 HF475|July 13, 2017) at 30.07.2018 17:52:02, Serialize complete at 30.07.2018 17:52:02, Serialize by Router on DEMA02/SRV/Pilz(Release 9.0.1FP8 HF475|July 13, 2017) at 30.07.2018 17:52:02, Itemize by SMTP Server on desm01/dmz(Release 9.0.1FP8|February 23, 2017) at 30.07.2018 17:51:54, Serialize by Router on desm01/dmz(Release 9.0.1FP8|February 23, 2017) at 30.07.2018 17:51:55, Serialize complete at 30.07.2018 17:51:55 X-TNEFEvaluated: 1 MIME-Version: 1.0 Subject: [Buildroot] [PATCH 1/3] Support script for defconfig comparison X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.24 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marcel Patzlaff Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" This patch adds a new support script that allows to compare two defconfigs and to output the differences in a form such that it can be used as configuration fragment. The comparison is done in two steps: 1) Apply a plain "diff" on the two files (A and B) and collect all item names where diff sees a difference. This results in a list of newline separated item names. 2) For each item name in the list, the complete line out of the .config file derived from B is taken and written to stdout. Signed-off-by: Marcel Patzlaff --- utils/diff_defconfig.sh | 95 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100755 utils/diff_defconfig.sh diff --git a/utils/diff_defconfig.sh b/utils/diff_defconfig.sh new file mode 100755 index 0000000000..385e741813 --- /dev/null +++ b/utils/diff_defconfig.sh @@ -0,0 +1,95 @@ +#!/bin/sh + +# diff_defconfig.sh - Takes two defconfig files A and B as well as the config +# file derived from B and outputs the differences that lead from A to B. +# The output can be used as configuration fragment. +# It is garanteed, that the output only contains configuration items that are +# present in either defconfig. So it's assumed, that all configuration items +# this script outputs are also user-settable. +# +# +# Copyright 2018 Pilz GmbH & Co. KG +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. + +set -e + +THIS_FILE=$(basename "${0}") + +USAGE="${THIS_FILE} [OPTIONS] " + +fail_msg() { + printf "%s\n" "${1}" 1>&2 + exit 1 +} + +help() { + cat <<-_EOF_ + Usage: + ${USAGE} + + ${THIS_FILE} takes two defconfig files A and B as well as the .config + file derived from B and outputs the differences that lead from A to B on + stdout. The output can be used as configuration fragment. + + Options: + -h display this help text + -p do not restrict config prefix to CONFIG_ + + Returns: + 0 If no error + !0 If any error + _EOF_ +} + + +ALLPREFIXES=false +# parse options +while true; do + case "${1}" in + "-h") + help + exit 0 + ;; + "-p") + ALLPREFIXES=true + shift + ;; + *) + break + ;; + esac +done + +# check if all files are given +[ "${#}" -eq "3" ] || fail_msg "Usage: ${USAGE}" + +# test if files exist +[ -f "${1}" ] || fail_msg "First defconfig file '${1}' does not exist!" +[ -f "${2}" ] || fail_msg "Second defconfig file '${2}' does not exist!" +[ -f "${3}" ] || fail_msg "Config file '${3}' does not exist!" + +ITEM_EXP="s/^[<>]\s\(# \)\{0,1\}\(CONFIG_[a-zA-Z0-9_]*\)[= ].*/\2/p" +if [ "${ALLPREFIXES}" = "true" ]; then + ITEM_EXP="s/^[<>]\s\(# \)\{0,1\}\([a-zA-Z][a-zA-Z0-9_]*\)[= ].*/\2/p" +fi + +# use normal diff and collect all differing item names +ITEMS=$(diff "${1}" "${2}" | sed -n "${ITEM_EXP}" | sort | uniq) + +# output their values +# Note: ITEMS does only contain newline separators and no other whitespaces. +# See regular expression above. +for item in ${ITEMS}; do + # some items disable/hide others so grep may fail here + grep -w "${item}" "${3}" || true +done + +exit 0