From patchwork Wed Aug 23 14:21:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Voss X-Patchwork-Id: 805024 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xcqNz6ndMz9s7g for ; Thu, 24 Aug 2017 00:21:39 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 52E7489238; Wed, 23 Aug 2017 14:21:35 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZiN98-4rrTLw; Wed, 23 Aug 2017 14:21:33 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 6F1F589259; Wed, 23 Aug 2017 14:21:33 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id BBAE61C25D4 for ; Wed, 23 Aug 2017 14:21:31 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id A7F18887DE for ; Wed, 23 Aug 2017 14:21:31 +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 jh-c--hUREQz for ; Wed, 23 Aug 2017 14:21:30 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from ch3vs02.rockwellcollins.com (smtpimr.rockwellcollins.com [205.175.226.29]) by whitealder.osuosl.org (Postfix) with ESMTPS id 6BD96887CF for ; Wed, 23 Aug 2017 14:21:30 +0000 (UTC) Received: from ofwch3n02.rockwellcollins.com (HELO ciulimr01.rockwellcollins.com) ([205.175.226.14]) by ch3vs02.rockwellcollins.com with ESMTP; 23 Aug 2017 09:21:29 -0500 X-Received: from largo.rockwellcollins.com (unknown [192.168.140.76]) by ciulimr01.rockwellcollins.com (Postfix) with ESMTP id 062896019A; Wed, 23 Aug 2017 09:21:29 -0500 (CDT) From: Sam Voss To: buildroot@buildroot.org Date: Wed, 23 Aug 2017 09:21:26 -0500 Message-Id: <1503498086-1593-1-git-send-email-sam.voss@rockwellcollins.com> X-Mailer: git-send-email 1.9.1 Cc: Sam Voss Subject: [Buildroot] [PATCH 1/1] Support: Config generation script X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" Add script to create kconfig fragments that are directly usable. - Sort commented out packages - Output to stdout, must be redirected - Add linux example Signed-off-by: Sam Voss --- Relates to: https://patchwork.ozlabs.org/patch/686694/ Missing feature to combine all fragments used to create newest configuration file, which can make it difficult to diff large fragment sets. I was hoping to leverage buildroot's fragment combiner, but haven't had a chance to look into it. --- support/scripts/diffconfig.sh | 75 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100755 support/scripts/diffconfig.sh diff --git a/support/scripts/diffconfig.sh b/support/scripts/diffconfig.sh new file mode 100755 index 0000000..59227ad --- /dev/null +++ b/support/scripts/diffconfig.sh @@ -0,0 +1,75 @@ +#!/bin/bash + +################################################################################ +# DESCRIPTION: +# Creates a fragment by comparing two kconfigs. +# +# Required arguments: +# $1 - config #1. This is generally the new one created +# $2 - config #2: The configuration file to compare against. +# +# Linux Example +# ./support/scripts/diffconfig.sh /build/linux-x.y.z/defconfig +# board/custom-board/linux-x.y.z.config +################################################################################ + +usage () +{ +cat <<-_EOF_ + diffconfig.sh: + Creates a fragment by comparing two kconfigs. + + Required arguments: + $1 - config #1. This is generally the new one created + $2 - config #2: The configuration file to compare against. +_EOF_ + + exit 1 +} + +if [ -z "$1" ] || [ -z "$2" ]; then + usage +fi + +declare -a loaded_first_config loaded_second_config + +# spaces must be removed, and then re-replaced. +SPACE_DELIM="_s_p_a_c_e_" + +while read line; do + if [ "${line:0:1}" != "#" ]; then + loaded_first_config+=("${line// /${SPACE_DELIM}}") + elif [ "${line:2:3}" = "BR2" ] || [ "${line:2:6}" = "CONFIG" ]; then + # was a commented line, but still needs alpha sorting + NOC="${line:2}" + loaded_first_config+=("${NOC// /${SPACE_DELIM}}") + fi +done < "$1" # load file 1 + +while read line; do + if [ "${line:0:1}" != "#" ]; then + loaded_second_config+=("${line// /${SPACE_DELIM}}") + elif [ "${line:2:3}" = "BR2" ] || [ "${line:2:6}" = "CONFIG" ]; then + # was a commented line, but still needs alpha sorting + NOC="${line:2}" + loaded_second_config+=("${NOC// /${SPACE_DELIM}}") + fi +done < "$2" # load file 2 + +D=($(comm -23 <(printf '%s\n' "${loaded_first_config[@]}" | sort -d) <(printf '%s\n' "${loaded_second_config[@]}" | sort -d))) + +# Earlier, the '# ' were removed from the beginning of not-set packages for +# sorting. Add them back. +declare -a NFRAG + +for line in "${D[@]}"; do + # if the line does not have an '=', it was a comment + if [ "${line#*=*}" = "${line}" ]; then + NFRAG+=("# ${line}") + else + NFRAG+=($line) + fi +done + +# Earlier, spaces were replaced with '_space_'. Revert this and dump to stdout. +printf "%s\n" "${NFRAG[@]//${SPACE_DELIM}/ }"