1 |
Author: agaffney |
2 |
Date: 2008-09-03 03:46:48 +0000 (Wed, 03 Sep 2008) |
3 |
New Revision: 562 |
4 |
|
5 |
Added: |
6 |
trunk/tools/ |
7 |
trunk/tools/stage_build.sh |
8 |
Modified: |
9 |
trunk/ChangeLog |
10 |
Log: |
11 |
Create tools directory |
12 |
Initial commit of stage_build.sh script |
13 |
|
14 |
Modified: trunk/ChangeLog |
15 |
=================================================================== |
16 |
--- trunk/ChangeLog 2008-08-25 20:05:12 UTC (rev 561) |
17 |
+++ trunk/ChangeLog 2008-09-03 03:46:48 UTC (rev 562) |
18 |
@@ -2,6 +2,10 @@ |
19 |
# Copyright 1999-2008 Gentoo Foundation; Distributed under the GPL v2 |
20 |
# $Header: $ |
21 |
|
22 |
+ 03 Sep 2008; <agaffney@g.o> ChangeLog: |
23 |
+ Create tools directory |
24 |
+ Initial commit of stage_build.sh script |
25 |
+ |
26 |
25 Aug 2008; Tobias Scherbaum <dertobi123@g.o> |
27 |
releases/2008.0/kconfig/hppa/installcd-2.6.24-livecd64.config |
28 |
releases/2008.0/kconfig/hppa/installcd-2.6.24-livecd32.config |
29 |
|
30 |
Added: trunk/tools/stage_build.sh |
31 |
=================================================================== |
32 |
--- trunk/tools/stage_build.sh (rev 0) |
33 |
+++ trunk/tools/stage_build.sh 2008-09-03 03:46:48 UTC (rev 562) |
34 |
@@ -0,0 +1,162 @@ |
35 |
+#!/bin/bash |
36 |
+ |
37 |
+PID=$$ |
38 |
+ |
39 |
+profile= |
40 |
+version_stamp= |
41 |
+subarch= |
42 |
+stage1_seed= |
43 |
+snapshot= |
44 |
+config=/etc/catalyst/catalyst.conf |
45 |
+email_from="catalyst@localhost" |
46 |
+email_to="root@localhost" |
47 |
+verbose=0 |
48 |
+ |
49 |
+usage() { |
50 |
+ msg=$1 |
51 |
+ |
52 |
+ if [ -n "${msg}" ]; then |
53 |
+ echo -e "${msg}\n"; |
54 |
+ fi |
55 |
+ |
56 |
+ cat <<EOH |
57 |
+Usage: |
58 |
+ stage_build [-p|--profile <profile>] [-v|--version-stamp <stamp>] |
59 |
+ [-a|--arch <arch>] [-s|--stage1-seed <seed>] [--verbose] |
60 |
+ [-f|--email-from <from>] [-t|--email-to <to>] [-h|--help] |
61 |
+ |
62 |
+Options: |
63 |
+ -p|--profile Sets the portage profile (required) |
64 |
+ -v|--version-stamp Sets the version stamp (required) |
65 |
+ -a|--arch Sets the 'subarch' in the spec (required) |
66 |
+ -s|--stage1-seed Sets the seed for the stage1 (required) |
67 |
+ -S|--snapshot Sets the snapshot name (if not given defaults to today's |
68 |
+ date) |
69 |
+ -c|--config catalyst config to use, defaults to catalyst default |
70 |
+ --verbose Send output of commands to console as well as log |
71 |
+ -f|--email-from Sets the 'From' on emails sent from this script (defaults |
72 |
+ to catalyst@localhost) |
73 |
+ -t|--email-to Sets the 'To' on emails sent from this script (defaults |
74 |
+ to root@localhost) |
75 |
+ -h|--help Show this message and quit |
76 |
+ |
77 |
+Example: |
78 |
+ stage_build -p default-linux/x86/2006.1 -v 2007.0_pre -a i686 -s default/stage3-i686-2006.1 |
79 |
+EOH |
80 |
+} |
81 |
+ |
82 |
+send_email() { |
83 |
+ subject="[${subarch}] $1" |
84 |
+ body=$2 |
85 |
+ |
86 |
+ echo -e "From: ${email_from}\r\nTo: ${email_to}\r\nSubject: ${subject}\r\n\r\nArch: ${subarch}\r\nProfile: ${profile}\r\nVersion stamp: ${version_stamp}\r\nStage1 seed: ${stage1_seed}\r\nSnapshot: ${snapshot}\r\n\r\n${body}\r\n" | /usr/sbin/sendmail -f ${email_from} ${email_to} |
87 |
+} |
88 |
+ |
89 |
+run_cmd() { |
90 |
+ cmd=$1 |
91 |
+ logfile=$2 |
92 |
+ |
93 |
+ if [ $verbose = 1 ]; then |
94 |
+ ${cmd} 2>&1 | tee ${logfile} |
95 |
+ else |
96 |
+ ${cmd} &> ${logfile} |
97 |
+ fi |
98 |
+} |
99 |
+ |
100 |
+# Parse args |
101 |
+params=${#} |
102 |
+while [ ${#} -gt 0 ] |
103 |
+do |
104 |
+ a=${1} |
105 |
+ shift |
106 |
+ case "${a}" in |
107 |
+ -h|--help) |
108 |
+ usage |
109 |
+ exit 0 |
110 |
+ ;; |
111 |
+ -p|--profile) |
112 |
+ profile=$1 |
113 |
+ shift |
114 |
+ ;; |
115 |
+ -v|--version-stamp) |
116 |
+ version_stamp=$1 |
117 |
+ shift |
118 |
+ ;; |
119 |
+ -a|--arch) |
120 |
+ subarch=$1 |
121 |
+ shift |
122 |
+ ;; |
123 |
+ -f|--email-from) |
124 |
+ email_from=$1 |
125 |
+ shift |
126 |
+ ;; |
127 |
+ -t|--email-to) |
128 |
+ email_to=$1 |
129 |
+ shift |
130 |
+ ;; |
131 |
+ -s|--stage1-seed) |
132 |
+ stage1_seed=$1 |
133 |
+ shift |
134 |
+ ;; |
135 |
+ -S|--snapshot) |
136 |
+ snapshot=$1 |
137 |
+ shift |
138 |
+ ;; |
139 |
+ -c|--config) |
140 |
+ config=$1 |
141 |
+ shift |
142 |
+ ;; |
143 |
+ --verbose) |
144 |
+ verbose=1 |
145 |
+ ;; |
146 |
+ -*) |
147 |
+ echo "You have specified an invalid option: ${a}" |
148 |
+ usage |
149 |
+ exit 1 |
150 |
+ ;; |
151 |
+ esac |
152 |
+done |
153 |
+ |
154 |
+# Make sure all required values were specified |
155 |
+if [ -z "${profile}" ]; then |
156 |
+ usage "You must specify a profile." |
157 |
+ exit 1 |
158 |
+fi |
159 |
+if [ -z "${version_stamp}" ]; then |
160 |
+ usage "You must specify a version stamp." |
161 |
+ exit 1 |
162 |
+fi |
163 |
+if [ -z "${subarch}" ]; then |
164 |
+ usage "You must specify an arch." |
165 |
+ exit 1 |
166 |
+fi |
167 |
+if [ -z "${stage1_seed}" ]; then |
168 |
+ usage "You must specify a stage1 seed." |
169 |
+ exit 1 |
170 |
+fi |
171 |
+cd /tmp |
172 |
+ |
173 |
+if [ -z "${snapshot}" ]; then |
174 |
+ snapshot=`date +%Y%m%d` |
175 |
+ run_cmd "catalyst -c ${config} -s '${snapshot}'" "/tmp/catalyst_build_snapshot.${PID}.log" |
176 |
+ if [ $? != 0 ]; then |
177 |
+ send_email "Catalyst build error - snapshot" "$(</tmp/catalyst_build_snapshot.${PID}.log)" |
178 |
+ exit 1 |
179 |
+ fi |
180 |
+fi |
181 |
+ |
182 |
+for i in 1 2 3; do |
183 |
+ echo -e "subarch: ${subarch}\ntarget: stage${i}\nversion_stamp: ${version_stamp}\nrel_type: default\nprofile: ${profile}\nsnapshot: ${snapshot}" > stage${i}.spec |
184 |
+ if [ ${i} = 1 ]; then |
185 |
+ echo "source_subpath: ${stage1_seed}" >> stage${i}.spec |
186 |
+ else |
187 |
+ echo "source_subpath: default/stage$(expr ${i} - 1)-${subarch}-${version_stamp}" >> stage${i}.spec |
188 |
+ fi |
189 |
+ run_cmd "catalyst -a -p -c ${config} -f stage${i}.spec" "/tmp/catalyst_build_stage${i}.${PID}.log" |
190 |
+ if [ $? != 0 ]; then |
191 |
+ send_email "Catalyst build error - stage${i}" "$(tail -n 200 /tmp/catalyst_build_stage${i}.${PID}.log)\r\n\r\nFull build log at /tmp/catalyst_build_stage${i}.${PID}.log" |
192 |
+ exit 1 |
193 |
+ fi |
194 |
+done |
195 |
+ |
196 |
+send_email "Catalyst build success" "Everything finished successfully." |
197 |
|
198 |
|
199 |
Property changes on: trunk/tools/stage_build.sh |
200 |
___________________________________________________________________ |
201 |
Name: svn:executable |
202 |
+ * |