[oe] script to remove orphaned files

Frans Meulenbroeks fransmeulenbroeks at gmail.com
Mon Aug 23 20:19:02 UTC 2010


Dear all,

As I indicated before there are quite some orphaned patch files that
are not used in any recipe.

To resolve this I've written a small bash script to remove unused
patches/files from a directory.
Below is a copy of the script.
This is posted to get feedback on the script (with the review comments
added this can probably be put in the contrib dir).
If the script is considered to be good, we can run it on the
directories that we have to clean them up.
My preference is that recipe owners do this, but as a lot of dirs are
orphaned, I am planning to do this myself in due time (after the
review and after giving recipe owners a chance to do it themselves).

Attached is the script. It takes a recipe dir as argument (e.g. recipes/gcc)
It searches for all .patch and .diff files in that dir, and checks if
they are mentioned in a .bb file or .inc file
if the file is there, nothing is done.
If the fileis not there and there is a -d argument before the dir
name, the files are actually removed and the change committed.
Otherwise this filename is just listed.

Proposal is to start with a 1 week script review period.

Frans.

The script:

#!/bin/bash
# clean-recipe: a small shell script to clean unneeded patch/diff
files from a recipe folder
if [ $# -eq 0 ]
then
    echo "usage " $0 "[-d] recipe-dir-name"
    exit
fi
delete=0
if [ $1 = "-d" ]
then
    delete=1
    shift;
fi
dir=$1
if [ ! -d $dir ]
then
    echo $dir " is not a directory"
    exit
fi
cd $dir
removed=0
find -name "*.diff" -o -name "*.patch" | (while  read name
    do
        bname=`basename $name`
        grep -q $bname *.bb *.inc || \
        if [ $delete -eq 0 ]
        then
        echo $name " is unused"
        else
        git rm $name
        removed=1
        fi
    done
    if [ $removed -eq 1 ]
    then
        echo $dir ": removed unneeded files" | git commit -s -F -
    fi )




More information about the Openembedded-devel mailing list