From f082c7c5cf72296566dcf92bba4fcb4c95f2186f Mon Sep 17 00:00:00 2001 From: Thomas Petazzoni Date: Wed, 31 Aug 2011 23:35:02 +0200 Subject: support: move scripts/ to a new support/ directory Signed-off-by: Thomas Petazzoni Signed-off-by: Peter Korsgaard --- Makefile | 6 +- scripts/build-ext3-img | 152 --------------------- scripts/copy.sh | 20 --- scripts/graph-depends | 169 ------------------------ scripts/mkmakefile | 47 ------- scripts/pkg-stats | 284 ---------------------------------------- scripts/setlocalversion | 72 ---------- support/scripts/build-ext3-img | 152 +++++++++++++++++++++ support/scripts/copy.sh | 20 +++ support/scripts/graph-depends | 169 ++++++++++++++++++++++++ support/scripts/mkmakefile | 47 +++++++ support/scripts/pkg-stats | 284 ++++++++++++++++++++++++++++++++++++++++ support/scripts/setlocalversion | 72 ++++++++++ 13 files changed, 747 insertions(+), 747 deletions(-) delete mode 100755 scripts/build-ext3-img delete mode 100755 scripts/copy.sh delete mode 100755 scripts/graph-depends delete mode 100755 scripts/mkmakefile delete mode 100755 scripts/pkg-stats delete mode 100755 scripts/setlocalversion create mode 100755 support/scripts/build-ext3-img create mode 100755 support/scripts/copy.sh create mode 100755 support/scripts/graph-depends create mode 100755 support/scripts/mkmakefile create mode 100755 support/scripts/pkg-stats create mode 100755 support/scripts/setlocalversion diff --git a/Makefile b/Makefile index 8779d3f1f..8fdc9eb0f 100644 --- a/Makefile +++ b/Makefile @@ -37,7 +37,7 @@ DATE:=$(shell date +%Y%m%d) # Compute the full local version string so packages can use it as-is # Need to export it, so it can be got from environment in children (eg. mconf) -export BR2_VERSION_FULL:=$(BR2_VERSION)$(shell $(TOPDIR)/scripts/setlocalversion) +export BR2_VERSION_FULL:=$(BR2_VERSION)$(shell $(TOPDIR)/support/scripts/setlocalversion) noconfig_targets:=menuconfig nconfig gconfig xconfig config oldconfig randconfig \ defconfig %_defconfig savedefconfig allyesconfig allnoconfig silentoldconfig release \ @@ -425,7 +425,7 @@ erase-fakeroots: target-finalize: ifeq ($(BR2_HAVE_DEVFILES),y) - ( scripts/copy.sh $(STAGING_DIR) $(TARGET_DIR) ) + ( support/scripts/copy.sh $(STAGING_DIR) $(TARGET_DIR) ) else rm -rf $(TARGET_DIR)/usr/include $(TARGET_DIR)/usr/lib/pkgconfig $(TARGET_DIR)/usr/share/aclocal find $(TARGET_DIR)/lib \( -name '*.a' -o -name '*.la' \) -print0 | xargs -0 rm -f @@ -607,7 +607,7 @@ endif # ifeq ($(BR2_HAVE_DOT_CONFIG),y) # output directory. outputmakefile: ifeq ($(NEED_WRAPPER),y) - $(Q)$(TOPDIR)/scripts/mkmakefile $(TOPDIR) $(O) + $(Q)$(TOPDIR)/support/scripts/mkmakefile $(TOPDIR) $(O) endif clean: diff --git a/scripts/build-ext3-img b/scripts/build-ext3-img deleted file mode 100755 index 1cab710c2..000000000 --- a/scripts/build-ext3-img +++ /dev/null @@ -1,152 +0,0 @@ -#!/bin/sh - -BLOCKSIZE=516096 -WORKING_DIR=`pwd` - -echo "This script will create a bootable ext3 image from buildroot." - -echo "Enter the path to the image (${WORKING_DIR})" -read IMG_PATH - -if [ "${IMAGE_PATH}" = "" ]; then - IMAGE_PATH=${WORKING_DIR} -fi - -echo "Enter the name of the image file (buildroot.img)" -read IMG_NAME - -if [ "${IMAGE_NAME}" = "" ]; then - IMAGE_NAME="buildroot.img" -fi - -IMAGE=${IMAGE_PATH}/${IMAGE_NAME} - -echo "Enter the path and filename for the root filesystem" -echo "tarball that you want to install into the image" -read ROOT_PATH - -if [ "${ROOT_PATH}" = "" ]; then - echo "Error: you must specify a path." - exit 1 -fi - -CYLINDERS=`du --summarize --block-size=${BLOCKSIZE} ${ROOT_PATH}` -BYTE_SIZE=`du --summarize --block-size=${BLOCKSIZE} --human-readable ${ROOT_PATH}` - -CYLINDERS=${CYLINDERS%${ROOT_PATH}} -BYTE_SIZE=${BYTE_SIZE%${ROOT_PATH}} - -CYLINDERS=`expr ${CYLINDERS} "*" 2` - -echo "Now I will create an ext3 image file" -echo "using ${CYLINDERS} cylinders, with ${BLOCKSIZE} bytes per block" -echo "in other words, ${BYTE_SIZE}bytes..." - - dd if=/dev/zero of=${IMAGE} bs=${BLOCKSIZE}c count=${CYLINDERS} - -# Create file partition and filesystem - - # STEP 1. create partition - /sbin/losetup /dev/loop3 ${IMAGE} - # probably should figure out how to use GNU parted to do this non-interactively - /sbin/fdisk -u -C${CYLINDERS} -S63 -H16 /dev/loop3 - /sbin/losetup -d /dev/loop3 - - # STEP 2. make file system (ext3) - /sbin/losetup -o 32256 /dev/loop3 ${IMAGE} - /sbin/mkfs.ext3 /dev/loop3 - /sbin/losetup -d /dev/loop3 - -# Install Software to the image - mkdir -p ${IMAGE_PATH}/temp - mount -o offset=32256,loop ${IMAGE} ${IMAGE_PATH}/temp - tar -xvf ${ROOT_PATH} --directory ${IMAGE_PATH}/temp - # make sure to unmount the image - umount ${IMAGE_PATH}/temp - rm -rf ${IMAGE_PATH}/temp - -# Create a VMware .vmx file -cat > ${IMAGE_PATH}/buildroot.vmx < test.dot -# dot -Tpdf test.dot -o test.pdf -# -# With no arguments, graph-depends will draw a complete graph of -# dependencies for the current configuration. With an argument, -# graph-depends will draw a graph of dependencies for the given -# package name. -# -# Limitations -# -# * Some packages have dependencies that depend on the Buildroot -# configuration. For example, many packages have a dependency on -# openssl if openssl has been enabled. This tool will graph the -# dependencies as they are with the current Buildroot -# configuration. -# -# * The X.org package definitions are only included when -# BR2_PACKAGE_XORG7 is enabled, so if this option is not enabled, -# it isn't possible to graph the dependencies of X.org stack -# components. -# -# Copyright (C) 2010 Thomas Petazzoni - -import sys -import subprocess - -# In FULL_MODE, we draw the full dependency graph for all selected -# packages -FULL_MODE = 1 - -# In PKG_MODE, we only draw the dependency graph for a given package -PKG_MODE = 2 - -mode = 0 - -if len(sys.argv) == 1: - mode = FULL_MODE -elif len(sys.argv) == 2: - mode = PKG_MODE - rootpkg = sys.argv[1] -else: - print "Usage: graph-depends [package-name]" - sys.exit(1) - -allpkgs = [] -unknownpkgs = [] - -# Execute the "make show-targets" command to get the list of the main -# Buildroot TARGETS and return it formatted as a Python list. This -# list is used as the starting point for full dependency graphs -def get_targets(): - sys.stderr.write("Getting targets\n") - cmd = ["make", "show-targets"] - p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - output = p.communicate()[0].strip() - if p.returncode != 0: - return None - if output == '': - return [] - return output.split(' ') - -# Execute the "make -show-depends" command to get the list of -# dependencies of a given package, and return the list of dependencies -# formatted as a Python list. -def get_depends(pkg): - sys.stderr.write("Getting dependencies for %s\n" % pkg) - cmd = ["make", "%s-show-depends" % pkg] - p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - output = p.communicate()[0].strip() - if p.returncode != 0: - return None - if output == '': - return [] - return output.split(' ') - -# Recursive function that builds the tree of dependencies for a given -# package. The dependencies are built in a list called 'dependencies', -# which contains tuples of the form (pkg1 -> -# pkg2_on_which_pkg1_depends) and the function finally returns this -# list. -def get_all_depends(pkg): - dependencies = [] - - # We already have the dependencies for this package - if pkg in allpkgs: - return - allpkgs.append(pkg) - depends = get_depends(pkg) - - # We couldn't get the dependencies of this package, because it - # doesn't use the generic or autotools infrastructure. Add it to - # unknownpkgs so that it is later rendered in red color to warn - # the user. - if depends == None: - unknownpkgs.append(pkg) - return - - # This package has no dependency. - if depends == []: - return - - # Add dependencies to the list of dependencies - for dep in depends: - dependencies.append((pkg, dep)) - - # Recurse into the dependencies - for dep in depends: - newdeps = get_all_depends(dep) - if newdeps != None: - dependencies += newdeps - - return dependencies - -# The Graphviz "dot" utility doesn't like dashes in node names. So for -# node names, we strip all dashes. -def pkg_node_name(pkg): - return pkg.replace("-","") - -# In full mode, start with the result of get_targets() to get the main -# targets and then use get_all_depends() for each individual target. -if mode == FULL_MODE: - targets = get_targets() - dependencies = [] - allpkgs.append('all') - for tg in targets: - # Skip uninteresting targets - if tg == 'target-generic-issue' or \ - tg == 'target-finalize' or \ - tg == 'erase-fakeroots' or \ - tg == 'target-generic-hostname': - continue - dependencies.append(('all', tg)) - deps = get_all_depends(tg) - if deps != None: - dependencies += deps - -# In pkg mode, start directly with get_all_depends() on the requested -# package -elif mode == PKG_MODE: - dependencies = get_all_depends(rootpkg) - -# Start printing the graph data -print "digraph G {" - -# First, the dependencies. Usage of set allows to remove duplicated -# dependencies in the graph -for dep in set(dependencies): - print "%s -> %s" % (pkg_node_name(dep[0]), pkg_node_name(dep[1])) - -# Then, the node attributes: color, style and label. -for pkg in allpkgs: - if pkg == 'all': - print "all [label = \"ALL\"]" - print "all [color=lightblue,style=filled]" - continue - - print "%s [label = \"%s\"]" % (pkg_node_name(pkg), pkg) - - if pkg in unknownpkgs: - print "%s [color=red,style=filled]" % pkg_node_name(pkg) - elif mode == PKG_MODE and pkg == rootpkg: - print "%s [color=lightblue,style=filled]" % pkg_node_name(rootpkg) - else: - print "%s [color=grey,style=filled]" % pkg_node_name(pkg) - -print "}" diff --git a/scripts/mkmakefile b/scripts/mkmakefile deleted file mode 100755 index cef2ec707..000000000 --- a/scripts/mkmakefile +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/sh -# Generates a small Makefile used in the root of the output -# directory, to allow make to be started from there. -# The Makefile also allow for more convenient build of external modules - -# Usage -# $1 - Kernel src directory -# $2 - Output directory - - -test ! -r $2/Makefile -o -O $2/Makefile || exit 0 -# Only overwrite automatically generated Makefiles -# (so we do not overwrite buildroot Makefile) -if test -e $2/Makefile && ! grep -q Automatically $2/Makefile -then - exit 0 -fi -if [ "${quiet}" != "silent_" ]; then - echo " GEN $2/Makefile" -fi - -cat << EOF > $2/Makefile -# Automatically generated by $0: don't edit - -lastword = \$(word \$(words \$(1)),\$(1)) -makedir := \$(dir \$(call lastword,\$(MAKEFILE_LIST))) - -MAKEARGS := -C $1 -MAKEARGS += O=\$(if \$(patsubst /%,,\$(makedir)),\$(CURDIR)/)\$(patsubst %/,%,\$(makedir)) - -MAKEFLAGS += --no-print-directory - -.PHONY: all \$(MAKECMDGOALS) - -all := \$(filter-out all Makefile,\$(MAKECMDGOALS)) - -all: - \$(MAKE) \$(MAKEARGS) \$(all) - -Makefile:; - -\$(all): all - @: - -%/: all - @: -EOF diff --git a/scripts/pkg-stats b/scripts/pkg-stats deleted file mode 100755 index 7bb292830..000000000 --- a/scripts/pkg-stats +++ /dev/null @@ -1,284 +0,0 @@ -#!/bin/bash - -# Copyright (C) 2009 by Thomas Petazzoni -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -# This script generates an HTML file that contains a report about all -# Buildroot packages, their usage of the different package -# infrastructure and possible cleanup actions -# -# Run the script from the Buildroot toplevel directory: -# -# ./scripts/pkg-stats > /tmp/pkg.html -# - -echo " - - - -Results
- - - - - - - - - - - - - - - - - - - - - -" - -convert_to_generic_target=0 -convert_to_generic_host=0 -convert_to_autotools=0 -total_patch_count=0 -cnt=1 -for i in $(find package/ -name '*.mk') ; do - - if test \ - $i = "package/java/java.mk" -o \ - $i = "package/games/games.mk" -o \ - $i = "package/multimedia/multimedia.mk" -o \ - $i = "package/customize/customize.mk" -o \ - $i = "package/gnuconfig/gnuconfig.mk" -o \ - $i = "package/matchbox/matchbox.mk" -o \ - $i = "package/x11r7/x11r7.mk" ; then - echo "skipping $i" 1>&2 - continue - fi - - cnt=$((cnt+1)) - - is_auto_host=0 - is_auto_target=0 - is_cmake_host=0 - is_cmake_target=0 - is_pkg_target=0 - is_pkg_host=0 - is_manual_target=0 - is_manual_host=0 - - if grep -E "\(call AUTOTARGETS,[^,]*,[^,]*,host\)" $i > /dev/null ; then - is_auto_host=1 - fi - - if grep -E "\(call AUTOTARGETS,[^,]*,[^,]*(,target|)\)" $i > /dev/null ; then - is_auto_target=1 - fi - - if grep -E "\(call GENTARGETS,[^,]*,[^,]*,host\)" $i > /dev/null ; then - is_pkg_host=1 - fi - - if grep -E "\(call GENTARGETS,[^,]*,[^,]*(,target|)\)" $i > /dev/null ; then - is_pkg_target=1 - fi - - if grep -E "\(call CMAKETARGETS,[^,]*,[^,]*,host\)" $i > /dev/null ; then - is_cmake_host=1 - fi - - if grep -E "\(call CMAKETARGETS,[^,]*,[^,]*(,target|)\)" $i > /dev/null ; then - is_cmake_target=1 - fi - - pkg=$(basename $i) - pkg=${pkg%.mk} - - if grep "^host-$pkg:" $i > /dev/null ; then - is_manual_host=1 - fi - - if test $is_pkg_target -eq 0 -a $is_auto_target -eq 0 -a $is_cmake_target -eq 0; then - is_manual_target=1 - fi - - tasks="" - - if [ $is_manual_target -eq 1 ] ; then - if grep "/configure" $i > /dev/null ; then - tasks=$tasks"
  • convert package to autotools ?
  • " - convert_to_target_autotools=$((convert_to_target_autotools+1)) - else - tasks=$tasks"
  • convert to generic target
  • " - convert_to_generic_target=$((convert_to_generic_target+1)) - fi - fi - - if [ $is_manual_host -eq 1 ]; then - if grep "/configure" $i > /dev/null ; then - tasks=$tasks"
  • convert package to autotools ?
  • " - convert_to_host_autotools=$((convert_to_host_autotools+1)) - else - tasks=$tasks"
  • convert to generic host
  • " - convert_to_generic_host=$((convert_to_generic_host+1)) - fi - fi - - if test -n "$tasks" ; then - echo "" - else - echo "" - fi - - echo "" - echo "" - - package_dir=$(dirname $i) - patch_count=$(find ${package_dir} -name '*.patch' | wc -l) - total_patch_count=$(($total_patch_count+$patch_count)) - - if test $patch_count -lt 1 ; then - patch_count_color="#00ff00" - elif test $patch_count -lt 5 ; then - patch_count_color="#ffc600" - else - patch_count_color="#ff0000" - fi - - echo "" - - echo "" - - echo "" - - echo "" - - echo "" - - echo "" - - echo "" - - echo "" - - echo "" - - echo "" - - echo "" - -done -echo "
    IdPackagePatch countAUTOTARGETSGENTARGETSCMAKETARGETSmanualActions
    hosttargethosttargethosttargethosttarget
    $cnt$i" - echo $patch_count - echo "" - if [ $is_auto_host -eq 1 ] ; then - echo "YES" - else - echo "NO" - fi - echo "" - if [ $is_auto_target -eq 1 ] ; then - echo "YES" - else - echo "NO" - fi - echo "" - if [ $is_pkg_host -eq 1 ] ; then - echo "YES" - else - echo "NO" - fi - echo "" - if [ $is_pkg_target -eq 1 ] ; then - echo "YES" - else - echo "NO" - fi - echo "" - if [ $is_cmake_host -eq 1 ] ; then - echo "YES" - else - echo "NO" - fi - echo "" - if [ $is_cmake_target -eq 1 ] ; then - echo "YES" - else - echo "NO" - fi - echo "" - if [ $is_manual_host -eq 1 ] ; then - echo "YES" - else - echo "NO" - fi - echo "" - if [ $is_manual_target -eq 1 ] ; then - echo "YES" - else - echo "NO" - fi - echo "" - echo "
      " - echo $tasks - echo "
    " - echo "
    " - -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "
    Packages to convert to generic target$convert_to_generic_target
    Packages to convert to generic host$convert_to_generic_host
    Packages to convert to target autotools$convert_to_target_autotools
    Packages to convert to host autotools$convert_to_host_autotools
    Number of patches in all packages$total_patch_count
    TOTAL$cnt
    " diff --git a/scripts/setlocalversion b/scripts/setlocalversion deleted file mode 100755 index 8d6fe909f..000000000 --- a/scripts/setlocalversion +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/sh -# Print additional version information for non-release trees. - -usage() { - echo "Usage: $0 [srctree]" >&2 - exit 1 -} - -cd "${1:-.}" || usage - -# Check for git and a git repo. -if head=`git rev-parse --verify --short HEAD 2>/dev/null`; then - # Do we have an untagged version? - if git name-rev --tags HEAD | grep -E '^HEAD[[:space:]]+(.*~[0-9]*|undefined)$' > /dev/null; then - if tag=`git describe 2>/dev/null`; then - echo $tag | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}' - else - printf '%s%s' -g $head - fi - fi - - # Is this git on svn? - if git config --get svn-remote.svn.url >/dev/null; then - printf -- '-svn%s' "`git svn find-rev $head`" - fi - - # Are there uncommitted changes? - git update-index --refresh --unmerged > /dev/null - if git diff-index --name-only HEAD | grep -v "^scripts/package" \ - | read dummy; then - printf '%s' -dirty - fi - - # All done with git - exit -fi - -# Check for mercurial and a mercurial repo. -if hgid=`hg id 2>/dev/null`; then - tag=`printf '%s' "$hgid" | cut -d' ' -f2` - - # Do we have an untagged version? - if [ -z "$tag" -o "$tag" = tip ]; then - id=`printf '%s' "$hgid" | sed 's/[+ ].*//'` - printf '%s%s' -hg "$id" - fi - - # Are there uncommitted changes? - # These are represented by + after the changeset id. - case "$hgid" in - *+|*+\ *) printf '%s' -dirty ;; - esac - - # All done with mercurial - exit -fi - -# Check for svn and a svn repo. -if rev=`LANG=C svn info 2>/dev/null | grep '^Last Changed Rev'`; then - rev=`echo $rev | awk '{print $NF}'` - changes=`LANG=C svn status 2>/dev/null | grep '^[AMD]' | wc -l` - - # Are there uncommitted changes? - if [ $changes != 0 ]; then - printf -- '-svn%s%s' "$rev" -dirty - else - printf -- '-svn%s' "$rev" - fi - - # All done with svn - exit -fi diff --git a/support/scripts/build-ext3-img b/support/scripts/build-ext3-img new file mode 100755 index 000000000..1cab710c2 --- /dev/null +++ b/support/scripts/build-ext3-img @@ -0,0 +1,152 @@ +#!/bin/sh + +BLOCKSIZE=516096 +WORKING_DIR=`pwd` + +echo "This script will create a bootable ext3 image from buildroot." + +echo "Enter the path to the image (${WORKING_DIR})" +read IMG_PATH + +if [ "${IMAGE_PATH}" = "" ]; then + IMAGE_PATH=${WORKING_DIR} +fi + +echo "Enter the name of the image file (buildroot.img)" +read IMG_NAME + +if [ "${IMAGE_NAME}" = "" ]; then + IMAGE_NAME="buildroot.img" +fi + +IMAGE=${IMAGE_PATH}/${IMAGE_NAME} + +echo "Enter the path and filename for the root filesystem" +echo "tarball that you want to install into the image" +read ROOT_PATH + +if [ "${ROOT_PATH}" = "" ]; then + echo "Error: you must specify a path." + exit 1 +fi + +CYLINDERS=`du --summarize --block-size=${BLOCKSIZE} ${ROOT_PATH}` +BYTE_SIZE=`du --summarize --block-size=${BLOCKSIZE} --human-readable ${ROOT_PATH}` + +CYLINDERS=${CYLINDERS%${ROOT_PATH}} +BYTE_SIZE=${BYTE_SIZE%${ROOT_PATH}} + +CYLINDERS=`expr ${CYLINDERS} "*" 2` + +echo "Now I will create an ext3 image file" +echo "using ${CYLINDERS} cylinders, with ${BLOCKSIZE} bytes per block" +echo "in other words, ${BYTE_SIZE}bytes..." + + dd if=/dev/zero of=${IMAGE} bs=${BLOCKSIZE}c count=${CYLINDERS} + +# Create file partition and filesystem + + # STEP 1. create partition + /sbin/losetup /dev/loop3 ${IMAGE} + # probably should figure out how to use GNU parted to do this non-interactively + /sbin/fdisk -u -C${CYLINDERS} -S63 -H16 /dev/loop3 + /sbin/losetup -d /dev/loop3 + + # STEP 2. make file system (ext3) + /sbin/losetup -o 32256 /dev/loop3 ${IMAGE} + /sbin/mkfs.ext3 /dev/loop3 + /sbin/losetup -d /dev/loop3 + +# Install Software to the image + mkdir -p ${IMAGE_PATH}/temp + mount -o offset=32256,loop ${IMAGE} ${IMAGE_PATH}/temp + tar -xvf ${ROOT_PATH} --directory ${IMAGE_PATH}/temp + # make sure to unmount the image + umount ${IMAGE_PATH}/temp + rm -rf ${IMAGE_PATH}/temp + +# Create a VMware .vmx file +cat > ${IMAGE_PATH}/buildroot.vmx < test.dot +# dot -Tpdf test.dot -o test.pdf +# +# With no arguments, graph-depends will draw a complete graph of +# dependencies for the current configuration. With an argument, +# graph-depends will draw a graph of dependencies for the given +# package name. +# +# Limitations +# +# * Some packages have dependencies that depend on the Buildroot +# configuration. For example, many packages have a dependency on +# openssl if openssl has been enabled. This tool will graph the +# dependencies as they are with the current Buildroot +# configuration. +# +# * The X.org package definitions are only included when +# BR2_PACKAGE_XORG7 is enabled, so if this option is not enabled, +# it isn't possible to graph the dependencies of X.org stack +# components. +# +# Copyright (C) 2010 Thomas Petazzoni + +import sys +import subprocess + +# In FULL_MODE, we draw the full dependency graph for all selected +# packages +FULL_MODE = 1 + +# In PKG_MODE, we only draw the dependency graph for a given package +PKG_MODE = 2 + +mode = 0 + +if len(sys.argv) == 1: + mode = FULL_MODE +elif len(sys.argv) == 2: + mode = PKG_MODE + rootpkg = sys.argv[1] +else: + print "Usage: graph-depends [package-name]" + sys.exit(1) + +allpkgs = [] +unknownpkgs = [] + +# Execute the "make show-targets" command to get the list of the main +# Buildroot TARGETS and return it formatted as a Python list. This +# list is used as the starting point for full dependency graphs +def get_targets(): + sys.stderr.write("Getting targets\n") + cmd = ["make", "show-targets"] + p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + output = p.communicate()[0].strip() + if p.returncode != 0: + return None + if output == '': + return [] + return output.split(' ') + +# Execute the "make -show-depends" command to get the list of +# dependencies of a given package, and return the list of dependencies +# formatted as a Python list. +def get_depends(pkg): + sys.stderr.write("Getting dependencies for %s\n" % pkg) + cmd = ["make", "%s-show-depends" % pkg] + p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + output = p.communicate()[0].strip() + if p.returncode != 0: + return None + if output == '': + return [] + return output.split(' ') + +# Recursive function that builds the tree of dependencies for a given +# package. The dependencies are built in a list called 'dependencies', +# which contains tuples of the form (pkg1 -> +# pkg2_on_which_pkg1_depends) and the function finally returns this +# list. +def get_all_depends(pkg): + dependencies = [] + + # We already have the dependencies for this package + if pkg in allpkgs: + return + allpkgs.append(pkg) + depends = get_depends(pkg) + + # We couldn't get the dependencies of this package, because it + # doesn't use the generic or autotools infrastructure. Add it to + # unknownpkgs so that it is later rendered in red color to warn + # the user. + if depends == None: + unknownpkgs.append(pkg) + return + + # This package has no dependency. + if depends == []: + return + + # Add dependencies to the list of dependencies + for dep in depends: + dependencies.append((pkg, dep)) + + # Recurse into the dependencies + for dep in depends: + newdeps = get_all_depends(dep) + if newdeps != None: + dependencies += newdeps + + return dependencies + +# The Graphviz "dot" utility doesn't like dashes in node names. So for +# node names, we strip all dashes. +def pkg_node_name(pkg): + return pkg.replace("-","") + +# In full mode, start with the result of get_targets() to get the main +# targets and then use get_all_depends() for each individual target. +if mode == FULL_MODE: + targets = get_targets() + dependencies = [] + allpkgs.append('all') + for tg in targets: + # Skip uninteresting targets + if tg == 'target-generic-issue' or \ + tg == 'target-finalize' or \ + tg == 'erase-fakeroots' or \ + tg == 'target-generic-hostname': + continue + dependencies.append(('all', tg)) + deps = get_all_depends(tg) + if deps != None: + dependencies += deps + +# In pkg mode, start directly with get_all_depends() on the requested +# package +elif mode == PKG_MODE: + dependencies = get_all_depends(rootpkg) + +# Start printing the graph data +print "digraph G {" + +# First, the dependencies. Usage of set allows to remove duplicated +# dependencies in the graph +for dep in set(dependencies): + print "%s -> %s" % (pkg_node_name(dep[0]), pkg_node_name(dep[1])) + +# Then, the node attributes: color, style and label. +for pkg in allpkgs: + if pkg == 'all': + print "all [label = \"ALL\"]" + print "all [color=lightblue,style=filled]" + continue + + print "%s [label = \"%s\"]" % (pkg_node_name(pkg), pkg) + + if pkg in unknownpkgs: + print "%s [color=red,style=filled]" % pkg_node_name(pkg) + elif mode == PKG_MODE and pkg == rootpkg: + print "%s [color=lightblue,style=filled]" % pkg_node_name(rootpkg) + else: + print "%s [color=grey,style=filled]" % pkg_node_name(pkg) + +print "}" diff --git a/support/scripts/mkmakefile b/support/scripts/mkmakefile new file mode 100755 index 000000000..cef2ec707 --- /dev/null +++ b/support/scripts/mkmakefile @@ -0,0 +1,47 @@ +#!/bin/sh +# Generates a small Makefile used in the root of the output +# directory, to allow make to be started from there. +# The Makefile also allow for more convenient build of external modules + +# Usage +# $1 - Kernel src directory +# $2 - Output directory + + +test ! -r $2/Makefile -o -O $2/Makefile || exit 0 +# Only overwrite automatically generated Makefiles +# (so we do not overwrite buildroot Makefile) +if test -e $2/Makefile && ! grep -q Automatically $2/Makefile +then + exit 0 +fi +if [ "${quiet}" != "silent_" ]; then + echo " GEN $2/Makefile" +fi + +cat << EOF > $2/Makefile +# Automatically generated by $0: don't edit + +lastword = \$(word \$(words \$(1)),\$(1)) +makedir := \$(dir \$(call lastword,\$(MAKEFILE_LIST))) + +MAKEARGS := -C $1 +MAKEARGS += O=\$(if \$(patsubst /%,,\$(makedir)),\$(CURDIR)/)\$(patsubst %/,%,\$(makedir)) + +MAKEFLAGS += --no-print-directory + +.PHONY: all \$(MAKECMDGOALS) + +all := \$(filter-out all Makefile,\$(MAKECMDGOALS)) + +all: + \$(MAKE) \$(MAKEARGS) \$(all) + +Makefile:; + +\$(all): all + @: + +%/: all + @: +EOF diff --git a/support/scripts/pkg-stats b/support/scripts/pkg-stats new file mode 100755 index 000000000..7bb292830 --- /dev/null +++ b/support/scripts/pkg-stats @@ -0,0 +1,284 @@ +#!/bin/bash + +# Copyright (C) 2009 by Thomas Petazzoni +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +# This script generates an HTML file that contains a report about all +# Buildroot packages, their usage of the different package +# infrastructure and possible cleanup actions +# +# Run the script from the Buildroot toplevel directory: +# +# ./scripts/pkg-stats > /tmp/pkg.html +# + +echo " + + + +Results
    + + + + + + + + + + + + + + + + + + + + + +" + +convert_to_generic_target=0 +convert_to_generic_host=0 +convert_to_autotools=0 +total_patch_count=0 +cnt=1 +for i in $(find package/ -name '*.mk') ; do + + if test \ + $i = "package/java/java.mk" -o \ + $i = "package/games/games.mk" -o \ + $i = "package/multimedia/multimedia.mk" -o \ + $i = "package/customize/customize.mk" -o \ + $i = "package/gnuconfig/gnuconfig.mk" -o \ + $i = "package/matchbox/matchbox.mk" -o \ + $i = "package/x11r7/x11r7.mk" ; then + echo "skipping $i" 1>&2 + continue + fi + + cnt=$((cnt+1)) + + is_auto_host=0 + is_auto_target=0 + is_cmake_host=0 + is_cmake_target=0 + is_pkg_target=0 + is_pkg_host=0 + is_manual_target=0 + is_manual_host=0 + + if grep -E "\(call AUTOTARGETS,[^,]*,[^,]*,host\)" $i > /dev/null ; then + is_auto_host=1 + fi + + if grep -E "\(call AUTOTARGETS,[^,]*,[^,]*(,target|)\)" $i > /dev/null ; then + is_auto_target=1 + fi + + if grep -E "\(call GENTARGETS,[^,]*,[^,]*,host\)" $i > /dev/null ; then + is_pkg_host=1 + fi + + if grep -E "\(call GENTARGETS,[^,]*,[^,]*(,target|)\)" $i > /dev/null ; then + is_pkg_target=1 + fi + + if grep -E "\(call CMAKETARGETS,[^,]*,[^,]*,host\)" $i > /dev/null ; then + is_cmake_host=1 + fi + + if grep -E "\(call CMAKETARGETS,[^,]*,[^,]*(,target|)\)" $i > /dev/null ; then + is_cmake_target=1 + fi + + pkg=$(basename $i) + pkg=${pkg%.mk} + + if grep "^host-$pkg:" $i > /dev/null ; then + is_manual_host=1 + fi + + if test $is_pkg_target -eq 0 -a $is_auto_target -eq 0 -a $is_cmake_target -eq 0; then + is_manual_target=1 + fi + + tasks="" + + if [ $is_manual_target -eq 1 ] ; then + if grep "/configure" $i > /dev/null ; then + tasks=$tasks"
  • convert package to autotools ?
  • " + convert_to_target_autotools=$((convert_to_target_autotools+1)) + else + tasks=$tasks"
  • convert to generic target
  • " + convert_to_generic_target=$((convert_to_generic_target+1)) + fi + fi + + if [ $is_manual_host -eq 1 ]; then + if grep "/configure" $i > /dev/null ; then + tasks=$tasks"
  • convert package to autotools ?
  • " + convert_to_host_autotools=$((convert_to_host_autotools+1)) + else + tasks=$tasks"
  • convert to generic host
  • " + convert_to_generic_host=$((convert_to_generic_host+1)) + fi + fi + + if test -n "$tasks" ; then + echo "" + else + echo "" + fi + + echo "" + echo "" + + package_dir=$(dirname $i) + patch_count=$(find ${package_dir} -name '*.patch' | wc -l) + total_patch_count=$(($total_patch_count+$patch_count)) + + if test $patch_count -lt 1 ; then + patch_count_color="#00ff00" + elif test $patch_count -lt 5 ; then + patch_count_color="#ffc600" + else + patch_count_color="#ff0000" + fi + + echo "" + + echo "" + + echo "" + + echo "" + + echo "" + + echo "" + + echo "" + + echo "" + + echo "" + + echo "" + + echo "" + +done +echo "
    IdPackagePatch countAUTOTARGETSGENTARGETSCMAKETARGETSmanualActions
    hosttargethosttargethosttargethosttarget
    $cnt$i" + echo $patch_count + echo "" + if [ $is_auto_host -eq 1 ] ; then + echo "YES" + else + echo "NO" + fi + echo "" + if [ $is_auto_target -eq 1 ] ; then + echo "YES" + else + echo "NO" + fi + echo "" + if [ $is_pkg_host -eq 1 ] ; then + echo "YES" + else + echo "NO" + fi + echo "" + if [ $is_pkg_target -eq 1 ] ; then + echo "YES" + else + echo "NO" + fi + echo "" + if [ $is_cmake_host -eq 1 ] ; then + echo "YES" + else + echo "NO" + fi + echo "" + if [ $is_cmake_target -eq 1 ] ; then + echo "YES" + else + echo "NO" + fi + echo "" + if [ $is_manual_host -eq 1 ] ; then + echo "YES" + else + echo "NO" + fi + echo "" + if [ $is_manual_target -eq 1 ] ; then + echo "YES" + else + echo "NO" + fi + echo "" + echo "
      " + echo $tasks + echo "
    " + echo "
    " + +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "
    Packages to convert to generic target$convert_to_generic_target
    Packages to convert to generic host$convert_to_generic_host
    Packages to convert to target autotools$convert_to_target_autotools
    Packages to convert to host autotools$convert_to_host_autotools
    Number of patches in all packages$total_patch_count
    TOTAL$cnt
    " diff --git a/support/scripts/setlocalversion b/support/scripts/setlocalversion new file mode 100755 index 000000000..8d6fe909f --- /dev/null +++ b/support/scripts/setlocalversion @@ -0,0 +1,72 @@ +#!/bin/sh +# Print additional version information for non-release trees. + +usage() { + echo "Usage: $0 [srctree]" >&2 + exit 1 +} + +cd "${1:-.}" || usage + +# Check for git and a git repo. +if head=`git rev-parse --verify --short HEAD 2>/dev/null`; then + # Do we have an untagged version? + if git name-rev --tags HEAD | grep -E '^HEAD[[:space:]]+(.*~[0-9]*|undefined)$' > /dev/null; then + if tag=`git describe 2>/dev/null`; then + echo $tag | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}' + else + printf '%s%s' -g $head + fi + fi + + # Is this git on svn? + if git config --get svn-remote.svn.url >/dev/null; then + printf -- '-svn%s' "`git svn find-rev $head`" + fi + + # Are there uncommitted changes? + git update-index --refresh --unmerged > /dev/null + if git diff-index --name-only HEAD | grep -v "^scripts/package" \ + | read dummy; then + printf '%s' -dirty + fi + + # All done with git + exit +fi + +# Check for mercurial and a mercurial repo. +if hgid=`hg id 2>/dev/null`; then + tag=`printf '%s' "$hgid" | cut -d' ' -f2` + + # Do we have an untagged version? + if [ -z "$tag" -o "$tag" = tip ]; then + id=`printf '%s' "$hgid" | sed 's/[+ ].*//'` + printf '%s%s' -hg "$id" + fi + + # Are there uncommitted changes? + # These are represented by + after the changeset id. + case "$hgid" in + *+|*+\ *) printf '%s' -dirty ;; + esac + + # All done with mercurial + exit +fi + +# Check for svn and a svn repo. +if rev=`LANG=C svn info 2>/dev/null | grep '^Last Changed Rev'`; then + rev=`echo $rev | awk '{print $NF}'` + changes=`LANG=C svn status 2>/dev/null | grep '^[AMD]' | wc -l` + + # Are there uncommitted changes? + if [ $changes != 0 ]; then + printf -- '-svn%s%s' "$rev" -dirty + else + printf -- '-svn%s' "$rev" + fi + + # All done with svn + exit +fi -- cgit v1.2.3-55-g7522