#!/usr/bin/env python1#2# checkcats.py - verify that master categories in all ports are correct and3# report any problems.4#5# ----------------------------------------------------------------------------6# "THE BEER-WARE LICENSE" (Revision 42, (c) Poul-Henning Kamp):7# Maxim Sobolev <[email protected]> wrote this file. As long as you retain8# this notice you can do whatever you want with this stuff. If we meet some9# day, and you think this stuff is worth it, you can buy me a beer in return.10#11# Maxim Sobolev12# ----------------------------------------------------------------------------13#14# MAINTAINER= [email protected] <- any unapproved commits to this file are15# highly discouraged!!!16#1718import glob, os.path19import patchtool20from patchtool import True, False2122PORTSDIR = '/usr/ports'2324if __name__ == '__main__':25portdirs = glob.glob(os.path.join(PORTSDIR, '*/*'))26for dirname in portdirs:27if not os.path.isfile(os.path.join(dirname, 'Makefile')):28continue29categories = patchtool.querymakevar('CATEGORIES', dirname)30try:31mastercat = categories.split()[0]32except IndexError:33print '%s: categories list is empty' % dirname34continue35mastercat_real = os.path.basename(os.path.dirname(dirname))36if mastercat != mastercat_real:37print '%s: specified master category `%s\' doesn\'t match real one `%s\'' \38% (dirname, mastercat, mastercat_real)39404142