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:50 +0000
commit4984b60c76171f76237373b8fb37d8094004307c (patch)
tree275c6bc5a5c17d7749c0505ae8e27b0036290cd0 /scripts/distro/distrocompare.sh
parent5442688efe20d1cb7f33fd02e47cfe3d89014df6 (diff)
downloadpoky-4984b60c76171f76237373b8fb37d8094004307c.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 (From OE-Core rev: 32b363c2ba91fde4f10e5fe2c898b2fc2702aa85) Signed-off-by: Tan Shen Joon <shen.joon.tan@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
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 @@
1#!/usr/bin/env bash
2#
3# Copyright (c) 2017, Intel Corporation.
4# All rights reserved.
5#
6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 2 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
18# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19#
20# distrocompare.sh : provides capability to get a list of new packages
21# based on two distinct branches. This script takes
22# 2 parameters; either a commit-ish or a branch name
23#
24# To run : distrocompare.sh <older hash> <newer hash>
25# E.g. distrocompare.sh morty 92aa0e7
26# E.g. distrocompare.sh morty pyro
27#
28
29# get input as version
30previous_version=$1
31current_version=$2
32
33# set previous and current version
34if [ -z "$2" ]; then
35 previous_version=$1
36 current_version="current"
37fi
38
39# get script location. That's where the source supposedly located as well.
40scriptdir="$( realpath $(dirname "${BASH_SOURCE[0]}" ))"
41sourcedir="$( realpath $scriptdir/../.. )"
42
43# create working directory
44workdir=$(mktemp -d)
45
46# prepare to rollback to the branch if not similar
47branch=`cd $sourcedir; git branch | grep \* | cut -d ' ' -f2`
48
49# set current workdir to store final result
50currentworkdir=`pwd`
51
52# persists the file after local repo change
53cp $scriptdir/build-recipe-list.py $workdir
54
55#==================================================================
56
57function bake_distrodata {
58 # get to source directory of the git
59 cd $sourcedir
60
61 # change the branch / commit. Do not change if input is current
62 if [ "$1" != "current" ]; then
63 output=$(git checkout $1 2>&1)
64
65 # exit if git fails
66 if [[ $output == *"error"* ]]; then
67 echo "git error : $output"
68 echo "exiting ... "
69 rm -rf $workdir
70 exit
71 fi
72 fi
73
74 # make tmp as workdir
75 cd $workdir
76
77 # source oe-init to generate a new build folder
78 source $sourcedir/oe-init-build-env $1
79
80 # if file already exists with distrodata, do not append
81 if ! grep -q "distrodata" "conf/local.conf"; then
82 # add inherit distrodata to local.conf to enable distrodata feature
83 echo 'INHERIT += "distrodata"' >> conf/local.conf
84 fi
85
86 # use from tmp
87 $workdir/build-recipe-list.py generate_recipe_list
88}
89
90bake_distrodata $previous_version
91bake_distrodata $current_version
92
93#==================================================================
94
95cd $workdir
96
97# compare the 2 generated recipe-list.txt
98$workdir/build-recipe-list.py compare_recipe $previous_version $current_version
99
100# copy final result to current working directory
101cp $workdir/*_new_recipe_list.txt $currentworkdir
102
103if [ $? -ne 0 ]; then
104 rm -rf $workdir/$previous_version
105 rm -rf $workdir/$current_version
106 rm $workdir/build-recipe-list.py
107 # preserve the result in /tmp/distrodata if fail to copy the result over
108 exit
109fi
110
111# cleanup
112rm -rf $workdir
113
114# perform rollback branch
115cd $sourcedir
116currentbranch=`git branch | grep \* | cut -d ' ' -f2`
117if [ "$currentbranch" != "$branch" ]; then
118 git checkout $branch
119fi
120
121cd $currentworkdir
122
123#==================================================================