aboutsummaryrefslogtreecommitdiffstats
path: root/yocto-autobuilder-setup
blob: b84d42b715dd195107f40b5272361554b09d37c1 (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
# Yocto Build Server Setup Script
# Elizabeth Flanagan <pidge@toganlabs.com>
#
# Copyright (C) 2011-2017 Intel Corp.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA


#########################################
# buildbot update wants to parse the config
# So, we export bogus values just to get the 
# config to parse
#########################################

export WORKERBASEDIR=`pwd`/yocto-worker
export PUBLISH_BUILDS=False
export PUBLISH_SOURCE_MIRROR=False
export PUBLISH_SSTATE=False
export SSTATE_PUBLISH_DIR="/tmp/yocto-autobuilder/sstate_mirror"
export SOURCE_PUBLISH_DIR="/tmp/yocto-autobuilder/source"
export DL_DIR="/tmp/yocto-autobuilder/downloads"
export SSTATE_DIR="/tmp/yocto-autobuilder/sstate"
export BUILD_PUBLISH_DIR="/tmp/yocto-autobuilder/builds"
export RELEASE_PUBLISH_DIR="/tmp/yocto-autobuilder/releases"
export BUILD_HISTORY_COLLECT=False
export SOURCE_DL_DIR="/tmp/yocto-autobuilder/downloads"
export SOURCE_SSTATE_DIR="/tmp/yocto-autobuilder/sstate"
export LSB_SSTATE_DIR="/tmp/yocto-autobuilder/lsb-sstate"
export CLEAN_SOURCE_DIR=False
export BUILD_HISTORY_DIR="/tmp/yocto-autobuilder/buildhistory"
export BUILD_HISTORY_REPO="file:////tmp/yocto-autobuilder/buildhistory-repo"
export EMGD_DRIVER_DIR="/tmp/yocto-autobuilder/emgd-driver"
export ADTREPO_POPULATE=False
export ADTREPO_GENERATE_INSTALLER=False
export ADTREPO_DEV_POPULATE=False
export ADTREPO_GENERATE_DEV_INSTALLER=True
export ADTREPO_URL="http://adtrepo.yoctoproject.org/"
export ADTREPO_PATH="/srv/www/vhosts/adtrepo.yoctoproject.org/"
export ADTREPO_DEV_URL="http://adtrepo-dev.yoctoproject.org/"
export ADTREPO_DEV_PATH="/srv/www/vhosts/adtrepo-dev/"
export PATH=`pwd`/bin:$PATH
export YOCTO_AB_CONFIG=`pwd`/buildset-config/yoctoAB.conf
export RESOLVED_TRIGGERED_HEAD=True
export OPTIMIZED_GIT_CLONE=False
export OGIT_TRASH_DIR=/tmp/yocto-autobuilder/git/trash
export OGIT_TRASH_CRON_TIME="0 0 * * *"
export OGIT_TRASH_NICE_LEVEL="19"
if ! HOST_ADDR=$(hostname -I 2> /dev/null); then
    HOST_ADDR=$(hostname -i)
fi

##########################
#
# Check to see if we've got a username/password set
#
##########################
if [ ! -f  "${PWD}/yocto-controller/buildbot.tac" ]; then
    echo ""
    echo "Creating yocto-controller/buildbot.tac from an example buildbot.tac"
    echo ""
    /bin/cp yocto-controller/buildbot.tac.example yocto-controller/buildbot.tac
fi

if [ ! -f  "${PWD}/yocto-worker/buildbot.tac" ]; then
    echo ""
    echo "Creating yocto-worker/buildbot.tac from an example buildbot.tac"
    echo ""
    /bin/cp yocto-worker/buildbot.tac.example yocto-worker/buildbot.tac
fi


if [ ! -f  "${PWD}/yocto-controller/controller.cfg" ]; then
    echo ""
    echo "Creating yocto-controller/controller.cfg from an example controller.cfg"
    echo ""
    /bin/cp yocto-controller/controller.cfg.example yocto-controller/controller.cfg
fi

if [ "${PWD}/yocto-controller/controller.cfg" ]; then
    config_check=`cat ${PWD}/yocto-controller/controller.cfg|grep "<PASS>"`
fi

USERSITE="`python2 -m site --user-site`"
ABPTHPATH="${USERSITE}/autobuilder.pth"
if [  ! -f  "${ABPTHPATH}" ]; then
    echo "Adding autobuilder modules to ${ABPTHPATH}"
    mkdir -p ${USERSITE}
    cat ${PWD}/autobuilder.pth.in | sed "s@<YPABDIR>@${PWD}@g" > ${ABPTHPATH}
fi

#########################################
#
# I dislike people touching my .bashrc
# so, let's warn here that they should add
# this to their env
#
#########################################
echo "#########################################################################"
echo " Setting envvars. "
echo " In the future though please add the following to your shell environment: "
echo " PATH=${PWD}/bin:"'$PATH'
echo " YOCTO_AB_CONFIG=${PWD}/buildset-config/yoctoAB.conf"
echo ""
echo " If you don't, you should source this script everytime you want start the "
echo " autobuilder."

##########################
#
# Check to see if we've got an autobuilder.conf
#
##########################
if [  ! -f  "./config/autobuilder.conf" ]; then
    echo ""
    echo "Creating config/autobuilder.conf from an example autobuilder.conf"
    echo ""
    /bin/cp config/autobuilder.conf.example config/autobuilder.conf
fi

if [  ! -d  "./buildset-config" ]; then
    echo ""
    echo "Creating buildset-config from buildset-config.controller"
    echo ""
    /bin/cp -R buildset-config.controller buildset-config
fi


if [ -n "${config_check:+x}" ]; then
    echo ""
    echo " You've not setup the autobuilder before. Generating a server/client password"
    echo " combo for you."
    password=`cat /dev/urandom|tr -dc "a-zA-Z0-9"|fold -w 9|head -n1`
    echo " Client/Server Password = $password " 
    echo ""
    echo " Modifying the following files with this password:"
    echo ""
    echo " ${PWD}/yocto-controller/controller.cfg "
    sed -i "s/<PASS>/$password/g" ${PWD}/yocto-controller/controller.cfg
    echo " ${PWD}/yocto-controller/buildbot.tac "
    sed -i "s/<PASS>/$password/g" ${PWD}/yocto-controller/buildbot.tac
    echo " ${PWD}/yocto-worker/buildbot.tac "
    sed -i "s/<PASS>/$password/g" ${PWD}/yocto-worker/buildbot.tac

    echo ""
    echo " Updating worker-init script used for google cloud building. "
    sed -i "s/<HOST_ADDR>/$HOST_ADDR/" ${PWD}/bin/worker-init
    sed -i "s/<PASS>/$password/" ${PWD}/bin/worker-init
    echo ""
    echo " If you wish to use your own generated username and password please "
    echo " modify the above files as needed. Please see the README for more "
    echo " information. "
    echo ""
    htpath=${PWD}/.htpasswd

    if [  ! -f  $htpath ]; then
        touch $htpath
        upassword=`cat /dev/urandom|tr -dc "a-zA-Z0-9"|fold -w 8|head -n1`
        echo " Generating an .htpasswd file using your current username and $upassword at ${PWD}/.htpasswd"
        ./bin/htpasswd -b $htpath $USER $upassword
    fi
    sed -i "s?<HTPASSWDPATH>?$htpath?g" ${PWD}/yocto-controller/controller.cfg
    echo "#########################################################################"
    echo ""
    echo " Please modify ${PWD}/config/autobuilder.conf if you wish to specify "
    echo " a different location in which to publish build artifacts, etc."
    echo ""
    echo "#########################################################################"
    echo ""
    echo " Ready to start the yocto autobuilder."
    echo ""
    echo " The yocto-autobuilder runs buildbot 0.8.8 with some modifications and"
    echo " a different git fetcher (yoctogit.py)"
    echo ""
    echo "#########################################################################"
    buildbot upgrade-master ${PWD}/yocto-controller
    ################
    #
    # We touch this because we know they've at least run this once
    #
    ################
    touch ${PWD}/.setupdone
fi

echo " To start the autobuilder:"
echo " ./yocto-start-autobuilder <worker|controller|both>"
echo ""
echo " To stop the autobuilder:"
echo " ./yocto-stop-autobuilder <worker|controller|both>"
echo ""