revert between 56095 -> 55830 in arch
[AROS.git] / scripts / nightly / build
blob72f0ef24d4bb5325cd609ad4a038ebf49cff9a85
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 if [ "$2" != "" ]; then
8 export LANG=$2
9 else
10 export LANG=en_US.ISO8859-1
13 export SP=$(dirname $0)
14 export CFG_NAME=$1
15 source $SP/setup initial
16 source $SP/mail
18 #-- Update sources -----------------------------------------------------------
19 printi "Starting $LANG nightly build on $CFG_NAME..."
20 zsh $SP/update
21 if [ $? != 0 ]; then
22 printe "Updating sources FAILED! ABORTING SCRIPT!"
24 STOP_TIME=$(date -u +"%H:%M")
26 mail_start "FAILED COMPLETELY"
27 mail_write ""
28 mail_write "Updating sources FAILED! Please see attached log."
30 mail_send "-a$LOG_BASE/update.log"
32 mail_stop
34 exit 5
37 #-- Pre-build crosstools -----------------------------------------------------
38 if [ "$CFG_PREBUILD_TOOLCHAIN_PACKAGE" != "none" ]; then
39 # Place the package indicated as crosstools as first package
40 CFG_PACKAGES=($CFG_PREBUILD_TOOLCHAIN_PACKAGE ${CFG_PACKAGES[@]})
43 #-- Build packages -----------------------------------------------------------
44 failed=()
45 succeeded=()
46 for package in $CFG_PACKAGES; do
47 printe "package $package[(ws:.:)1]-$package[(ws:.:)3]"
48 zsh $SP/pkg/$package[(ws:.:)1]-$package[(ws:.:)3]
49 if [ $? != 0 ]; then
50 printe "Build of package '"$package[(ws:.:)1]-$package[(ws:.:)3]"' FAILED."
51 failed=( $failed $package[(ws:.:)1]-$package[(ws:.:)3] )
52 else
53 printi "Build of package '"$package[(ws:.:)1]-$package[(ws:.:)3]"' completed successfully."
54 succeeded=( $succeeded $package[(ws:.:)1]-$package[(ws:.:)3] )
56 done
58 #-- Cleanup ------------------------------------------------------------------
59 setl cleanup.log
60 source $SP/cleanup
61 resetl
63 #-- Compress log files -------------------------------------------------------
64 printi "Compressing log files..."
65 pushd
66 cd $LOG_BASE
67 for file in *.log; do
68 bzip2 $file
69 md5sum $file.bz2 >$file.bz2.md5
70 done
71 popd
73 STOP_TIME=$(date -u +"%H:%M")
75 #-- Fix permissions ----------------------------------------------------------
76 chmod -R o-wx,g+wr Archive/
77 find Archive/ -type d | xargs chmod a+s,g+rwx,o+x
79 #-- Upload (backup and distribution) -----------------------------------------
80 printi "Uploading archives..."
81 if [ "$CFG_UPLOAD_ENABLE" = "yes" ]; then
82 UPLOAD_START_TIME=$(date -u +"%H:%M")
83 if [ "$CFG_BACKUP_ENABLE" = "yes" ]; then
84 rsync -avz -e "ssh -i $CFG_BS_KEY" Archive/ $CFG_BS_USER@$CFG_BS:$CFG_BS_DIRECTORY
85 if [ $? != 0 ]; then
86 CFG_UPLOAD_PRUNE="no"
89 rsync -avz -e "ssh -i $CFG_DS_KEY" Archive/ $CFG_DS_USER@$CFG_DS:$CFG_DS_DIRECTORY
90 if [ $? != 0 ]; then
91 CFG_UPLOAD_PRUNE="no"
93 UPLOAD_STOP_TIME=$(date -u +"%H:%M")
96 #-- Generate report ----------------------------------------------------------
97 if [ "$CFG_MAIL_ENABLE" = "yes" ]; then
98 if [ -z "$failed" ]; then
99 RESULT="completed successfully"
100 elif [ -z "$succeeded" ]; then
101 RESULT="FAILED COMPLETELY"
102 else
103 RESULT="FAILED PARTLY"
106 mail_start $RESULT
108 ATTACH=()
109 if [ ! -z "$failed" ]; then
110 mail_write ""
111 mail_write "The following packages FAILED to build completely:"
112 for package in $failed; do
113 mail_write $package
114 bzcat $LOG_BASE/$package.log.bz2 | tail -100 >/tmp/_aros_build_log_$package
115 ATTACH=( $ATTACH -a/tmp/_aros_build_log_$package )
116 done
117 mail_write ""
118 mail_write "Please see the attached shortened logs or the full logs at"
119 NIGHTLY=$(basename $CFG_DS_DIRECTORY)
120 mail_write "http://www.aros.org/downloads/$NIGHTLY/$VERSION/logs/ for details."
122 if [ ! -z "$succeeded" ]; then
123 mail_write ""
124 mail_write "The following packages were built successfully:"
125 for package in $succeeded; do
126 mail_write "$package"
127 done
128 mail_write ""
129 mail_write "The following archives were created:"
130 mail_write "$( find $ARCHIVE_BASE -type f -not -path '*/logs/*' -not -name '*.md5' | xargs -n 1 basename )"
131 mail_write ""
132 mail_write "The archives will be available for download from http://www.aros.org/download.php."
135 mail_send $ATTACH
137 if [ ! -z "$failed" ]; then
138 rm -rf /tmp/_aros_build_log_*
140 mail_stop
143 #-- Remove uploaded files ----------------------------------------------------
144 if [[ "$CFG_UPLOAD_ENABLE" = "yes" && "$CFG_UPLOAD_PRUNE" = "yes" ]]; then
145 # This is the old way.
146 rm -rf Archive/*
147 # The rm below is UNSAFE. If ARCHIVE_ROOT is undefined somehow, bye-bye
148 # to everything the build user can delete, from / on down.
149 #rm -rf $(ARCHIVE_ROOT)/*