~dad-maintainers/dad/trunk

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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
# DaD is written by Adrien Cunin <adri2000@ubuntu.com> and Albin Tonnerre <lutin@ubuntu.com>
# License: GNU GPL
# update: update lists, process updates/new merges, remove packages which no longer need a merge, regenerate the web page; should be put in a cron

DIST=$1
SECTION=$2
tomerge="tomerge-$SECTION"
tmpfile="./update-$SECTION"
MERGES=$3

echo "Let's update $SECTION"

[ -f $tmpfile ] && echo "update-$SECTION is already running. Aborting..." && exit || touch $tmpfile

# Make sure $MERGES exists
mkdir $MERGES
# Copy dad.css to $MERGES
cp dad.css $MERGES/
# Copy grab-merge.sh to $MERGES
cp grab-merge.sh $MERGES/
# Copy report-messages to $MERGES
cp process/report-messages $MERGES/
# Make sure $MERGES/$tomerge exists
touch $MERGES/$tomerge
# Make sure $MERGES/comments exists and make it writable
touch $MERGES/comments && chmod a+w $MERGES/comments

echo "Updating the code"
bzr update

echo "apt-get updating"
sudo apt-get update || { echo "apt-get update error. Aborting..."; rm $tmpfile; exit 1; }
pre-process/dist-apt-get.bash sid update || { echo "apt-get update error. Aborting..."; rm $tmpfile; exit 1; }
pre-process/dist-apt-get.bash $DIST-$SECTION update || { echo "apt-get update error. Aborting..."; rm $tmpfile; exit 1; }

echo "Listing merges to do"
cd pre-process && ./listmerges $DIST $SECTION $MERGES && cd ..

echo "Merging..."
cd process && ./merge $SECTION $MERGES && cd .. && sort $MERGES/$tomerge -o $MERGES/$tomerge

echo "Cleaning up"
cd post-process && ./cleanup $SECTION $MERGES && cd ..

echo "Generating $MERGES/$SECTION.php"
php index.template $SECTION $MERGES > $MERGES/$SECTION.php
sed -i "s,@count@,$(wc -l $MERGES/$tomerge | cut -d' ' -f1)," $MERGES/$SECTION.php

rm $tmpfile