Personal tools
     DOCUMENTATION

Conary:Recipe Doctor

From rPath Wiki

Jump to: navigation, search
 
#!/bin/bash
# checks and fixes common problems for recipies and outputs helpful commit
# hints
 
if [ -n "$1" ]; then
 
        file="$1"
else
 
        file="*.recipe"
fi
 
message=""
 
did_it_change() {
 
        [ "$(cat $file)" !=  "${recipe}" ] && message="${message}, $@"
 
}
 
# update licence
 
recipe="$(cat $file)"
 
sed -e 's/# All rights reserved/# This file is distributed under the terms of the MIT License.\n# A copy is available at http:\/\/www.rpath.com\/permanent\/mit-license.html/' -i $file
 
did_it_change added MIT licence
 
# we might want "rpath" to be lowercase in some situations, so replace only in the header
 
recipe="$(cat $file)"
 
sed -e '/Copyright/s/rpath/rPath/g' -i $file
 
sed -e '/Copyright/s/Specifix/rPath/' -i $file
 
did_it_change fixed copyright holder
 
# delete trailing whitespace
 
recipe="$(cat $file)"
 
sed -e 's/[ \t]*$//' -i $file
 
did_it_change deleted trailing whitespace
 
# replaces tabs with 8 spaces
 
recipe="$(cat $file)"
 
sed -e 's/\t/        /g' -i $file
 
did_it_change replaced tabs with spaces
 
# we only want to change the date if something else has changed
 
if [ -n "$(cvc diff)" ]; then
 
        recipe="$(cat $file)"
 
        year="$(date +%Y)"
 
        sed -e '/Copyright/s/ \(200[0-9]\) / \1-'${year}' /' -i $file
 
        sed -e '/Copyright/s/ \(200[0-9]\)[, -]*200[0-9] / \1-'${year}' /' -i $file
 
        sed -e "/Copyright/s/ $year-$year / $year /" -i $file
 
        did_it_change updated copyright date
 
fi
 
# tidy up the commit messages
 
echo ${message}  | sed -e 's/<sup>\,*//' | sed -e 's/</sup>[ \t]*//;s/[ \t]*$//'