Commit 488c047a authored by Rafael Monnerat's avatar Rafael Monnerat

playbook: Clean up and move to use a Makefile.

This simplifies the procedure to debug.
parent 7131a7ae
template:
./prepare_templates.sh
download_cache:
./prepare_download_cache.sh || (echo "Impossible to build SlapOS, exiting." && exit 1)
tarball:
./prepare_tarball.sh
deb:
./prepare_debian.sh
obs:
./prepare_obs_upload.sh
all: template download_cache tarball deb obs
.PHONY: template download_cache tarball deb obs
#!/bin/bash
# Add entry to changelog
cd $CURRENT_DIRECTORY/debian
dch -pm -v $VERSION+$RECIPE_VERSION+$RELEASE --check-dirname-level=0 "New version of slapos ($VERSION+$RECIPE_VERSION+$RELEASE)"
cd $CURRENT_DIRECTORY
tar -czf debian.tar.gz debian
cp $CURRENT_DIRECTORY/debian.tar.gz $OBS_DIRECTORY
#!/bin/bash
VERSION=$1
RECIPE_VERSION=$3
BUILDOUT_URL=$2
source release_configuration.sh
##########
# VERSION comes from release_configuration.sh
# RECIPE_VERSION comes from release_configuration.sh
TARGET_DIRECTORY=/opt/slapos
BUILD_ROOT_DIRECTORY="$(pwd)/build"
BUILD_ROOT_DIRECTORY="$CURRENT_DIRECTORY/$SLAPOS_DIRECTORY/slapos/build"
BUILD_DIRECTORY=$BUILD_ROOT_DIRECTORY$TARGET_DIRECTORY
#rm -rf $BUILD_ROOT_DIRECTORY
#./configure --prefix=/opt/slapos/parts/<NAME>
echo "Preparing source tarball (recipe version: $RECIPE_VERSION)"
echo " Build Directory: $BUILD_DIRECTORY "
echo " Buildroot Directory: $BUILD_ROOT_DIRECTORY "
mkdir -p $BUILD_DIRECTORY/{extends-cache,download-cache}
mkdir -p $BUILD_DIRECTORY/{eggs,extends-cache,download-cache,download-cache/dist}
set -e
echo "$BUILD_ROOT_DIRECTORY" > ./original_directory
sed "s!\%BUILDOUT_URL\%!$BUILDOUT_URL!g;s/\%RECIPE_VERSION\%/$RECIPE_VERSION/g;s|\%PATCHES_DIRECTORY\%|$PATCHES_DIRECTORY|g;s|\%TARGET_DIRECTORY\%|$TARGET_DIRECTORY|g;s|\%BUILD_ROOT_DIRECTORY\%|$BUILD_ROOT_DIRECTORY|g;s|\%BUILD_DIRECTORY\%|$BUILD_DIRECTORY|g" buildout.cfg.in > $BUILD_DIRECTORY/buildout.cfg
sed "s/\%RECIPE_VERSION\%/$RECIPE_VERSION/g;s|\%PATCHES_DIRECTORY\%|$PATCHES_DIRECTORY|g;s|\%TARGET_DIRECTORY\%|$TARGET_DIRECTORY|g;s|\%BUILD_ROOT_DIRECTORY\%|$BUILD_ROOT_DIRECTORY|g;s|\%BUILD_DIRECTORY\%|$BUILD_DIRECTORY|g" $BUILD_ROOT_DIRECTORY/../buildout.cfg.in > $BUILD_DIRECTORY/buildout.cfg
# Build first time to get download-cache and extends-cache ready
cd $BUILD_DIRECTORY
echo "$BUILD_ROOT_DIRECTORY" > ./original_directory
# Download bootstrap file
wget https://bootstrap.pypa.io/bootstrap-buildout.py --no-check-certificate -O bootstrap.py
(python -S bootstrap.py --buildout-version 2.5.1.post2 --setuptools-to-dir eggs -f http://www.nexedi.org/static/packages/source/ -f http://www.nexedi.org/static/packages/source/slapos.buildout/ && \
./bin/buildout) || (echo "Failed to run buildout, exiting.")
./bin/buildout || (echo "Failed to run buildout, exiting." && exit 1)
(python -S bootstrap.py --buildout-version 2.5.1.post2 \
--setuptools-version 19.6.2 \
--setuptools-to-dir eggs \
-f http://www.nexedi.org/static/packages/source/ \
-f http://www.nexedi.org/static/packages/source/slapos.buildout/ && \
./bin/buildout -v) || (./bin/buildout -v || (echo "Failed to run buildout, exiting." && exit 1))
# remove all files from build keeping only caches
echo "Deleting unecessary files to reduce source tarball size"
......@@ -41,13 +50,17 @@ chmod -R u+w .
cp -R eggs/slapos.rebootstrap* $BUILD_ROOT_DIRECTORY/..
rm -fv .installed.cfg environment.*
rm -rfv ./{downloads,parts,eggs,develop-eggs,bin,rebootstrap}
# Removing empty directories
find . -type d -empty -prune -exec rmdir '{}' ';'
python -S bootstrap.py --buildout-version 2.5.1.post2 --setuptools-to-dir eggs -f http://www.nexedi.org/static/packages/source/ -f http://www.nexedi.org/static/packages/source/slapos.buildout/
mkdir -p $BUILD_DIRECTORY/eggs
python -S bootstrap.py --setuptools-version 19.6.2 \
--buildout-version 2.5.1.post2 \
--setuptools-to-dir eggs \
-f http://www.nexedi.org/static/packages/source/ \
-f http://www.nexedi.org/static/packages/source/slapos.buildout/
cp -R $BUILD_ROOT_DIRECTORY/../slapos.rebootstrap* eggs
......
#!/bin/bash
source release_configuration.sh
cd $OBS_DIRECTORY
# Update directory
osc up
# Remove former configuration
osc rm -f $SLAPOS_ORGINAL_DIRECTORY*.tar.gz
osc rm -f slapos.spec
# Prepare new tarball
cp $CURRENT_DIRECTORY/$SLAPOS_DIRECTORY.tar.gz .
osc add $SLAPOS_DIRECTORY.tar.gz
# Prepare new specfile
sed $VERSION_REGEX $TEMPLATES_DIRECTORY/slapos.spec.in > slapos.spec
osc add slapos.spec
# Prepare new .dsc file
osc rm -f slapos*.dsc
sed $VERSION_REGEX $TEMPLATES_DIRECTORY/slapos.dsc.in > $SLAPOS_DIRECTORY.dsc
osc add $SLAPOS_DIRECTORY.dsc
osc rm -f PKGBUILD
SOURCEMD5=`md5sum $SLAPOS_DIRECTORY.tar.gz | cut -d\ -f1`
sed "$VERSION_REGEX;s/\%SOURCEMD5\%/$SOURCEMD5/g" $TEMPLATES_DIRECTORY/PKGBUILD.in > PKGBUILD
cp $TEMPLATES_DIRECTORY/slapos-node.install .
osc add PKGBUILD slapos-node.install
## Upload new Package
osc commit -m "New SlapOS Recipe $RECIPE_VERSION"
#!/bin/sh -e
# Edit for release
VERSION=1.3.15
# Edit for release
RECIPE_VERSION=1.0.32
# Edit for release
RELEASE=7
CURRENT_DIRECTORY="$(pwd)"
# Development Section
OBS_DIRECTORY=$CURRENT_DIRECTORY/home:VIFIBnexedi:branches:home:VIFIBnexedi/SlapOS-Node
VERSION_REGEX="s!\%BUILDOUT_URL\%!$BUILDOUT_URL!g;s/\%RECIPE_VERSION\%/$RECIPE_VERSION/g;s/\%VERSION\%/$VERSION/g;s/\%RELEASE\%/$RELEASE/g"
TEMPLATES_DIRECTORY=$CURRENT_DIRECTORY/templates
SLAPOS_ORGINAL_DIRECTORY=slapos-node
SLAPOS_DIRECTORY=slapos-node_$VERSION+$RECIPE_VERSION+$RELEASE
export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
function prepare_template_files
{
# Prepare directory for new version if needed
mkdir -p $CURRENT_DIRECTORY/$SLAPOS_DIRECTORY
cp -rf $CURRENT_DIRECTORY/$SLAPOS_ORGINAL_DIRECTORY/* $CURRENT_DIRECTORY/$SLAPOS_DIRECTORY
rm -rf $CURRENT_DIRECTORY/$SLAPOS_DIRECTORY/slapos/slapos_repository
cp -R slapos_repository $CURRENT_DIRECTORY/$SLAPOS_DIRECTORY/slapos/
sed $VERSION_REGEX $TEMPLATES_DIRECTORY/Makefile.in > $CURRENT_DIRECTORY/$SLAPOS_DIRECTORY/slapos/Makefile
}
function prepare_download_cache
{
cd $CURRENT_DIRECTORY/$SLAPOS_DIRECTORY/slapos/
rm -rf build/
bash $CURRENT_DIRECTORY/prepare_download_cache.sh $VERSION $BUILDOUT_URL $RECIPE_VERSION || (echo "Impossible to build SlapOS, exiting." && exit 1)
# Go back to starting point
cd $CURRENT_DIRECTORY
}
function prepare_tarball
{
tar -czf $SLAPOS_DIRECTORY.tar.gz $SLAPOS_DIRECTORY
}
function prepare_deb_packaging
{
# Add entry to changelog
cd $CURRENT_DIRECTORY/debian
dch -pm -v $VERSION+$RECIPE_VERSION+$RELEASE --check-dirname-level=0 "New version of slapos ($VERSION+$RECIPE_VERSION+$RELEASE)"
# Add cron and logrotate files
cp $CURRENT_DIRECTORY/$SLAPOS_ORGINAL_DIRECTORY/template/slapos-node.cron.d $CURRENT_DIRECTORY/debian/cron.d
cp $CURRENT_DIRECTORY/$SLAPOS_ORGINAL_DIRECTORY/template/slapos-node.logrotate $CURRENT_DIRECTORY/debian/slapos-node.logrotate
cd $CURRENT_DIRECTORY
tar -czf debian.tar.gz debian
cp $CURRENT_DIRECTORY/debian.tar.gz $OBS_DIRECTORY
}
function obs_upload
{
cd $OBS_DIRECTORY
# Update directory
osc up
# Remove former configuration
osc rm -f $SLAPOS_ORGINAL_DIRECTORY*.tar.gz
osc rm -f slapos.spec
# Prepare new tarball
cp $CURRENT_DIRECTORY/$SLAPOS_DIRECTORY.tar.gz .
osc add $SLAPOS_DIRECTORY.tar.gz
# Prepare new specfile
sed $VERSION_REGEX $TEMPLATES_DIRECTORY/slapos.spec.in > slapos.spec
osc add slapos.spec
# Prepare new .dsc file
osc rm -f slapos*.dsc
sed $VERSION_REGEX $TEMPLATES_DIRECTORY/slapos.dsc.in > $SLAPOS_DIRECTORY.dsc
osc add $SLAPOS_DIRECTORY.dsc
osc rm -f PKGBUILD
SOURCEMD5=`md5sum $SLAPOS_DIRECTORY.tar.gz | cut -d\ -f1`
sed "$VERSION_REGEX;s/\%SOURCEMD5\%/$SOURCEMD5/g" $TEMPLATES_DIRECTORY/PKGBUILD.in > PKGBUILD
cp $TEMPLATES_DIRECTORY/slapos-node.install .
osc add PKGBUILD slapos-node.install
## Upload new Package
osc commit -m "New SlapOS Recipe $RECIPE_VERSION"
}
prepare_template_files
prepare_download_cache
prepare_tarball
prepare_deb_packaging
obs_upload
#!/bin/bash
source release_configuration.sh
tar -czf $SLAPOS_DIRECTORY.tar.gz $SLAPOS_DIRECTORY
#!/bin/bash
source release_configuration.sh
# Prepare directory for new version if needed
mkdir -p $CURRENT_DIRECTORY/$SLAPOS_DIRECTORY
cp -rf $CURRENT_DIRECTORY/$SLAPOS_ORGINAL_DIRECTORY/* $CURRENT_DIRECTORY/$SLAPOS_DIRECTORY
cp $CURRENT_DIRECTORY/debian/cron.d $CURRENT_DIRECTORY/$SLAPOS_DIRECTORY/slapos-node.cron.d
cp $CURRENT_DIRECTORY/debian/slapos-node.logrotate $CURRENT_DIRECTORY/$SLAPOS_DIRECTORY/slapos-node.logrotate
rm -rf $CURRENT_DIRECTORY/$SLAPOS_DIRECTORY/slapos/slapos_repository
cp -R slapos_repository $CURRENT_DIRECTORY/$SLAPOS_DIRECTORY/slapos/
sed $VERSION_REGEX $TEMPLATES_DIRECTORY/Makefile.in > $CURRENT_DIRECTORY/$SLAPOS_DIRECTORY/slapos/Makefile
####################################################
# Use on script as source release_configuration.sh
####################################################
# Edit for release
VERSION=1.3.15
# Edit for release
RECIPE_VERSION=1.0.32
# Edit for release
RELEASE=7
CURRENT_DIRECTORY="$(pwd)"
# Development Section
OBS_DIRECTORY=$CURRENT_DIRECTORY/home:VIFIBnexedi:branches:home:VIFIBnexedi/SlapOS-Node
VERSION_REGEX="s!\%BUILDOUT_URL\%!$BUILDOUT_URL!g;s/\%RECIPE_VERSION\%/$RECIPE_VERSION/g;s/\%VERSION\%/$VERSION/g;s/\%RELEASE\%/$RELEASE/g"
TEMPLATES_DIRECTORY=$CURRENT_DIRECTORY/templates
SLAPOS_ORGINAL_DIRECTORY=slapos-node
SLAPOS_DIRECTORY=slapos-node_$VERSION+$RECIPE_VERSION+$RELEASE
export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
SHELL=/bin/sh
PATH=/usr/bin:/usr/sbin:/sbin:/bin
MAILTO=""
# Run "Installation/Destruction of Software Releases" and "Deploy/Start/Stop Partitions" once per minute
* * * * * root /opt/slapos/bin/slapos node software --maximal_delay=30 --verbose --logfile=/opt/slapos/log/slapos-node-software.log > /dev/null 2>&1
* * * * * root /opt/slapos/bin/slapos node instance --maximal_delay=20 --promise-timeout 20 --verbose --logfile=/opt/slapos/log/slapos-node-instance.log > /dev/null 2>&1
# Run "Destroy Partitions to be destroyed" once per hour
0 * * * * root /opt/slapos/bin/slapos node report --maximal_delay=3600 --verbose --logfile=/opt/slapos/log/slapos-node-report.log > /dev/null 2>&1
# Run "Check/add IPs and so on" once per hour
0 * * * * root /opt/slapos/bin/slapos node format >> /opt/slapos/log/slapos-node-format.log 2>&1
# Run "Booting" on every system start
@reboot root /opt/slapos/bin/slapos node boot >> /opt/slapos/log/slapos-node-format.log 2>&1
# Run "Collect" once a minute
* * * * * root /opt/slapos/bin/slapos node collect >> /opt/slapos/log/slapos-node-collect.log 2>&1
# Generated by SlapOS. Assumes that slapos is installed in default location.
/opt/slapos/log/slapos-node-software.log /opt/slapos/log/slapos-node-instance.log /opt/slapos/log/slapos-node-report.log {
nocompress
dateext
daily
rotate 14
missingok
notifempty
create 640 root root
sharedscripts
}
/opt/slapos/log/slapos-node-collect.log {
nocompress
dateext
daily
rotate 14
missingok
notifempty
create 640 root root
sharedscripts
}
/opt/slapos/log/slapos-node-format.log {
nocompress
dateext
daily
rotate 100
missingok
notifempty
create 640 root root
sharedscripts
}
/srv/slapgrid/*/.slapgrid/log/instance.log {
compress
dateext
daily
rotate 30
missingok
notifempty
sharedscripts
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment