Commit f82ec463 authored by Diego Giovane Pasqualin's avatar Diego Giovane Pasqualin
Browse files

jenkins_continous_integration.sh: Implemente createPackage()


Signed-off-by: default avatarDiego Giovane Pasqualin <dpasqualin@c3sl.ufpr.br>
parent fc626248
......@@ -33,6 +33,7 @@ PREFIX="$(dirname $0)"
REPOROOT="$PREFIX/.."
REPOCONFIGFILE="$REPOROOT/.git/config"
PUBLISHSCRIPT="$PREFIX/le-publica.sh"
PACKAGESDEST="$REPOROOT/pkgs"
# List of files/directories inside this repository that do not represent a
# module.
......@@ -41,6 +42,11 @@ DONTGENERATE="bin doc README"
GIT_PREVIOUS_COMMIT=$1
GIT_COMMIT=$2
function prepare() {
mkdir -p $PACKAGESDEST
rm -f $PACKAGESDEST/*.deb
}
# Return all packages that have changed since the last build.
function getChangedPackages() {
local allFiles=""
......@@ -70,18 +76,55 @@ function getCurrentRepository() {
}
# Publish <pkg> on <repo>
# <repo>: unstable, testing, stable
function publish() {
local pkg=$1
local repo="le5-$2"
local pkgFile=$(ls $PACKAGESDEST/$pkg*.deb | sort | tail -1)
$PUBLISHSCRIPT le5-$TOREPO "$pkgFile"
if test $? -ne 0; then
echo ERROR publishing package $pkg on repository $repo
fi
return $?
}
# Generate a debian package for $pkg ($1), updating the version based on
# $kind (#2), where $kind can be revision, minor, or major.
function createPackage() {
local pkg=$1
local kind=$2
local version=""
local major=""
local minor=""
local revision=""
local controlFile="$REPOROOT/$PKG/pacote/DEBIAN/control"
version=$(grep "^Version:" $controlFile | awk '{print $2}')
major=$(echo $version | cut -d. -f1)
minor=$(echo $version | cut -d. -f2)
revision=$(echo $version | cut -d. -f3)
case $kind in
major)
((major++))
minor=0
revision=0
;;
minor)
((minor++))
revision=0
;;
*)
((revision++))
;;
esac
version="${mejor}.${minor}.${revision}"
sed -i -e "s/Version:/Version: $version/" $controlFile
fakeroot dpkg -b $REPOROOT/$PKG/pacote/ $PACKAGESDEST
return $?
}
function showHelp() {
......@@ -98,11 +141,23 @@ if test $# -lt 1 || test $# -gt 2; then
exit 1
fi
# Remove previous generated debian packages.
# This is necessary because jenkins would archive again files already
# archied on previous execution os this script
prepare
repository=$(getCurrentRepository)
for pkg in $(getChangedPackages); do
echo $pkg
# Generate Package
# ...
# TODO: allow user to change minor and major too
if ! createPackage $pkg revision; then
echo ERROR creating package $pkg.
exit 1
fi
# Publish it
# ...
if ! publish $pkg $repository; then
echo ERROR publishing package $pkg on repository $repository.
exit 1
fi
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