aboutsummaryrefslogtreecommitdiff
path: root/cbuild2.sh
blob: fd18f6863c47da0546779db7e093654987a15e19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
#!/bin/sh

# load commonly used functions
. "$(dirname "$0")/lib/common.sh" || exit 1

# load the configure file produced by configure
. "${PWD}/host.conf" || exit 1

# this is used to launch builds of dependant components
command_line_arguments=$*

clean_build()
{
    echo "Cleaning build..."
}

#
# These functions actually do something
#

# This gets a list from a remote server of the available tarballs. We use HTTP
# instead of SSH so it's more accessible to those behind nasty firewalls.
# base - already checkout out source trees
# snapshots - tarballs of various source snapshots
# prebuilt - prebuilt executables
get_list()
{
    echo "Get version list for $1..."

    url="http://cbuild.validation.linaro.org/snapshots"
    # http://cbuild.validation.linaro.org/snapshots
    case $1 in
	base|b*)
	    #base="`ssh cbuild@toolchain64.lab ls -C1 /home/cbuild/var/snapshots/base/*.xz | sed -e 's:^.*/::'`"
	    base="`lynx -dump ${url}/base | grep "${url}/base" | sed -e 's:.*/::' -e 's:%2b:+:' | grep -v '^$'`"
	    echo "${base}"
	    ;;
	snapshots|s*)
	    #snapshots="`ssh cbuild@toolchain64.lab ls -C1 /home/cbuild/var/snapshots/*.{xz,bz2} | sed -e 's:^.*/::'`"
	    snapshots="`lynx -dump ${url} | grep "${url}" | sed -e 's:.*/::' -e 's:%2b:+:' | egrep -v "md5sums|base|prebuilt" | grep -v '^$'`"
	    echo "${snapshots}"
	    ;;
	infrastructure|i*)
	    infrastructure="`lynx -dump ${url}/infrastructure | grep "${url}/infrastructure" | sed -e 's:.*/::' -e 's:%2b:+:' | egrep -v "md5sums|base|prebuilt" | grep -v '^$'`"
	    echo "${infrastructure}"
	    ;;
	prebuilt|p*)
	    #prebuilt="`ssh cbuild@toolchain64.lab ls -C1 /home/cbuild/var/snapshots/prebuilt/*.{xz,bz2} | sed -e 's:^.*/::'`"
	    #prebuilt="`lynx -dump ${url}/prebuilt | `"
	    echo "${prebuilt}"
	    ;;
    esac
}

# Get some info on the build system
# $1 - If specified, it's the hostname of the remote system
get_build_machine_info()
{
    if test x"$1" = x; then
	cpus="`getconf _NPROCESSORS_ONLN`"
	libc="`getconf GNU_LIBC_VERSION`"
	kernel="`uname -r`"
	build_arch="`uname -p`"
	hostname="`uname -n`"
	distribution="`lsb_release -sc`"
    else
	# FIXME: this assumes the user has their ssh keys setup to the point
	# where the don't need a password but is secure.
	echo "Getting config info from $1"
	cpus="`ssh $1 getconf _NPROCESSORS_ONLN`"
	libc="`ssh $1 getconf GNU_LIBC_VERSION`"
	kernel="`ssh $1 uname -r`"
	build_arch="`ssh $1 uname -p`"
	hostname="`ssh $1 uname -n`"
	distribution="`ssh $1 lsb_release -sc`"	
    fi
}

dispatch()
{
    echo "Dispatching LAVA build on $1..."
}

# Takes no arguments. Dumps all the important config data
dump()
{
    # These variables are always determined dynamically at run time
    echo "Build triplet is:  ${build}"
    echo "Target triplet is: ${target}"
    echo "GCC is:            ${gcc}"
    echo "GCC version:       ${gcc_version}"
    echo "Sysroot is:        ${sysroot}"

    # These variables have default values which we don't care about
    echo "Binutils is:       ${binutils}"
    echo "Libc is:           ${libc}"
    echo "Config file is:    ${configfile}"
    echo "Snapshot URL is:   ${snapshots}"
    echo "DB User name is:   ${dbuser}"
    echo "DB Password is:    ${dbpasswd}"

    echo "Build # cpus is:   ${cpus}"
    echo "Kernel:            ${kernel}"
    echo "Build Arch:        ${build_arch}"
    echo "Hostname:          ${hostname}"
    echo "Distribution:      ${distribution}"
}

