#!/usr/bin/env python """\ Sanitize a bitbake file following the OpenEmbedded style guidelines, see http://openembedded.org/wiki/StyleGuide (C) 2006 Cyril Romain <cyril.romain@gmail.com> MIT license TODO: - add the others OpenEmbedded variables commonly used: - parse command arguments and print usage on misuse . prevent giving more than one .bb file in arguments - write result to a file - backup the original .bb file - make a diff and ask confirmation for patching ? - do not use startswith only: /!\ startswith('SOMETHING') is not taken into account due to the previous startswith('S'). - count rule breaks and displays them in the order frequence """ from __future__ import print_function import fileinput import string import re __author__ = "Cyril Romain <cyril.romain@gmail.com>" __version__ = "$Revision: 0.5 $" # The standard set of variables often found in .bb files in the preferred order OE_vars = [ 'SUMMARY', 'DESCRIPTION', 'AUTHOR', 'HOMEPAGE', 'SECTION', 'LICENSE', 'LIC_FILES_CHKSUM', 'DEPENDS', 'PROVIDES', 'SRCREV', 'SRCDATE', 'PE', 'PV', 'PR', 'INC_PR', 'SRC_URI', 'S', 'GPE_TARBALL_SUFFIX', 'inherit', 'EXTRA_', 'export', 'do_fetch', 'do_unpack', 'do_patch', 'WORKDIR', 'acpaths', 'do_configure', 'do_compile', 'do_install', 'PACKAGES', 'PACKAGE_ARCH', 'RDEPENDS', 'RRECOMMENDS', 'RSUGGESTS', 'RPROVIDES', 'RCONFLICTS', 'FILES', 'do_package', 'do_stage', 'addhandler', 'addtask', 'bindir', 'headers', 'include', 'includedir', 'python', 'qtopiadir', 'pkg_preins', 'pkg_prerm', 'pkg_postins', 'pkg_postrm', 'require', 'sbindir', 'basesysconfdir', 'sysconfdir', 'ALLOW_EMPTY', 'ALTERNATIVE_NAME', 'ALTERNATIVE_PATH', 'ALTERNATIVE_LINK', 'ALTERNATIVE_PRIORITY', 'ALTNAME', 'AMD_DRIVER_LABEL', 'AMD_DRIVER_VERSION', 'ANGSTROM_EXTRA_INSTALL', 'APPDESKTOP', 'APPIMAGE', 'APPNAME', 'APPTYPE', 'APPWEB_BUILD', 'APPWEB_HOST', 'AR', 'ARCH', 'ARM_INSTRUCTION_SET', 'ARM_MUTEX', 'ART_CONFIG', 'B', 'BJAM_OPTS', 'BJAM_TOOLS', 'BONOBO_HEADERS', 'BOOTSCRIPTS', 'BROKEN', 'BUILD_CPPFLAGS', 'CFLAGS', 'CCFLAGS', 'CMDLINE', 'COLLIE_MEMORY_SIZE', 'COMPATIBLE_HOST', 'COMPATIBLE_MACHINE', 'COMPILE_HERMES', 'CONFFILES', 'CONFLICTS', 'CORE_EXTRA_D', 'CORE_IMAGE_EXTRA_INSTALL', 'CORE_PACKAGES_D', 'CORE_PACKAGES_RD', 'CPPFLAGS', 'CVSDATE', 'CXXFLAGS', 'DEBIAN_NOAUTONAME', 'DEBUG_APPS', 'DEFAULT_PREFERENCE', 'DB4_CONFIG', 'EXCLUDE_FROM_SHLIBS', 'EXCLUDE_FROM_WORLD', 'FIXEDSRCDATE', 'GLIBC_ADDONS', 'GLIBC_EXTRA_OECONF', 'GNOME_VFS_HEADERS', 'HEADERS', 'INHIBIT_DEFAULT_DEPS', 'INITSCRIPT_PACKAGES', 'INITSCRIPT_NAME', 'INITSCRIPT_PARAMS', 'INSANE_SKIP', 'PACKAGE_INSTALL', 'KERNEL_IMAGETYPE', 'KERNEL_IMAGEDEST', 'KERNEL_OUTPUT', 'KERNEL_RELEASE', 'KERNEL_PRIORITY', 'KERNEL_SOURCE', 'KERNEL_SUFFIX', 'KERNEL_VERSION', 'K_MAJOR', 'K_MICRO', 'K_MINOR', 'HHV', 'KV', 'LDFLAGS', 'LD', 'LD_SO', 'LDLIBS', 'LEAD_SONAME', 'LIBTOOL', 'LIBBDB_EXTRA', 'LIBV', 'MACHINE_ESSENTIAL_EXTRA_RDEPENDS', 'MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS', 'MACHINE_EXTRA_RDEPENDS', 'MACHINE_EXTRA_RRECOMMENDS', 'MACHINE_FEATURES', 'MACHINE_TASKS', 'MACHINE', 'MACHTYPE', 'MAKE_TARGETS', 'MESSAGEUSER', 'MESSAGEHOME', 'MIRRORS', 'MUTEX', 'OE_QMAKE_INCDIR_QT', 'OE_QMAKE_CXXFLAGS', 'ORBIT_IDL_SRC', 'PARALLEL_MAKE', 'PAKCAGE_ARCH', 'PCMCIA_MANAGER', 'PKG_BASENAME', 'PKG', 'QEMU', 'QMAKE_PROFILES', 'QPEDIR', 'QPF_DESCRIPTION', 'QPF_PKGPATTERN', '2013-10-14gnome-desktop-testing: addRoss Burton