Gentoo Archives: gentoo-commits

From: "Andrew Gaffney (agaffney)" <agaffney@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] releng r581 - trunk/tools
Date: Sun, 28 Sep 2008 20:15:25
Message-Id: E1Kk2fq-0001Rq-Co@stork.gentoo.org
1 Author: agaffney
2 Date: 2008-09-28 20:15:21 +0000 (Sun, 28 Sep 2008)
3 New Revision: 581
4
5 Modified:
6 trunk/tools/ChangeLog
7 trunk/tools/catalyst-auto
8 Log:
9 Add --keep-tmpdir option
10 Move tailing of logfile to send_email() function
11
12 Modified: trunk/tools/ChangeLog
13 ===================================================================
14 --- trunk/tools/ChangeLog 2008-09-28 19:47:57 UTC (rev 580)
15 +++ trunk/tools/ChangeLog 2008-09-28 20:15:21 UTC (rev 581)
16 @@ -3,6 +3,9 @@
17 # $Id$
18
19 28 Sep 2008; Andrew Gaffney <agaffney@g.o> catalyst-auto:
20 + Add --keep-tmpdir option Move tailing of logfile to send_email() function
21 +
22 + 28 Sep 2008; Andrew Gaffney <agaffney@g.o> catalyst-auto:
23 Add another sed to add the datestamp to the ISO name
24
25 28 Sep 2008; Andrew Gaffney <agaffney@g.o>
26
27 Modified: trunk/tools/catalyst-auto
28 ===================================================================
29 --- trunk/tools/catalyst-auto 2008-09-28 19:47:57 UTC (rev 580)
30 +++ trunk/tools/catalyst-auto 2008-09-28 20:15:21 UTC (rev 581)
31 @@ -4,6 +4,7 @@
32
33 config_file=
34 verbose=0
35 +keep_tmpdir=0
36
37 usage() {
38 msg=$1
39 @@ -26,9 +27,16 @@
40
41 send_email() {
42 subject="${EMAIL_SUBJECT_PREPEND} $1"
43 - body=$2
44 + message=$2
45 + logfile=$3
46
47 - echo -e "From: ${EMAIL_FROM}\r\nTo: ${EMAIL_TO}\r\nSubject: ${subject}\r\n\r\n${body}\r\n" | /usr/sbin/sendmail -f ${EMAIL_FROM} ${EMAIL_TO}
48 + if [ -n "${logfile}" ]; then
49 + body=$(echo -e "${message}\n\n"; tail -n 200 "${logfile}"; echo -e "\n\n\nFull build log at ${logfile}")
50 + else
51 + body=${message}
52 + fi
53 +
54 + echo -e "From: ${EMAIL_FROM}\r\nTo: ${EMAIL_TO}\r\nSubject: ${subject}\r\n\r\n${body}" | /usr/sbin/sendmail -f ${EMAIL_FROM} ${EMAIL_TO}
55 }
56
57 run_cmd() {
58 @@ -75,6 +83,9 @@
59 --verbose)
60 verbose=1
61 ;;
62 + -k|--keep-tmpdir)
63 + keep_tmpdir=1
64 + ;;
65 -*)
66 echo "You have specified an invalid option: ${a}"
67 usage
68 @@ -115,7 +126,7 @@
69 done
70
71 if ! run_cmd "pre_build" "${TMPDIR}/log/pre_build.log"; then
72 - send_email "Catalyst build error - pre_build" "$(echo -e "Your pre_build function sucks\n\n"; tail -n 200 "${TMPDIR}/log/pre_build.log")"
73 + send_email "Catalyst build error - pre_build" "Your pre_build function sucks" "${TMPDIR}/log/pre_build.log"
74 exit 1
75 fi
76
77 @@ -153,7 +164,7 @@
78
79 # Create snapshot
80 if ! run_cmd "catalyst -c ${CATALYST_CONFIG} -s ${DATESTAMP}" "${TMPDIR}/log/snapshot.log"; then
81 - send_email "Catalyst build error - snapshot" "$(tail -n 200 ${TMPDIR}/log/snapshot.log)"
82 + send_email "Catalyst build error - snapshot" "" "${TMPDIR}/log/snapshot.log"
83 exit 1
84 fi
85
86 @@ -161,19 +172,21 @@
87 LOGFILE="${TMPDIR}/log/$(echo "${i}" | sed -e 's:/:_:' -e 's:\.spec$::').log"
88 run_cmd "catalyst -a -p -c ${CATALYST_CONFIG} -f ${i}" ${LOGFILE}
89 if [ $? != 0 ]; then
90 - send_email "Catalyst build error - ${i}" "$(tail -n 200 ${LOGFILE})\r\n\r\nFull build log at ${LOGFILE}"
91 + send_email "Catalyst build error - ${i}" "" "${LOGFILE}"
92 exit 1
93 fi
94 done
95
96 if ! run_cmd "post_build" "${TMPDIR}/log/post_build.log"; then
97 - send_email "Catalyst build error - post_build" "$(echo -e "Your post_build function sucks\n\n"; tail -n 200 "${TMPDIR}/log/post_build.log")"
98 + send_email "Catalyst build error - post_build" "Your post_build function sucks" "${TMPDIR}/log/post_build.log"
99 exit 1
100 fi
101
102 send_email "Catalyst build success" "Everything finished successfully."
103
104 -if ! rm -rf "${TMPDIR}"; then
105 - echo "Could not remove tmpdir ${TMPDIR}!"
106 - exit 1
107 +if [ "${keep_tmpdir}" = 0 ]; then
108 + if ! rm -rf "${TMPDIR}"; then
109 + echo "Could not remove tmpdir ${TMPDIR}!"
110 + exit 1
111 + fi
112 fi