Commit 53c04309 authored by Diego Pasqualin's avatar Diego Pasqualin

Initial implementation of jenkins_continuous_integration.sh

Signed-off-by: default avatarDiego Pasqualin <dpasqualin@c3sl.ufpr.br>
parent defa0e9a
#!/bin/bash
#
# Copyright (C) 2004-2010 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
#
# This file is part of Linux Educacional project
#
# Linux Educacional 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
# -------------------------------------------------------------------------
# This script is used by jenkins to generate and publish debian packages.
# The LE5 project has several packages, separated in different directories.
# Jenkins polls the git repository periodically and runs this script when a
# change is detected, which will find out which packages have changed, build
# and publish them into the right mirror (unstable/testing/stable).
# -------------------------------------------------------------------------
PREFIX="$(dirname $0)"
REPOROOT="$PREFIX/.."
REPOCONFIGFILE="$REPOROOT/.git/config"
PUBLISHSCRIPT="$PREFIX/le-publica.sh"
# List of files/directories inside this repository that do not represent a
# module.
DONTGENERATE="bin doc README"
GIT_PREVIOUS_COMMIT=$1
GIT_COMMIT=$2
# Return all packages that have changed since the last build.
function getChangedPackages() {
local allFiles=""
local pkgs=""
# Get all changed files
allFiles=$(git diff --name-only ${GIT_PREVIOUS_COMMIT}..${GIT_COMMIT}|
cut -d/ -f1 | sort | uniq)
# Filter only the ones that represents valid packages
for file in $allFiles; do
if test -d "$REPOROOT/$file" && ! echo $DONTGENERATE | grep -q "\<$file\>"; then
pkgs="$pkgs $file"
fi
done
echo $pkgs
}
# As we have tree mirrors for LE5 (unstable/testing/stable), let's find out
# and return in which one we are going to publish the generated packages.
function getCurrentRepository() {
local repo=$(grep 'git@git.c3sl.ufpr.br:./le5/' $REPOCONFIGFILE |
cut -d'/' -f3 | cut -d'.' -f1)
echo $repo
}
# Publish <pkg> on <repo>
function publish() {
local pkg=$1
local repo="le5-$2"
$PUBLISHSCRIPT le5-$TOREPO "$pkgFile"
if test $? -ne 0; then
echo ERROR publishing package $pkg on repository $repo
fi
}
function createPackage() {
local pkg=$1
}
function showHelp() {
echo "$0 <previous commit> [current commit]"
echo ""
echo "Generate packages that have changed since <previous commit> to"
echo "[current commit]."
echo "If [current commit] is ommited, the script used HEAD."
}
# Sanity check
if test $# -lt 1 || test $# -gt 2; then
showHelp
exit 1
fi
repository=$(getCurrentRepository)
for pkg in $(getChangedPackages); do
echo $pkg
# Generate Package
# ...
# Publish it
# ...
done
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