Disabled upload to backup server and building of contrib binary
[cake.git] / scripts / nightly / build
blob85f9373f45d9bd176924533909780073106d41ec
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 printi "Uploading archives..."
68 if [ "$CFG_UPLOAD_ENABLE" = "yes" ]; then
69 UPLOAD_START_TIME=$(date -u +"%H:%M")
70 if [ "$CFG_BACKUP_ENABLE" = "yes" ]; then
71 rsync -avz -e "ssh -i $CFG_BS_KEY" Archive/ $CFG_BS_USER@$CFG_BS:$CFG_BS_DIRECTORY
73 rsync -avz -e "ssh -i $CFG_DS_KEY" Archive/ $CFG_DS_USER@$CFG_DS:$CFG_DS_DIRECTORY
74 UPLOAD_STOP_TIME=$(date -u +"%H:%M")
77 #-- Generate report ----------------------------------------------------------
78 if [ "$CFG_MAIL_ENABLE" = "yes" ]; then
79 if [ -z $failed ]; then
80 RESULT="completed successfully"
81 elif [ -z $succeeded ]; then
82 RESULT="FAILED COMPLETELY"
83 else
84 RESULT="FAILED PARTLY"
87 mail_start $RESULT
89 ATTACH=()
90 if [ ! -z $failed ]; then
91 mail_write ""
92 mail_write "The following packages FAILED to build completely:"
93 for package in $failed; do
94 mail_write $package
95 bzcat $LOG_BASE/$package.log.bz2 | tail -100 - >/tmp/_aros_build_log_$package
96 ATTACH=( $ATTACH -a/tmp/_aros_build_log_$package )
97 done
98 mail_write ""
99 mail_write "Please see the attached shortened logs or the full logs at"
100 mail_write "http://www.aros.org/downloads/nightly/$VERSION/logs/ for details."
102 if [ ! -z $succeeded ]; then
103 mail_write ""
104 mail_write "The following packages were built successfully:"
105 for package in $succeeded; do
106 mail_write "$package"
107 done
108 mail_write ""
109 mail_write "The following archives were created:"
110 mail_write "$( find $ARCHIVE_BASE -type f -not -path '*/logs/*' -not -name '*.md5' | xargs -n 1 basename )"
111 mail_write ""
112 mail_write "The archives will be available for download from http://www.aros.org/download.php."
115 mail_send $ATTACH
117 if [ ! -z $failed ]; then
118 rm -rf /tmp/_aros_build_log_*
120 mail_stop
123 #-- Remove uploaded files ----------------------------------------------------
124 if [[ "$CFG_UPLOAD_ENABLE" = "yes" && "$CFG_UPLOAD_PRUNE" = "yes" ]]; then
125 # This is the old way.
126 rm -rf Archive/*
127 # The rm below is UNSAFE. If ARCHIVE_ROOT is undefined somehow, bye-bye
128 # to everything the build user can delete, from / on down.
129 #rm -rf $(ARCHIVE_ROOT)/*