]> Sergey Matveev's repositories - godlighty.git/blob - make-update
Use mtime instead of ctime
[godlighty.git] / make-update
1 #!/bin/sh -ex
2
3 w=$1
4 [ -n "$w" ]
5 [ -d rc/$w.cfg ]
6 redo $w
7 mkdir -p updates
8 [ -s updates/$w.old ] || {
9     echo This is first run
10     mv $w updates/$w.old
11     exit
12 }
13 bsdiff updates/$w.old $w updates/$w.bsdiff
14 mv updates/$w.old updates/$w.older
15 mv $w updates/$w.old
16 cat > updates/$w-update.sh <<EOF
17 #!/bin/sh -ex
18 w=\$1
19 [ -n "\$w" ]
20 their_hash=\`sha512 < \$w\`
21 our_hash=`sha512 < updates/$w.older`
22 [ "\$their_hash" = "\$our_hash" ]
23 b64decode -o \$w.bsdiff < \$0
24 bspatch \$w \$w.new \$w.bsdiff
25 their_hash=\`sha512 < \$w.new\`
26 our_hash=`sha512 < updates/$w.old`
27 [ "\$their_hash" = "\$our_hash" ]
28 chown \`stat -f %u:%g \$w\` \$w.new
29 chmod \`stat -f %Mp%Lp \$w\` \$w.new
30 rm \$w.bsdiff
31 mv -f \$w.new \$w
32 exit
33 EOF
34 b64encode updates/$w.bsdiff < updates/$w.bsdiff >> updates/$w-update.sh
35 chmod +x updates/$w-update.sh