Commit 58a43e8d authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[CHANGE] - unified release management and put it into a script.

parent b5a935a9
#!/bin/bash
#---------------------------------------------------------------------------
#
# Project: OpenWalnut ( http://www.openwalnut.org )
#
# Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
# For more information see http://www.openwalnut.org/copying
#
# This file is part of OpenWalnut.
#
# OpenWalnut is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenWalnut 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 Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
#
#---------------------------------------------------------------------------
#############################################################################################################
# Internal Variables
#############################################################################################################
# what to build
ARCHITECTURES="amd64 i386"
DISTRIBUTIONS="sid wheezy squeeze lucid maverick natty"
PACKAGES="deb"
# Where to put logs from this script not distri/arch or pack specific.
MAINLOGFILE="$0.log"
#############################################################################################################
# Functions
#############################################################################################################
#########################################################################################################
# Clean up previous mess
Purge()
{
# we need root since the build-user in the chroot is root and created some
# files
rm -f $0-*.log
rm -f $MAINLOGFILE
sudo ./owpack purge || exit $?
}
#########################################################################################################
# Build for different target systems
BuildAll()
{
echo "LOG created by $0 on `date`" > $MAINLOGFILE
# init
./owpack init | tee -a $MAINLOGFILE || exit $?
for distri in $DISTRIBUTIONS
do
for arch in $ARCHITECTURES
do
for pack in $PACKAGES
do
LOGFILE=$0-$pack-$distri-$arch.log
echo "LOG created by $0 on `date`" > $LOGFILE
echo "* Building $pack for \"$distri-$arch\". Log: $LOGFILE" | tee -a $MAINLOGFILE
# check for chroot existence
sudo ./owbuildchroot $arch $distri check >> $MAINLOGFILE
if [ $? -ne 0 ]; then
echo " * Error. Build chroot not found." | tee -a $MAINLOGFILE
continue
fi
# create a log
sudo ./owbuildchroot $arch $distri run /build/owpack $pack $distri-$arch /build >> $LOGFILE
# for later error reporting
if [ $? -ne 0 ]; then
echo " * Error while building for \"$distri\", $arch. Check \"$LOGFILE\" for details" | tee -a $MAINLOGFILE
continue
fi
done
done
done
}
#########################################################################################################
# Main
# Handle user command
case "$1" in
purge)
Purge || exit $?
;;
build)
Purge || exit $?
BuildAll || exit $?
;;
*)
echo "Usage: $0 {purge|build}"
echo " COMMANDS:"
echo " purge: Purges logs and calls owpack purge."
echo " build: Build all."
echo ""
exit 2
;;
esac
......@@ -152,7 +152,7 @@ Builder_DEB()
# debuild requires the debian config dir to be present in OpenWalnut src dir
echo "* Setup debian package config."
cp -r "$BUILDER_DEB_UPSTREAM_SRC_DIR/tools/packaging/debian" "$BUILDER_DEB_UPSTREAM_SRC_DIR"
cp -r "$BUILDER_DEB_UPSTREAM_SRC_DIR/tools/release/packaging/debian" "$BUILDER_DEB_UPSTREAM_SRC_DIR"
if [ $? -ne 0 ]; then
echo " * Failed to copy debian package config."
exit 1
......@@ -232,10 +232,11 @@ Exit()
# Quit and print usage info.
UsageExit()
{
echo "Usage: $0 {init|clean|purge|deb|rpm|tgz} BUILD_DIR_PREFIX [WORKING_DIR]"
echo "Usage: $0 {init|clean|deb|src|rpm|tgz} BUILD_DIR_PREFIX [WORKING_DIR]"
echo " COMMANDS:"
echo " clean: removes created build sub-directories."
echo " deb: build source and binary packages for debian systems."
echo " src: create simple src archive."
echo " rpm: build binary packages using rpm."
echo " tgz: build binary tgz using cpack."
echo ""
......@@ -277,6 +278,15 @@ case "$1" in
EnsureConfigAndSource || Exit $?
Builder_DEB || Exit $?
;;
src)
# BUILD_DIR_PREFIX is mandatory
if [ $# -lt 2 ]; then
echo "* Need BUILD_DIR_PREFIX."
UsageExit
fi
EnsureConfigAndSource || Exit $?
Builder_SRC || Exit $?
;;
rpm)
# BUILD_DIR_PREFIX is mandatory
if [ $# -lt 2 ]; then
......
......@@ -25,23 +25,48 @@
#---------------------------------------------------------------------------
#############################################################################################################
# Internal Variables
# Release Configuration Variables
#############################################################################################################
# Ensure english warning/error text (easier googling)
export LC_ALL=C
# Where to grab the sources?
REPO="ssh://openwalnut.com//srv/hg/ow"
VERSION_BASE=1.2.5
REPO_BRANCH="OpenWalnut_$VERSION_BASE"
# Which packages to build
PACKAGES="deb src tgz"
# Define which chroot/distribution to use for build the packages
# As we only need a source DEB, we do not build the deb for all supported distributions. The NeuroDebian project is doing this.
# DISTRIBUTIONS_DEB="sid wheezy squeeze lucid maverick natty"
DISTRIBUTIONS_DEB="sid"
# use these distributions to build binary tgz
DISTRIBUTIONS_TGZ="sid wheezy squeeze lucid maverick natty"
# Architectures to build for
# NOTE: we need the debsrc package.
ARCHITECTURES_DEB="amd64"
# Build binary tgz for 386 and amd64
ARCHITECTURES_TGZ="i368 amd64"
#############################################################################################################
# Internal Variables
#############################################################################################################
# Ensure english warning/error text (easier googling)
export LC_ALL=C
# Where to put the files
CHECKOUT_DIR="OpenWalnut-hg"
# the source config file
CONFIG_FILE=owrelease.config
# Where to put logs from this script not distri/arch or pack specific.
MAINLOGFILE="$0.log"
#############################################################################################################
# Functions
#############################################################################################################
......@@ -70,17 +95,27 @@ Bootstrap()
# The version. You can use shell commands to evaluate this. The command is
# called inside the working dir of owpack script.
echo "VERSION=$VERSION_BASE+hg`cd $CHECKOUT_DIR;hg parents --template "{rev}"`" >> $CONFIG_FILE
echo "VERSION_BASE=$VERSION_BASE" >> $CONFIG_FILE
# get the latest scripts
cp $CHECKOUT_DIR/tools/packaging/owpack .
cp $CHECKOUT_DIR/tools/packaging/owbuildchroot .
cp $CHECKOUT_DIR/tools/packaging/owrelease .
cp $CHECKOUT_DIR/tools/release/owpack .
cp $CHECKOUT_DIR/tools/release/owbuildchroot .
cp $CHECKOUT_DIR/tools/release/owrelease .
}
#########################################################################################################
# Cleanup any mess. Remove checkout dir and config file.
CleanUp()
{
echo "* Removing logs."
# we need root since the build-user in the chroot is root and created some
# files
rm -f $0-*.log
rm -f $MAINLOGFILE
echo "* Removing buildfiles."
sudo ./owpack clean || exit $?
echo "* Removing checkout."
rm -rf $CHECKOUT_DIR
......@@ -93,6 +128,84 @@ CleanUp()
rm -f $CONFIG_FILE
}
#########################################################################################################
# Build for different target systems
BuildAll()
{
echo "LOG created by $0 on `date`" > $MAINLOGFILE
# does config exist? Needed. If not found, abort
if [ ! -f $CONFIG_FILE ]; then
echo " * File \"$CONFIG_FILE\" not found! Forgot to bootstrap?"
exit 1
fi
for pack in $PACKAGES
do
# gather information on the needed distributions and architectures for this type of package
PkgDistributions="sid" # default
PkgArchitectures="i386 amd64"
case "$pack" in
src)
PkgDistributions="sid"
PkgArchitectures="amd64"
;;
deb)
PkgDistributions=$DISTRIBUTIONS_DEB
PkgArchitectures=$ARCHITECTURES_DEB
;;
tgz)
PkgDistributions=$DISTRIBUTIONS_TGZ
PkgArchitectures=$ARCHITECTURES_TGZ
;;
*)
echo "* Unknown package \"$pack\"" | tee -a $MAINLOGFILE
exit 1
;;
esac
# as this cannot be paralellized, we need to do a first run to check and create the chroots if needed
for distri in $PkgDistributions
do
for arch in $PkgArchitectures
do
LOGFILE=$0-$pack-$distri-$arch.log
echo "LOG created by $0 on `date`" > $LOGFILE
echo "* Building $pack for \"$distri-$arch\". Log: $LOGFILE" | tee -a $MAINLOGFILE
# check for chroot existence
sudo ./owbuildchroot $arch $distri check >> $MAINLOGFILE
if [ $? -ne 0 ]; then
echo " * Build chroot not found. Creating." | tee -a $MAINLOGFILE
# sudo ./owbuildchroot $arch $distri create >> $MAINLOGFILE
if [ $? -ne 0 ]; then
echo " * Error. Build chroot not found." | tee -a $MAINLOGFILE
# do not be very tolerant. A missing chroot is a fatal error
exit 1
fi
fi
done
done
# this can be done in parallel
for distri in $PkgDistributions
do
for arch in $PkgArchitectures
do
# do
# sudo ./owbuildchroot $arch $distri run /build/owpack $pack $distri-$arch /build >> $LOGFILE
# for later error reporting
if [ $? -ne 0 ]; then
echo " * Error while building for \"$distri\", $arch. Check \"$LOGFILE\" for details" | tee -a $MAINLOGFILE
continue
fi
done
done
done
}
#########################################################################################################
# Something went wrong. Quit.
#
......@@ -107,10 +220,14 @@ Exit()
# Quit and print usage info.
UsageExit()
{
echo "Central script for release management. Bootstraps the OpenWalnut Release code and starts the building."
echo ""
echo "Usage: $0 {bootstrap|clean}"
echo " COMMANDS:"
echo " clean: removes created build sub-directories."
echo " bootstrap: gets a fresh copy of OpenWalnut."
echo " bootstrap: gets a fresh copy of OpenWalnut."
echo " do: does the actual building."
echo ""
Exit 2
}
......@@ -126,6 +243,9 @@ case "$1" in
bootstrap)
Bootstrap || Exit $?
;;
do)
BuildAll || Exit $?
;;
*)
UsageExit
;;
......
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