exclude useles links
[ktest-util.git] / vzt-show-list
blob05cbf2a37646f4bbc63a9ed895802bbbc3da8c8e
1 #! /bin/bash
3 function show_usage
5 echo "Create plain patch list from list-XXX and XXX.spec"
6 echo "Usage: -l|--list_file <LIST_FILE> "
7 echo " -s|--spec_file <SPEC_FILE>"
8 echo " -p|--prefix <PREFIX_PATH> patch prefix"
9 exit
12 while [ $# -gt 0 ]; do
13 case "$1" in
14 -h|--help)
15 show_usage
16 exit
18 -l|--list_file)
19 list_file=$2
20 shift
22 -s|--spec_file)
23 spec_file=$2
24 shift
26 -p|--prefix)
27 prefix_dir=$2
28 shift
31 show_usage
32 break
34 esac
35 shift
36 done
38 list_dir=`dirname $list_file`
39 patch_dir=$list_dir
40 spec_dir=`dirname $spec_file`
41 out_patch_dir=$prefix_dir/patches
42 out_vzmod_dir=$prefix_dir/vzmod
44 if [ ! -f "$list_file" ]; then
45 echo "No such list $list_file"
46 exit
49 if [ ! -f "$spec_file" ]; then
50 echo "No such spec $spec_file"
51 exit
54 function cat_list_file
56 ldir=$1
57 lfile=$2
58 odir=$3
59 cat "$lfile" | grep -v '^[:space:]*$' | \
60 while read patch rest; do
61 echo $patch | grep '^[:space:]*#' && {
62 echo $patch $rest
63 continue
65 if [ "$patch" = "include" ]; then
66 echo "#-> $rest"
67 cat_list_file "$ldir" "$ldir/$rest" "$odir"
68 echo "#<- $rest"
69 continue
71 if [ "$patch" = "cd" ]; then
72 echo "#cd $rest"
73 continue
75 if [ "$patch" = "merge" ]; then
76 echo "#merge $rest"
77 continue
79 echo $odir/$patch
80 done
83 function cat_spec_file {
85 sdir=$1
86 sfile=$2
87 odir=$3
88 odir_scr="$(echo $odir | sed -r 's/\//\\\//g')"
89 cat $sfile | \
90 awk 'BEGIN{lock=1}{
91 if ($0 ~ /# Start VZ patches/) lock=0;\
92 if (lock==0) print $0;\
93 if ($0 ~ /# End VZ patches/) lock=1 ;\
94 }' | \
95 sed -r "s/^Patch[0-9]+:[[:space:]]+/$odir_scr\//" | \
96 grep -v "^$odir/patch-%{ovzver}-core"| \
97 grep -v "^$odir/patch-%{ovzver}-mod"
99 echo "update-uname-core-begin"
100 cat_list_file $list_dir $list_file $out_patch_dir
101 echo "update-uname-mod-begin"
102 cat_spec_file $spec_dir $spec_file $out_vzmod_dir
103 echo "update-uname-mod-end"