/
foswiki-trunk-update.sh
executable file
·97 lines (78 loc) · 3.2 KB
/
foswiki-trunk-update.sh
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/sh
ROOT=/var/www/trunk.foswiki.org
PROD=/var/www/foswiki.org
cd $ROOT
ls -la $ROOT/core/working/work_areas/FoswikiOrgPlugin/distro
ls -la $ROOT/core/lib/Foswiki.pm
# Whenever anyone commits to distro, the webhook should update the distro workarea file.
# This script updates Foswiki.pm. So if distro is older than Foswiki.pm, we can
# skip the trunk rebuild. Could also check FoswikiOrgPlugin and FoswikirefsPlugin.
if [ $ROOT/core/working/work_areas/FoswikiOrgPlugin/distro -ot $ROOT/core/lib/Foswiki.pm ];
then
echo Skipping trunk update. core/lib/Foswiki.pm is newer than core/working/work_areas/FoswikiOrgPlugin/distro
exit
fi
git checkout core/lib/Foswiki.pm
git status -uno
git stash save --quiet
git reset HEAD --hard
# Clean everything except
# - Configuration: bin/LocalLib and lib/LocalSite
# - working. Has cgi sessions, plugin storage.
# - Main and Sandbox webs - they get updated
# other webs are either symlinks that will be re-established, or can be discarded, like Trash
# - Logs in data: debug, error, event and configure
git clean -fdx \
--exclude="logs" \
--exclude="core/bin/LocalLib*" --exclude="core/lib/LocalSite*" \
--exclude="core/working" \
--exclude="core/data/Main" --exclude="core/pub/Main" \
--exclude="core/data/Sandbox" --exclude="core/pub/Sandbox" \
--exclude="core/data/Trash" --exclude="core/pub/Trash" \
--exclude="core/data/configur*" --exclude="core/data/debug*" --exclude="core/data/error*" --exclude="core/data/events*" --exclude="core/data/log*" --exclude="core/data/warn*"
# Regenrate the languages list - pick up encoding, spelling changes, and new languages.
rm $ROOT/core/working/languages.cache
echo Pulling updates from github
git pull --force
cd $ROOT/FoswikiOrgPlugin
git pull --force
cd $ROOT/FoswikirefsPlugin
git pull --force
# Remove broken links.
echo Removing broken links
cd $ROOT
find -L . -type l -exec rm \{\} \;
# Restore the modified files, install the default modules, and optional extensions
cd $ROOT
git stash pop --quiet
cd $ROOT/core
perl -T pseudo-install.pl -link default
perl -T pseudo-install.pl -link JsonRpcContrib
perl -T pseudo-install.pl -link ConfigurePlugin
perl -T pseudo-install.pl -link FoswikiOrgPlugin
perl -T pseudo-install.pl -link FoswikirefsPlugin
# Copy any files from the foswiki.org site that are lost during the git clean.
cp -a $PROD/data/System/WebLeftBarFoswikiWebsList.txt* $ROOT/core/data/System/.
cp -a $PROD/data/System/FoswikiSiteChanges.txt* $ROOT/core/data/System/.
cp -a $PROD/data/System/WebTopBar* $ROOT/core/data/System/.
# Modify Foswiki.pm to show the last revision
REV=`git log --abbrev=12 --format=format:"Commit: %h - %ci" -1`
BR=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/Branch: \1/'`
cd $ROOT/core/lib
# Default string $RELEASE = 'Foswiki-1.2.0 GIT';
sed -e "s/\(RELEASE = .*\)';/\1: $BR $REV';/" Foswiki.pm > Foswiki.pm.new
mv Foswiki.pm.new Foswiki.pm
# Make sure we have links to all non-existing webs to trunk
cd $ROOT/core/lib
for dir in data pub; do
cd ../$dir
for f in $PROD/$dir/*; do
if [ -d $f -a ! -e `basename $f` ]; then
echo Linking $f into `pwd`
ln -s $f
fi
done
done
# Refresh the page cache
cd $ROOT/core/bin
./view refresh=all > /dev/null