diff options
| author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-12-18 12:02:06 +0000 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-12-18 16:19:34 +0000 |
| commit | e4e0445431d64ba4ed9c59086791f189d218191b (patch) | |
| tree | 458c338b3b8a43ae20e8db0696c9c44b6aa592f8 /scripts | |
| parent | 42cc9e6c99f40a885352e17f7c7d68d70c3fffbd (diff) | |
| download | poky-e4e0445431d64ba4ed9c59086791f189d218191b.tar.gz | |
scripts/distro: Remove as using obsolete APIs and need re-implementing sanely
(From OE-Core rev: 83d0049bb406e09251b368dba9478be71fe2b0a8)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/distro/build-recipe-list.py | 129 | ||||
| -rwxr-xr-x | scripts/distro/distrocompare.sh | 123 |
2 files changed, 0 insertions, 252 deletions
diff --git a/scripts/distro/build-recipe-list.py b/scripts/distro/build-recipe-list.py deleted file mode 100755 index 2162764850..0000000000 --- a/scripts/distro/build-recipe-list.py +++ /dev/null | |||
| @@ -1,129 +0,0 @@ | |||
| 1 | #!/usr/bin/env python3 | ||
| 2 | # | ||
| 3 | # Copyright (c) 2017, Intel Corporation. | ||
| 4 | # | ||
| 5 | # This program is free software; you can redistribute it and/or modify it | ||
| 6 | # under the terms and conditions of the GNU General Public License, | ||
| 7 | # version 2, as published by the Free Software Foundation. | ||
| 8 | # | ||
| 9 | # This program is distributed in the hope it will be useful, but WITHOUT | ||
| 10 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 11 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| 12 | # more details. | ||
| 13 | # | ||
| 14 | |||
| 15 | import os | ||
| 16 | import shutil | ||
| 17 | import csv | ||
| 18 | import sys | ||
| 19 | import argparse | ||
| 20 | |||
| 21 | __version__ = "0.1.0" | ||
| 22 | |||
| 23 | # set of BPNs | ||
| 24 | recipenames = set() | ||
| 25 | # map of recipe -> data | ||
| 26 | allrecipes = {} | ||
| 27 | |||
| 28 | def make_bpn(recipe): | ||
| 29 | prefixes = ("nativesdk-",) | ||
| 30 | suffixes = ("-native", "-cross", "-initial", "-intermediate", "-crosssdk", "-cross-canadian") | ||
| 31 | for ix in prefixes + suffixes: | ||
| 32 | if ix in recipe: | ||
| 33 | recipe = recipe.replace(ix, "") | ||
| 34 | return recipe | ||
| 35 | |||
| 36 | def gather_recipes(rows): | ||
| 37 | for row in rows: | ||
| 38 | recipe = row[0] | ||
| 39 | bpn = make_bpn(recipe) | ||
| 40 | if bpn not in recipenames: | ||
| 41 | recipenames.add(bpn) | ||
| 42 | if recipe not in allrecipes: | ||
| 43 | allrecipes[recipe] = row | ||
| 44 | |||
| 45 | def generate_recipe_list(): | ||
| 46 | # machine list | ||
| 47 | machine_list = ( "qemuarm64", "qemuarm", "qemumips64", "qemumips", "qemuppc", "qemux86-64", "qemux86" ) | ||
| 48 | # set filename format | ||
| 49 | fnformat = 'distrodata.%s.csv' | ||
| 50 | |||
| 51 | # store all data files in distrodata | ||
| 52 | datadir = 'distrodata' | ||
| 53 | |||
| 54 | # create the directory if it does not exists | ||
| 55 | if not os.path.exists(datadir): | ||
| 56 | os.mkdir(datadir) | ||
| 57 | |||
| 58 | # doing bitbake distrodata | ||
| 59 | for machine in machine_list: | ||
| 60 | os.system('MACHINE='+ machine + ' bitbake -k universe -c distrodata') | ||
| 61 | shutil.copy('tmp/log/distrodata.csv', 'distrodata/' + fnformat % machine) | ||
| 62 | |||
| 63 | for machine in machine_list: | ||
| 64 | with open('distrodata/' + fnformat % machine) as f: | ||
| 65 | reader = csv.reader(f) | ||
| 66 | rows = reader.__iter__() | ||
| 67 | gather_recipes(rows) | ||
| 68 | |||
| 69 | with open('recipe-list.txt', 'w') as f: | ||
| 70 | for recipe in sorted(recipenames): | ||
| 71 | f.write("%s\n" % recipe) | ||
| 72 | print("file : recipe-list.txt is created with %d entries." % len(recipenames)) | ||
| 73 | |||
| 74 | with open('all-recipe-list.txt', 'w') as f: | ||
| 75 | for recipe, row in sorted(allrecipes.items()): | ||
| 76 | f.write("%s\n" % ','.join(row)) | ||
| 77 | |||
| 78 | |||
| 79 | def diff_for_new_recipes(recipe1, recipe2): | ||
| 80 | prev_recipe_path = recipe1 + '/' | ||
| 81 | curr_recipe_path = recipe2 + '/' | ||
| 82 | if not os.path.isfile(prev_recipe_path + 'recipe-list.txt') or not os.path.isfile(curr_recipe_path + 'recipe-list.txt'): | ||
| 83 | print("recipe files do not exists. please verify that the file exists.") | ||
| 84 | exit(1) | ||
| 85 | |||
| 86 | import csv | ||
| 87 | |||
| 88 | prev = [] | ||
| 89 | new = [] | ||
| 90 | |||
| 91 | with open(prev_recipe_path + 'recipe-list.txt') as f: | ||
| 92 | prev = f.readlines() | ||
| 93 | |||
| 94 | with open(curr_recipe_path + 'recipe-list.txt') as f: | ||
| 95 | new = f.readlines() | ||
| 96 | |||
| 97 | updates = [] | ||
| 98 | for pn in new: | ||
| 99 | if not pn in prev: | ||
| 100 | updates.append(pn.rstrip()) | ||
| 101 | |||
| 102 | allrecipe = [] | ||
| 103 | with open(recipe1 + '_' + recipe2 + '_new_recipe_list.txt','w') as dr: | ||
| 104 | with open(curr_recipe_path + 'all-recipe-list.txt') as f: | ||
| 105 | reader = csv.reader(f, delimiter=',') | ||
| 106 | for row in reader: | ||
| 107 | if row[0] in updates: | ||
| 108 | dr.write("%s,%s,%s" % (row[0], row[3], row[5])) | ||
| 109 | if len(row[9:]) > 0: | ||
| 110 | dr.write(",%s" % ','.join(row[9:])) | ||
| 111 | dr.write("\n") | ||
| 112 | |||
| 113 | def main(argv): | ||
| 114 | if argv[0] == "generate_recipe_list": | ||
| 115 | generate_recipe_list() | ||
| 116 | elif argv[0] == "compare_recipe": | ||
| 117 | diff_for_new_recipes(argv[1], argv[2]) | ||
| 118 | else: | ||
| 119 | print("no such option. choose either 'generate_recipe_list' or 'compare_recipe'") | ||
| 120 | |||
| 121 | exit(0) | ||
| 122 | |||
| 123 | if __name__ == "__main__": | ||
| 124 | try: | ||
| 125 | sys.exit(main(sys.argv[1:])) | ||
| 126 | except Exception as e: | ||
| 127 | print("Exception :", e) | ||
| 128 | sys.exit(1) | ||
| 129 | |||
diff --git a/scripts/distro/distrocompare.sh b/scripts/distro/distrocompare.sh deleted file mode 100755 index 908760c235..0000000000 --- a/scripts/distro/distrocompare.sh +++ /dev/null | |||
| @@ -1,123 +0,0 @@ | |||
| 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 | ||
| 30 | previous_version=$1 | ||
| 31 | current_version=$2 | ||
| 32 | |||
| 33 | # set previous and current version | ||
| 34 | if [ -z "$2" ]; then | ||
| 35 | previous_version=$1 | ||
| 36 | current_version="current" | ||
| 37 | fi | ||
| 38 | |||
| 39 | # get script location. That's where the source supposedly located as well. | ||
| 40 | scriptdir="$( realpath $(dirname "${BASH_SOURCE[0]}" ))" | ||
| 41 | sourcedir="$( realpath $scriptdir/../.. )" | ||
| 42 | |||
| 43 | # create working directory | ||
| 44 | workdir=$(mktemp -d) | ||
| 45 | |||
| 46 | # prepare to rollback to the branch if not similar | ||
| 47 | branch=`cd $sourcedir; git branch | grep \* | cut -d ' ' -f2` | ||
| 48 | |||
| 49 | # set current workdir to store final result | ||
| 50 | currentworkdir=`pwd` | ||
| 51 | |||
| 52 | # persists the file after local repo change | ||
| 53 | cp $scriptdir/build-recipe-list.py $workdir | ||
| 54 | |||
| 55 | #================================================================== | ||
| 56 | |||
| 57 | function 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 | |||
| 90 | bake_distrodata $previous_version | ||
| 91 | bake_distrodata $current_version | ||
| 92 | |||
| 93 | #================================================================== | ||
| 94 | |||
| 95 | cd $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 | ||
| 101 | cp $workdir/*_new_recipe_list.txt $currentworkdir | ||
| 102 | |||
| 103 | if [ $? -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 | ||
| 109 | fi | ||
| 110 | |||
| 111 | # cleanup | ||
| 112 | rm -rf $workdir | ||
| 113 | |||
| 114 | # perform rollback branch | ||
| 115 | cd $sourcedir | ||
| 116 | currentbranch=`git branch | grep \* | cut -d ' ' -f2` | ||
| 117 | if [ "$currentbranch" != "$branch" ]; then | ||
| 118 | git checkout $branch | ||
| 119 | fi | ||
| 120 | |||
| 121 | cd $currentworkdir | ||
| 122 | |||
| 123 | #================================================================== | ||
