summaryrefslogtreecommitdiffstats
path: root/scripts/distro/distrocompare.sh
diff options
context:
space:
mode:
authorTan Shen Joon <shen.joon.tan@intel.com>2017-08-10 06:57:01 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-01-29 08:49:43 +0000
commit32b363c2ba91fde4f10e5fe2c898b2fc2702aa85 (patch)
treec6edd26fbda1da70b3eb8572ac841d5ebc0c4777 /scripts/distro/distrocompare.sh
parentdb59381121d564a1ba5d199a8099d120620f0527 (diff)
downloadopenembedded-core-32b363c2ba91fde4f10e5fe2c898b2fc2702aa85.tar.gz
distrodata: add a utility script to compare list of recipes
distrocompare.sh is added to compare the added list of recipes between two releases. The output of the script will share the information of the licenses required and other distributions that are using the package. If a single input is provided, it will compare the current branch with the provided branch/commit-ish package list. To run : distrocompare.sh <older hash> <newer hash> E.g. distrocompare.sh morty 92aa0e7 E.g. distrocompare.sh morty pyro E.g. distrocompare.sh morty output : The script will produce a file ending with new_recipe_list.txt preceeded by the branch name from input Signed-off-by: Tan Shen Joon <shen.joon.tan@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
Diffstat (limited to 'scripts/distro/distrocompare.sh')
-rwxr-xr-xscripts/distro/distrocompare.sh123
1 files changed, 123 insertions, 0 deletions
diff --git a/scripts/distro/distrocompare.sh b/scripts/distro/distrocompare.sh
new file mode 100755
index 0000000000..908760c235
--- /dev/null
+++ b/scripts/distro/distrocompare.sh
@@ -0,0 +1,123 @@
+#!/usr/bin/env bash
+#
+# Copyright (c) 2017, Intel Corporation.
+# All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# 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.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# distrocompare.sh : provides capability to get a list of new packages
+# based on two distinct branches. This script takes
+# 2 parameters; either a commit-ish or a branch name
+#
+# To run : distrocompare.sh <older hash> <newer hash>
+# E.g. distrocompare.sh morty 92aa0e7
+# E.g. distrocompare.sh morty pyro
+#
+
+# get input as version
+previous_version=$1
+current_version=$2
+
+# set previous and current version
+if [ -z "$2" ]; then
+ previous_version=$1
+ current_version="current"
+fi
+
+# get script location. That's where the source supposedly located as well.
+scriptdir="$( realpath $(dirname "${BASH_SOURCE[0]}" ))"
+sourcedir="$( realpath $scriptdir/../.. )"
+
+# create working directory
+workdir=$(mktemp -d)
+
+# prepare to rollback to the branch if not similar
+branch=`cd $sourcedir; git branch | grep \* | cut -d ' ' -f2`
+
+# set current workdir to store final result
+currentworkdir=`pwd`
+
+# persists the file after local repo change
+cp $scriptdir/build-recipe-list.py $workdir
+
+#==================================================================
+
+function bake_distrodata {
+ # get to source directory of the git
+ cd $sourcedir
+
+ # change the branch / commit. Do not change if input is current
+ if [ "$1" != "current" ]; then
+ output=$(git checkout $1 2>&1)
+
+ # exit if git fails
+ if [[ $output == *"error"* ]]; then
+ echo "git error : $output"
+ echo "exiting ... "
+ rm -rf $workdir
+ exit
+ fi
+ fi
+
+ # make tmp as workdir
+ cd $workdir
+
+ # source oe-init to generate a new build folder
+ source $sourcedir/oe-init-build-env $1
+
+ # if file already exists with distrodata, do not append
+ if ! grep -q "distrodata" "conf/local.conf"; then
+ # add inherit distrodata to local.conf to enable distrodata feature
+ echo 'INHERIT += "distrodata"' >> conf/local.conf
+ fi
+
+ # use from tmp
+ $workdir/build-recipe-list.py generate_recipe_list
+}
+
+bake_distrodata $previous_version
+bake_distrodata $current_version
+
+#==================================================================
+
+cd $workdir
+
+# compare the 2 generated recipe-list.txt
+$workdir/build-recipe-list.py compare_recipe $previous_version $current_version
+
+# copy final result to current working directory
+cp $workdir/*_new_recipe_list.txt $currentworkdir
+
+if [ $? -ne 0 ]; then
+ rm -rf $workdir/$previous_version
+ rm -rf $workdir/$current_version
+ rm $workdir/build-recipe-list.py
+ # preserve the result in /tmp/distrodata if fail to copy the result over
+ exit
+fi
+
+# cleanup
+rm -rf $workdir
+
+# perform rollback branch
+cd $sourcedir
+currentbranch=`git branch | grep \* | cut -d ' ' -f2`
+if [ "$currentbranch" != "$branch" ]; then
+ git checkout $branch
+fi
+
+cd $currentworkdir
+
+#==================================================================