Adding support for package versionning

Create a tag with release/X.X.X to change the package version
This commit is contained in:
Philippe Caseiro 2015-08-20 16:29:36 +02:00
parent a4b739dc97
commit 8aec313e11
3 changed files with 44 additions and 23 deletions

View File

@ -9,30 +9,44 @@ fi
# Get commits log as changelog
logs=$(git log --pretty=format:"%an - %h : %s" | sed 's/"/\\"/g')
tags=$(git tag master -l "release/*")
# Set the top commiter as the maintainer of the project if not defined
top_contributor=$(git log --pretty=short | git shortlog -s -n -e | sed 's/^\s*[0-9]*\s*//g' | head -n 1)
maintainer=$(get_opt maintainer "${top_contributor}")
if [[ -z ${tags} ]]
then
error "No relase tag found, you repo must have a tag like 'release/X.X'"
exit 2
fi
project_name=$(get_opt project_name)
version=$(get_opt version 0.0.0)
distribution=$(get_opt distribution UNRELEASED)
urgency=$(get_opt urgency low)
git checkout $(get_opt build_branch dist/ubuntu/precise/master)
touch debian/changelog
commit_count=$(git rev-list --count --first-parent HEAD)
current_commit=$(git log -n 1 --pretty=format:"%h")
version_suffix=${commit_count}~${current_commit}
for tag in ${tags}
do
logs=$(git log --pretty=format:"%an - %h : %s" ${tag} | sed 's/"/\\"/g')
echo "${project_name} (${version}.tamarin${version_suffix}) ${distribution}; urgency=${urgency}" > debian/changelog
# Set the top commiter as the maintainer of the project if not defined
top_contributor=$(git log --pretty=short | git shortlog -s -n -e | sed 's/^\s*[0-9]*\s*//g' | head -n 1)
maintainer=$(get_opt maintainer "${top_contributor}")
echo >> debian/changelog
project_name=$(get_opt project_name)
version=${tag#*/} #$(get_opt version 0.0.0)
distribution=$(get_opt distribution UNRELEASED)
urgency=$(get_opt urgency low)
while read -r entry; do
commit_count=$(git rev-list --count --first-parent HEAD)
current_commit=$(git log -n 1 --pretty=format:"%h")
version_suffix=${commit_count}~${current_commit}
echo "${project_name} (${version}.tamarin${version_suffix}) ${distribution}; urgency=${urgency}" >> debian/changelog
echo >> debian/changelog
while read -r entry; do
echo " * ${entry}" >> debian/changelog
done <<< "$(echo -e "${logs}" | sed 's/^"//')"
done <<< "$(echo -e "${logs}" | sed 's/^"//')"
echo >> debian/changelog
echo >> debian/changelog
echo " -- ${maintainer} $(date -R)" >> debian/changelog
echo >> debian/changelog
echo " -- ${maintainer} $(date -R)" >> debian/changelog
echo >> debian/changelog
done

View File

@ -8,7 +8,8 @@ source "${TAMARIN_UTIL}"
DIST_DIR="${BASE_DIR}/dist"
SRC_DIR="${BASE_DIR}/src"
PROJECT_NAME=${1}
BUILD_DIR=${2}
BUILD_BRANCH=${2}
BUILD_DIR=${3}
function build_project()
{
@ -17,6 +18,7 @@ function build_project()
set_opt project_name "${PROJECT_NAME}"
set_opt build_dir "${BUILD_DIR}"
set_opt build_branch "${BUILD_BRANCH}"
local workspace=$(mktemp -p ${BUILD_DIR} -d)/${PROJECT_NAME}
info "Build dir is ${workspace}"

View File

@ -18,6 +18,7 @@ function show_usage {
echo " -i Optional : Name of the Docker image to use for build (default: debian:jessie)"
echo " -k Optional : Keep the Docker container after build "
echo " -b Optional : Build directory (default /tmp)"
echo " -B Optional : Build branch (for git projects only) (default dist/ubuntu/precise/master)"
echo
exit 2
}
@ -46,7 +47,7 @@ function create_container {
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update &&\
apt-get install --yes build-essential devscripts equivs
apt-get install --yes build-essential devscripts equivs git-buildpackage
RUN mkdir /root/.tamarin
RUN mkdir /project
@ -61,10 +62,10 @@ EOF
if [[ -z ${BUILD_DIR} ]]
then
echo " CMD /root/.tamarin/lib/build.sh ${projectName} /tmp" >> "$temp_dir/Dockerfile"
echo " CMD /root/.tamarin/lib/build.sh ${projectName} ${BUILD_BRANCH} /tmp" >> "$temp_dir/Dockerfile"
else
echo " VOLUME /build" >> "$temp_dir/Dockerfile"
echo " CMD /root/.tamarin/lib/build.sh ${projectName} /build" >> "$temp_dir/Dockerfile"
echo " CMD /root/.tamarin/lib/build.sh ${projectName} ${BUILD_BRANCH} /build" >> "$temp_dir/Dockerfile"
fi
exec_hooks "containerbuild" "$temp_dir"
@ -115,7 +116,7 @@ function main {
#
# Parsing options
#
while getopts "kp:d:i:b:" option
while getopts "kp:d:i:b:B:" option
do
case $option in
k)
@ -133,6 +134,9 @@ do
b)
BUILD_DIR=$(readlink -f ${OPTARG})
;;
B)
BUILD_BRANCH=${OPTARG}
;;
*)
show_usage
;;
@ -142,6 +146,7 @@ done
[[ -z ${PROJECT_PATH} ]] && show_usage
[[ -z ${PROJECT_DEST} ]] && PROJECT_DEST=$(readlink -f "./packages")
[[ -z ${BASE_IMAGE} ]] && BASE_IMAGE="debian:jessie"
[[ -z ${BUILD_BRANCH} ]] && BUILD_BRANCH="dist/ubuntu/precise/master"
[[ -z ${PERSIST_CONTAINER} ]] && PERSIST_CONTAINER=0
#