summaryrefslogtreecommitdiff
path: root/contrib/clean-recipe
blob: 8336f267ca8edffe4978cbb06d3be450cbb59bb2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
# clean-recipe: a small shell script to clean unneeded patch/diff files from a recipe folder
shopt -s extglob 
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
if [ ${dir} = "obsolete" -o ${dir} = "nonworking" ]
then
    echo skipping ${dir}
    exit
fi
cd ${dir}
moved=0
grep -q "file://.*\\$" *.+(bb|inc) && echo "cannot handle recipes with metavariables in the name" && exit
find -name "*.diff" -o -name "*.patch" | (while  read name 
    do
        bname=`basename ${name}`
        dname=`dirname ${name}`
        grep -q ${bname} *.+(bb|inc) || \
        if [ ${delete} -eq 0 ]
        then
    	    echo ${name} " in recipe dir $dir is unused"
        else
	    mkdir -p ../obsolete/${dir}/${dname}
    	    git mv ${name} ../obsolete/${dir}/${dname}/
    	    moved=1
        fi
    done
    if [ ${moved} -eq 1 ]
    then
        for b in *.bb
	do
	    bitbake -cpatch -b $b || echo patch failed for $b
	done
        echo ${dir} ": moved unused files to obsolete dir" | git commit -s -F -
    fi )