More changes for SVN (from patch sent by Adam Chodorowski).
[cake.git] / scripts / nightly / build
blob907905cf87c15ef68a5468e88fd571fbddaf3708
1 #!/bin/zsh
2 START_TIME=$(date -u +"%H:%M")
3 STOP_TIME="N/A"
4 UPLOAD_START_TIME="N/A"
5 UPLOAD_STOP_TIME="N/A"
7 export SP=$(dirname $0)
8 export CFG_NAME=$1
9 source $SP/setup initial
10 source $SP/mail
12 #-- Update sources -----------------------------------------------------------
13 printi "Starting nightly build on $CFG_NAME..."
14 zsh $SP/update
15 if [ $? != 0 ]; then
16 printe "Updating sources FAILED! ABORTING SCRIPT!"
18 STOP_TIME=$(date -u +"%H:%M")
20 mail_start "FAILED COMPLETELY"
21 mail_write ""
22 mail_write "Updating sources FAILED! Please see attached log."
24 mail_send "-a$LOG_BASE/update.log"
26 mail_stop
28 exit 5
31 #-- Build packages -----------------------------------------------------------
32 failed=()
33 succeeded=()
34 for package in $CFG_PACKAGES; do
35 zsh $SP/pkg/$package
36 if [ $? != 0 ]; then
37 printe "Build of package '"$package"' FAILED."
38 failed=( $failed $package )
39 else
40 printi "Build of package '"$package"' completed successfully."
41 succeeded=( $succeeded $package )
43 done
45 #-- Cleanup ------------------------------------------------------------------
46 setl cleanup.log
47 source $SP/cleanup
48 resetl
50 #-- Compress log files -------------------------------------------------------
51 printi "Compressing log files..."
52 pushd
53 cd $LOG_BASE
54 for file in *.log; do
55 bzip2 $file
56 md5sum $file.bz2 >$file.bz2.md5
57 done
58 popd
60 STOP_TIME=$(date -u +"%H:%M")
62 #-- Fix permissions ----------------------------------------------------------
63 chmod -R o-wx,g+wr Archive/
64 find Archive/ -type d | xargs chmod a+s,g+rwx,o+x
66 #-- Upload (backup and distribution) -----------------------------------------
67 if [ "$CFG_UPLOAD_ENABLE" = "yes" ]; then
68 UPLOAD_START_TIME=$(date -u +"%H:%M")
69 rsync -avz -e "ssh -i $CFG_BS_KEY" Archive/ $CFG_BS_USER@$CFG_BS:$CFG_BS_DIRECTORY
70 rsync -avz -e "ssh -i $CFG_DS_KEY" Archive/ $CFG_DS_USER@$CFG_DS:$CFG_DS_DIRECTORY
71 UPLOAD_STOP_TIME=$(date -u +"%H:%M")
74 #-- Generate report ----------------------------------------------------------
75 if [ "$CFG_MAIL_ENABLE" = "yes" ]; then
76 if [ -z $failed ]; then
77 RESULT="completed successfully"
78 elif [ -z $succeeded ]; then
79 RESULT="FAILED COMPLETELY"
80 else
81 RESULT="FAILED PARTLY"
84 mail_start $RESULT
86 ATTACH=()
87 if [ ! -z $failed ]; then
88 mail_write ""
89 mail_write "The following packages FAILED to build completely:"
90 for package in $failed; do
91 mail_write $package
92 bzcat $LOG_BASE/$package.log.bz2 | tail -100 - >/tmp/_aros_build_log_$package
93 ATTACH=( $ATTACH -a/tmp/_aros_build_log_$package )
94 done
95 mail_write ""
96 mail_write "Please see the attached shortened logs or the full logs at"
97 mail_write "http://www.aros.org/downloads/nightly/$VERSION/logs/ for details."
99 if [ ! -z $succeeded ]; then
100 mail_write ""
101 mail_write "The following packages were built successfully:"
102 for package in $succeeded; do
103 mail_write "$package"
104 done
105 mail_write ""
106 mail_write "The following archives were created:"
107 mail_write "$( find $ARCHIVE_BASE -type f -not -path '*/logs/*' -not -name '*.md5' | xargs -n 1 basename )"
108 mail_write ""
109 mail_write "The archives will be available for download from http://www.aros.org/download.php."
112 mail_send $ATTACH
114 if [ ! -z $failed ]; then
115 rm -rf /tmp/_aros_build_log_*
117 mail_stop
120 #-- Remove uploaded files ----------------------------------------------------
121 if [[ "$CFG_UPLOAD_ENABLE" = "yes" && "$CFG_UPLOAD_PRUNE" = "yes" ]]; then
122 # This is the old way.
123 rm -rf Archive/*
124 # The rm below is UNSAFE. If ARCHIVE_ROOT is undefined somehow, bye-bye
125 # to everything the build user can delete, from / on down.
126 #rm -rf $(ARCHIVE_ROOT)/*