Fixed typos.
[tangerine.git] / scripts / nightly / build
blob869dec7b280ab96691feb8f6a8f1f264b54d8d92
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 LANG=en_US.ISO8859-1
8 export SP=$(dirname $0)
9 export CFG_NAME=$1
10 source $SP/setup initial
11 source $SP/mail
13 #-- Update sources -----------------------------------------------------------
14 printi "Starting $LANG nightly build on $CFG_NAME..."
15 zsh $SP/update
16 if [ $? != 0 ]; then
17 printe "Updating sources FAILED! ABORTING SCRIPT!"
19 STOP_TIME=$(date -u +"%H:%M")
21 mail_start "FAILED COMPLETELY"
22 mail_write ""
23 mail_write "Updating sources FAILED! Please see attached log."
25 mail_send "-a$LOG_BASE/update.log"
27 mail_stop
29 exit 5
32 #-- Build packages -----------------------------------------------------------
33 failed=()
34 succeeded=()
35 for package in $CFG_PACKAGES; do
36 printe "package $package[(ws:.:)1]-$package[(ws:.:)3]"
37 zsh $SP/pkg/$package[(ws:.:)1]-$package[(ws:.:)3]
38 if [ $? != 0 ]; then
39 printe "Build of package '"$package[(ws:.:)1]-$package[(ws:.:)3]"' FAILED."
40 failed=( $failed $package[(ws:.:)1]-$package[(ws:.:)3] )
41 else
42 printi "Build of package '"$package[(ws:.:)1]-$package[(ws:.:)3]"' completed successfully."
43 succeeded=( $succeeded $package[(ws:.:)1]-$package[(ws:.:)3] )
45 done
47 #-- Cleanup ------------------------------------------------------------------
48 setl cleanup.log
49 source $SP/cleanup
50 resetl
52 #-- Compress log files -------------------------------------------------------
53 printi "Compressing log files..."
54 pushd
55 cd $LOG_BASE
56 for file in *.log; do
57 bzip2 $file
58 md5sum $file.bz2 >$file.bz2.md5
59 done
60 popd
62 STOP_TIME=$(date -u +"%H:%M")
64 #-- Fix permissions ----------------------------------------------------------
65 chmod -R o-wx,g+wr Archive/
66 find Archive/ -type d | xargs chmod a+s,g+rwx,o+x
68 #-- Upload (backup and distribution) -----------------------------------------
69 printi "Uploading archives..."
70 if [ "$CFG_UPLOAD_ENABLE" = "yes" ]; then
71 UPLOAD_START_TIME=$(date -u +"%H:%M")
72 if [ "$CFG_BACKUP_ENABLE" = "yes" ]; then
73 rsync -avz -e "ssh -i $CFG_BS_KEY" Archive/ $CFG_BS_USER@$CFG_BS:$CFG_BS_DIRECTORY
75 rsync -avz -e "ssh -i $CFG_DS_KEY" Archive/ $CFG_DS_USER@$CFG_DS:$CFG_DS_DIRECTORY
76 UPLOAD_STOP_TIME=$(date -u +"%H:%M")
79 #-- Generate report ----------------------------------------------------------
80 if [ "$CFG_MAIL_ENABLE" = "yes" ]; then
81 if [ -z $failed ]; then
82 RESULT="completed successfully"
83 elif [ -z $succeeded ]; then
84 RESULT="FAILED COMPLETELY"
85 else
86 RESULT="FAILED PARTLY"
89 mail_start $RESULT
91 ATTACH=()
92 if [ ! -z $failed ]; then
93 mail_write ""
94 mail_write "The following packages FAILED to build completely:"
95 for package in $failed; do
96 mail_write $package
97 bzcat $LOG_BASE/$package.log.bz2 | tail -100 - >/tmp/_aros_build_log_$package
98 ATTACH=( $ATTACH -a/tmp/_aros_build_log_$package )
99 done
100 mail_write ""
101 mail_write "Please see the attached shortened logs or the full logs at"
102 mail_write "http://www.aros.org/downloads/nightly/$VERSION/logs/ for details."
104 if [ ! -z $succeeded ]; then
105 mail_write ""
106 mail_write "The following packages were built successfully:"
107 for package in $succeeded; do
108 mail_write "$package"
109 done
110 mail_write ""
111 mail_write "The following archives were created:"
112 mail_write "$( find $ARCHIVE_BASE -type f -not -path '*/logs/*' -not -name '*.md5' | xargs -n 1 basename )"
113 mail_write ""
114 mail_write "The archives will be available for download from http://www.aros.org/download.php."
117 mail_send $ATTACH
119 if [ ! -z $failed ]; then
120 rm -rf /tmp/_aros_build_log_*
122 mail_stop
125 #-- Remove uploaded files ----------------------------------------------------
126 if [[ "$CFG_UPLOAD_ENABLE" = "yes" && "$CFG_UPLOAD_PRUNE" = "yes" ]]; then
127 # This is the old way.
128 rm -rf Archive/*
129 # The rm below is UNSAFE. If ARCHIVE_ROOT is undefined somehow, bye-bye
130 # to everything the build user can delete, from / on down.
131 #rm -rf $(ARCHIVE_ROOT)/*