usage()
{
    echo "Usage: $0 "
    echo "  --build (architecture for the build machine, default native)"
    echo "  --target (architecture for the target machine, default native)"
    echo "  --snapshots XXX (URL of remote host or local directory)"
    echo "  --libc {newlib,eglibc,glibc} (C library to use)"
#        echo "  --list {gcc,binutils,libc} (list possible values for component versions)"
    echo "  --list {base,prebuilt,snapshots} (list possible values for component versions)"
    echo "  --set {gcc,binutils,libc,latest}=XXX (change config file setting)"
    echo "  --binutils (binutils version to use, default $PATH)"
    echo "  --gcc (gcc version to use, default $PATH)"
    echo "  --config XXX (alternate config file)"
    echo "  --clean (clean a previous build, default is to start where it left off)"
    echo "  --dispatch (run on LAVA build farm, probably remote)"
    echo "  --sysroot XXX (specify path to alternate sysroot)"
    echo "  --db-user XXX (specify MySQL user"
    echo "  --db-passwd XXX (specify MySQL password)"
    echo "  --dump (dump the values in the config file)"
    echo "  --dostep XXX (fetch,extract,configure,build,checkout,push)"
    echo "  --release XXX (make a release tarball)"
    echo "  --clobber (force files to be downloaded even when they exist)"
    echo "  --force (force make errors to be ignored, answer yes for any prompts)"
    echo "  --parallel (do parallel builds, one per cpu core)"
    exit 1
}

# get_build_machine_info

# Process the multiple command line arguments
while test $# -gt 0; do
    case "$1" in
	--build)
            set_build $2
	    shift
            ;;
	--fetch)
            fetch $2
	    shift
            ;;
	--target)
            set_target $2
	    shift
            ;;
	--sysroot)
            set_sysroot $2
	    shift
            ;;
	--binutils)
            set_binutils $2
	    shift
            ;;
	--clean)
            clean_build $2
	    shift
            ;;
	--config)
            set_config $2
	    shift
            ;;
	--gcc)
            set_gcc $2
	    shift
            ;;
	--parallel|p*)
            make_flags="-j ${cpus}"
            ;;
	--libc)
            set_libc $2
	    shift
            ;;
	--list)
            get_list $2
	    shift
            ;;
	--dispatch)
            dispatch $2
	    shift
            ;;
	--snapshots)
            set_snapshots $2
	    shift
            ;;
	--release)
            release $2
	    shift
            ;;
	--db-user)
            set_dbuser $2
	    shift
            ;;
	--db-passwd)
            set_dbpasswd $2
	    shift
            ;;
	--dump)
            dump $2
	    shift
            ;;
	--dostep)
            case $2 in
		fetch|f*)
		    fetch $3   
		    ;;
		extract|e*)
		    extract $3
		    ;;
		build|b*)
		    build $3
		    ;;
		commit|com*)
		    commit $3 $4
		    shift
		    ;;
		configure|con*)
		    configure_build $3
		    ;;
		checkout|ch*)
		    checkout $3
		    ;;
		depend|d*)
		    infrastructure $3
		    ;;
		install|i*)
		    make_install $3
		    ;;
		make|m*)
		    make_all $3
		    ;;
		push|p*)
		    push $3
		    ;;
		release|r*)
		    release $3
		    ;;
		tag|ta**)
		    tag $3 $4
		    shift
		    ;;
		test|t*)
		    make_check $3
		    ;;
		*)
		    ;;
            esac
	    shift
            ;;
	--clobber)
            clobber=yes
            ;;
	--help)
            usage
            ;;
	*)
	    #usage
            ;;
    esac
    if test $# -gt 0; then
	shift
    fi
done