Debian Codegraph @

SPEC/spec-gen

raw
1 #!/bin/sh
2 #
3 # $Id: spec-gen,v 1.41 2009/11/21 00:20:16 pawelz Exp $
4 #
5 # Automated fortunes-pl.spec and tarball generator
6 # originally by Michal Kochanowicz <[email protected]>
7 #
8
9 VERSION="`date +%Y%m%d`"
10 RELEASE="1"
11
12 README="../README"
13
14 COOKIES="`find .. -maxdepth 1 -type f | egrep -v \(README\|cvsignore\|ChangeLog\|skrypt.awk\)|cut -b 4-`"
15
16 SPEC_NAME="fortunes-pl.spec"
17
18 [ -e "$SPEC_NAME" ] && rm "$SPEC_NAME"
19
20 wget -O- 'http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/fortunes-pl/fortunes-pl.spec?rev=HEAD;content-type=text%2Fplain' | awk '/^%define date/ {p=1} {if (p==1) print}' > spec-template-footer
21
22 cat "spec-template-header" \
23 | sed \
24 -e "s/@@VERSION@@/$VERSION/g" \
25 -e "s/@@RELEASE@@/$RELEASE/g" \
26 > "$SPEC_NAME"
27
28 for f in $COOKIES; do
29 NAME="$f"
30 SUMMARY_PL="Zestaw fortunek: $f"
31 SUMMARY_EN="Fortune mod: $f"
32
33 grep "+ $f --" $README > /dev/null
34 if [ $? -eq 0 ]
35 then
36 DONE=0
37 LINES=10
38 for c in `seq 0 10`; do
39 if [ $DONE -eq 0 ]
40 then
41 grep "+ $f --" $README -A$c > spec-gen-desc
42 LAST="`cat spec-gen-desc | tail -n 1`"
43 echo "$LAST" | grep -Ev "[:alnum:]" > /dev/null
44 if [ $? -eq 0 ]
45 then
46 DONE=1
47 LINES=$c
48 fi
49 fi
50 done
51 grep "+ $f --" $README -A$LINES > spec-gen-desc
52 DISABLE_EN_DESC=1
53 DESCRIPTION_PL="`cut -b3- spec-gen-desc`"
54 DESCRIPTION_EN="`cut -b3- spec-gen-desc`"
55 else
56 DISABLE_EN_DESC=0
57 INITIAL_AUTHOR="`cd ..;cvs log $NAME|egrep ^revision\ 1.1\$ -A1|tail -n1|sed -e 's/.*author: \(.*\); state.*/\1/'`"
58 DESCRIPTION_PL="Zestaw fortunek: $f\n\nPrzykro nam, że nie ma bardziej dokładnego opisu,\nale $INITIAL_AUTHOR nie potrafi dodać opisu do pliku README.\nProśby prosimy kierować na adres [email protected]"
59 DESCRIPTION_EN="Fortune mod: $f\n\nWe are sorry that there is no more useful description,\nbut $INITIAL_AUTHOR is too lame to add description to the README\nfile. Send your requests to [email protected]"
60 fi
61
62 cat "spec-template-subpackage-header" \
63 | sed \
64 -e "s/@@VERSION@@/$VERSION/g" \
65 -e "s/@@RELEASE@@/$RELEASE/g" \
66 -e "s/@@NAME@@/$NAME/g" \
67 -e "s/@@SUMMARY_PL@@/$SUMMARY_PL/g" \
68 -e "s/@@SUMMARY_EN@@/$SUMMARY_EN/g" \
69 >> "$SPEC_NAME"
70
71 echo >> "$SPEC_NAME"
72 if [ $DISABLE_EN_DESC -eq 0 ]
73 then
74 echo "%description -n fortune-mod-pl-$NAME" >> "$SPEC_NAME"
75 echo "$DESCRIPTION_EN" >> "$SPEC_NAME"
76 echo >> "$SPEC_NAME"
77 fi
78 echo "%description -n fortune-mod-pl-$NAME -l pl.UTF-8" >> "$SPEC_NAME"
79 echo "$DESCRIPTION_PL" >> "$SPEC_NAME"
80 echo >> "$SPEC_NAME"
81
82 cat "spec-template-files" \
83 | sed \
84 -e "s/@@NAME@@/$NAME/g" \
85 >> "spec-generated-files"
86 done
87
88 #cat "spec-template-build" \
89 # | sed \
90 # -e "s/@@COOKIES@@/$COOKIES/g" \
91 # >> $SPEC_NAME
92 cat "spec-template-build" >> $SPEC_NAME
93 cat "spec-generated-files" >> $SPEC_NAME
94 cat "spec-template-footer" >> $SPEC_NAME
95
96 rm -f "spec-generated-files"
97 rm -f "spec-gen-desc"
98
99 # TARBALL ##############################################################
100 mkdir fortunes-pl-$VERSION
101 cd ..
102 cp $COOKIES SPEC/fortunes-pl-$VERSION
103 cd SPEC
104 tar cf - fortunes-pl-$VERSION | bzip2 > "fortunes-pl-$VERSION.tar.bz2"
105 rm -rf fortunes-pl-$VERSION
106 MD5=$(md5sum fortunes-pl-$VERSION.tar.bz2 | cut -f1 -d\ )
107 sed -i s,@@SOURCEMD5@@,$MD5, $SPEC_NAME
108 # TARBALL ##############################################################