rrs/tools/rrs_unique_recipes.py: Now only filter same pn recipes.

Don't remove native, cross, crossinitial and sdk recipes now only
keep major version of recipe based by pn.

Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
This commit is contained in:
Aníbal Limón 2015-07-07 17:34:27 -05:00 committed by Paul Eggleton
parent 00df9ede1e
commit ad5cfbed01

View File

@ -13,7 +13,7 @@ import optparse
import logging import logging
sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__)))) sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__))))
from common import common_setup, update_repo, get_pv_type, get_logger from common import common_setup, get_pv_type, get_logger, get_recipe_pv_without_srcpv
common_setup() common_setup()
from layerindex import utils from layerindex import utils
@ -21,6 +21,17 @@ utils.setup_django()
from django.db import transaction from django.db import transaction
import settings import settings
logger = get_logger("UniqueRecipes", settings)
fetchdir = settings.LAYER_FETCH_DIR
if not fetchdir:
logger.error("Please set LAYER_FETCH_DIR in settings.py")
sys.exit(1)
# setup bitbake
bitbakepath = os.path.join(fetchdir, 'bitbake')
sys.path.insert(0, os.path.join(bitbakepath, 'lib'))
from bb.utils import vercmp_string
from layerindex.models import Recipe, LayerBranch from layerindex.models import Recipe, LayerBranch
if __name__=="__main__": if __name__=="__main__":
@ -30,50 +41,31 @@ if __name__=="__main__":
help = "Enable debug output", help = "Enable debug output",
action="store_const", const=logging.DEBUG, dest="loglevel", default=logging.INFO) action="store_const", const=logging.DEBUG, dest="loglevel", default=logging.INFO)
logger = get_logger("UniqueRecipes", settings)
options, args = parser.parse_args(sys.argv) options, args = parser.parse_args(sys.argv)
logger.setLevel(options.loglevel) logger.setLevel(options.loglevel)
# setup poky
pokypath = update_repo(settings.LAYER_FETCH_DIR, 'poky', settings.POKY_REPO_URL,
True, logger)
sys.path.insert(0, os.path.join(pokypath, 'bitbake', 'lib'))
sys.path.insert(0, os.path.join(pokypath, 'meta', 'lib'))
from bb.utils import vercmp_string
from oe.recipeutils import get_recipe_pv_without_srcpv
logger.info('Starting unique recipes ...') logger.info('Starting unique recipes ...')
transaction.enter_transaction_management() transaction.enter_transaction_management()
transaction.managed(True) transaction.managed(True)
# remove native, nativesdk cross and initial recipes
logger.info('Starting remove of recipes with preffix or suffix ...')
words = ['nativesdk-', '-native', '-cross', '-initial', '-source']
for layerbranch in LayerBranch.objects.all():
for recipe in Recipe.objects.filter(layerbranch=layerbranch):
match = any(w in recipe.pn for w in words)
if match:
recipe.delete()
logger.debug("%s: Removed found prefix or suffix." % recipe.pn)
# only keep the major version of recipe # only keep the major version of recipe
logger.info('Starting remove of duplicate recipes only keep major version ...') logger.info('Starting remove of duplicate recipes only keep major version ...')
for layerbranch in LayerBranch.objects.all(): for layerbranch in LayerBranch.objects.all():
recipes = {} recipes = {}
for recipe in Recipe.objects.filter(layerbranch=layerbranch): for recipe in Recipe.objects.filter(layerbranch=layerbranch):
recipes[recipe.bpn] = None recipes[recipe.pn] = None
for bpn in recipes.keys(): for pn in recipes.keys():
for recipe in Recipe.objects.filter(layerbranch=layerbranch, for recipe in Recipe.objects.filter(layerbranch=layerbranch,
bpn=bpn): pn=pn):
if recipes[bpn] is None: if recipes[pn] is None:
recipes[bpn] = recipe recipes[pn] = recipe
else: else:
(ppv, _, _) = get_recipe_pv_without_srcpv(recipes[bpn].pv, (ppv, _, _) = get_recipe_pv_without_srcpv(recipes[pn].pv,
get_pv_type(recipes[bpn].pv)) get_pv_type(recipes[pn].pv))
(npv, _, _) = get_recipe_pv_without_srcpv(recipe.pv, (npv, _, _) = get_recipe_pv_without_srcpv(recipe.pv,
get_pv_type(recipe.pv)) get_pv_type(recipe.pv))
@ -83,12 +75,12 @@ if __name__=="__main__":
recipe.delete() recipe.delete()
elif ppv == 'git' or vercmp_string(ppv, npv) == -1: elif ppv == 'git' or vercmp_string(ppv, npv) == -1:
logger.debug("%s: Removed older recipe (%s), new recipe (%s)." \ logger.debug("%s: Removed older recipe (%s), new recipe (%s)." \
% (recipes[bpn].pn, recipes[bpn].pv, recipe.pv)) % (recipes[pn].pn, recipes[pn].pv, recipe.pv))
recipes[bpn].delete() recipes[pn].delete()
recipes[bpn] = recipe recipes[pn] = recipe
else: else:
logger.debug("%s: Removed older recipe (%s), current recipe (%s)." \ logger.debug("%s: Removed older recipe (%s), current recipe (%s)." \
% (recipes[bpn].pn, recipe.pv, recipes[bpn].pv)) % (recipes[pn].pn, recipe.pv, recipes[pn].pv))
recipe.delete() recipe.delete()