| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
set -e |
| 4 |
set -x |
| 5 |
|
| 6 |
################################# |
| 7 |
# AUTOMATICALLY DETECT ENV HERE # |
| 8 |
################################# |
| 9 |
|
| 10 |
if ! [ -r /etc/pkgos/pkgos.conf ] ; then |
| 11 |
echo "Could not read /etc/pkgos/pkgos.conf" |
| 12 |
exit 1 |
| 13 |
else |
| 14 |
. /etc/pkgos/pkgos.conf |
| 15 |
fi |
| 16 |
|
| 17 |
detect_env () { |
| 18 |
DEB_RELEASE=`lsb_release -a | grep Codename: | awk '{print $2}'` |
| 19 |
DEB_RELEASE_NUM=`lsb_release -a | grep Release: | awk '{print $2}'` |
| 20 |
DEB_DIST_TYPE=$(lsb_release -a | grep "Distributor ID:" | awk '{print $3}') |
| 21 |
APT="apt-get install -y" |
| 22 |
echo 'APT::Install-Recommends "0";' >/etc/apt/apt.conf.d/80norecommends |
| 23 |
} |
| 24 |
|
| 25 |
configure_hostname () { |
| 26 |
DEFROUTE_IF=`LC_ALL=C /sbin/route | grep default |awk -- '{ print $8 }' | cut -d" " -f1` |
| 27 |
if [ -n "${DEFROUTE_IF}" ] ; then |
| 28 |
DEFROUTE_IP=`LC_ALL=C ip addr show "${DEFROUTE_IF}" | grep inet | head -n 1 | awk '{print $2}' | cut -d/ -f1 | grep -E '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$'` |
| 29 |
if [ -n "${DEFROUTE_IP}" ] ; then |
| 30 |
echo "Detected IP: ${DEFROUTE_IP}" |
| 31 |
echo "127.0.0.1 localhost.localdomain localhost |
| 32 |
${DEFROUTE_IP} ${HOST_FQDN} ${TARGET_OPENSTACK_REL}-${TARGET_DISTRO} |
| 33 |
|
| 34 |
# The following lines are desirable for IPv6 capable hosts |
| 35 |
::1 ip6-localhost ip6-loopback |
| 36 |
fe00::0 ip6-localnet |
| 37 |
ff00::0 ip6-mcastprefix |
| 38 |
ff02::1 ip6-allnodes |
| 39 |
ff02::2 ip6-allrouters |
| 40 |
ff02::3 ip6-allhosts |
| 41 |
" >/etc/hosts |
| 42 |
fi |
| 43 |
fi |
| 44 |
echo $HOST_FQDN >/etc/hostname |
| 45 |
hostname `cat /etc/hostname` |
| 46 |
} |
| 47 |
|
| 48 |
install_all_software () { |
| 49 |
${APT} ${ADDED_DEB_PKG} sbuild apache2 screen joe apache2 pure-ftpd ftp most \ |
| 50 |
man-db git-buildpackage debhelper eatmydata build-essential python-setuptools \ |
| 51 |
fakeroot python3-all python-all python3-setuptools pristine-tar dh-autoreconf ssl-cert \ |
| 52 |
dh-python dh-systemd python-sphinx sudo debootstrap openstack-pkg-tools \ |
| 53 |
lintian lsb-release postfix gem2deb |
| 54 |
} |
| 55 |
|
| 56 |
configure_apache () { |
| 57 |
a2enmod proxy |
| 58 |
a2enmod proxy_http |
| 59 |
a2enmod ssl |
| 60 |
a2enmod headers |
| 61 |
if [ "${DEB_RELEASE}" = "precise" ] ; then |
| 62 |
APACHE_SSL_VHOST_CONF=default-ssl |
| 63 |
FORWARD_TO_ADDR=ip6-localhost |
| 64 |
DEFAULT_SITE=default |
| 65 |
DEFAULT_SSL_SITE=default-ssl |
| 66 |
elif [ "${DEB_RELEASE}" = "wheezy" ] ; then |
| 67 |
APACHE_SSL_VHOST_CONF=default-ssl |
| 68 |
FORWARD_TO_ADDR=localhost |
| 69 |
DEFAULT_SITE=default |
| 70 |
DEFAULT_SSL_SITE=default-ssl |
| 71 |
else |
| 72 |
APACHE_SSL_VHOST_CONF=default-ssl.conf |
| 73 |
FORWARD_TO_ADDR=localhost |
| 74 |
DEFAULT_SITE=000-default.conf |
| 75 |
DEFAULT_SSL_SITE=default-ssl.conf |
| 76 |
fi |
| 77 |
a2ensite ${DEFAULT_SSL_SITE} |
| 78 |
APACHE_SSL_VHOST_CONF_FULL_PATH=/etc/apache2/sites-available/${APACHE_SSL_VHOST_CONF} |
| 79 |
echo "<IfModule mod_ssl.c> |
| 80 |
<VirtualHost *:443> |
| 81 |
ServerAdmin webmaster@localhost |
| 82 |
ErrorLog \${APACHE_LOG_DIR}/error.log |
| 83 |
CustomLog \${APACHE_LOG_DIR}/access.log combined |
| 84 |
|
| 85 |
SSLEngine on |
| 86 |
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem |
| 87 |
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key |
| 88 |
|
| 89 |
<FilesMatch \"\.(cgi|shtml|phtml|php)\$\"> |
| 90 |
SSLOptions +StdEnvVars |
| 91 |
</FilesMatch> |
| 92 |
<Directory /usr/lib/cgi-bin> |
| 93 |
SSLOptions +StdEnvVars |
| 94 |
</Directory> |
| 95 |
|
| 96 |
# Jenkins proxy (and reverse) |
| 97 |
ProxyPass / http://${FORWARD_TO_ADDR}:8080/ nocanon |
| 98 |
ProxyPassReverse / http://${FORWARD_TO_ADDR}:8080/ |
| 99 |
ProxyRequests Off |
| 100 |
AllowEncodedSlashes NoDecode |
| 101 |
Header edit Location ^http://${HOST_FQDN}/ https://${HOST_FQDN}/ |
| 102 |
RequestHeader set X-Forwarded-Proto \"https\" |
| 103 |
RequestHeader set X-Forwarded-Port \"443\" |
| 104 |
ProxyPreserveHost on |
| 105 |
SetOutputFilter INFLATE;proxy-html;DEFLATE |
| 106 |
SetEnv proxy-nokeepalive 1 |
| 107 |
|
| 108 |
ServerAdmin webmaster@localhost |
| 109 |
</VirtualHost> |
| 110 |
</IfModule> |
| 111 |
" >${APACHE_SSL_VHOST_CONF_FULL_PATH} |
| 112 |
a2ensite ${APACHE_SSL_VHOST_CONF} |
| 113 |
invoke-rc.d apache2 restart |
| 114 |
if [ ! -e /var/www/html/debian ] && [ ! -h /var/www/html/debian ] ; then |
| 115 |
ln -s /home/ftp/debian /var/www/html/debian |
| 116 |
fi |
| 117 |
} |
| 118 |
|
| 119 |
configure_pure () { |
| 120 |
if getent passwd ftp >/dev/null ; then |
| 121 |
echo "FTP user already existing" |
| 122 |
else |
| 123 |
/usr/sbin/useradd -m ftp |
| 124 |
fi |
| 125 |
chown ${THE_DEV_USER}:${THE_DEV_USER} /home/ftp |
| 126 |
rm -f /etc/pure-ftpd/conf/NoAnonymous |
| 127 |
invoke-rc.d pure-ftpd stop |
| 128 |
sleep 2 |
| 129 |
invoke-rc.d pure-ftpd start |
| 130 |
} |
| 131 |
|
| 132 |
install_jenkins_plugins () { |
| 133 |
jenkins-cli -s https://${HOST_FQDN}/ -noCertificateCheck install-plugin instant-messaging |
| 134 |
jenkins-cli -s https://${HOST_FQDN}/ -noCertificateCheck install-plugin ircbot |
| 135 |
} |
| 136 |
|
| 137 |
configure_jenkins_dotgitconfig () { |
| 138 |
echo "[user] |
| 139 |
email = [email protected] |
| 140 |
name = Thomas Goirand |
| 141 |
[gitreview] |
| 142 |
username = thomas-goirand |
| 143 |
[alias] |
| 144 |
wdiff = diff --color-words |
| 145 |
wshow = show --color-words |
| 146 |
[color] |
| 147 |
ui = true" >/var/lib/jenkins/.gitconfig |
| 148 |
} |
| 149 |
|
| 150 |
configure_jenkins_sudoers () { |
| 151 |
echo "jenkins ALL = NOPASSWD: /usr/bin/sbuild-update -udcar ${TARGET_DISTRO}-amd64" >/etc/sudoers.d/jenkins |
| 152 |
chmod 440 /etc/sudoers.d/jenkins |
| 153 |
} |
| 154 |
|
| 155 |
# @param: $1 homedir of the GPG user |
| 156 |
gen_the_dev_user_gpg_key () { |
| 157 |
GPG_USER_HOMEDIR=${1} |
| 158 |
mkdir -p ${GPG_USER_HOMEDIR}/.gnupg |
| 159 |
chmod 700 ${GPG_USER_HOMEDIR}/.gnupg |
| 160 |
chmod 700 ${GPG_USER_HOMEDIR}/.gnupg |
| 161 |
if ! [ -r ${GPG_USER_HOMEDIR}/.gnupg/gpg.conf ] ; then |
| 162 |
echo "keyserver hkp://pool.sks-keyservers.net |
| 163 |
personal-digest-preferences SHA256 |
| 164 |
default-preference-list SHA512 SHA384 SHA256 SHA224 AES256 AES192 AES CAST5 ZLIB BZIP2 ZIP Uncompressed |
| 165 |
cert-digest-algo SHA256 |
| 166 |
" >${GPG_USER_HOMEDIR}/.gnupg/gpg.conf |
| 167 |
fi |
| 168 |
if ! [ -r ${GPG_USER_HOMEDIR}/.gnupg/pkgos-gen-key-batchfile ] ; then |
| 169 |
echo " |
| 170 |
%echo Generating a basic OpenPGP key |
| 171 |
Key-Type: RSA |
| 172 |
Key-Length: 4096 |
| 173 |
Name-Real: Autogenerated key |
| 174 |
Name-Email: ${THE_DEV_USER}@"`hostname --fqdn`" |
| 175 |
Expire-Date: 0 |
| 176 |
" >${GPG_USER_HOMEDIR}/.gnupg/pkgos-gen-key-batchfile |
| 177 |
fi |
| 178 |
chown -R ${THE_DEV_USER}:${THE_DEV_USER} ${GPG_USER_HOMEDIR}/.gnupg |
| 179 |
su ${THE_DEV_USER} -c 'gpg --gen-key --batch '${GPG_USER_HOMEDIR}'/.gnupg/pkgos-gen-key-batchfile' |
| 180 |
} |
| 181 |
|
| 182 |
configure_jenkins_gpg_key () { |
| 183 |
# Generate a self-signed gpg key so that we can sign packages |
| 184 |
if ! [ -e /var/lib/jenkins/.gnupg/secring.gpg ] ; then |
| 185 |
gen_the_dev_user_gpg_key /var/lib/jenkins |
| 186 |
fi |
| 187 |
} |
| 188 |
|
| 189 |
|
| 190 |
check_user_gpg_key () { |
| 191 |
if ! [ -d /home/${THE_DEV_USER}/.gnupg ] ; then |
| 192 |
echo "There's no /home/${THE_DEV_USER}/.gnupg folder," |
| 193 |
echo "do you want this script to generate one? If you" |
| 194 |
echo "don't, the script will exit." |
| 195 |
echo -n "Generate a GPG key (Y/n)?" |
| 196 |
read GEN_KEY |
| 197 |
if [ -z "${GEN_KEY}" ] || [ "${GEN_KEY}" = "y" ] || [ "${GEN_KEY}" = "Y" ] ; then |
| 198 |
echo "Genrating a gpg key for you..." |
| 199 |
gen_the_dev_user_gpg_key /home/${THE_DEV_USER} |
| 200 |
else |
| 201 |
echo "No gpg key: exiting..." |
| 202 |
exit 1 |
| 203 |
fi |
| 204 |
fi |
| 205 |
GPG_KEY_ID=$(su ${THE_DEV_USER} -c "gpg --list-keys ${THE_DEV_USER} | grep ^pub | awk '{print \$2}' | cut -d/ -f2 | head -n 1") |
| 206 |
if [ -z "${GPG_KEY_ID}" ] ; then |
| 207 |
echo "Cloud not find key ID, but there's a /home/${THE_DEV_USER}/.gnupg" |
| 208 |
echo -n "Generate a GPG key (Y/n)?" |
| 209 |
read GEN_KEY |
| 210 |
if [ -z "${GEN_KEY}" ] || [ "${GEN_KEY}" = "y" ] || [ "${GEN_KEY}" = "Y" ] ; then |
| 211 |
echo "Genrating a gpg key for you..." |
| 212 |
gen_the_dev_user_gpg_key /home/${THE_DEV_USER} |
| 213 |
else |
| 214 |
echo "No gpg key: exiting..." |
| 215 |
exit 1 |
| 216 |
fi |
| 217 |
fi |
| 218 |
GPG_KEY_ID=$(su ${THE_DEV_USER} -c "gpg --list-keys ${THE_DEV_USER} | grep ^pub | awk '{print \$2}' | cut -d/ -f2 | head -n 1") |
| 219 |
echo "===> Key ID: ${GPG_KEY_ID}" |
| 220 |
} |
| 221 |
|
| 222 |
build_ostack_archive_keyring_package () { |
| 223 |
# Export the jenkins GPG key as pubkey.gpg in debian/dists/pubkey.gpg |
| 224 |
mkdir -p ${REPO_ROOT}/debian/dists |
| 225 |
chown -R ${THE_DEV_USER}:${THE_DEV_USER} ${REPO_ROOT}/debian/dists |
| 226 |
chown ${THE_DEV_USER}:${THE_DEV_USER} ${REPO_ROOT}/debian |
| 227 |
su ${THE_DEV_USER} -c "gpg --export -a ${THE_DEV_USER}" >${REPO_ROOT}/debian/dists/pubkey.gpg |
| 228 |
# Create a Debian package out of it, called openstack-debian-archive-keyring |
| 229 |
# and put it in the newly created Debian repository. |
| 230 |
# Yes, a working, Debian-policy-compliant package is really only a few lines of shell... :) |
| 231 |
TMPDIR=`mktemp -d` |
| 232 |
MYCWD=`pwd` |
| 233 |
cd ${TMPDIR} |
| 234 |
chown ${THE_DEV_USER}:${THE_DEV_USER} . |
| 235 |
VER=0.1 |
| 236 |
NAME=${TARGET_DISTRO}-${TARGET_OPENSTACK_REL}-archive-keyring |
| 237 |
rm -rf ${NAME}-${VER} |
| 238 |
mkdir -p ${NAME}-${VER}/debian/source |
| 239 |
cd ${NAME}-${VER} |
| 240 |
export DEBFULLNAME="Debian OpenStack Jenkins" |
| 241 |
export DEBEMAIL="${THE_DEV_USER}@${HOST_FQDN}" |
| 242 |
dch --create --package ${NAME} -D unstable --noquery --newversion 0.1 -m "Automatic archive package build." |
| 243 |
sed -i 's/MAINTAINER <EMAIL>/Debian OpenStack <'${THE_DEV_USER}'@'${HOST_FQDN}'>/' debian/changelog |
| 244 |
echo "3.0 (native)" >debian/source/format |
| 245 |
echo 9 >debian/compat |
| 246 |
echo "#!/usr/bin/make -f |
| 247 |
%: |
| 248 |
dh \$@ |
| 249 |
" >debian/rules |
| 250 |
echo "Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ |
| 251 |
Upstream-Name: ${NAME} |
| 252 |
Source: See the openstack-pkg-tools package |
| 253 |
|
| 254 |
Files: * |
| 255 |
Copyright: (c) 2015, Thomas Goirand <[email protected]> |
| 256 |
License: Apache-2 |
| 257 |
Licensed under the Apache License, Version 2.0 (the \"License\"); |
| 258 |
you may not use this file except in compliance with the License. |
| 259 |
You may obtain a copy of the License at |
| 260 |
. |
| 261 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 262 |
. |
| 263 |
Unless required by applicable law or agreed to in writing, software |
| 264 |
distributed under the License is distributed on an \"AS IS\" BASIS, |
| 265 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 266 |
See the License for the specific language governing permissions and |
| 267 |
limitations under the License. |
| 268 |
. |
| 269 |
On Debian-based systems the full text of the Apache version 2.0 license |
| 270 |
can be found in /usr/share/common-licenses/Apache-2.0. |
| 271 |
" >debian/copyright |
| 272 |
echo "Source: ${NAME} |
| 273 |
Section: net |
| 274 |
Priority: extra |
| 275 |
Maintainer: PKG OpenStack <[email protected]> |
| 276 |
Uploaders: Thomas Goirand <[email protected]> |
| 277 |
Build-Depends: debhelper (>= 9) |
| 278 |
Standards-Version: 3.9.6 |
| 279 |
|
| 280 |
Package: ${NAME} |
| 281 |
Architecture: all |
| 282 |
Depends: \${misc:Depends} |
| 283 |
Description: OpenStack ${TARGET_OPENSTACK_REL} ${TARGET_DISTRO} archive keyring |
| 284 |
OpenStack ${TARGET_OPENSTACK_REL} ${TARGET_DISTRO} archive keyring |
| 285 |
">debian/control |
| 286 |
cp ${REPO_ROOT}/debian/dists/pubkey.gpg . |
| 287 |
echo "pubkey.gpg /usr/share/${NAME}" >debian/${NAME}.install |
| 288 |
echo "#!/bin/sh |
| 289 |
set -e |
| 290 |
|
| 291 |
if [ \"\$1\" = \"configure\" ] || [ \"\$1\" = \"reconfigure\" ] ; then |
| 292 |
apt-key add /usr/share/${NAME}/pubkey.gpg |
| 293 |
fi |
| 294 |
|
| 295 |
#DEBHELPER# |
| 296 |
|
| 297 |
exit 0 |
| 298 |
" >debian/${NAME}.postinst |
| 299 |
chown -R ${THE_DEV_USER}:${THE_DEV_USER} . |
| 300 |
su ${THE_DEV_USER} -c dpkg-buildpackage || true |
| 301 |
FIRST_LETTER=`echo ${TARGET_OPENSTACK_REL} | awk '{print substr($0,0,2)}'` |
| 302 |
cd .. |
| 303 |
MYDEST=${REPO_ROOT}/debian/pool/${REPO_DEST}/main/${FIRST_LETTER}/${NAME} |
| 304 |
MYDEST2=${REPO_ROOT}/debian/pool/${REPO_NOCHANGE_BACKPORT_DEST}/main/${FIRST_LETTER}/${NAME} |
| 305 |
for i in ${MYDEST} ${MYDEST2} ; do |
| 306 |
su ${THE_DEV_USER} -c "mkdir -p ${i}" |
| 307 |
cp *.changes *.tar.xz *.deb *.dsc ${i} |
| 308 |
chown -R ${THE_DEV_USER}:${THE_DEV_USER} ${i} |
| 309 |
done |
| 310 |
cd ${MYCWD} |
| 311 |
rm -r ${TMPDIR} |
| 312 |
} |
| 313 |
|
| 314 |
configure_sbuildrc () { |
| 315 |
GPG_KEY_ID=$(su ${THE_DEV_USER} -c "gpg --list-keys ${THE_DEV_USER} | grep ^pub | awk '{print \$2}' | cut -d/ -f2") |
| 316 |
DOT_SBUILDRC_PATH=${THE_USER_HOMEDIR}/.sbuildrc |
| 317 |
if ! [ -r "${DOT_SBUILDRC_PATH}" ] ; then |
| 318 |
echo "# don't remove this, Perl needs it: |
| 319 |
|
| 320 |
\$build_arch_all = 1; |
| 321 |
\$build_source = 1; |
| 322 |
\$distribution = '"${TARGET_DISTRO}"'; |
| 323 |
\$run_lintian = 0; |
| 324 |
|
| 325 |
# Don't sign packages: |
| 326 |
#\$pgp_options = '-us -uc'; |
| 327 |
|
| 328 |
# FIX THIS !!! |
| 329 |
\$key_id = '${GPG_KEY_ID}'; |
| 330 |
|
| 331 |
1; |
| 332 |
" >${DOT_SBUILDRC_PATH} |
| 333 |
fi |
| 334 |
} |
| 335 |
|
| 336 |
configure_sbuild () { |
| 337 |
USE_OVERLAY=yes |
| 338 |
# Setup the gpg key for sbuild |
| 339 |
mkdir -p /root/.gnupg |
| 340 |
chmod 600 /root/.gnupg |
| 341 |
gpg --list-keys |
| 342 |
sbuild-update --keygen |
| 343 |
|
| 344 |
# Add jenkins as a sbuild user |
| 345 |
sbuild-adduser ${THE_DEV_USER} |
| 346 |
|
| 347 |
if [ "${USE_OVERLAY}" = "yes" ] ; then |
| 348 |
# Create the actual schroot env |
| 349 |
if ! [ -e /var/lib/sbuild/${TARGET_DISTRO} ] ; then |
| 350 |
# Using AUFS or overlay |
| 351 |
sbuild-createchroot ${TARGET_DISTRO} /var/lib/sbuild/${TARGET_DISTRO} ${CLOSEST_DEBIAN_MIRROR} |
| 352 |
fi |
| 353 |
else |
| 354 |
# Create the actual schroot env |
| 355 |
if ! [ -e /var/lib/sbuild/${TARGET_DISTRO}-amd64.tar.gz ] ; then |
| 356 |
# Using tarballs |
| 357 |
sbuild-createchroot --make-sbuild-tarball=/var/lib/sbuild/${TARGET_DISTRO}-amd64.tar.gz ${TARGET_DISTRO} `mktemp -d` ${CLOSEST_DEBIAN_MIRROR} |
| 358 |
fi |
| 359 |
fi |
| 360 |
|
| 361 |
# Make sure git-buildpackage is using sbuild |
| 362 |
sed -i 's/^[ #\t]*builder[ #\t]*=.*/builder = sbuild -v --no-apt-update/' /etc/git-buildpackage/gbp.conf |
| 363 |
sed -i 's/^[ #\t]*cleaner[ #\t]*=.*/cleaner = \/bin\/true/' /etc/git-buildpackage/gbp.conf |
| 364 |
|
| 365 |
# Make sure that /dev/shm is mounted in the chroot, otherwise anything which |
| 366 |
# uses /dev/shm (like python-taskflow, etc.) will fail to build |
| 367 |
sed -i 's|#/dev/shm|/dev/shm|' /etc/schroot/default/fstab |
| 368 |
|
| 369 |
# Install the juno-jessie-archive-keyring package in the repository |
| 370 |
FIRST_LETTER=`echo ${TARGET_OPENSTACK_REL} | awk '{print substr($0,0,2)}'` |
| 371 |
NAME=${TARGET_OPENSTACK_REL}-${TARGET_DISTRO}-archive-keyring |
| 372 |
VERS=0.1 |
| 373 |
MYPKG_FILE_NAME=${NAME}_0.1_all.deb |
| 374 |
LOCATION=debian/pool/${TARGET_DISTRO}-${TARGET_OPENSTACK_REL}-backports/main/${FIRST_LETTER}/${NAME}/${MYPKG_FILE_NAME} |
| 375 |
if [ "${USE_OVERLAY}" = "yes" ] ; then |
| 376 |
cp /home/ftp/${LOCATION} /var/lib/sbuild/${TARGET_DISTRO} |
| 377 |
chroot /var/lib/sbuild/${TARGET_DISTRO} dpkg -i ${MYPKG_FILE_NAME} |
| 378 |
rm /var/lib/sbuild/${TARGET_DISTRO}/${MYPKG_FILE_NAME} |
| 379 |
else |
| 380 |
schroot -c source:${TARGET_DISTRO}-amd64-sbuild -u root -- apt-get install -y wget |
| 381 |
schroot -c source:${TARGET_DISTRO}-amd64-sbuild -u root -- wget http://localhost/${LOCATION} |
| 382 |
schroot -c source:${TARGET_DISTRO}-amd64-sbuild -u root -- dpkg -i ${MYPKG_FILE_NAME} |
| 383 |
fi |
| 384 |
|
| 385 |
# Since we have already a first package (the archive-keyring one), |
| 386 |
# let's scan the tree in /home/ftp/debian/pool, and build a valid Debian repo |
| 387 |
|
| 388 |
MYCWD=`pwd` |
| 389 |
cd ${THE_USER_HOMEDIR} |
| 390 |
su ${THE_DEV_USER} -c pkgos-scan-repo |
| 391 |
su ${THE_DEV_USER} -c pkgos-scan-repo ${REPO_NOCHANGE_BACKPORT_DEST} |
| 392 |
cd ${MYCWD} |
| 393 |
|
| 394 |
if [ "${USE_OVERLAY}" = "yes" ] ; then |
| 395 |
echo "deb http://localhost/debian ${TARGET_DISTRO}-${TARGET_OPENSTACK_REL}-backports main |
| 396 |
deb http://localhost/debian ${REPO_NOCHANGE_BACKPORT_DEST} main" >/var/lib/sbuild/${TARGET_DISTRO}/etc/apt/sources.list.d/openstack.list |
| 397 |
else |
| 398 |
# Add a hook to have both our repositories used inside the sbuild chroot |
| 399 |
echo "#!/bin/sh |
| 400 |
|
| 401 |
set -e |
| 402 |
|
| 403 |
. \"\$SETUP_DATA_DIR/common-data\" |
| 404 |
. \"\$SETUP_DATA_DIR/common-functions\" |
| 405 |
. \"\$SETUP_DATA_DIR/common-config\" |
| 406 |
|
| 407 |
if [ \$STAGE = \"setup-start\" ] || [ \$STAGE = \"setup-recover\" ]; then |
| 408 |
echo \"deb http://localhost/debian ${TARGET_DISTRO}-${TARGET_OPENSTACK_REL}-backports main\" >\${CHROOT_PATH}/etc/apt/sources.list.d/openstack.list |
| 409 |
echo \"deb http://localhost/debian ${REPO_NOCHANGE_BACKPORT_DEST} main\" >\${CHROOT_PATH}/etc/apt/sources.list.d/openstack-backports.list |
| 410 |
fi" >>/etc/schroot/setup.d/80sources |
| 411 |
chmod +x /etc/schroot/setup.d/80sources |
| 412 |
fi |
| 413 |
} |
| 414 |
|
| 415 |
configure_jenkins_job_builder () { |
| 416 |
GENERATED_PASSWORD=$(dd if=/dev/random bs=64 count=1 2>|/dev/null | md5sum | awk '{print $1}') |
| 417 |
echo "[job_builder] |
| 418 |
ignore_cache=True |
| 419 |
keep_descriptions=False |
| 420 |
include_path=/usr/local/bin |
| 421 |
recursive=False |
| 422 |
allow_duplicates=False |
| 423 |
|
| 424 |
[jenkins] |
| 425 |
user=zigo |
| 426 |
password=${JENKINS_JOBS_BUILDER_PASS} |
| 427 |
url=http://localhost:8080/ |
| 428 |
" >/etc/jenkins_jobs/jenkins_jobs.ini |
| 429 |
echo "" >job.yaml |
| 430 |
for i in `cat /etc/pkgos/build-list` ; do |
| 431 |
echo "- job: |
| 432 |
name: $i |
| 433 |
builders: |
| 434 |
- shell: 'pkgos-bop-jenkins "${i}"' |
| 435 |
auth-token: g5rjtpms5emw |
| 436 |
logrotate: |
| 437 |
numToKeep: 4 |
| 438 |
publishers: |
| 439 |
- ircbot: |
| 440 |
strategy: all |
| 441 |
notify-start: true |
| 442 |
message-type: summary |
| 443 |
wrappers: |
| 444 |
- ansicolor: |
| 445 |
colormap: xterm |
| 446 |
" >>job.yaml |
| 447 |
done |
| 448 |
jenkins-jobs update job.yaml |
| 449 |
} |
| 450 |
|
| 451 |
restart_jenkins () { |
| 452 |
service jenkins restart |
| 453 |
} |
| 454 |
|
| 455 |
############################## |
| 456 |
# ACTUAL START OF THE SCRIPT # |
| 457 |
############################## |
| 458 |
|
| 459 |
usage () { |
| 460 |
echo "Wrong usage: $0 [dev|jenkins] <username>" |
| 461 |
echo "the username 2nd param is only if you use the dev mode" |
| 462 |
exit 1 |
| 463 |
} |
| 464 |
|
| 465 |
if [ "${1}" = "dev" ] ; then |
| 466 |
echo "Setting-up a developer machine." |
| 467 |
DEV_OR_JENKINS=dev |
| 468 |
shift |
| 469 |
if [ -z "${1}" ] ; then |
| 470 |
usage |
| 471 |
fi |
| 472 |
THE_DEV_USER=${1} |
| 473 |
shift |
| 474 |
if [ -n "${1}" ] ; then |
| 475 |
usage |
| 476 |
fi |
| 477 |
THE_USER_HOMEDIR=/home/${THE_DEV_USER} |
| 478 |
elif [ "${1}" = "jenkins" ] ; then |
| 479 |
echo "Setting-up a Jenkins build server." |
| 480 |
DEV_OR_JENKINS=jenkins |
| 481 |
THE_DEV_USER=jenkins |
| 482 |
shift |
| 483 |
if [ -n "${1}" ] ; then |
| 484 |
usage |
| 485 |
fi |
| 486 |
THE_USER_HOMEDIR=/var/lib/jenkins |
| 487 |
else |
| 488 |
usage |
| 489 |
fi |
| 490 |
|
| 491 |
detect_env |
| 492 |
[ "${DEV_OR_JENKINS}" = "jenkins" ] && configure_hostname |
| 493 |
install_all_software |
| 494 |
configure_apache |
| 495 |
configure_pure |
| 496 |
# This often fails because the list of plugins isn't fetched by Jenkins |
| 497 |
#install_jenkins_plugins |
| 498 |
[ "${DEV_OR_JENKINS}" = "jenkins" ] && configure_jenkins_dotgitconfig |
| 499 |
[ "${DEV_OR_JENKINS}" = "jenkins" ] && configure_jenkins_sudoers |
| 500 |
[ "${DEV_OR_JENKINS}" = "jenkins" ] && configure_jenkins_gpg_key |
| 501 |
[ "${DEV_OR_JENKINS}" = "dev" ] && check_user_gpg_key |
| 502 |
configure_sbuildrc |
| 503 |
build_ostack_archive_keyring_package |
| 504 |
configure_sbuild |
| 505 |
#[ "${DEV_OR_JENKINS}" = "jenkins" ] && configure_jenkins_job_builder |
| 506 |
# This is needed so that jenkins can login into sbuild |
| 507 |
[ "${DEV_OR_JENKINS}" = "jenkins" ] && restart_jenkins |