2016-04-04 18:09:23 -04:00
|
|
|
#!/bin/bash -xe
|
|
|
|
#
|
|
|
|
# Build a Puppetfile with latest dependencies
|
|
|
|
#
|
|
|
|
|
2016-05-13 15:25:04 +02:00
|
|
|
DIR='puppet-openstack-integration'
|
2016-04-04 18:09:23 -04:00
|
|
|
|
|
|
|
# header
|
2016-05-13 15:25:04 +02:00
|
|
|
echo -e "# Auto-generated Puppetfile for Puppet OpenStack project\n" > $DIR/Puppetfile
|
2016-04-04 18:09:23 -04:00
|
|
|
|
|
|
|
# OpenStack Modules
|
2016-05-13 15:25:04 +02:00
|
|
|
echo "## OpenStack modules" >> $DIR/Puppetfile
|
2016-04-04 18:09:23 -04:00
|
|
|
for p in $(cat openstack_modules.txt); do
|
|
|
|
# hack for puppet-openstack-integration
|
|
|
|
# where namespace is openstack_integration
|
|
|
|
title=$(echo $p | sed 's/-/_/g')
|
|
|
|
# TODO(emilien) we need to add support for stable branches
|
2016-05-16 09:05:18 +02:00
|
|
|
cat >> $DIR/Puppetfile <<EOF
|
2016-04-04 18:09:23 -04:00
|
|
|
mod '$title',
|
|
|
|
:git => 'https://git.openstack.org/openstack/puppet-$p',
|
|
|
|
:ref => 'master'
|
|
|
|
|
|
|
|
EOF
|
|
|
|
done
|
|
|
|
|
|
|
|
# External Modules
|
2016-05-13 15:25:04 +02:00
|
|
|
echo -e "## External modules" >> $DIR/Puppetfile
|
2016-04-04 18:09:23 -04:00
|
|
|
for e in $(cat external_modules.txt); do
|
|
|
|
namespace=$(echo $e | awk -F'/' '{print $1}' | cut -d "," -f 1)
|
|
|
|
module=$(echo $e | awk -F'/' '{print $2}' | cut -d "," -f 1)
|
|
|
|
title=$(echo $module | awk -F'/' '{print $1}' | cut -d "-" -f 2)
|
|
|
|
pin=$(echo $e | grep "," | cut -d "," -f 2)
|
|
|
|
if [ ! -z "$pin" ]; then
|
|
|
|
git ls-remote --exit-code https://github.com/$namespace/$module $pin
|
|
|
|
if (($? == 2)); then
|
|
|
|
echo "Wrong pin: $pin does not exist in $module module."
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
tag=$pin
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
git clone https://github.com/$namespace/$module modules/$module
|
|
|
|
tag=$(cd modules/$module; git describe --tags $(git rev-list --tags --max-count=1))
|
|
|
|
rm -rf modules/$module
|
|
|
|
fi
|
2016-05-13 15:25:04 +02:00
|
|
|
cat >> $DIR/Puppetfile <<EOF
|
2016-04-04 18:09:23 -04:00
|
|
|
mod '$title',
|
|
|
|
:git => 'https://github.com/$namespace/$module',
|
|
|
|
:ref => '$tag'
|
|
|
|
|
|
|
|
EOF
|
|
|
|
done
|
|
|
|
|
|
|
|
# for debug
|
2016-05-13 15:25:04 +02:00
|
|
|
cat $DIR/Puppetfile
|