-
Notifications
You must be signed in to change notification settings - Fork 0
/
Upgrade Chef 11 to chef 12.txt
26 lines (18 loc) · 1.47 KB
/
Upgrade Chef 11 to chef 12.txt
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
#To do on cookbooks:
# Remove VCS directory (.svn, .git) still present (bad chefignore file on uploader repo_path)
find ./ -name '.svn' -prune -exec rm -r {} \;
find ./ -name '.git' -prune -exec rm -r {} \;
## Fixes to metadata.rb files:
# convert windows end of line to unix end of line
file */metadata.rb | grep CRLF | cut -d ':' -f 1 | xargs fromdos
# Convert from ISO-8859 to UTF8
for myf in `file */metadata.rb | grep ISO-88 | cut -d ':' -f 1`; do iconv -f ISO-8859-1 -t UTF8 $myf -o ${myf}.new; mv ${myf}.new $myf; done
for myf in `file */*.md | grep ISO-88 | cut -d ':' -f 1`; do iconv -f ISO-8859-1 -t UTF8 $myf -o ${myf}.new; mv ${myf}.new $myf; done
# Add name entry to cookbooks without it
grep -Le '^name ' */metadata.rb | awk -F[/] -v OFS="" '{ n=$1;gsub(/-([0-9][.]?)+/,"",n); cmdline="sed -i \"1s/^/name \\\""n"\\\"\\n/\" "$FILENAME; system(cmdline) }'
# Validate cookbook name match folder name
grep -e '^name ' */metadata.rb | awk -F"[:/]" '{ dname=$1; gsub(/-([0-9]+[.]*)+$/,"",dname); split($3,mname,/[ \t]+/); gsub(/["\047]/,"",mname[2]); if (dname != mname[2]) { cmdline="sed -i \"s/name *[\\\"\047]" mname[2] "[\\\"\047]/name \\\"" dname"\\\"/\" " $1"/"$2; system(cmdline) } }'
# Fix depends lines badly formated
grep -lP '^depends.*,\s*[\047"][~><=]{1,2}\d' */metadata.rb | xargs sed -i 's/^\(depends.*,\s*["\x27][~><=]\{1,2\}\)\([0-9]\)/\1 \2/gm'
# Ensure all dependencies are resolvable
grep -P '^depends.*,\s*[\047"]=\d' */metadata.rb