Worked on configure a bit
[hrr.git] / not / csig
blob429e693f63ecc5e1bc63cf71cfd790687c700294
1 #!/bin/sh
2 DEFAULT_KEY=0xA6E706B3
3 if expr $# "<" "1" > /dev/null; then
4 echo "Usage: csig <file.c>"
5 exit
6 fi
8 echo "********* " $1 "*********"
10 if ! test -f $1; then
11 echo $1 "no such file :("
12 exit
15 if gpg --verify $1; then
16 echo "*** already signed, and verifiable- doing nothing"
17 exit
20 rm -f /tmp/csig.sign
21 grep HEADER: $0 | grep -v grep | sed -e s/HEADER://g > /tmp/csig.plain
23 cat /tmp/csig.plain | wc -l > /tmp/header_size
25 head -n `expr \`cat /tmp/header_size\` + 4` $1 | tail -n `cat /tmp/header_size` > /tmp/diff_one
27 if `diff /tmp/csig.plain /tmp/diff_one > /dev/null`; then
28 echo "*** ok, resigning"
30 grep TAIL: $0 | grep -v grep | sed -e s/TAIL://g > /tmp/tail
31 cat /tmp/tail | wc -l > /tmp/tail_size
32 expr `cat /tmp/tail_size` + 8 > /tmp/tail_size
35 tail +`expr \`cat /tmp/header_size\` + 5` $1 > /tmp/strip0
38 cat /tmp/strip0 | wc -l > /tmp/strip_size
39 head -n `expr \` cat /tmp/strip_size\` - \`cat /tmp/tail_size\`` /tmp/strip0 > /tmp/strip
41 else
42 echo "*** ok, signing new file"
43 cp $1 /tmp/strip
46 cat /tmp/strip >> /tmp/csig.plain
47 grep TAIL: $0 | grep -v grep | sed -e s/TAIL://g >> /tmp/csig.plain
48 if ! gpg --default-key $DEFAULT_KEY --armor --output /tmp/csig.sign --clearsign /tmp/csig.plain; then
49 echo "*** couldn't sign for some reason (probably doesn't have the private key), aborting"
50 rm -rf /tmp/csig.plain \
51 /tmp/csig.sign \
52 /tmp/diff_one \
53 /tmp/header_size \
54 /tmp/tail_size \
55 /tmp/tail \
56 /tmp/strip_size \
57 /tmp/strip \
58 /tmp/strip0
60 exit
63 echo "/*" > /tmp/strip
64 cat /tmp/csig.sign >> /tmp/strip
65 echo "*/" >> /tmp/strip
67 cp /tmp/strip $1
68 rm -rf /tmp/csig.plain \
69 /tmp/csig.sign \
70 /tmp/diff_one \
71 /tmp/header_size \
72 /tmp/tail_size \
73 /tmp/tail \
74 /tmp/strip_size \
75 /tmp/strip \
76 /tmp/strip0
78 exit
80 HEADER: m m mm mmm .----------. .---------------------. mmm mm m m
81 HEADER: 8 8 88 888 | .--------` | .------------------` 888 88 8 8
82 HEADER: 8 8 88 888 | ```````|`V```````| |``||``|`````| 888 88 8 8
83 HEADER: 8 8 88 888 `------ | | [] | |``````|| | [] | 888 88 8 8
84 HEADER: 8 8 88 888 |`````` | | | ````|```` | | 888 88 8 8
85 HEADER: ` ` `` ``` ``````````````> |````````````| |`` ``` `` ` `
86 HEADER: ==============` `---`
87 HEADER: L A B O R A T O R I E S
88 HEADER:
89 HEADER:This file is part of Hacker Radio Rec.
90 HEADER:
91 HEADER:Hacker Radio Rec is free software: you can redistribute it and/or
92 HEADER:modify it under the terms of the GNU General Public License as
93 HEADER:published by the Free Software Foundation, either version 3 of
94 HEADER:the License or (at your option) any later version.
95 HEADER:
96 HEADER:Hacker Radio Rec is distributed in the hope that it will be
97 HEADER:useful, but WITHOUT ANY WARRANTY; without even the implied
98 HEADER:warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
99 HEADER:See the GNU General Public License for more details.
100 HEADER:
101 HEADER: Copyright (C) 2009, Thea DeSilva
102 HEADER: You can find a copy of GNU General Public License in COPYING
103 HEADER:*/
105 TAIL:/*
106 TAIL: Thank you for your attention